repo_id
stringlengths
19
138
file_path
stringlengths
32
200
content
stringlengths
1
12.9M
__index_level_0__
int64
0
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/utils/eClock.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file eClock.h * */ #ifndef ECLOCK_H_ #define ECLOCK_H_ #if defined(_WIN32) #include <time.h> #include <windows.h> #if defined(_MSC_VER) || defined(_MSC_EXTENSIONS) #define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64 #else #define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL #endif struct timezone { int tz_minuteswest; /* minutes W of Greenwich */ int tz_dsttime; /* type of dst correction */ }; #else #include <sys/time.h> #include <chrono> #endif #include "../rtps/common/Time_t.h" using namespace eprosima::fastrtps::rtps; namespace eprosima { namespace fastrtps{ /** * Class eClock used to obtain the time and to sleep some processes. * Time measured since 1970. * @ingroup UTILITIES_MODULE */ class RTPS_DllAPI eClock { public: eClock(); virtual ~eClock(); //!Seconds from 1900 to 1970, initialized to 0 to comply with RTPS 2.2 int32_t m_seconds_from_1900_to_1970; //!Difference from UTC in seconds int32_t m_utc_seconds_diff; /** * Fill a Time_t with the current time * @param now Pointer to a Time_t instance to fill with the current time * @return true on success */ bool setTimeNow(Time_t* now); /** * Method to start measuring an interval in us. */ void intervalStart(); /** * Method to finish measuring an interval in us. * @return Time of the interval in us */ uint64_t intervalEnd(); /** * Put the current thread to sleep. * @param milliseconds Time to sleep */ static void my_sleep(uint32_t milliseconds); #if defined(_WIN32) FILETIME ft; unsigned long long ftlong; FILETIME ft1,ft2; LARGE_INTEGER freq; LARGE_INTEGER li1,li2; #else timeval m_now; timeval m_interval1,m_interval2; #endif }; } /* namespace rtps */ } /* namespace eprosima */ #endif /* CLOCK_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/utils/md5.h
/* MD5 converted to C++ class by Frank Thilo (thilo@unix-ag.org) for bzflag (http://www.bzflag.org) based on: md5.h and md5.c reference implementation of RFC 1321 Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All rights reserved. License to copy and use this software is granted provided that it is identified as the "RSA Data Security, Inc. MD5 Message-Digest Algorithm" in all material mentioning or referencing this software or this function. License is also granted to make and use derivative works provided that such works are identified as "derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm" in all material mentioning or referencing the derived work. RSA Data Security, Inc. makes no representations concerning either the merchantability of this software or the suitability of this software for any particular purpose. It is provided "as is" without express or implied warranty of any kind. These notices must be retained in any copies of any part of this documentation and/or software. */ #ifndef BZF_MD5_H #define BZF_MD5_H #include <cstring> #include <iostream> #include "../fastrtps_dll.h" /** * Class MD5, for calculating MD5 hashes of strings or byte arrays * it is not meant to be fast or secure * * usage: 1) feed it blocks of uchars with update() * 2) finalize() * 3) get hexdigest() string * or * MD5(std::string).hexdigest() * * assumes that char is 8 bit and int is 32 bit * @ingroup UTILITIES_MODULE */ class RTPS_DllAPI MD5 { public: typedef unsigned char uint1; // 8bit typedef unsigned int size_type; // must be 32bit MD5(); MD5(const std::string& text); void update(const unsigned char *buf, size_type length); void update(const char *buf, size_type length); MD5& finalize(); std::string hexdigest() const; friend std::ostream& operator<<(std::ostream&, MD5& md5); uint1 digest[16]; // the result void init(); private: typedef unsigned int uint4; // 32bit enum {blocksize = 64}; // VC6 won't eat a const static int here void transform(const uint1 block[blocksize]); static void decode(uint4 output[], const uint1 input[], size_type len); static void encode(uint1 output[], const uint4 input[], size_type len); bool finalized; uint1 buffer[blocksize]; // bytes that didn't fit in last 64 byte chunk uint4 count[2]; // 64bit counter for number of bits (lo, hi) uint4 state[4]; // digest so far // low level logic operations static inline uint4 F(uint4 x, uint4 y, uint4 z); static inline uint4 G(uint4 x, uint4 y, uint4 z); static inline uint4 H(uint4 x, uint4 y, uint4 z); static inline uint4 I(uint4 x, uint4 y, uint4 z); static inline uint4 rotate_left(uint4 x, int n); static inline void FF(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac); static inline void GG(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac); static inline void HH(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac); static inline void II(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac); }; std::string md5(const std::string str); #endif
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/utils/TimeConversion.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file TimeConversion.h * */ #ifndef TIMECONVERSION_H_ #define TIMECONVERSION_H_ #include <cstdint> #include "../rtps/common/Time_t.h" namespace eprosima { namespace fastrtps{ namespace rtps { namespace TimeConv{ /** * Convert Time_t to seconds as a double */ inline double Time_t2SecondsDouble(const Time_t& t) { return (double)t.seconds + (double)(t.fraction/pow(2.0,32)); } /** * Convert Time_t to seconds as an int64 */ inline int64_t Time_t2MicroSecondsInt64(const Time_t& t) { return (int64_t)(t.fraction/pow(2.0,32)*pow(10.0,6))+t.seconds*(int64_t)pow(10.0,6); } /** * Convert Time_t to microseconds as a double */ inline double Time_t2MicroSecondsDouble(const Time_t& t) { return ((double)t.fraction/pow(2.0,32)*pow(10.0,6))+(double)t.seconds*pow(10.0,6); } /** * Convert Time_t to milliseconds as an int64 */ inline int64_t Time_t2MilliSecondsInt64(const Time_t& t) { return (int64_t)(t.fraction/pow(2.0,32)*pow(10.0,3))+t.seconds*(int64_t)pow(10.0,3); } /** * Convert Time_t to milliseconds as a double */ inline double Time_t2MilliSecondsDouble(const Time_t& t) { return ((double)t.fraction/pow(2.0,32)*pow(10.0,3))+(double)t.seconds*pow(10.0,3); } /** * Convert milliseconds to Time_t */ inline Time_t MilliSeconds2Time_t(double millisec) { Time_t t; t.seconds = (int32_t)(millisec/pow(10.0,3)); t.fraction = (uint32_t)((millisec-(double)t.seconds*pow(10.0,3))/pow(10.0,3)*pow(2.0,32)); return t; } /** * Convert microseconds to Time_t */ inline Time_t MicroSeconds2Time_t(double microsec) { Time_t t; t.seconds = (int32_t)(microsec/pow(10.0,6)); t.fraction = (uint32_t)((microsec-(double)t.seconds*pow(10.0,6))/pow(10.0,6)*pow(2.0,32)); return t; } /** * Convert seconds to Time_t */ inline Time_t Seconds2Time_t(double seconds) { Time_t t; t.seconds = (int32_t)seconds; t.fraction = (uint32_t)((seconds-(double)t.seconds)*pow(2.0,32)); return t; } /** * Get the absolute difference between two Time_t in milliseconds as double */ inline double Time_tAbsDiff2DoubleMillisec(const Time_t& t1,const Time_t& t2) { double result = 0; result +=(double)abs((t2.seconds-t1.seconds)*1000); result +=(double)std::abs((t2.fraction-t1.fraction)/pow(2.0,32)*1000); return result; } //! Create a random Time_t that is millisec + [-randoff,randoff] inline Time_t MilliSecondsWithRandOffset2Time_t(double millisec, double randoff) { randoff = std::abs(randoff); millisec = millisec + (-randoff) + static_cast <double> (rand()) /( static_cast <double> (RAND_MAX/(2*randoff))); return MilliSeconds2Time_t(millisec); } //! Create a random Time_t that is microsec + [-randoff,randoff] inline Time_t MicroSecondsWithRandOffset2Time_t(double microsec, double randoff) { randoff = std::abs(randoff); microsec = microsec + (-randoff) + static_cast <double> (rand()) /( static_cast <double> (RAND_MAX/(2*randoff))); return MicroSeconds2Time_t(microsec); } //! Create a random Time_t that is sec + [-randoff,randoff] inline Time_t SecondsWithRandOffset2Time_t(double sec, double randoff) { randoff = std::abs(randoff); sec = sec + (-randoff) + static_cast <double> (rand()) /( static_cast <double> (RAND_MAX/(2*randoff))); return Seconds2Time_t(sec); } } } } /* namespace rtps */ } /* namespace eprosima */ #endif /* TIMECONVERSION_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/utils/DBQueue.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // #ifndef DBQUEUE_H #define DBQUEUE_H #include <queue> #include <mutex> #include <memory> #include <condition_variable> namespace eprosima { namespace fastrtps{ /** * Double buffered, threadsafe queue for MPSC (multi-producer, single-consumer) comms. */ template<class T> class DBQueue { public: DBQueue(): mForegroundQueue(&mQueueAlpha), mBackgroundQueue(&mQueueBeta) {} //! Clears foreground queue and swaps queues. void Swap() { std::unique_lock<std::mutex> fgGuard(mForegroundMutex); std::unique_lock<std::mutex> bgGuard(mBackgroundMutex); // Clear the foreground queue. std::queue<T>().swap(*mForegroundQueue); auto* swap = mBackgroundQueue; mBackgroundQueue = mForegroundQueue; mForegroundQueue = swap; } //! Pushes to the background queue. void Push(const T& item) { std::unique_lock<std::mutex> guard(mBackgroundMutex); mBackgroundQueue->push(item); } //! Returns a reference to the front element //! in the foregrund queue. T& Front() { std::unique_lock<std::mutex> guard(mForegroundMutex); return mForegroundQueue->front(); } const T& Front() const { std::unique_lock<std::mutex> guard(mForegroundMutex); return mForegroundQueue->front(); } //! Pops from the foreground queue. void Pop() { std::unique_lock<std::mutex> guard(mForegroundMutex); mForegroundQueue->pop(); } //! Reports whether the foreground queue is empty. bool Empty() const { std::unique_lock<std::mutex> guard(mForegroundMutex); return mForegroundQueue->empty(); } //! Reports the size of the foreground queue. size_t Size() const { std::unique_lock<std::mutex> guard(mForegroundMutex); return mForegroundQueue->size(); } //! Clears foreground and background. void Clear() { std::unique_lock<std::mutex> fgGuard(mForegroundMutex); std::unique_lock<std::mutex> bgGuard(mBackgroundMutex); std::queue<T>().swap(*mForegroundQueue); std::queue<T>().swap(*mBackgroundQueue); } private: // Underlying queues std::queue<T> mQueueAlpha; std::queue<T> mQueueBeta; // Front and background queue references (double buffering) std::queue<T>* mForegroundQueue; std::queue<T>* mBackgroundQueue; mutable std::mutex mForegroundMutex; mutable std::mutex mBackgroundMutex; }; } // namespace fastrtps } // namespace eprosima #endif
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/utils/ObjectPool.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file ObjectPool.h * */ #ifndef OBJECTPOOL_H_ #define OBJECTPOOL_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include <vector> #include <cstdint> namespace eprosima { namespace fastrtps{ namespace rtps { /** * ObjectPool class used to define an object pool of different types. * @ingroup UTILITIESMODULE */ template <typename T> class ObjectPool { public: /** * @param defaultGroupSize Default group size */ ObjectPool(uint16_t defaultGroupSize); virtual ~ObjectPool(); T& reserve_Object(); void release_Object(T& obj); protected: std::vector<T*> m_free_objects; std::vector<T*> m_all_objects; uint16_t m_group_size; void allocateGroup(); }; } } /* namespace rtps */ } /* namespace eprosima */ #endif #endif /* OBJECTPOOL_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/Endpoint.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file Endpoint.h */ #ifndef ENDPOINT_H_ #define ENDPOINT_H_ #include <mutex> #include "common/Types.h" #include "common/Locator.h" #include "common/Guid.h" #include "attributes/EndpointAttributes.h" namespace eprosima { namespace fastrtps{ namespace rtps { class RTPSParticipantImpl; class ResourceEvent; /** * Class Endpoint, all entities of the RTPS network derive from this class. * Although the RTPSParticipant is also defined as an endpoint in the RTPS specification, in this implementation * the RTPSParticipant class **does not** inherit from the endpoint class. Each Endpoint object owns a pointer to the * RTPSParticipant it belongs to. * @ingroup COMMON_MODULE */ class Endpoint { friend class RTPSParticipantImpl; protected: Endpoint(RTPSParticipantImpl* pimpl,GUID_t& guid,EndpointAttributes& att); virtual ~Endpoint(); public: /** * Get associated GUID * @return Associated GUID */ RTPS_DllAPI inline const GUID_t& getGuid() const { return m_guid; }; /** * Get mutex * @return Associated Mutex */ RTPS_DllAPI inline std::recursive_mutex* getMutex() const { return mp_mutex; } /** * Get associated attributes * @return Endpoint attributes */ RTPS_DllAPI inline EndpointAttributes* getAttributes() { return &m_att; } #if HAVE_SECURITY bool supports_rtps_protection() { return supports_rtps_protection_; } bool is_submessage_protected() { return is_submessage_protected_; } bool is_payload_protected() { return is_payload_protected_; } #endif protected: //!Pointer to the RTPSParticipant containing this endpoint. RTPSParticipantImpl* mp_RTPSParticipant; //!Endpoint GUID const GUID_t m_guid; //!Endpoint Attributes EndpointAttributes m_att; //!Endpoint Mutex std::recursive_mutex* mp_mutex; private: Endpoint& operator=(const Endpoint&)NON_COPYABLE_CXX11; #if HAVE_SECURITY bool supports_rtps_protection_; bool is_submessage_protected_; bool is_payload_protected_; #endif }; } } /* namespace rtps */ } /* namespace eprosima */ #endif /* ENDPOINT_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/rtps_all.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file rtps_all.h * */ #ifndef RTPS_ALL_H_ #define RTPS_ALL_H_ #include "common/all_common.h" #include "attributes/WriterAttributes.h" #include "attributes/ReaderAttributes.h" #include "RTPSDomain.h" #include "participant/RTPSParticipant.h" #include "participant/RTPSParticipantListener.h" #include "writer/RTPSWriter.h" #include "writer/WriterListener.h" #include "history/WriterHistory.h" #include "reader/RTPSReader.h" #include "reader/ReaderListener.h" #include "history/ReaderHistory.h" #include "../utils/IPFinder.h" #include "../log/Log.h" #include "../utils/eClock.h" #include "../utils/TimeConversion.h" #include "../qos/ParameterList.h" #include "../qos/QosPolicies.h" #include "../log/Log.h" #endif /* RTPS_ALL_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/rtps_fwd.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file rtps_fwd.h * */ #ifndef RTPS_FWD_H_ #define RTPS_FWD_H_ namespace eprosima { namespace fastrtps { namespace rtps { class RTPSWriter; class RTPSReader; class WriterHistory; class ReaderHistory; class RTPSParticipant; } } } #endif /* RTPS_FWD_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/RTPSDomain.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file RTPSDomain.h */ #ifndef RTPSRTPSParticipant_H_ #define RTPSRTPSParticipant_H_ #include "common/Types.h" #include "attributes/RTPSParticipantAttributes.h" #include <set> namespace eprosima{ namespace fastrtps{ namespace rtps{ class RTPSParticipantImpl; class RTPSParticipant; class RTPSParticipantListener; class RTPSWriter; class WriterAttributes; class WriterHistory; class WriterListener; class RTPSReader; class ReaderAttributes; class ReaderHistory; class ReaderListener; /** * Class RTPSDomain,it manages the creation and destruction of RTPSParticipant RTPSWriter and RTPSReader. It stores * a list of all created RTPSParticipant. Is has only static methods. * @ingroup RTPS_MODULE */ class RTPSDomain { typedef std::pair<RTPSParticipant*,RTPSParticipantImpl*> t_p_RTPSParticipant; private: RTPSDomain(); /** * DomainRTPSParticipant destructor */ ~RTPSDomain(); public: /** * Method to shut down all RTPSParticipants, readers, writers, etc. * It must be called at the end of the process to avoid memory leaks. * It also shut downs the DomainRTPSParticipant. */ RTPS_DllAPI static void stopAll(); /** * @brief Create a RTPSParticipant. * @snippet fastrtps_example.cpp ex_RTPSParticipantCreation * @param PParam RTPSParticipant Parameters. * @param plisten Pointer to the ParticipantListener. * @return Pointer to the RTPSParticipant. */ RTPS_DllAPI static RTPSParticipant* createParticipant(RTPSParticipantAttributes& PParam, RTPSParticipantListener* plisten = nullptr); /** * Create a RTPSWriter in a participant. * @param p Pointer to the RTPSParticipant. * @param watt Writer Attributes. * @param hist Pointer to the WriterHistory. * @param listen Pointer to the WriterListener. * @return Pointer to the created RTPSWriter. */ RTPS_DllAPI static RTPSWriter* createRTPSWriter(RTPSParticipant* p, WriterAttributes& watt, WriterHistory* hist, WriterListener* listen = nullptr); /** * Remove a RTPSWriter. * @param writer Pointer to the writer you want to remove. * @return True if correctly removed. */ RTPS_DllAPI static bool removeRTPSWriter(RTPSWriter* writer); /** * Create a RTPSReader in a participant. * @param p Pointer to the RTPSParticipant. * @param ratt Reader Attributes. * @param hist Pointer to the ReaderHistory. * @param listen Pointer to the ReaderListener. * @return Pointer to the created RTPSReader. */ RTPS_DllAPI static RTPSReader* createRTPSReader(RTPSParticipant* p, ReaderAttributes& ratt, ReaderHistory* hist, ReaderListener* listen = nullptr); /** * Remove a RTPSReader. * @param reader Pointer to the reader you want to remove. * @return True if correctly removed. */ RTPS_DllAPI static bool removeRTPSReader(RTPSReader* reader); /** * Remove a RTPSParticipant and delete all its associated Writers, Readers, resources, etc. * @param[in] p Pointer to the RTPSParticipant; * @return True if correct. */ RTPS_DllAPI static bool removeRTPSParticipant(RTPSParticipant* p); /** * Set the maximum RTPSParticipantID. * @param maxRTPSParticipantId ID. */ static inline void setMaxRTPSParticipantId(uint32_t maxRTPSParticipantId) { m_maxRTPSParticipantID = maxRTPSParticipantId; } private: static uint32_t m_maxRTPSParticipantID; static std::vector<t_p_RTPSParticipant> m_RTPSParticipants; /** * @brief Get Id to create a RTPSParticipant. * @return Different ID for each call. */ static inline uint32_t getNewId() {return m_maxRTPSParticipantID++;} static std::set<uint32_t> m_RTPSParticipantIDs; }; } } /* namespace */ } /* namespace eprosima */ #endif /* DOMAINRTPSParticipant_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/reader/StatelessReader.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file StatelessReader.h */ #ifndef STATELESSREADER_H_ #define STATELESSREADER_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include <mutex> #include "RTPSReader.h" namespace eprosima { namespace fastrtps{ namespace rtps { /** * Class StatelessReader, specialization of the RTPSReader for Best Effort Readers. * @ingroup READER_MODULE */ class StatelessReader: public RTPSReader { friend class RTPSParticipantImpl; public: virtual ~StatelessReader(); private: StatelessReader(RTPSParticipantImpl*,GUID_t& guid, ReaderAttributes& att,ReaderHistory* hist,ReaderListener* listen=nullptr); public: /** * Add a matched writer represented by a WriterProxyData object. * @param wdata Pointer to the WPD object to add. * @return True if correctly added. */ bool matched_writer_add(RemoteWriterAttributes& wdata); /** * Remove a WriterProxyData from the matached writers. * @param wdata Pointer to the WPD object. * @return True if correct. */ bool matched_writer_remove(RemoteWriterAttributes& wdata); /** * Tells us if a specific Writer is matched against this reader * @param wdata Pointer to the WriterProxyData object * @return True if it is matched. */ bool matched_writer_is_matched(RemoteWriterAttributes& wdata); /** * Method to indicate the reader that some change has been removed due to HistoryQos requirements. * @param change Pointer to the CacheChange_t. * @param prox Pointer to the WriterProxy. * @return True if correctly removed. */ bool change_removed_by_history(CacheChange_t* change,WriterProxy* prox = nullptr); /** * Processes a new DATA message. Previously the message must have been accepted by function acceptMsgDirectedTo. * * @param change Pointer to the CacheChange_t. * @return true if the reader accepts messages from the. */ bool processDataMsg(CacheChange_t *change); /** * Processes a new DATA FRAG message. Previously the message must have been accepted by function acceptMsgDirectedTo. * @param change Pointer to the CacheChange_t. * @param sampleSize Size of the complete assembled message. * @param fragmentStartingNum fragment number of this particular fragment. * @return true if the reader accepts message. */ bool processDataFragMsg(CacheChange_t *change, uint32_t sampleSize, uint32_t fragmentStartingNum); /** * Processes a new HEARTBEAT message. Previously the message must have been accepted by function acceptMsgDirectedTo. * * @return true if the reader accepts messages from the. */ bool processHeartbeatMsg(GUID_t &writerGUID, uint32_t hbCount, SequenceNumber_t &firstSN, SequenceNumber_t &lastSN, bool finalFlag, bool livelinessFlag); bool processGapMsg(GUID_t &writerGUID, SequenceNumber_t &gapStart, SequenceNumberSet_t &gapList); /** * This method is called when a new change is received. This method calls the received_change of the History * and depending on the implementation performs different actions. * @param a_change Pointer of the change to add. * @return True if added. */ bool change_received(CacheChange_t* a_change, std::unique_lock<std::recursive_mutex> &lock); /** * Read the next unread CacheChange_t from the history * @param change Pointer to pointer of CacheChange_t * @param wpout Pointer to pointer of the matched writer proxy * @return True if read. */ bool nextUnreadCache(CacheChange_t** change,WriterProxy** wpout=nullptr); /** * Take the next CacheChange_t from the history; * @param change Pointer to pointer of CacheChange_t * @param wpout Pointer to pointer of the matched writer proxy * @return True if read. */ bool nextUntakenCache(CacheChange_t** change,WriterProxy** wpout=nullptr); /** * Get the number of matched writers * @return Number of matched writers */ inline size_t getMatchedWritersSize() const {return m_matched_writers.size();}; /*! * @brief Returns there is a clean state with all Writers. * StatelessReader allways return true; * @return true */ bool isInCleanState() const { return true; } inline RTPSParticipantImpl* getRTPSParticipant() const {return mp_RTPSParticipant;} private: bool acceptMsgFrom(GUID_t& entityId); //!List of GUID_t os matched writers. //!Is only used in the Discovery, to correctly notify the user using SubscriptionListener::onSubscriptionMatched(); std::vector<RemoteWriterAttributes> m_matched_writers; }; } } /* namespace rtps */ } /* namespace eprosima */ #endif #endif /* STATELESSREADER_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/reader/WriterProxy.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file WriterProxy.h */ #ifndef WRITERPROXY_H_ #define WRITERPROXY_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include <mutex> #include "../common/Types.h" #include "../common/Locator.h" #include "../common/CacheChange.h" #include "../attributes/ReaderAttributes.h" #include<set> // Testing purpose #ifndef TEST_FRIENDS #define TEST_FRIENDS #endif // TEST_FRIENDS namespace eprosima { namespace fastrtps { namespace rtps { class StatefulReader; class HeartbeatResponseDelay; class WriterProxyLiveliness; class InitialAckNack; /** * Class WriterProxy that contains the state of each matched writer for a specific reader. * @ingroup READER_MODULE */ class WriterProxy { TEST_FRIENDS public: ~WriterProxy(); /** * Constructor. * @param watt RemoteWriterAttributes. * @param SR Pointer to the StatefulReader. */ WriterProxy(RemoteWriterAttributes& watt, StatefulReader* SR); /** * Get the maximum sequenceNumber received from this Writer. * @return the maximum sequence number. */ const SequenceNumber_t available_changes_max() const; /** * Update the missing changes up to the provided sequenceNumber. * All changes with status UNKNOWN with seqNum <= input seqNum are marked MISSING. * @param[in] seqNum Pointer to the SequenceNumber. */ void missing_changes_update(const SequenceNumber_t& seqNum); /** * Update the lost changes up to the provided sequenceNumber. * All changes with status UNKNOWN or MISSING with seqNum < input seqNum are marked LOST. * @param[in] seqNum Pointer to the SequenceNumber. * @return True if there was some lost change. In other case false. */ bool lost_changes_update(const SequenceNumber_t& seqNum); /** * The provided change is marked as RECEIVED. * @param seqNum Sequence number of the change * @return True if correct. */ bool received_change_set(const SequenceNumber_t& seqNum); /** * Set a change as RECEIVED and NOT RELEVANT. * @param seqNum Sequence number of the change * @return true on success */ bool irrelevant_change_set(const SequenceNumber_t& seqNum); void setNotValid(const SequenceNumber_t& seqNum); bool areThereMissing(); /** * The method returns a vector containing all missing changes. * @return Vector of missing changes.. */ const std::vector<ChangeFromWriter_t> missing_changes(); size_t unknown_missing_changes_up_to(const SequenceNumber_t& seqNum); //! Pointer to associated StatefulReader. StatefulReader* mp_SFR; //! Parameters of the WriterProxy RemoteWriterAttributes m_att; //! Acknack Count uint32_t m_acknackCount; //! NACKFRAG Count uint32_t m_nackfragCount; //! LAst HEartbeatcount. uint32_t m_lastHeartbeatCount; //!Timed event to postpone the heartbeatResponse. HeartbeatResponseDelay* mp_heartbeatResponse; //!TO check the liveliness Status periodically. WriterProxyLiveliness* mp_writerProxyLiveliness; //! Timed event to send initial acknack. InitialAckNack* mp_initialAcknack; //!Indicates if the heartbeat has the final flag set. bool m_heartbeatFinalFlag; /** * Check if the writer is alive * @return true if the writer is alive */ inline bool isAlive(){return m_isAlive;}; /** * Set the writer as alive */ void assertLiveliness(); /** * Set the writer as not alive * @return */ inline void setNotAlive(){m_isAlive = false;}; /** * Get the mutex * @return Associated mutex */ inline std::recursive_mutex* getMutex(){return mp_mutex;}; /*! * @brief Returns number of ChangeFromWriter_t managed currently by the WriterProxy. * @return Number of ChangeFromWriter_t managed currently by the WriterProxy. */ size_t numberOfChangeFromWriter() const; /*! * @brief Returns next CacheChange_t to be notified. * @return Next CacheChange_t to be nofified or invalid SequenceNumber_t * if any CacheChange_t to be notified. */ SequenceNumber_t nextCacheChangeToBeNotified(); private: /*! * @brief Add ChangeFromWriter_t up to the sequenceNumber passed, but not including this. * Ex: If you have seqNums 1,2,3 and you receive seqNum 6, you need to add 4 and 5. * @param sequence_number * @param default_status ChangeFromWriter_t added will be created with this ChangeFromWriterStatus_t. * @return True if sequence_number will be the next after last element in the m_changesFromW container. * @remarks No thread-safe. */ bool maybe_add_changes_from_writer_up_to(const SequenceNumber_t& sequence_number, const ChangeFromWriterStatus_t default_status = ChangeFromWriterStatus_t::UNKNOWN); bool received_change_set(const SequenceNumber_t& seqNum, bool is_relevance); void cleanup(); //!Is the writer alive bool m_isAlive; //Print Method for log purposes void print_changes_fromWriter_test2(); //!Mutex Pointer std::recursive_mutex* mp_mutex; //!Vector containing the ChangeFromWriter_t objects. std::set<ChangeFromWriter_t, ChangeFromWriterCmp> m_changesFromW; SequenceNumber_t changesFromWLowMark_; //! Store last ChacheChange_t notified. SequenceNumber_t lastNotified_; void for_each_set_status_from(decltype(m_changesFromW)::iterator first, decltype(m_changesFromW)::iterator last, ChangeFromWriterStatus_t status, ChangeFromWriterStatus_t new_status); void for_each_set_status_from_and_maybe_remove(decltype(m_changesFromW)::iterator first, decltype(m_changesFromW)::iterator last, ChangeFromWriterStatus_t status, ChangeFromWriterStatus_t orstatus, ChangeFromWriterStatus_t new_status); }; } /* namespace rtps */ } /* namespace fastrtps */ } /* namespace eprosima */ #endif #endif /* WRITERPROXY_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/reader/ReaderListener.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file ReaderListener.h * */ #ifndef READERLISTENER_H_ #define READERLISTENER_H_ #include "../common/MatchingInfo.h" #include <mutex> namespace eprosima{ namespace fastrtps{ namespace rtps{ class RTPSReader; struct CacheChange_t; /** * Class ReaderListener, to be used by the user to override some of is virtual method to program actions to certain events. * @ingroup READER_MODULE */ class RTPS_DllAPI ReaderListener { public: ReaderListener(){}; virtual ~ReaderListener(){}; /** * This method is invoked when a new reader matches * @param reader Matching reader * @param info Matching information of the reader */ virtual void onReaderMatched(RTPSReader* reader, MatchingInfo& info){(void)reader; (void)info;}; /** * This method is called when a new CacheChange_t is added to the ReaderHistory. * @param reader Pointer to the reader. * @param change Pointer to the CacheChange_t. This is a const pointer to const data * to indicate that the user should not dispose of this data himself. * To remove the data call the remove_change method of the ReaderHistory. * reader->getHistory()->remove_change((CacheChange_t*)change). */ virtual void onNewCacheChangeAdded(RTPSReader* reader, const CacheChange_t* const change){(void)reader; (void)change;}; }; //Namespace enders } } } #endif /* READERLISTENER_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/reader/RTPSReader.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file RTPSReader.h */ #ifndef RTPSREADER_H_ #define RTPSREADER_H_ #include "../Endpoint.h" #include "../attributes/ReaderAttributes.h" namespace eprosima { namespace fastrtps { namespace rtps { // Forward declarations class ReaderListener; class ReaderHistory; struct CacheChange_t; class WriterProxy; struct SequenceNumber_t; class SequenceNumberSet_t; class FragmentedChangePitStop; /** * Class RTPSReader, manages the reception of data from its matched writers. * @ingroup READER_MODULE */ class RTPSReader : public Endpoint { friend class ReaderHistory; friend class RTPSParticipantImpl; friend class MessageReceiver; friend class EDP; protected: RTPSReader(RTPSParticipantImpl*,GUID_t& guid, ReaderAttributes& att,ReaderHistory* hist,ReaderListener* listen=nullptr); virtual ~RTPSReader(); public: /** * Add a matched writer represented by its attributes. * @param wdata Attributes of the writer to add. * @return True if correctly added. */ RTPS_DllAPI virtual bool matched_writer_add(RemoteWriterAttributes& wdata) = 0; /** * Remove a writer represented by its attributes from the matched writers. * @param wdata Attributes of the writer to remove. * @return True if correctly removed. */ RTPS_DllAPI virtual bool matched_writer_remove(RemoteWriterAttributes& wdata) = 0; /** * Tells us if a specific Writer is matched against this reader * @param wdata Pointer to the WriterProxyData object * @return True if it is matched. */ RTPS_DllAPI virtual bool matched_writer_is_matched(RemoteWriterAttributes& wdata) = 0; /** * Returns true if the reader accepts a message directed to entityId. */ RTPS_DllAPI bool acceptMsgDirectedTo(EntityId_t& entityId); /** * Processes a new DATA message. Previously the message must have been accepted by function acceptMsgDirectedTo. * * @param change Pointer to the CacheChange_t. * @return true if the reader accepts messages from the. */ RTPS_DllAPI virtual bool processDataMsg(CacheChange_t *change) = 0; /** * Processes a new DATA FRAG message. Previously the message must have been accepted by function acceptMsgDirectedTo. * * @param change Pointer to the CacheChange_t. * @param sampleSize Size of the complete, assembled message. * @param fragmentStartingNum Starting number of this particular fragment. * @return true if the reader accepts message. */ RTPS_DllAPI virtual bool processDataFragMsg(CacheChange_t *change, uint32_t sampleSize, uint32_t fragmentStartingNum) = 0; /** * Processes a new HEARTBEAT message. Previously the message must have been accepted by function acceptMsgDirectedTo. * * @return true if the reader accepts messages from the. */ RTPS_DllAPI virtual bool processHeartbeatMsg(GUID_t &writerGUID, uint32_t hbCount, SequenceNumber_t &firstSN, SequenceNumber_t &lastSN, bool finalFlag, bool livelinessFlag) = 0; RTPS_DllAPI virtual bool processGapMsg(GUID_t &writerGUID, SequenceNumber_t &gapStart, SequenceNumberSet_t &gapList) = 0; /** * Method to indicate the reader that some change has been removed due to HistoryQos requirements. * @param change Pointer to the CacheChange_t. * @param prox Pointer to the WriterProxy. * @return True if correctly removed. */ RTPS_DllAPI virtual bool change_removed_by_history(CacheChange_t* change, WriterProxy* prox = nullptr) = 0; /** * Get the associated listener, secondary attached Listener in case it is of coumpound type * @return Pointer to the associated reader listener. */ RTPS_DllAPI ReaderListener* getListener(); /** * Switch the ReaderListener kind for the Reader. * If the RTPSReader does not belong to the built-in protocols it switches out the old one. * If it belongs to the built-in protocols, it sets the new ReaderListener callbacks to be called after the * built-in ReaderListener ones. * @param target Pointed to ReaderLister to attach * @return True is correctly set. */ RTPS_DllAPI bool setListener(ReaderListener* target); /** * Reserve a CacheChange_t. * @param change Pointer to pointer to the Cache. * @return True if correctly reserved. */ RTPS_DllAPI bool reserveCache(CacheChange_t** change, uint32_t dataCdrSerializedSize); /** * Release a cacheChange. */ RTPS_DllAPI void releaseCache(CacheChange_t* change); /** * Read the next unread CacheChange_t from the history * @param change POinter to pointer of CacheChange_t * @param wp Pointer to pointer to the WriterProxy * @return True if read. */ RTPS_DllAPI virtual bool nextUnreadCache(CacheChange_t** change, WriterProxy** wp) = 0; /** * Get the next CacheChange_t from the history to take. * @param change Pointer to pointer of CacheChange_t. * @param wp Pointer to pointer to the WriterProxy. * @return True if read. */ RTPS_DllAPI virtual bool nextUntakenCache(CacheChange_t** change, WriterProxy** wp) = 0; /** * @return True if the reader expects Inline QOS. */ RTPS_DllAPI inline bool expectsInlineQos(){ return m_expectsInlineQos; }; //! Returns a pointer to the associated History. RTPS_DllAPI inline ReaderHistory* getHistory() {return mp_history;}; /*! * @brief Search if there is a CacheChange_t, giving SequenceNumber_t and writer GUID_t, * waiting to be completed because it is fragmented. * @param sequence_number SequenceNumber_t of the searched CacheChange_t. * @param writer_guid writer GUID_t of the searched CacheChange_t. * @return If a CacheChange_t was found, it will be returned. In other case nullptr is returned. */ CacheChange_t* findCacheInFragmentedCachePitStop(const SequenceNumber_t& sequence_number, const GUID_t& writer_guid); /*! * @brief Returns there is a clean state with all Writers. * It occurs when the Reader received all samples sent by Writers. In other words, * its WriterProxies are up to date. * @return There is a clean state with all Writers. */ virtual bool isInCleanState() const = 0; protected: void setTrustedWriter(EntityId_t writer) { m_acceptMessagesFromUnkownWriters=false; m_trustedWriterEntityId = writer; } //!ReaderHistory ReaderHistory* mp_history; //!Listener ReaderListener* mp_listener; //!Accept msg to unknwon readers (default=true) bool m_acceptMessagesToUnknownReaders; //!Accept msg from unknwon writers (BE-true,RE-false) bool m_acceptMessagesFromUnkownWriters; //!Trusted writer (for Builtin) EntityId_t m_trustedWriterEntityId; //!Expects Inline Qos. bool m_expectsInlineQos; //TODO Select one FragmentedChangePitStop* fragmentedChangePitStop_; private: RTPSReader& operator=(const RTPSReader&) NON_COPYABLE_CXX11; }; } /* namespace rtps */ } /* namespace fastrtps */ } /* namespace eprosima */ #endif /* RTPSREADER_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/reader/StatefulReader.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file StatefulReader.h */ #ifndef STATEFULREADER_H_ #define STATEFULREADER_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include "RTPSReader.h" #include <mutex> namespace eprosima { namespace fastrtps{ namespace rtps { class WriterProxy; /** * Class StatefulReader, specialization of RTPSReader than stores the state of the matched writers. * @ingroup READER_MODULE */ class StatefulReader:public RTPSReader { public: friend class RTPSParticipantImpl; virtual ~StatefulReader(); private: StatefulReader(RTPSParticipantImpl*,GUID_t& guid, ReaderAttributes& att,ReaderHistory* hist,ReaderListener* listen=nullptr); public: /** * Add a matched writer represented by a WriterProxyData object. * @param wdata Pointer to the WPD object to add. * @return True if correctly added. */ bool matched_writer_add(RemoteWriterAttributes& wdata); /** * Remove a WriterProxyData from the matached writers. * @param wdata Pointer to the WPD object. * @param deleteWP If the Reader has to delete the associated WP object or not. * @return True if correct. */ bool matched_writer_remove(RemoteWriterAttributes& wdata,bool deleteWP); /** * Remove a WriterProxyData from the matached writers. * @param wdata Pointer to the WPD object. * @return True if correct. */ bool matched_writer_remove(RemoteWriterAttributes& wdata); /** * Tells us if a specific Writer is matched against this reader * @param wdata Pointer to the WriterProxyData object * @return True if it is matched. */ bool matched_writer_is_matched(RemoteWriterAttributes& wdata); /** * Look for a specific WriterProxy. * @param writerGUID GUID_t of the writer we are looking for. * @param WP Pointer to pointer to a WriterProxy. * @return True if found. */ bool matched_writer_lookup(const GUID_t& writerGUID, WriterProxy** WP); /** * Processes a new DATA message. Previously the message must have been accepted by function acceptMsgDirectedTo. * @param change Pointer to the CacheChange_t. * @return true if the reader accepts messages. */ bool processDataMsg(CacheChange_t *change); /** * Processes a new DATA FRAG message. Previously the message must have been accepted by function acceptMsgDirectedTo. * @param change Pointer to the CacheChange_t. * @param sampleSize Size of the complete assembled message. * @param fragmentStartingNum fragment number of this particular fragment. * @return true if the reader accepts messages. */ bool processDataFragMsg(CacheChange_t *change, uint32_t sampleSize, uint32_t fragmentStartingNum); /** * Processes a new HEARTBEAT message. Previously the message must have been accepted by function acceptMsgDirectedTo. * * @return true if the reader accepts messages. */ bool processHeartbeatMsg(GUID_t &writerGUID, uint32_t hbCount, SequenceNumber_t &firstSN, SequenceNumber_t &lastSN, bool finalFlag, bool livelinessFlag); bool processGapMsg(GUID_t &writerGUID, SequenceNumber_t &gapStart, SequenceNumberSet_t &gapList); /** * Method to indicate the reader that some change has been removed due to HistoryQos requirements. * @param change Pointer to the CacheChange_t. * @param prox Pointer to the WriterProxy. * @return True if correctly removed. */ bool change_removed_by_history(CacheChange_t* change ,WriterProxy* prox = nullptr); /** * This method is called when a new change is received. This method calls the received_change of the History * and depending on the implementation performs different actions. * @param a_change Pointer of the change to add. * @param prox Pointer to the WriterProxy that adds the Change. * @param lock mutex protecting the StatefulReader. * @return True if added. */ bool change_received(CacheChange_t* a_change, WriterProxy* prox, std::unique_lock<std::recursive_mutex> &lock); /** * Get the RTPS participant * @return Associated RTPS participant */ inline RTPSParticipantImpl* getRTPSParticipant() const {return mp_RTPSParticipant;} /** * Read the next unread CacheChange_t from the history * @param change Pointer to pointer of CacheChange_t * @param wpout Pointer to pointer the matched writer proxy * @return True if read. */ bool nextUnreadCache(CacheChange_t** change,WriterProxy** wpout=nullptr); /** * Take the next CacheChange_t from the history; * @param change Pointer to pointer of CacheChange_t * @param wpout Pointer to pointer the matched writer proxy * @return True if read. */ bool nextUntakenCache(CacheChange_t** change,WriterProxy** wpout=nullptr); /** * Update the times parameters of the Reader. * @param times ReaderTimes reference. * @return True if correctly updated. */ bool updateTimes(ReaderTimes& times); /** * * @return Reference to the ReaderTimes. */ inline ReaderTimes& getTimes(){return m_times;}; /** * Get the number of matched writers * @return Number of matched writers */ inline size_t getMatchedWritersSize() const { return matched_writers.size(); } /*! * @brief Returns there is a clean state with all Writers. * It occurs when the Reader received all samples sent by Writers. In other words, * its WriterProxies are up to date. * @return There is a clean state with all Writers. */ bool isInCleanState() const; private: bool acceptMsgFrom(GUID_t &entityGUID ,WriterProxy **wp, bool checkTrusted = true); /*! * @remarks Nn thread-safe. */ bool findWriterProxy(const GUID_t& writerGUID, WriterProxy** WP); //!ReaderTimes of the StatefulReader. ReaderTimes m_times; //! Vector containing pointers to the matched writers. std::vector<WriterProxy*> matched_writers; }; } } /* namespace rtps */ } /* namespace eprosima */ #endif #endif /* STATEFULREADER_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/reader
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/reader/timedevent/InitialAckNack.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file InitialAckNack.h * */ #ifndef INITIALACKNACK_H_ #define INITIALACKNACK_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include <fastrtps/rtps/resources/TimedEvent.h> #include <fastrtps/rtps/common/CDRMessage_t.h> #include <fastrtps/rtps/common/Guid.h> #include <fastrtps/rtps/messages/RTPSMessageGroup.h> namespace eprosima { namespace fastrtps{ namespace rtps{ class RTPSParticipantImpl; class StatefulReader; class WriterProxy; /** * InitialAckNack class, controls the initial send operation of AckNack. * @ingroup WRITER_MODULE */ class InitialAckNack: public TimedEvent { public: /** * * @param p_RP * @param interval */ InitialAckNack(WriterProxy* wp, double interval); virtual ~InitialAckNack(); /** * Method invoked when the event occurs * * @param code Code representing the status of the event * @param msg Message associated to the event */ void event(EventCode code, const char* msg= nullptr); //! RTPSMessageGroup_t m_cdrmessages; //! WriterProxy* wp_; }; } } } /* namespace eprosima */ #endif #endif /* INITIALACKNACK_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/reader
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/reader/timedevent/HeartbeatResponseDelay.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file HeartbeatResponseDelay.h * */ #ifndef HEARTBEATRESPONSEDELAY_H_ #define HEARTBEATRESPONSEDELAY_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include "../../resources/TimedEvent.h" #include "../../common/CDRMessage_t.h" #include "../../messages/RTPSMessageGroup.h" namespace eprosima { namespace fastrtps{ namespace rtps { class StatefulReader; class WriterProxy; /** * Class HeartbeatResponseDelay, TimedEvent used to delay the response to a specific HB. * @ingroup READER_MODULE */ class HeartbeatResponseDelay:public TimedEvent { public: virtual ~HeartbeatResponseDelay(); /** * @param p_WP * @param interval */ HeartbeatResponseDelay(WriterProxy* p_WP,double interval); /** * Method invoked when the event occurs * * @param code Code representing the status of the event * @param msg Message associated to the event */ void event(EventCode code, const char* msg= nullptr); //!Pointer to the WriterProxy associated with this specific event. WriterProxy* mp_WP; //!CDRMessage_t used in the response. RTPSMessageGroup_t m_cdrmessages; }; } } /* namespace rtps */ } /* namespace eprosima */ #endif #endif /* HEARTBEATRESPONSEDELAY_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/reader
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/reader/timedevent/WriterProxyLiveliness.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file WriterProxyLiveliness.h * */ #ifndef WRITERPROXYLIVELINESS_H_ #define WRITERPROXYLIVELINESS_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include "../../resources/TimedEvent.h" namespace eprosima { namespace fastrtps{ namespace rtps { class WriterProxy; /** * Class WriterProxyLiveliness, timed event to check the liveliness of a writer each leaseDuration. * @ingroup READER_MODULE */ class WriterProxyLiveliness: public TimedEvent { public: /** * @param wp * @param interval */ WriterProxyLiveliness(WriterProxy* wp,double interval); virtual ~WriterProxyLiveliness(); /** * Method invoked when the event occurs * * @param code Code representing the status of the event * @param msg Message associated to the event */ void event(EventCode code, const char* msg= nullptr); //!Pointer to the WriterProxy associated with this specific event. WriterProxy* mp_WP; }; } } /* namespace rtps */ } /* namespace eprosima */ #endif #endif /* WRITERPROXYLIVELINESS_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/flowcontrol/ThroughputControllerDescriptor.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef THROUGHPUT_CONTROLLER_DESCRIPTOR_H #define THROUGHPUT_CONTROLLER_DESCRIPTOR_H #include <fastrtps/fastrtps_dll.h> #include <cstdint> namespace eprosima{ namespace fastrtps{ namespace rtps{ /** * Descriptor for a Throughput Controller, containing all constructor information * for it. * @ingroup NETWORK_MODULE */ struct ThroughputControllerDescriptor { //! Packet size in bytes that this controller will allow in a given period. uint32_t bytesPerPeriod; //! Window of time in which no more than 'bytesPerPeriod' bytes are allowed. uint32_t periodMillisecs; RTPS_DllAPI ThroughputControllerDescriptor(); RTPS_DllAPI ThroughputControllerDescriptor(uint32_t size, uint32_t time); }; } // namespace rtps } // namespace fastrtps } // namespace eprosima #endif // THROUGHPUT_CONTROLLER_DESCRIPTOR_H
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/flowcontrol/ThroughputController.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef THROUGHPUT_CONTROLLER_H #define THROUGHPUT_CONTROLLER_H #include "FlowController.h" #include "ThroughputControllerDescriptor.h" #include <thread> namespace eprosima{ namespace fastrtps{ namespace rtps{ class RTPSWriter; class RTPSParticipantImpl; /** * Simple filter that only clears changes up to a certain accumulated payload size. * It refreshes after a given time in MS, in a staggered way (e.g. if it clears * 500kb at t=0 and 800 kb at t=10, it will refresh 500kb at t = 0 + period, and * then fully refresh at t = 10 + period). */ class ThroughputController : public FlowController { public: ThroughputController(const ThroughputControllerDescriptor&, const RTPSWriter* associatedWriter); ThroughputController(const ThroughputControllerDescriptor&, const RTPSParticipantImpl* associatedParticipant); virtual void operator()(std::vector<CacheChange_t*>& changes); private: uint32_t mBytesPerPeriod; uint32_t mAccumulatedPayloadSize; uint32_t mPeriodMillisecs; std::recursive_mutex mThroughputControllerMutex; const RTPSParticipantImpl* mAssociatedParticipant; const RTPSWriter* mAssociatedWriter; /* * Schedules the filter to be refreshed in period ms. When it does, its capacity * will be partially restored, by "sizeToRestore" bytes. */ void ScheduleRefresh(uint32_t sizeToRestore); }; } // namespace rtps } // namespace fastrtps } // namespace eprosima #endif
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/flowcontrol/FlowController.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef FLOW_CONTROLLER_H #define FLOW_CONTROLLER_H #include <vector> #include <mutex> #include <functional> #include <memory> #include <fastrtps/rtps/common/CacheChange.h> #include <thread> namespace asio{ class io_context; typedef io_context io_service; } namespace eprosima{ namespace fastrtps{ namespace rtps{ /** * Flow Controllers take a vector of cache changes (by reference) and return a filtered * vector, with a collection of changes this filter considers valid for sending, * ordered by its subjective priority. * @ingroup NETWORK_MODULE. * */ class FlowController { public: //! Called when a change is finally dispatched. static void NotifyControllersChangeSent(CacheChange_t*); //! Controller operator. Transforms the vector of changes in place. virtual void operator()(std::vector<CacheChange_t*>& changes) = 0; virtual ~FlowController(); FlowController(); private: virtual void NotifyChangeSent(CacheChange_t*){}; void RegisterAsListeningController(); void DeRegisterAsListeningController(); static std::vector<FlowController*> ListeningControllers; static std::unique_ptr<std::thread> ControllerThread; static void StartControllerService(); static void StopControllerService(); // No copy, assignment or move! Controllers are accessed by reference // from several places. // Ownership to be transferred via unique_ptr move semantics only. const FlowController& operator=(const FlowController&) = delete; FlowController(const FlowController&) = delete; FlowController(FlowController&&) = delete; protected: static std::recursive_mutex FlowControllerMutex; static std::unique_ptr<asio::io_service> ControllerService; public: // To be used by derived filters to schedule asynchronous operations. static bool IsListening(FlowController*); }; } // namespace rtps } // namespace fastrtps } // namespace eprosima #endif
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/messages/RTPSMessageGroup.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file RTPSMessageGroup.h * */ #ifndef RTPSMESSAGEGROUP_H_ #define RTPSMESSAGEGROUP_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include "../messages/RTPSMessageCreator.h" #include "../../qos/ParameterList.h" #include <fastrtps/rtps/common/FragmentNumber.h> #include <vector> #include <cassert> namespace eprosima { namespace fastrtps{ namespace rtps { class RTPSParticipantImpl; class Endpoint; /** * Class RTPSMessageGroup_t that contains the messages used to send multiples changes as one message. * @ingroup WRITER_MODULE */ class RTPSMessageGroup_t { public: RTPSMessageGroup_t(uint32_t payload, GuidPrefix_t participant_guid): rtpsmsg_submessage_(payload), rtpsmsg_fullmsg_(payload) #if HAVE_SECURITY , rtpsmsg_encrypt_(payload) #endif { CDRMessage::initCDRMsg(&rtpsmsg_fullmsg_); RTPSMessageCreator::addHeader(&rtpsmsg_fullmsg_, participant_guid); } CDRMessage_t rtpsmsg_submessage_; CDRMessage_t rtpsmsg_fullmsg_; #if HAVE_SECURITY CDRMessage_t rtpsmsg_encrypt_; #endif }; class RTPSWriter; /** * RTPSMessageGroup Class used to construct a RTPS message. * @ingroup WRITER_MODULE */ class RTPSMessageGroup { public: enum ENDPOINT_TYPE { WRITER, READER }; RTPSMessageGroup(RTPSParticipantImpl* participant, Endpoint* endpoint, ENDPOINT_TYPE, RTPSMessageGroup_t& msg_group); ~RTPSMessageGroup(); bool add_data(const CacheChange_t& change, const std::vector<GUID_t>& remote_readers, const LocatorList_t& locators, bool expectsInlineQos); bool add_data_frag(const CacheChange_t& change, const uint32_t fragment_number, const std::vector<GUID_t>& remote_readers, const LocatorList_t& locators, bool expectsInlineQos); bool add_heartbeat(const std::vector<GUID_t>& remote_readers, const SequenceNumber_t& firstSN, const SequenceNumber_t& lastSN, Count_t count, bool isFinal, bool livelinessFlag, const LocatorList_t& locators); bool add_gap(std::vector<SequenceNumber_t>& changesSeqNum, const GUID_t& remote_reader, const LocatorList_t& locators); bool add_acknack(const GUID_t& remote_writer, SequenceNumberSet_t& SNSet, int32_t count, bool finalFlag, const LocatorList_t& locators); bool add_nackfrag(const GUID_t& remote_writer, SequenceNumber_t& writerSN, FragmentNumberSet_t fnState, int32_t count, const LocatorList_t locators); private: void reset_to_header(); bool check_preconditions(const LocatorList_t& locator_list, const std::vector<GuidPrefix_t>& remote_participants) const; void flush_and_reset(const LocatorList_t& locator_list, std::vector<GuidPrefix_t>&& remote_participants); void flush(); void send(); void check_and_maybe_flush(const LocatorList_t& locator_list, const std::vector<GUID_t>& remote_endpoints); bool insert_submessage(const std::vector<GUID_t>& remote_endpoints); bool add_info_dst_in_buffer(CDRMessage_t* buffer, const std::vector<GUID_t>& remote_endpoints); bool add_info_ts_in_buffer(const std::vector<GUID_t>& remote_readers); RTPSParticipantImpl* participant_; Endpoint* endpoint_; ENDPOINT_TYPE type_; CDRMessage_t* full_msg_; CDRMessage_t* submessage_msg_; #if HAVE_SECURITY CDRMessage_t* encrypt_msg_; #endif LocatorList_t current_locators_; GuidPrefix_t current_dst_; std::vector<GuidPrefix_t> current_remote_participants_; }; } /* namespace rtps */ } /* namespace fastrtps */ } /* namespace eprosima */ #endif #endif /* RTPSMESSAGEGROUP_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/messages/CDRMessagePool.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file CDRMessagePool.h * */ #ifndef CDRMESSAGEPOOL_H_ #define CDRMESSAGEPOOL_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include "../common/CDRMessage_t.h" #include <vector> #include <mutex> namespace eprosima { namespace fastrtps{ namespace rtps { /** *@ingroup COMMON_MODULE */ class CDRMessagePool { public: /** * @param defaultGroupSize Number of messages per allocated group. */ CDRMessagePool(uint32_t defaultGroupSize); virtual ~CDRMessagePool(); //! CDRMessage_t& reserve_CDRMsg(); /** * @param payload Payload size for the reserved message. */ CDRMessage_t& reserve_CDRMsg(uint16_t payload); /** * @param obj */ void release_CDRMsg(CDRMessage_t& obj); protected: std::vector<CDRMessage_t*> m_free_objects; std::vector<CDRMessage_t*> m_all_objects; uint16_t m_group_size; void allocateGroup(); void allocateGroup(uint16_t payload); std::mutex *mutex_; }; } } /* namespace rtps */ } /* namespace eprosima */ #endif #endif /* CDRMESSAGEPOOL_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/messages/MessageReceiver.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file MessageReceiver.h */ #ifndef MESSAGERECEIVER_H_ #define MESSAGERECEIVER_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include "../common/all_common.h" #include "../../qos/ParameterList.h" #include <fastrtps/rtps/writer/StatelessWriter.h> #include <fastrtps/rtps/writer/StatefulWriter.h> using namespace eprosima::fastrtps; namespace eprosima { namespace fastrtps{ namespace rtps { class RTPSWriter; class RTPSReader; struct SubmessageHeader_t; /** * Class MessageReceiver, process the received messages. * @ingroup MANAGEMENT_MODULE */ class MessageReceiver { public: /** * @param rec_buffer_size */ MessageReceiver(RTPSParticipantImpl* participant, uint32_t rec_buffer_size); MessageReceiver(RTPSParticipantImpl* participant); virtual ~MessageReceiver(); //!Reset the MessageReceiver to process a new message. void reset(); /** Init MessageReceiver. Does what the constructor used to do. This is now on an independent function since MessageReceiver now stands inside a struct. @param rec_buffer_size **/ void init(uint32_t rec_buffer_size); /** * Process a new CDR message. * @param[in] RTPSParticipantguidprefix RTPSParticipant Guid Prefix * @param[in] loc Locator indicating the sending address. * @param[in] msg Pointer to the message */ void processCDRMsg(const GuidPrefix_t& RTPSParticipantguidprefix,Locator_t* loc, CDRMessage_t*msg); //!Pointer to the Listen Resource that contains this MessageReceiver. //!Received message CDRMessage_t m_rec_msg; #if HAVE_SECURITY CDRMessage_t m_crypto_msg; #endif //!PArameter list ParameterList_t m_ParamList; // Functions to associate/remove associatedendpoints void associateEndpoint(Endpoint *to_add); void removeEndpoint(Endpoint *to_remove); private: std::vector<RTPSWriter *> AssociatedWriters; std::vector<RTPSReader *> AssociatedReaders; std::mutex mtx; //ReceiverControlBlock* receiver_resources; CacheChange_t* mp_change; //!Protocol version of the message ProtocolVersion_t sourceVersion; //!VendorID that created the message VendorId_t sourceVendorId; //!GuidPrefix of the entity that created the message GuidPrefix_t sourceGuidPrefix; //!GuidPrefix of the entity that receives the message. GuidPrefix of the RTPSParticipant. GuidPrefix_t destGuidPrefix; //!Reply addresses (unicast). LocatorList_t unicastReplyLocatorList; //!Reply addresses (multicast). LocatorList_t multicastReplyLocatorList; //!Has the message timestamp? bool haveTimestamp; //!Timestamp associated with the message Time_t timestamp; //!Version of the protocol used by the receiving end. ProtocolVersion_t destVersion; //!Default locator used in reset Locator_t defUniLoc; /**@name Processing methods. * These methods are designed to read a part of the message * and perform the corresponding actions: * -Modify the message receiver state if necessary. * -Add information to the history. * -Return an error if the message is malformed. * @param[in] msg Pointer to the message * @param[out] params Different parameters depending on the message * @return True if correct, false otherwise */ ///@{ /** * Check the RTPSHeader of a received message. * @param msg Pointer to the message. * @return True if correct. */ bool checkRTPSHeader(CDRMessage_t*msg); /** * Read the submessage header of a message. * @param msg Pointer to the CDRMessage_t to read. * @param smh Pointer to the submessageheader structure. * @return True if correctly read. */ bool readSubmessageHeader(CDRMessage_t*msg, SubmessageHeader_t* smh); /** * * @param msg * @param smh * @param last * @return */ bool proc_Submsg_Data(CDRMessage_t*msg, SubmessageHeader_t* smh,bool*last); bool proc_Submsg_DataFrag(CDRMessage_t*msg, SubmessageHeader_t* smh, bool*last); bool proc_Submsg_Acknack(CDRMessage_t*msg, SubmessageHeader_t* smh,bool*last); bool proc_Submsg_Heartbeat(CDRMessage_t*msg, SubmessageHeader_t* smh,bool*last); bool proc_Submsg_Gap(CDRMessage_t*msg, SubmessageHeader_t* smh,bool*last); bool proc_Submsg_InfoTS(CDRMessage_t*msg, SubmessageHeader_t* smh,bool*last); bool proc_Submsg_InfoDST(CDRMessage_t*msg,SubmessageHeader_t* smh,bool*last); bool proc_Submsg_InfoSRC(CDRMessage_t*msg,SubmessageHeader_t* smh,bool*last); bool proc_Submsg_NackFrag(CDRMessage_t*msg, SubmessageHeader_t* smh, bool*last); bool proc_Submsg_HeartbeatFrag(CDRMessage_t*msg, SubmessageHeader_t* smh, bool*last); bool proc_Submsg_SecureMessage(CDRMessage_t*msg, SubmessageHeader_t* smh,bool*last); bool proc_Submsg_SecureSubMessage(CDRMessage_t*msg, SubmessageHeader_t* smh,bool*last); RTPSParticipantImpl* participant_; }; } } /* namespace rtps */ } /* namespace eprosima */ #endif #endif /* MESSAGERECEIVER_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/messages/RTPS_messages.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file RTPS_messages.h */ #ifndef RTPS_MESSAGES_H_ #define RTPS_MESSAGES_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include "../common/Types.h" #include "../common/Guid.h" #include <iostream> #include <bitset> namespace eprosima{ namespace fastrtps{ namespace rtps{ // //!@brief Enumeration of the different Submessages types #define PAD 0x01 #define ACKNACK 0x06 #define HEARTBEAT 0x07 #define GAP 0x08 #define INFO_TS 0x09 #define INFO_SRC 0x0c #define INFO_REPLY_IP4 0x0d #define INFO_DST 0x0e #define INFO_REPLY 0x0f #define NACK_FRAG 0x12 #define HEARTBEAT_FRAG 0x13 #define DATA 0x15 #define DATA_FRAG 0x16 #define SEC_PREFIX 0x31 #define SRTPS_PREFIX 0x33 //!@brief Structure Header_t, RTPS Message Header Structure. //!@ingroup COMMON_MODULE struct Header_t{ //!Protocol version ProtocolVersion_t version; //!Vendor ID VendorId_t vendorId; //!GUID prefix GuidPrefix_t guidPrefix; Header_t(): version(c_ProtocolVersion) { set_VendorId_eProsima(vendorId); } ~Header_t(){ } }; /** * @param output * @param h * @return */ inline std::ostream& operator<<(std::ostream& output,const Header_t& h){ output << "RTPS HEADER of Version: " << (int)h.version.m_major << "." << (int)h.version.m_minor; output << " || VendorId: " <<std::hex<< (int)h.vendorId[0] << "." <<(int)h.vendorId[1] << std::dec; output << "GuidPrefix: " << h.guidPrefix; return output; } //!@brief Structure SubmessageHeader_t, used to contain the header information of a submessage. struct SubmessageHeader_t{ octet submessageId; uint16_t submessageLength; uint32_t submsgLengthLarger; SubmessageFlag flags; SubmessageHeader_t(): submessageId(0), submessageLength(0), submsgLengthLarger(0), flags(0) {} }; using std::cout; using std::endl; using std::bitset; /** * @param output * @param sh * @return */ inline std::ostream& operator<<(std::ostream& output,const SubmessageHeader_t& sh){ output << "Submessage Header, ID: " <<std::hex<< (int)sh.submessageId << std::dec; output << " length: " << (int)sh.submessageLength << " flags " << (bitset<8>) sh.flags; return output; } } } } #endif #endif /* RTPS_MESSAGES_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/messages/RTPSMessageCreator.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file RTPSMessageCreator.h */ #ifndef CDRMESSAGECREATOR_H_ #define CDRMESSAGECREATOR_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include "../common/CDRMessage_t.h" #include "../common/Guid.h" #include "../common/SequenceNumber.h" #include "../common/FragmentNumber.h" #include "../common/CacheChange.h" namespace eprosima { namespace fastrtps{ class ParameterList_t; namespace rtps{ /** * @brief Class RTPSMessageCreator, allows the generation of serialized CDR RTPS Messages. * @ingroup MANAGEMENT_MODULE */ class RTPSMessageCreator { public: RTPSMessageCreator(); virtual ~RTPSMessageCreator(); //! CDRMessage_t rtpsmc_submsgElem; //! CDRMessage_t rtpsmc_submsgHeader; /** * Create a Header to the serialized message. * @param msg Pointer to the Message. * @param Prefix RTPSParticipant prefix of the message. * @param version Protocol version. * @param vendorId Vendor Id. * @return True if correct. */ static bool addHeader(CDRMessage_t*msg ,const GuidPrefix_t& Prefix,ProtocolVersion_t version,VendorId_t vendorId); /** * Create a Header to the serialized message. * @param msg Pointer to the Message. * @param Prefix RTPSParticipant prefix of the message. * @return True if correct. */ static bool addHeader(CDRMessage_t*msg ,const GuidPrefix_t& Prefix); /** * Create SubmessageHeader. * @param msg Pointer to the CDRMessage. * @param id SubMessage Id. * @param flags Submessage flags. * @param size Submessage size. * @return True if correct. */ static bool addSubmessageHeader(CDRMessage_t* msg,octet id,octet flags,uint16_t size); /** @name CDR messages creation methods. * These methods create a CDR message for different types * Depending on the function a complete message (with RTPS Header is created) or only the submessage. * @param[out] msg Pointer to where the message is going to be created and stored. * @param[in] guidPrefix Guid Prefix of the RTPSParticipant. * @param[in] param Different parameters depending on the message. * @return True if correct. */ /// @{ static bool addMessageData(CDRMessage_t* msg, GuidPrefix_t& guidprefix, const CacheChange_t* change, TopicKind_t topicKind, const EntityId_t& readerId, bool expectsInlineQos, ParameterList_t* inlineQos); static bool addSubmessageData(CDRMessage_t* msg, const CacheChange_t* change, TopicKind_t topicKind, const EntityId_t& readerId, bool expectsInlineQos, ParameterList_t* inlineQos); static bool addMessageDataFrag(CDRMessage_t* msg, GuidPrefix_t& guidprefix, const CacheChange_t* change, uint32_t fragment_number, TopicKind_t topicKind, const EntityId_t& readerId, bool expectsInlineQos, ParameterList_t* inlineQos); static bool addSubmessageDataFrag(CDRMessage_t* msg, const CacheChange_t* change, uint32_t fragment_number, uint32_t sample_size, TopicKind_t topicKind, const EntityId_t& readerId, bool expectsInlineQos, ParameterList_t* inlineQos); static bool addMessageGap(CDRMessage_t* msg, const GuidPrefix_t& guidprefix, const GuidPrefix_t& remoteGuidPrefix, const SequenceNumber_t& seqNumFirst, const SequenceNumberSet_t& seqNumList,const EntityId_t& readerId,const EntityId_t& writerId); static bool addSubmessageGap(CDRMessage_t* msg, const SequenceNumber_t& seqNumFirst, const SequenceNumberSet_t& seqNumList,const EntityId_t& readerId,const EntityId_t& writerId); static bool addMessageHeartbeat(CDRMessage_t* msg, const GuidPrefix_t& guidprefix, const EntityId_t& readerId, const EntityId_t& writerId, const SequenceNumber_t& firstSN, const SequenceNumber_t& lastSN, Count_t count, bool isFinal, bool livelinessFlag); static bool addMessageHeartbeat(CDRMessage_t* msg,const GuidPrefix_t& guidprefix, const GuidPrefix_t& remoteGuidprefix, const EntityId_t& readerId, const EntityId_t& writerId, const SequenceNumber_t& firstSN, const SequenceNumber_t& lastSN, Count_t count, bool isFinal, bool livelinessFlag); static bool addSubmessageHeartbeat(CDRMessage_t* msg, const EntityId_t& readerId, const EntityId_t& writerId, const SequenceNumber_t& firstSN, const SequenceNumber_t& lastSN, Count_t count, bool isFinal, bool livelinessFlag); static bool addMessageHeartbeatFrag(CDRMessage_t* msg, const GuidPrefix_t& guidprefix, const EntityId_t& readerId, const EntityId_t& writerId, SequenceNumber_t& firstSN, FragmentNumber_t& lastFN, Count_t count); static bool addSubmessageHeartbeatFrag(CDRMessage_t* msg, const EntityId_t& readerId, const EntityId_t& writerId, SequenceNumber_t& firstSN, FragmentNumber_t& lastFN, Count_t count); static bool addMessageAcknack(CDRMessage_t* msg,const GuidPrefix_t& guidprefix, const GuidPrefix_t& remoteGuidPrefix, const EntityId_t& readerId,const EntityId_t& writerId,SequenceNumberSet_t& SNSet,int32_t count,bool finalFlag); static bool addSubmessageAcknack(CDRMessage_t* msg, const EntityId_t& readerId,const EntityId_t& writerId,SequenceNumberSet_t& SNSet,int32_t count,bool finalFlag); static bool addMessageNackFrag(CDRMessage_t* msg, const GuidPrefix_t& guidprefix, const GuidPrefix_t& remoteGuidPrefix, const EntityId_t& readerId, const EntityId_t& writerId, SequenceNumber_t& writerSN, FragmentNumberSet_t fnState, int32_t count); static bool addSubmessageNackFrag(CDRMessage_t* msg, const EntityId_t& readerId, const EntityId_t& writerId, SequenceNumber_t& writerSN, FragmentNumberSet_t fnState, int32_t count); static bool addSubmessageInfoTS(CDRMessage_t* msg,Time_t& time,bool invalidateFlag); static bool addSubmessageInfoTS_Now(CDRMessage_t* msg,bool invalidateFlag); static bool addSubmessageInfoDST(CDRMessage_t* msg, GuidPrefix_t guidP); }; } } /* namespace rtps */ } /* namespace eprosima */ #endif #endif /* CDRMESSAGECREATOR_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/messages/CDRMessage.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file CDRMessage.h */ #ifndef CDRMESSAGE_H_ #define CDRMESSAGE_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include "../common/CDRMessage_t.h" #include "../../qos/ParameterTypes.h" #include "../common/Property.h" #include "../common/BinaryProperty.h" #include "../security/common/ParticipantGenericMessage.h" using namespace eprosima::fastrtps; namespace eprosima { namespace fastrtps{ namespace rtps { /** * Namespace CDRMessage, contains inline methods to initialize CDRMessage_t and add or read different data types. @ingroup COMMON_MODULE */ namespace CDRMessage{ /** @name Read from a CDRMessage_t. * Methods to read different data types from a CDR message. Pointers to the message and to the data types are provided. * The read position is updated in the message. It fails if you attempt to read outside the * boundaries of the message. * @param[in] msg Pointer to message. * @param[out] data_ptr Pointer to data. * @param[in] size Number of bytes (if necessary). * @return True if correct. */ /// @{ inline bool readEntityId(CDRMessage_t* msg,const EntityId_t*id); inline bool readData(CDRMessage_t* msg, octet* o, uint32_t length); inline bool readDataReversed(CDRMessage_t* msg, octet* o, uint32_t length); inline bool readInt32(CDRMessage_t* msg,int32_t* lo); inline bool readUInt32(CDRMessage_t* msg, uint32_t* ulo); inline bool readInt64(CDRMessage_t* msg, int64_t* lolo); inline bool readSequenceNumber(CDRMessage_t* msg, SequenceNumber_t* sn); inline bool readInt16(CDRMessage_t* msg,int16_t* i16); inline bool readUInt16(CDRMessage_t* msg,uint16_t* i16); inline bool readLocator(CDRMessage_t* msg,Locator_t* loc); inline bool readOctet(CDRMessage_t* msg, octet* o); inline bool readSequenceNumberSet(CDRMessage_t* msg, SequenceNumberSet_t* snset); inline bool readFragmentNumberSet(CDRMessage_t* msg, FragmentNumberSet_t* snset); inline bool readTimestamp(CDRMessage_t*msg,Time_t* ts); inline bool readString(CDRMessage_t*msg,std::string* p_str); inline bool readOctetVector(CDRMessage_t*msg,std::vector<octet>* ocvec); inline bool readProperty(CDRMessage_t* msg, Property& property); inline bool readBinaryProperty(CDRMessage_t* msg, BinaryProperty& binary_property); inline bool readPropertySeq(CDRMessage_t* msg, PropertySeq& properties); inline bool readBinaryPropertySeq(CDRMessage_t* msg, BinaryPropertySeq& binary_properties); inline bool readDataHolder(CDRMessage_t* msg, DataHolder& data_holder); inline bool readDataHolderSeq(CDRMessage_t* msg, DataHolderSeq& data_holders); inline bool readMessageIdentity(CDRMessage_t* msg, ::security::MessageIdentity& message_identity); inline bool readParticipantGenericMessage(CDRMessage_t* msg, ::security::ParticipantGenericMessage& message); ///@} /** * Initialize given CDR message with default size. It frees the memory already allocated and reserves new one. * @param[in,out] msg Pointer to the message to initialize. * @param data_size Size of the data the message is suppose to carry * @return True if correct. */ inline bool initCDRMsg(CDRMessage_t* msg,uint32_t data_size=RTPSMESSAGE_COMMON_DATA_PAYLOAD_SIZE); inline bool wrapVector(CDRMessage_t* msg, std::vector<octet>& vectorToWrap); /** * Append given CDRMessage to existing CDR Message. Joins two messages into the first one if it has space. * @param[out] first Pointer to first message. * @param[in] second Pointer to second message. ** @return True if correct. */ inline bool appendMsg(CDRMessage_t* first,CDRMessage_t* second); /** @name Add to a CDRMessage_t. * Methods to add different data types to a CDR message. Pointers to the message and to the data types are provided. * The write position is updated in the message. It fails if you attempt to write outside the * boundaries of the message. * @param[in,out] Pointer to message. * @param[in] data Data to add (might be a pointer). * @param[in] byteSize Number of bytes (if necessary). * @return True if correct. */ /// @{ inline bool addData(CDRMessage_t*, const octet*, const uint32_t number_bytes); inline bool addDataReversed(CDRMessage_t*, const octet*, const uint32_t byte_number); inline bool addOctet(CDRMessage_t*msg,octet o); inline bool addUInt16(CDRMessage_t*msg,uint16_t us); inline bool addInt32(CDRMessage_t*msg,int32_t lo); inline bool addUInt32(CDRMessage_t*msg,uint32_t lo); inline bool addInt64(CDRMessage_t*msg,int64_t lo); inline bool addEntityId(CDRMessage_t*msg,const EntityId_t* id); inline bool addSequenceNumber(CDRMessage_t*msg, const SequenceNumber_t* sn); inline bool addSequenceNumberSet(CDRMessage_t*msg, const SequenceNumberSet_t* sns); inline bool addFragmentNumberSet(CDRMessage_t*msg, FragmentNumberSet_t* fns); inline bool addLocator(CDRMessage_t*msg,Locator_t*loc); inline bool addParameterStatus(CDRMessage_t*msg,octet status); inline bool addParameterKey(CDRMessage_t*msg, const InstanceHandle_t* iHandle); inline bool addParameterSentinel(CDRMessage_t*msg); inline bool addParameterId(CDRMessage_t*msg,ParameterId_t pid); inline bool addString(CDRMessage_t*msg, const std::string& in_str); inline bool addOctetVector(CDRMessage_t*msg, const std::vector<octet>* ocvec); inline bool addParameterSampleIdentity(CDRMessage_t *msg, const SampleIdentity &sample_id); ///@} inline bool addProperty(CDRMessage_t* msg, const Property& property); inline bool addBinaryProperty(CDRMessage_t* msg, const BinaryProperty& binary_property); inline bool addPropertySeq(CDRMessage_t* msg, const PropertySeq& properties); inline bool addBinaryPropertySeq(CDRMessage_t* msg, const BinaryPropertySeq& binary_properties); inline bool addBinaryPropertySeq(CDRMessage_t* msg, const BinaryPropertySeq& binary_properties, const std::string& property_limit); inline bool addDataHolder(CDRMessage_t* msg, const DataHolder& data_holder); inline bool addDataHolderSeq(CDRMessage_t* msg, const DataHolderSeq& data_holders); inline bool addMessageIdentity(CDRMessage_t* msg, const ::security::MessageIdentity& message_identity); inline bool addParticipantGenericMessage(CDRMessage_t* msg, const ::security::ParticipantGenericMessage& message); } } } /* namespace rtps */ } /* namespace eprosima */ #ifndef DOXYGEN_SHOULD_SKIP_THIS #include "CDRMessage.hpp" #endif /* DOXYGEN_SHOULD_SKIP_THIS */ #endif #endif /* CDRMESSAGE_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/messages/CDRMessage.hpp
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef DOXYGEN_SHOULD_SKIP_THIS /** * @file CDRMessage.hpp * */ #include <cassert> #include <algorithm> #include <vector> namespace eprosima { namespace fastrtps{ namespace rtps { inline bool CDRMessage::initCDRMsg(CDRMessage_t*msg,uint32_t payload_size) { if(msg->buffer==NULL) { msg->buffer = (octet*)malloc(payload_size+RTPSMESSAGE_COMMON_RTPS_PAYLOAD_SIZE); msg->max_size = payload_size+RTPSMESSAGE_COMMON_RTPS_PAYLOAD_SIZE; } msg->pos = 0; msg->length = 0; #if EPROSIMA_BIG_ENDIAN msg->msg_endian = BIGEND; #else msg->msg_endian = LITTLEEND; #endif return true; } inline bool CDRMessage::wrapVector(CDRMessage_t* msg, std::vector<octet>& vectorToWrap) { if (msg->buffer && !msg->wraps) free(msg->buffer); msg->wraps = true; msg->buffer = vectorToWrap.data(); msg->length = (uint32_t)vectorToWrap.size(); msg->max_size = (uint32_t)vectorToWrap.capacity(); #if EPROSIMA_BIG_ENDIAN msg->msg_endian = BIGEND; #else msg->msg_endian = LITTLEEND; #endif return true; } inline bool CDRMessage::appendMsg(CDRMessage_t*first, CDRMessage_t*second) { return(CDRMessage::addData(first,second->buffer,second->length)); } inline bool CDRMessage::readEntityId(CDRMessage_t* msg,const EntityId_t* id) { if(msg->pos+4>msg->length) return false; uint32_t* aux1 = (uint32_t*) id->value; uint32_t* aux2 = (uint32_t*) &msg->buffer[msg->pos]; *aux1 = *aux2; msg->pos+=4; return true; } inline bool CDRMessage::readData(CDRMessage_t* msg, octet* o, uint32_t length) { if(msg->pos+length > msg->length){ return false; } memcpy(o,&msg->buffer[msg->pos],length); msg->pos+=length; return true; } inline bool CDRMessage::readDataReversed(CDRMessage_t* msg, octet* o, uint32_t length) { for(uint16_t i=0;i<length;i++) { *(o+i)=*(msg->buffer+msg->pos+length-1-i); } msg->pos+=length; return true; } inline bool CDRMessage::readInt32(CDRMessage_t* msg,int32_t* lo) { if(msg->pos+4>msg->length) return false; octet* dest = (octet*)lo; if(msg->msg_endian == DEFAULT_ENDIAN){ for(uint8_t i =0;i<4;i++) dest[i] = msg->buffer[msg->pos+i]; msg->pos+=4; } else{ readDataReversed(msg,dest,4); } return true; } inline bool CDRMessage::readUInt32(CDRMessage_t* msg,uint32_t* ulo) { if(msg->pos+4>msg->length) return false; octet* dest = (octet*)ulo; if(msg->msg_endian == DEFAULT_ENDIAN){ for(uint8_t i =0;i<4;i++) dest[i] = msg->buffer[msg->pos+i]; msg->pos+=4; } else{ readDataReversed(msg,dest,4); } return true; } inline bool CDRMessage::readInt64(CDRMessage_t* msg, int64_t* lolo) { if(msg->pos+8 > msg->length) return false; octet* dest = (octet*)lolo; if(msg->msg_endian == DEFAULT_ENDIAN) { for(uint8_t i = 0; i < 8; ++i) dest[i] = msg->buffer[msg->pos+i]; msg->pos+=8; } else { readDataReversed(msg, dest, 8); } return true; } inline bool CDRMessage::readSequenceNumber(CDRMessage_t* msg,SequenceNumber_t* sn) { if(msg->pos+8>msg->length) return false; bool valid=readInt32(msg,&sn->high); valid&=readUInt32(msg,&sn->low); return true; } inline bool CDRMessage::readSequenceNumberSet(CDRMessage_t* msg,SequenceNumberSet_t* sns) { bool valid = true; valid &=CDRMessage::readSequenceNumber(msg,&sns->base); uint32_t numBits; valid &=CDRMessage::readUInt32(msg,&numBits); int32_t bitmap; SequenceNumber_t seqNum; for(uint32_t i=0;i<(numBits+31)/32;++i) { valid &= CDRMessage::readInt32(msg,&bitmap); for(uint8_t bit=0;bit<32;++bit) { if((bitmap & (1<<(31-bit%32)))==(1<<(31-bit%32))) { seqNum = sns->base+(i*32+bit); if(!sns->add(seqNum)) { return false; } } } } return valid; } inline bool CDRMessage::readFragmentNumberSet(CDRMessage_t* msg, FragmentNumberSet_t* fns) { bool valid = true; valid &= CDRMessage::readUInt32(msg, &fns->base); uint32_t numBits; valid &= CDRMessage::readUInt32(msg, &numBits); int32_t bitmap; FragmentNumber_t fragNum; for (uint32_t i = 0; i<(numBits + 31) / 32; ++i) { valid &= CDRMessage::readInt32(msg, &bitmap); for (uint8_t bit = 0; bit<32; ++bit) { if ((bitmap & (1 << (31 - bit % 32))) == (1 << (31 - bit % 32))) { fragNum = fns->base + (i * 32 + bit); if (!fns->add(fragNum)) { return false; } } } } return valid; } inline bool CDRMessage::readTimestamp(CDRMessage_t* msg, Time_t* ts) { bool valid = true; valid &=CDRMessage::readInt32(msg,&ts->seconds); valid &=CDRMessage::readUInt32(msg,&ts->fraction); return valid; } inline bool CDRMessage::readLocator(CDRMessage_t* msg,Locator_t* loc) { if(msg->pos+24>msg->length) return false; bool valid = readInt32(msg,&loc->kind); valid&=readUInt32(msg,&loc->port); valid&=readData(msg,loc->address,16); return valid; } inline bool CDRMessage::readInt16(CDRMessage_t* msg,int16_t* i16) { if(msg->pos+2>msg->length) return false; octet* o = (octet*)i16; if(msg->msg_endian == DEFAULT_ENDIAN) { *o = msg->buffer[msg->pos]; *(o+1) = msg->buffer[msg->pos+1]; } else{ *o = msg->buffer[msg->pos+1]; *(o+1) = msg->buffer[msg->pos]; } msg->pos+=2; return true; } inline bool CDRMessage::readUInt16(CDRMessage_t* msg,uint16_t* i16) { if(msg->pos+2>msg->length) return false; octet* o = (octet*)i16; if(msg->msg_endian == DEFAULT_ENDIAN){ *o = msg->buffer[msg->pos]; *(o+1) = msg->buffer[msg->pos+1]; } else{ *o = msg->buffer[msg->pos+1]; *(o+1) = msg->buffer[msg->pos]; } msg->pos+=2; return true; } inline bool CDRMessage::readOctet(CDRMessage_t* msg, octet* o) { if(msg->pos+1>msg->length) return false; *o = msg->buffer[msg->pos]; msg->pos++; return true; } inline bool CDRMessage::readOctetVector(CDRMessage_t*msg,std::vector<octet>* ocvec) { if(msg->pos+4>msg->length) return false; uint32_t vecsize; bool valid = CDRMessage::readUInt32(msg,&vecsize); ocvec->resize(vecsize); valid &= CDRMessage::readData(msg,ocvec->data(),vecsize); int rest = (vecsize) % 4; rest = rest== 0 ? 0 : 4-rest; msg->pos+=rest; return valid; } inline bool CDRMessage::readString(CDRMessage_t*msg, std::string* stri) { uint32_t str_size = 1; bool valid = true; valid&=CDRMessage::readUInt32(msg,&str_size); if(msg->pos+str_size > msg->length){ return false; } if(str_size>1) { *stri = std::string();stri->resize(str_size-1); octet* oc1 = (octet*)malloc(str_size); valid &= CDRMessage::readData(msg,oc1,str_size); for(uint32_t i =0;i<str_size-1;i++) stri->at(i) = oc1[i]; free((void*)oc1); } else { msg->pos+=str_size; } int rest = (str_size) % 4; rest = rest==0 ? 0 : 4-rest; msg->pos+=rest; return valid; } inline bool CDRMessage::addData(CDRMessage_t*msg, const octet *data, const uint32_t length) { if(msg->pos + length > msg->max_size) { return false; } memcpy(&msg->buffer[msg->pos],data,length); msg->pos +=length; msg->length+=length; return true; } inline bool CDRMessage::addDataReversed(CDRMessage_t*msg, const octet *data, const uint32_t length) { if(msg->pos + length > msg->max_size) { return false; } for(uint32_t i = 0;i<length;i++) { msg->buffer[msg->pos+i] = *(data+length-1-i); } msg->pos +=length; msg->length+=length; return true; } inline bool CDRMessage::addOctet(CDRMessage_t*msg, octet O) { if(msg->pos + 1 > msg->max_size) { return false; } //const void* d = (void*)&O; msg->buffer[msg->pos] = O; msg->pos++; msg->length++; return true; } inline bool CDRMessage::addUInt16(CDRMessage_t*msg,uint16_t us) { if(msg->pos + 2 > msg->max_size) { return false; } octet* o= (octet*)&us; if(msg->msg_endian == DEFAULT_ENDIAN) { msg->buffer[msg->pos] = *(o); msg->buffer[msg->pos+1] = *(o+1); } else { msg->buffer[msg->pos] = *(o+1); msg->buffer[msg->pos+1] = *(o); } msg->pos+=2; msg->length+=2; return true; } inline bool CDRMessage::addParameterId(CDRMessage_t* msg, ParameterId_t pid) { return CDRMessage::addUInt16(msg,(uint16_t)pid); } inline bool CDRMessage::addInt32(CDRMessage_t* msg, int32_t lo) { octet* o= (octet*)&lo; if(msg->pos + 4 > msg->max_size) { return false; } if(msg->msg_endian == DEFAULT_ENDIAN) { for(uint8_t i=0;i<4;i++) { msg->buffer[msg->pos+i] = *(o+i); } } else { for(uint8_t i=0;i<4;i++) { msg->buffer[msg->pos+i] = *(o+3-i); } } msg->pos+=4; msg->length+=4; return true; } inline bool CDRMessage::addUInt32(CDRMessage_t* msg, uint32_t ulo) { octet* o= (octet*)&ulo; if(msg->pos + 4 > msg->max_size) { return false; } if(msg->msg_endian == DEFAULT_ENDIAN) { for(uint8_t i=0;i<4;i++) { msg->buffer[msg->pos+i] = *(o+i); } } else { for(uint8_t i=0;i<4;i++) { msg->buffer[msg->pos+i] = *(o+3-i); } } msg->pos+=4; msg->length+=4; return true; } inline bool CDRMessage::addInt64(CDRMessage_t* msg, int64_t lolo) { octet* o= (octet*)&lolo; if(msg->pos + 8 > msg->max_size) { return false; } if(msg->msg_endian == DEFAULT_ENDIAN) { for(uint8_t i=0;i<8;i++) { msg->buffer[msg->pos+i] = *(o+i); } } else { for(uint8_t i=0;i<8;i++) { msg->buffer[msg->pos+i] = *(o+7-i); } } msg->pos+=8; msg->length+=8; return true; } inline bool CDRMessage::addOctetVector(CDRMessage_t*msg, const std::vector<octet>* ocvec) { // TODO Calculate without padding if(msg->pos+4+ocvec->size()>=msg->max_size) { return false; } bool valid = CDRMessage::addUInt32(msg,(uint32_t)ocvec->size()); valid &= CDRMessage::addData(msg,(octet*)ocvec->data(),(uint32_t)ocvec->size()); int rest = ocvec->size()% 4; if (rest != 0) { rest = 4 - rest; //how many you have to add octet oc = '\0'; for (int i = 0; i < rest; i++) { valid &= CDRMessage::addOctet(msg, oc); } } return valid; } inline bool CDRMessage::addEntityId(CDRMessage_t* msg, const EntityId_t*ID) { if(msg->pos+4>=msg->max_size) { return false; } int* aux1; int* aux2; aux1 = (int*)(&msg->buffer[msg->pos]); aux2 = (int*) ID->value; *aux1 = *aux2; msg->pos +=4; msg->length+=4; return true; } inline bool CDRMessage::addSequenceNumber(CDRMessage_t* msg, const SequenceNumber_t* sn) { addInt32(msg,sn->high); addUInt32(msg,sn->low); return true; } inline bool CDRMessage::addSequenceNumberSet(CDRMessage_t* msg, const SequenceNumberSet_t* sns) { CDRMessage::addSequenceNumber(msg, &sns->base); //Add set if(sns->isSetEmpty()) { addUInt32(msg,0); //numbits 0 return true; } SequenceNumber_t maxseqNum = sns->get_maxSeqNum(); uint32_t numBits = (maxseqNum - sns->base + 1).low; assert((maxseqNum - sns->base + 1).high == 0); if(numBits >= 256) numBits = 255; addUInt32(msg, numBits); uint8_t n_longs = (uint8_t)((numBits + 31) / 32); int32_t* bitmap = new int32_t[n_longs]; for(uint32_t i = 0; i < n_longs; i++) bitmap[i] = 0; uint32_t deltaN = 0; for(auto it = sns->get_begin(); it != sns->get_end(); ++it) { deltaN = (*it - sns->base).low; assert((*it - sns->base).high == 0); if(deltaN < 256) bitmap[(uint32_t)(deltaN/32)] = (bitmap[(uint32_t)(deltaN/32)] | (1<<(31-deltaN%32))); else break; } for(uint32_t i= 0;i<n_longs;i++) addInt32(msg,bitmap[i]); delete[] bitmap; return true; } inline bool CDRMessage::addFragmentNumberSet(CDRMessage_t* msg, FragmentNumberSet_t* fns) { if (fns->base == 0) return false; CDRMessage::addUInt32(msg, fns->base); //Add set if (fns->isSetEmpty()) { addUInt32(msg, 0); //numbits 0 return true; } FragmentNumber_t maxfragNum = *(std::prev(fns->set.end())); uint32_t numBits = (uint32_t)(maxfragNum - fns->base + 1); if (numBits > 256) return false; addUInt32(msg, numBits); uint8_t n_longs = (uint8_t)((numBits + 31) / 32); int32_t* bitmap = new int32_t[n_longs]; for (uint32_t i = 0; i<n_longs; i++) bitmap[i] = 0; uint32_t deltaN = 0; for (auto it = fns->get_begin(); it != fns->get_end(); ++it) { deltaN = (uint32_t)(*it - fns->base); bitmap[(uint32_t)(deltaN / 32)] = (bitmap[(uint32_t)(deltaN / 32)] | (1 << (31 - deltaN % 32))); } for (uint32_t i = 0; i<n_longs; i++) addInt32(msg, bitmap[i]); delete[] bitmap; return true; } inline bool CDRMessage::addLocator(CDRMessage_t* msg, Locator_t* loc) { addInt32(msg,loc->kind); addUInt32(msg,loc->port); addData(msg,loc->address,16); return true; } inline bool CDRMessage::addParameterStatus(CDRMessage_t* msg, octet status) { if(msg->pos+8>=msg->max_size) { return false; } CDRMessage::addUInt16(msg,PID_STATUS_INFO); CDRMessage::addUInt16(msg,4); CDRMessage::addOctet(msg,0); CDRMessage::addOctet(msg,0); CDRMessage::addOctet(msg,0); CDRMessage::addOctet(msg,status); return true; } inline bool CDRMessage::addParameterKey(CDRMessage_t* msg, const InstanceHandle_t* iHandle) { if(msg->pos+20>=msg->max_size) { return false; } CDRMessage::addUInt16(msg,PID_KEY_HASH); CDRMessage::addUInt16(msg,16); for(uint8_t i=0;i<16;i++) msg->buffer[msg->pos+i] = iHandle->value[i]; msg->pos+=16; msg->length+=16; return true; } inline bool CDRMessage::addParameterSentinel(CDRMessage_t* msg) { if(msg->pos+4>=msg->max_size) { return false; } CDRMessage::addUInt16(msg, PID_SENTINEL); CDRMessage::addUInt16(msg, 0); return true; } inline bool CDRMessage::addString(CDRMessage_t*msg, const std::string& in_str) { uint32_t str_siz = (uint32_t)in_str.size(); int rest = (str_siz+1) % 4; if (rest != 0) rest = 4 - rest; //how many you have to add bool valid = CDRMessage::addUInt32(msg, str_siz+1); valid &= CDRMessage::addData(msg, (unsigned char*) in_str.c_str(), str_siz+1); if (rest != 0) { octet oc = '\0'; for (int i = 0; i < rest; i++) { valid &= CDRMessage::addOctet(msg, oc); } } return valid; } inline bool CDRMessage::addParameterSampleIdentity(CDRMessage_t *msg, const SampleIdentity &sample_id) { if(msg->pos + 28 > msg->max_size) { return false; } CDRMessage::addUInt16(msg, PID_RELATED_SAMPLE_IDENTITY); CDRMessage::addUInt16(msg, 24); CDRMessage::addData(msg, sample_id.writer_guid().guidPrefix.value, GuidPrefix_t::size); CDRMessage::addData(msg, sample_id.writer_guid().entityId.value, EntityId_t::size); CDRMessage::addInt32(msg, sample_id.sequence_number().high); CDRMessage::addUInt32(msg, sample_id.sequence_number().low); return true; } inline bool CDRMessage::addProperty(CDRMessage_t* msg, const Property& property) { assert(msg); if(property.propagate()) { if(!CDRMessage::addString(msg, property.name())) return false; if(!CDRMessage::addString(msg, property.value())) return false; } return true; } inline bool CDRMessage::readProperty(CDRMessage_t* msg, Property& property) { assert(msg); if(!CDRMessage::readString(msg, &property.name())) return false; if(!CDRMessage::readString(msg, &property.value())) return false; return true; } inline bool CDRMessage::addBinaryProperty(CDRMessage_t* msg, const BinaryProperty& binary_property) { assert(msg); if(binary_property.propagate()) { if(!CDRMessage::addString(msg, binary_property.name())) return false; if(!CDRMessage::addOctetVector(msg, &binary_property.value())) return false; } return true; } inline bool CDRMessage::readBinaryProperty(CDRMessage_t* msg, BinaryProperty& binary_property) { assert(msg); if(!CDRMessage::readString(msg, &binary_property.name())) return false; if(!CDRMessage::readOctetVector(msg, &binary_property.value())) return false; binary_property.propagate(true); return true; } inline bool CDRMessage::addPropertySeq(CDRMessage_t* msg, const PropertySeq& properties) { assert(msg); bool returnedValue = false; if(msg->pos + 4 <= msg->max_size) { uint32_t number_to_serialize = 0; for(auto it = properties.begin(); it != properties.end(); ++it) if(it->propagate()) ++number_to_serialize; if(CDRMessage::addUInt32(msg, number_to_serialize)) { returnedValue = true; for(auto it = properties.begin(); returnedValue && it != properties.end(); ++it) if(it->propagate()) returnedValue = CDRMessage::addProperty(msg, *it); } } return returnedValue; } inline bool CDRMessage::readPropertySeq(CDRMessage_t* msg, PropertySeq& properties) { assert(msg); uint32_t length = 0; if(!CDRMessage::readUInt32(msg, &length)) return false; properties.resize(length); bool returnedValue = true; for(uint32_t i = 0; returnedValue && i < length; ++i) returnedValue = CDRMessage::readProperty(msg, properties.at(i)); return returnedValue; } inline bool CDRMessage::addBinaryPropertySeq(CDRMessage_t* msg, const BinaryPropertySeq& binary_properties) { assert(msg); bool returnedValue = false; if(msg->pos + 4 <= msg->max_size) { uint32_t number_to_serialize = 0; for(auto it = binary_properties.begin(); it != binary_properties.end(); ++it) if(it->propagate()) ++number_to_serialize; if(CDRMessage::addUInt32(msg, number_to_serialize)) { returnedValue = true; for(auto it = binary_properties.begin(); returnedValue && it != binary_properties.end(); ++it) if(it->propagate()) returnedValue = CDRMessage::addBinaryProperty(msg, *it); } } return returnedValue; } inline bool CDRMessage::addBinaryPropertySeq(CDRMessage_t* msg, const BinaryPropertySeq& binary_properties, const std::string& property_limit) { assert(msg); bool returnedValue = false; if(msg->pos + 4 <= msg->max_size) { uint32_t position = 0; uint32_t number_to_serialize = 0; for(auto it = binary_properties.begin(); it != binary_properties.end() && it->name().compare(property_limit) != 0; ++it) { if(it->propagate()) ++number_to_serialize; ++position; } if(CDRMessage::addUInt32(msg, number_to_serialize)) { returnedValue = true; for(uint32_t i = 0; returnedValue && i < position; ++i) if(binary_properties.at(i).propagate()) returnedValue = CDRMessage::addBinaryProperty(msg, binary_properties.at(i)); } } return returnedValue; } inline bool CDRMessage::readBinaryPropertySeq(CDRMessage_t* msg, BinaryPropertySeq& binary_properties) { assert(msg); uint32_t length = 0; if(!CDRMessage::readUInt32(msg, &length)) return false; binary_properties.resize(length); bool returnedValue = true; for(uint32_t i = 0; returnedValue && i < length; ++i) returnedValue = CDRMessage::readBinaryProperty(msg, binary_properties.at(i)); return returnedValue; } inline bool CDRMessage::addDataHolder(CDRMessage_t* msg, const DataHolder& data_holder) { assert(msg); if(!CDRMessage::addString(msg, data_holder.class_id())) return false; if(!CDRMessage::addPropertySeq(msg, data_holder.properties())) return false; if(!CDRMessage::addBinaryPropertySeq(msg, data_holder.binary_properties())) return false; return true; } inline bool CDRMessage::readDataHolder(CDRMessage_t* msg, DataHolder& data_holder) { assert(msg); if(!CDRMessage::readString(msg, &data_holder.class_id())) return false; if(!CDRMessage::readPropertySeq(msg, data_holder.properties())) return false; if(!CDRMessage::readBinaryPropertySeq(msg, data_holder.binary_properties())) return false; return true; } inline bool CDRMessage::addDataHolderSeq(CDRMessage_t* msg, const DataHolderSeq& data_holders) { assert(msg); bool returnedValue = false; if(msg->pos + 4 <= msg->max_size) { if(CDRMessage::addUInt32(msg, static_cast<uint32_t>(data_holders.size()))) { returnedValue = true; for(auto data_holder = data_holders.begin(); returnedValue && data_holder != data_holders.end(); ++data_holder) returnedValue = CDRMessage::addDataHolder(msg, *data_holder); } } return returnedValue; } inline bool CDRMessage::readDataHolderSeq(CDRMessage_t* msg, DataHolderSeq& data_holders) { assert(msg); uint32_t length = 0; if(!CDRMessage::readUInt32(msg, &length)) return false; data_holders.resize(length); bool returnedValue = true; for(uint32_t i = 0; returnedValue && i < length; ++i) returnedValue = CDRMessage::readDataHolder(msg, data_holders.at(i)); return returnedValue; } inline bool CDRMessage::addMessageIdentity(CDRMessage_t* msg, const ::security::MessageIdentity& message_identity) { assert(msg); if(!CDRMessage::addData(msg, message_identity.source_guid().guidPrefix.value, GuidPrefix_t::size)) return false; if(!CDRMessage::addData(msg, message_identity.source_guid().entityId.value, EntityId_t::size)) return false; if(!CDRMessage::addInt64(msg, message_identity.sequence_number())) return false; return true; } inline bool CDRMessage::readMessageIdentity(CDRMessage_t* msg, ::security::MessageIdentity& message_identity) { assert(msg); if(!CDRMessage::readData(msg, message_identity.source_guid().guidPrefix.value, GuidPrefix_t::size)) return false; if(!CDRMessage::readData(msg, message_identity.source_guid().entityId.value, EntityId_t::size)) return false; if(!CDRMessage::readInt64(msg, &message_identity.sequence_number())) return false; return true; } inline bool CDRMessage::addParticipantGenericMessage(CDRMessage_t* msg, const ::security::ParticipantGenericMessage& message) { assert(msg); if(!CDRMessage::addMessageIdentity(msg, message.message_identity())) return false; if(!CDRMessage::addMessageIdentity(msg, message.related_message_identity())) return false; if(!CDRMessage::addData(msg, message.destination_participant_key().guidPrefix.value, GuidPrefix_t::size)) return false; if(!CDRMessage::addData(msg, message.destination_participant_key().entityId.value, EntityId_t::size)) return false; if(!CDRMessage::addData(msg, message.destination_endpoint_key().guidPrefix.value, GuidPrefix_t::size)) return false; if(!CDRMessage::addData(msg, message.destination_endpoint_key().entityId.value, EntityId_t::size)) return false; if(!CDRMessage::addData(msg, message.source_endpoint_key().guidPrefix.value, GuidPrefix_t::size)) return false; if(!CDRMessage::addData(msg, message.source_endpoint_key().entityId.value, EntityId_t::size)) return false; if(!CDRMessage::addString(msg, message.message_class_id())) return false; if(!CDRMessage::addDataHolderSeq(msg, message.message_data())) return false; return true; } inline bool CDRMessage::readParticipantGenericMessage(CDRMessage_t* msg, ::security::ParticipantGenericMessage& message) { assert(msg); if(!CDRMessage::readMessageIdentity(msg, message.message_identity())) return false; if(!CDRMessage::readMessageIdentity(msg, message.related_message_identity())) return false; if(!CDRMessage::readData(msg, message.destination_participant_key().guidPrefix.value, GuidPrefix_t::size)) return false; if(!CDRMessage::readData(msg, message.destination_participant_key().entityId.value, EntityId_t::size)) return false; if(!CDRMessage::readData(msg, message.destination_endpoint_key().guidPrefix.value, GuidPrefix_t::size)) return false; if(!CDRMessage::readData(msg, message.destination_endpoint_key().entityId.value, EntityId_t::size)) return false; if(!CDRMessage::readData(msg, message.source_endpoint_key().guidPrefix.value, GuidPrefix_t::size)) return false; if(!CDRMessage::readData(msg, message.source_endpoint_key().entityId.value, EntityId_t::size)) return false; if(!CDRMessage::readString(msg, &message.message_class_id())) return false; if(!CDRMessage::readDataHolderSeq(msg, message.message_data())) return false; return true; } } } /* namespace rtps */ } /* namespace eprosima */ #endif /* DOXYGEN_SHOULD_SKIP_THIS */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/security
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/security/cryptography/CryptoKeyExchange.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /*! * @file Authentication.h */ #ifndef _RTPS_SECURITY_CRYPTOGRAPHY_CRYPTOKEYEXCHANGE_H_ #define _RTPS_SECURITY_CRYPTOGRAPHY_CRYPTOKEYEXCHANGE_H_ #include "CryptoTypes.h" namespace eprosima { namespace fastrtps { namespace rtps { namespace security { class CryptoKeyExchange { public: virtual ~CryptoKeyExchange(){} /** * Creates Crypto Tokens containing the info to decrypt text encoded by the local Participant. * To be sent to the remote participant. * @param local_participant_crypto_tokens (out) Returned CryptoTokenSeq. * @param local_participant_crypto CryptoHandle returned by a previous call to register_local_participant. * @param remote_participant_crypto CryptoHangle returned by a previous call to register_remote_participant. * @param exception (out) Security exception * @return TRUE is successful. */ virtual bool create_local_participant_crypto_tokens( ParticipantCryptoTokenSeq& local_participant_crypto_tokens, const ParticipantCryptoHandle& local_participant_crypto, ParticipantCryptoHandle& remote_participant_crypto, SecurityException& exception) = 0; /** * Configures the Cryptographic Plugin with the material needed to interpret messages coming from the remote crypto. * @param local_participant_crypto CryptoHandle returned by a previous call to register_local_participant. * @param remote_participant_crypto CryptoHandle returned by a previous call to register_matched_remote_participant. * @param remote_participant_tokens CryptoToken sequence received from the remote Participant * @param exception (out) Security exception * @return TRUE if successful */ virtual bool set_remote_participant_crypto_tokens( const ParticipantCryptoHandle &local_participant_crypto, ParticipantCryptoHandle &remote_participant_crypto, const ParticipantCryptoTokenSeq &remote_participant_tokens, SecurityException &exception) = 0; /** * Creates CryptoTokens containing the info to decrypt text encoded by the local DataWriter. * @param local_datawriter_crypto_tokens (out) Returned CryptoSeq * @param local_datawriter_crypto CryptoHandle returned by a previous call to register_local_datawriter. * @param remote_datawriter_crypto CryptoHandle returned by a previous call to register_matched_remote_datareader * @param exception (out) Security exception * @return TRUE if successful */ virtual bool create_local_datawriter_crypto_tokens( DatawriterCryptoTokenSeq &local_datawriter_crypto_tokens, DatawriterCryptoHandle &local_datawriter_crypto, DatareaderCryptoHandle &remote_datareader_crypto, SecurityException &exception) = 0; /** * Creates CryptoTokens containing the info to decrypt text encoded by the local DataReader. * @param local_datareader_crypto_tokens (out) * @param local_datareader_crypto * @param remote_datawriter_crypto * @param exception (out) Security exception * @return TRUE if successful */ virtual bool create_local_datareader_crypto_tokens( DatareaderCryptoTokenSeq &local_datareader_crypto_tokens, DatareaderCryptoHandle &local_datareader_crypto, DatawriterCryptoHandle &remote_datawriter_crypto, SecurityException &exception) = 0; /** * Configures the Cryptographic Plugin with the material needed to interpret messages coming from the remote DataReader. * @param local_datawriter_crypto * @param remote_datareader_crypto * @param remote_datareader_tokens * @param exception (out) Security exception * @return TRUE if successful */ virtual bool set_remote_datareader_crypto_tokens( DatawriterCryptoHandle &local_datawriter_crypto, DatareaderCryptoHandle &remote_datareader_crypto, const DatareaderCryptoTokenSeq &remote_datareader_tokens, SecurityException &exception) = 0; /** * Configures the Cryptographic Plugin with the material needed to interpret messages coming from the remote DataWriter. * @param local_datareader_crypto * @param remote_datawriter_crypto * @param remote_datawriter_tokens * @param exception (out) Security exception * @return TRUE if successful */ virtual bool set_remote_datawriter_crypto_tokens( DatareaderCryptoHandle &local_datareader_crypto, DatawriterCryptoHandle &remote_datawriter_crypto, const DatawriterCryptoTokenSeq &remote_datawriter_tokens, SecurityException &exception) = 0; /** * Release resources associated with a CryptoTokenSeq * @param crypto_tokens * @param exception (out) Security exception * @return TRUE if successful */ virtual bool return_crypto_tokens( const CryptoTokenSeq &crypto_tokens, SecurityException &exception) = 0; }; } //namespace eprosima } //namespace fastrtps } //namespace rtps } //namespace security #endif //_RTPS_SECURITY_CRYPTOGRAPHY_CRYPTOKEYEXCHANGE_H_
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/security
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/security/cryptography/CryptoTransform.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /*! * @file Authentication.h */ #ifndef _RTPS_SECURITY_CRYPTOGRAPHY_CRYPTOTRANSFORM_H_ #define _RTPS_SECURITY_CRYPTOGRAPHY_CRYPTOTRANSFORM_H_ #include "CryptoTypes.h" #include "../../common/CDRMessage_t.h" namespace eprosima { namespace fastrtps { namespace rtps { namespace security { class CryptoTransform { public: virtual ~CryptoTransform(){} /** * Serializes the payload sent by the user with a Datawriter. * @param encoded_buffer (out) Result of the encryption * @param extra_inline_qos (out) Contains additional parameters to be added to the inlineQos of the submessage * @param plain_buffer Plain input buffer * @param sending_datawriter_crypto Returned by a prior call to register_local_datawriter * @param exception (out) Security exception * @return TRUE if successful */ virtual bool encode_serialized_payload( std::vector<uint8_t> &encoded_buffer, std::vector<uint8_t> &extra_inline_qos, const std::vector<uint8_t> &plain_buffer, DatawriterCryptoHandle &sending_datawriter_crypto, SecurityException &exception) = 0; /** * Encodes a Data, DataFrag, Gap, Heartbeat or HeartBeatFrag * @param encoded_rtps_submessage (out) Result of the encryption * @param plain_rtps_submessage Plain input buffer * @param sending_datawriter_crypto Crypto of the datawriter that sends the message * @param receiving_datareader_crypto_list Crypto of the datareaders the message is aimed at * @param exception (out) Security exception * @return TRUE is successful */ virtual bool encode_datawriter_submessage( std::vector<uint8_t> &encoded_rtps_submessage, const std::vector<uint8_t> &plain_rtps_submessage, DatawriterCryptoHandle &sending_datawriter_crypto, std::vector<DatareaderCryptoHandle*>& receiving_datareader_crypto_list, SecurityException &exception) = 0; /** * Encodes an AckNack or NackFrag * @param encoded_rtps_submessage (out) Result of the encryption * @param plain_rtps_submessage Plain input buffer * @param sending_datareader_crypto Crypto of the sending datareader * @param receiving_datawriter_crypto_list List with Crypto of the intended datawriter recipients * @param exception (out) Security exception * @return TRUE if successful */ virtual bool encode_datareader_submessage( std::vector<uint8_t> &encoded_rtps_submessage, const std::vector<uint8_t> &plain_rtps_submessage, DatareaderCryptoHandle &sending_datareader_crypto, std::vector<DatawriterCryptoHandle*> &receiving_datawriter_crypto_list, SecurityException &exception) = 0; /** * Encodes a full rtps message * @param encoded_rtps_message (out) Result of the encryption * @param plain_rtps_message Plain input buffer * @param sending_crypto Crypto of the Participant where the message originates from * @param receiving_crypto_list Crypto of the Partipants the message is intended towards * @param exception (out) Security expcetion * @return TRUE if successful */ virtual bool encode_rtps_message( std::vector<uint8_t> &encoded_rtps_message, const std::vector<uint8_t> &plain_rtps_message, ParticipantCryptoHandle &sending_crypto, const std::vector<ParticipantCryptoHandle*> &receiving_crypto_list, SecurityException &exception) = 0; /** * Reverses the transformation performed by encode_rtps_message. Decrypts the contents and veryfies MACs or digital signatures. * @param plain_buffer (out) Decoded message * @param encoded_buffer Encoded message * @param receiving_crypto Crypto of the Participant that receives the message * @param sending_crypto Crypto of the Participant that wrote the message * @param exception (out) Security exception * @return TRUE is successful */ virtual bool decode_rtps_message( std::vector<uint8_t> &plain_buffer, const std::vector<uint8_t> &encoded_buffer, const ParticipantCryptoHandle &receiving_crypto, const ParticipantCryptoHandle &sending_crypto, SecurityException &exception) = 0; /** * Determines whether the secure submessage comes from a datawriter or a data reader and extracts the required CryptoHandle to decode it. * @param datawriter_crypt (out) Crypto of the sending datawriter, if applicable * @param datareader_crypto (out) Crypto of the sending datareader, if applicable * @param secure_submessage_category (out) Specifies wether the message comes from a datawriter or from a datareader * @param encoded_rtps_submessage encoded input submessage * @param receiving_crypto Crypto of the Participant that receives the message * @param sending_crypto Crypto of the Participant that sent the message * @param exception (out) Security exception * @return TRUE if successful */ virtual bool preprocess_secure_submsg( DatawriterCryptoHandle **datawriter_crypto, DatareaderCryptoHandle **datareader_crypto, SecureSubmessageCategory_t &secure_submessage_category, const CDRMessage_t& encoded_rtps_submessage, ParticipantCryptoHandle &receiving_crypto, ParticipantCryptoHandle &sending_crypto, SecurityException &exception) = 0; /** * Called after prprocess_secure_submessage when the submessage category is DATAWRITER_SUBMESSAGE * @param plain_rtps_message (out) Result of the decryption * @param encoded_rtps_submessage Encoded message * @param receiving_datareader_crypto Crypto of the target datareader * @param sending_datawriter_crypto Crypto of the datawriter that sent the message * @param exception (out) Security exception * @return TRUE if successful */ virtual bool decode_datawriter_submessage( CDRMessage_t& plain_rtps_submessage, CDRMessage_t& encoded_rtps_submessage, DatareaderCryptoHandle &receiving_datareader_crypto, DatawriterCryptoHandle &sending_datawriter_crypto, SecurityException &exception) = 0; /** * Called after preprocess_secure_submessage when the submessage category is DATAREADER_SUBMESSAGE * @param plain_rtps_submessage (out) Result of the decryption * @param encoded_rtps_submessage Encoded message * @param receiving_datawriter_crypto Crypto of the target datawriter * @param sending_datareader_crypto Crypto of the datareader that sent the message * @param exception (out) Security exception * @return TRUE if successful */ virtual bool decode_datareader_submessage( CDRMessage_t& plain_rtps_submessage, CDRMessage_t& encoded_rtps_submessage, DatawriterCryptoHandle &receiving_datawriter_crypto, DatareaderCryptoHandle &sending_datareader_crypto, SecurityException &exception) = 0; /** * Undoes the decryption transformation made on the writer side. * @param plain_buffer (out) Result of the decryption * @param encoded_buffer Encoded input buffer * @param inline_qos Coming from the data message that carries the target payload * @param receiving_datareader_crypto Crypto of the target datareader * @param sending_datawriter_crypto Crypto of the datawriter that sent the message * @param exception (out) Security exception * @return TRUE if successful */ virtual bool decode_serialized_payload( std::vector<uint8_t> &plain_buffer, const std::vector<uint8_t> &encoded_buffer, const std::vector<uint8_t> &inline_qos, DatareaderCryptoHandle &receiving_datareader_crypto, DatawriterCryptoHandle &sending_datawriter_crypto, SecurityException &exception) = 0; virtual uint32_t calculate_extra_size_for_rtps_message(uint32_t number_discovered_participants) const = 0; virtual uint32_t calculate_extra_size_for_rtps_submessage(uint32_t number_discovered_readers) const = 0; virtual uint32_t calculate_extra_size_for_encoded_payload(uint32_t number_discovered_readers) const = 0; }; } //namespace eprosima } //namespace fastrtps } //namespace rtps } //namespace security #endif //_RTPS_SECURITY_CRYPTOGRAPHY_CRYPTOTRANSFORM_H_
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/security
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/security/cryptography/CryptoTypes.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /*! * @file Authentication.h */ #ifndef _RTPS_SECURITY_CRYPTOGRAPHY_CRYPTOTYPES_H_ #define _RTPS_SECURITY_CRYPTOGRAPHY_CRYPTOTYPES_H_ #include "../../common/Token.h" #include "../common/Handle.h" #include "../common/SharedSecretHandle.h" #include "../exceptions/SecurityException.h" #include <array> #define GMCLASSID_SECURITY_PARTICIPANT_CRYPTO_TOKENS "dds.sec.participant_crypto_tokens" #define GMCLASSID_SECURITY_DATAWRITER_CRYPTO_TOKENS "dds.sec.datawriter_crypto_tokens" #define GMCLASSID_SECURITY_DATAREADER_CRYPTO_TOKENS "dds.sec.datareader_crypto_tokens" #define SEC_PREFIX 0x31 #define SEC_POSTFIX 0x32 #define SRTPS_PREFIX 0x33 #define SRTPS_POSTFIX 0x32 #define SecureBodySubmessage 0x30 namespace eprosima { namespace fastrtps { namespace rtps { namespace security { typedef std::array<uint8_t,4> CryptoTransformKind; typedef std::array<uint8_t,4> CryptoTransformKeyId; typedef Token CryptoToken; typedef Token ParticipantCryptoToken; typedef Token DatawriterCryptoToken; typedef Token DatareaderCryptoToken; typedef std::vector<CryptoToken> CryptoTokenSeq; typedef CryptoTokenSeq ParticipantCryptoTokenSeq; typedef CryptoTokenSeq DatawriterCryptoTokenSeq; typedef CryptoTokenSeq DatareaderCryptoTokenSeq; struct CryptoTransformIdentifier{ CryptoTransformKind transformation_kind; CryptoTransformKeyId transformation_key_id; }; enum SecureSubmessageCategory_t: uint8_t { INFO_SUBMESSAGE = 0, DATAWRITER_SUBMESSAGE, DATAREADER_SUBMESSAGE }; } //namespace eprosima } //namespace fastrtps } //namespace rtps } //namespace security #endif //_RTPS_SECURITY_CRYPTOGRAPHY_CRYPTOTYPES_H_
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/security
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/security/cryptography/Cryptography.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /*! * @file Cryptography.h */ #ifndef _RTPS_SECURITY_CRYPTOGRAPHY_CRYPTOGRAPHY_H_ #define _RTPS_SECURITY_CRYPTOGRAPHY_CRYPTOGRAPHY_H_ #include "CryptoKeyExchange.h" #include "CryptoKeyFactory.h" #include "CryptoTransform.h" #include "CryptoTypes.h" namespace eprosima { namespace fastrtps { namespace rtps { namespace security { class Cryptography { public: Cryptography(): m_cryptokeyexchange(nullptr), m_cryptokeyfactory(nullptr), m_cryptotransform(nullptr) {} virtual ~Cryptography() {} /* Specializations should add functions to access the private members */ CryptoKeyExchange* cryptkeyexchange() { return m_cryptokeyexchange; } CryptoKeyFactory* cryptokeyfactory() { return m_cryptokeyfactory; } CryptoTransform* cryptotransform() { return m_cryptotransform; } protected: CryptoKeyExchange *m_cryptokeyexchange; CryptoKeyFactory *m_cryptokeyfactory; CryptoTransform *m_cryptotransform; }; } //namespace security } //namespace rtps } //namespace fastrtps } //namespace eprosima #endif //_RTPS_SECURITY_CRYPTOGRAPHY_CRYPTOGRAPHY_H_
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/security
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/security/cryptography/CryptoKeyFactory.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /*! * @file CryptoKeyFactory.h */ #ifndef _RTPS_SECURITY_CRYPTOGRAPHY_CRYPTOKEYFACTORY_H_ #define _RTPS_SECURITY_CRYPTOGRAPHY_CRYPTOKEYFACTORY_H_ #include "CryptoTypes.h" namespace eprosima { namespace fastrtps { namespace rtps { namespace security { class CryptoKeyFactory { public: virtual ~CryptoKeyFactory(){} /** * Register a local, already authenticated Participant with the Cryptographic Plugin. * Creates Crypto material needed to encrypt messages directed to other Participants * @param participant_identity Made by a prior call to validate_local_identity * @param participant_permissions Made by a prior call to validate_local_permissions * @param participant_properties Combination of PropertyQoSPolicy and contents of AccessControl * @param exception (out) Security exception * @return ParticipantCryptoHandle with generated key material */ virtual ParticipantCryptoHandle * register_local_participant( const IdentityHandle &participant_identity, const PermissionsHandle &participant_permissions, const PropertySeq &participant_properties, SecurityException &exception) = 0; /** * Register a remote, already authenticated Participant with the Cryptographic Plugin. * Creates key material to decrypt messages coming from and aimed at it. * @param local_participant_crypto_handle Returned by a prior call to register_local_participant * @param remote_participant_identity Returned by a prior call to validate_remote_identity * @param remote_participant_permissions Returned by a prior call to validate_remote_permissions * @param shared_secret Returned by a prior call to get_shared_secret (Auth Handshake) * @param exception (out) Security exception * @return ParticipantCryptoHandle with generated key material */ virtual ParticipantCryptoHandle * register_matched_remote_participant( const ParticipantCryptoHandle& local_participant_crypto_handle, const IdentityHandle& remote_participant_identity, const PermissionsHandle& remote_participant_permissions, const SharedSecretHandle& shared_secret, SecurityException &exception) = 0; /** * Register a local DataWriter belonging to an authenticated Pariticipant. * Creates cryptomaterial for use with incoming/outgoing messages * @param participant_crypto returned by a prior call to register_local_participant * @param datawriter_prop Combination of PropertyWosPolicy and contents of AccessControl * @param exception (out) Security exception * @return CryptoHandle to be used with operations related to the DataWriter */ virtual DatawriterCryptoHandle * register_local_datawriter( ParticipantCryptoHandle &participant_crypto, const PropertySeq &datawriter_prop, SecurityException &exception) = 0; /** * Register a remote DataReader that has been granted permission to match with the local DataWriter. * Creates cryptographic material to encript/decrypt messages from and towards that DataReader. * @param local_datawriter_crypto_handle Returned by a prior call to register_local_datawriter * @param remote_participant_crypto Returned by a prior call to register_matched_remote_participant. * @param shared_secret Obtained as a result of the Authentication Handshake. * @param relay_only If FALSE it generates material for both a submessage and serialized payload. Submessages only if TRUE. * @param exception (out) Security exception. * @return Crypto Handle to the generated key material. */ virtual DatareaderCryptoHandle * register_matched_remote_datareader( DatawriterCryptoHandle &local_datawriter_crypto_handle, ParticipantCryptoHandle &remote_participant_crypto, const SharedSecretHandle &shared_secret, const bool relay_only, SecurityException &exception) = 0; /** * Register a local DataReader (belonging to an authenticated and authorized Participant) with the Cryptographic Plugin. * Creates crypto material to encode messages when the encryption is independent of the targeted DataWriter * @param participant_crypto Returned by a prior call to register_local_participant * @param datareader_properties Combination of PropertyQosPolicy and the contents of AccessControl * @param exception (out) Security exception * @return Crypto Handle to the generated key material */ virtual DatareaderCryptoHandle * register_local_datareader( ParticipantCryptoHandle &participant_crypto, const PropertySeq &datareader_properties, SecurityException &exception) = 0; /** * Register a remote DataWriter that has been granted permission to match with a local DataReader. * Creates crypto material to decrypt messages coming from and encode messages going towards that datareader * @param local_datareader_crypto_handle * @param remote_participant_crypt * @param shared_secret * @param exception (out) Security exception * @return Crypto handle to the generated key material */ virtual DatawriterCryptoHandle * register_matched_remote_datawriter( DatareaderCryptoHandle &local_datareader_crypto_handle, ParticipantCryptoHandle &remote_participant_crypt, const SharedSecretHandle &shared_secret, SecurityException &exception) = 0; /** * Releases resources associated with a Participant. The Crypto Handle becomes unusable after this * @param participant_crypto_handle Belonging to the Participant that awaits termination * @param exception (out) Security exception * @return TRUE is succesful */ virtual bool unregister_participant( ParticipantCryptoHandle* participant_crypto_handle, SecurityException &exception) = 0; /** * Releases resources associated with a DataWriter. The Crypto Handle becomes unusable after this * @param datawriter_crypto_handle Belonging to the DataWriter that awaits termination * @param exception (out) Security exception * @return TRUE is succesful */ virtual bool unregister_datawriter( DatawriterCryptoHandle *datawriter_crypto_handle, SecurityException &exception) = 0; /** * Releases resources associated with a DataReader. The Crypto Handle becomes unusable after this * @param datareader_crypto_handle Belonging to the DataReader that awaits termination * @param exception (out) Security exception * @return TRUE is succesful */ virtual bool unregister_datareader( DatareaderCryptoHandle *datareader_crypto_handle, SecurityException &exception) = 0; }; } //namespace security } //namespace rtps } //namespace fastrtps } //namespace eprosima #endif //_RTPS_SECURITY_CRYPTOGRAPHY_CRYPTOKEYFACTORY_H_
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/security
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/security/exceptions/SecurityException.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef _RTPS_SECURITY_EXCEPTIONS_SECURITYEXCEPTION_H_ #define _RTPS_SECURITY_EXCEPTIONS_SECURITYEXCEPTION_H_ #include "../../exceptions/Exception.h" namespace eprosima { namespace fastrtps { namespace rtps { namespace security { /** * @brief This class is thrown as an exception when there is an error in security module. * @ingroup EXCEPTIONMODULE */ class SecurityException : public Exception { public: RTPS_DllAPI SecurityException() {} /** * @brief Default constructor. * @param message An error message. This message is copied. */ RTPS_DllAPI SecurityException(const std::string& message) : Exception(message.c_str(), 1) {} /** * @brief Default copy constructor. * @param ex SecurityException that will be copied. */ RTPS_DllAPI SecurityException(const SecurityException &ex); /** * @brief Default move constructor. * @param ex SecurityException that will be moved. */ RTPS_DllAPI SecurityException(SecurityException&& ex); /** * @brief Assigment operation. * @param ex SecurityException that will be copied. */ RTPS_DllAPI SecurityException& operator=(const SecurityException &ex); /** * @brief Assigment operation. * @param ex SecurityException that will be moved. */ RTPS_DllAPI SecurityException& operator=(SecurityException&& ex); /// \brief Default constructor virtual RTPS_DllAPI ~SecurityException() throw(); /// \brief This function throws the object as an exception. virtual RTPS_DllAPI void raise() const; }; } // namespace security } // namespace rtps } // namespace fastrtps } // namespace eprosima #endif // _RTPS_SECURITY_EXCEPTIONS_SECURITYEXCEPTION_H_
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/security
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/security/common/ParticipantGenericMessage.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef _RTPS_SECURITY_COMMON_PARTICIPANTGENERICMESSAGE_H_ #define _RTPS_SECURITY_COMMON_PARTICIPANTGENERICMESSAGE_H_ #include "../../common/Guid.h" #include "../../common/Token.h" namespace eprosima { namespace fastrtps { namespace rtps { namespace security { class MessageIdentity { public: MessageIdentity() : sequence_number_(0) {} MessageIdentity(const MessageIdentity& mi) : source_guid_(mi.source_guid_), sequence_number_(mi.sequence_number_) { } MessageIdentity(MessageIdentity&& mi) : source_guid_(std::move(mi.source_guid_)), sequence_number_(mi.sequence_number_) { } MessageIdentity& operator=(const MessageIdentity& mi) { source_guid_ = mi.source_guid_; sequence_number_ = mi.sequence_number_; return *this; } MessageIdentity& operator=(MessageIdentity&& mi) { source_guid_ = std::move(mi.source_guid_); sequence_number_ = mi.sequence_number_; return *this; } void source_guid(const GUID_t& source_guid) { source_guid_ = source_guid; } void source_guid(GUID_t&& source_guid) { source_guid_ = std::move(source_guid); } const GUID_t& source_guid() const { return source_guid_; } GUID_t& source_guid() { return source_guid_; } void sequence_number(int64_t sequence_number) { sequence_number_ = sequence_number; } int64_t sequence_number() const { return sequence_number_; } int64_t& sequence_number() { return sequence_number_; } private: GUID_t source_guid_; int64_t sequence_number_; }; class MessageIdentityHelper { public: static size_t serialized_size(const MessageIdentity& /*message*/, size_t current_alignment = 0) { size_t initial_alignment = current_alignment; current_alignment += 16; current_alignment += alignment(current_alignment, 8) + 8; return current_alignment - initial_alignment; } private: inline static size_t alignment(size_t current_alignment, size_t dataSize) { return (dataSize - (current_alignment % dataSize)) & (dataSize-1);} }; class ParticipantGenericMessage { public: ParticipantGenericMessage() {} ParticipantGenericMessage(const ParticipantGenericMessage& message) : message_identity_(message.message_identity_), related_message_identity_(message.related_message_identity_), destination_participant_key_(message.destination_participant_key_), destination_endpoint_key_(message.destination_endpoint_key_), source_endpoint_key_(message.source_endpoint_key_), message_class_id_(message.message_class_id_), message_data_(message.message_data_) {} ParticipantGenericMessage(ParticipantGenericMessage&& message) : message_identity_(std::move(message.message_identity_)), related_message_identity_(std::move(message.related_message_identity_)), destination_participant_key_(std::move(message.destination_participant_key_)), destination_endpoint_key_(std::move(message.destination_endpoint_key_)), source_endpoint_key_(std::move(message.source_endpoint_key_)), message_class_id_(std::move(message.message_class_id_)), message_data_(std::move(message.message_data_)) {} ParticipantGenericMessage& operator=(const ParticipantGenericMessage& message) { message_identity_ = message.message_identity_; related_message_identity_ = message.related_message_identity_; destination_participant_key_ = message.destination_participant_key_; destination_endpoint_key_ = message.destination_endpoint_key_; source_endpoint_key_ = message.source_endpoint_key_; message_class_id_ = message.message_class_id_; message_data_ = message.message_data_; return *this; } ParticipantGenericMessage& operator=(ParticipantGenericMessage&& message) { message_identity_ = std::move(message.message_identity_); related_message_identity_ = std::move(message.related_message_identity_); destination_participant_key_ = std::move(message.destination_participant_key_); destination_endpoint_key_ = std::move(message.destination_endpoint_key_); source_endpoint_key_ = std::move(message.source_endpoint_key_); message_class_id_ = std::move(message.message_class_id_); message_data_ = std::move(message.message_data_); return *this; } void message_identity(const MessageIdentity& message_identity) { message_identity_ = message_identity; } void message_identity(MessageIdentity&& message_identity) { message_identity_ = std::move(message_identity); } const MessageIdentity& message_identity() const { return message_identity_; } MessageIdentity& message_identity() { return message_identity_; } void related_message_identity(const MessageIdentity& related_message_identity) { related_message_identity_ = related_message_identity; } void related_message_identity(MessageIdentity&& related_message_identity) { related_message_identity_ = std::move(related_message_identity); } const MessageIdentity& related_message_identity() const { return related_message_identity_; } MessageIdentity& related_message_identity() { return related_message_identity_; } void destination_participant_key(const GUID_t& destination_participant_key) { destination_participant_key_ = destination_participant_key; } void destination_participant_key(GUID_t&& destination_participant_key) { destination_participant_key_ = std::move(destination_participant_key); } const GUID_t& destination_participant_key() const { return destination_participant_key_; } GUID_t& destination_participant_key() { return destination_participant_key_; } void destination_endpoint_key(const GUID_t& destination_endpoint_key) { destination_endpoint_key_ = destination_endpoint_key; } void destination_endpoint_key(GUID_t&& destination_endpoint_key) { destination_endpoint_key_ = std::move(destination_endpoint_key); } const GUID_t& destination_endpoint_key() const { return destination_endpoint_key_; } GUID_t& destination_endpoint_key() { return destination_endpoint_key_; } void source_endpoint_key(const GUID_t& source_endpoint_key) { source_endpoint_key_ = source_endpoint_key; } void source_endpoint_key(GUID_t&& source_endpoint_key) { source_endpoint_key_ = std::move(source_endpoint_key); } const GUID_t& source_endpoint_key() const { return source_endpoint_key_; } GUID_t& source_endpoint_key() { return source_endpoint_key_; } void message_class_id(const std::string& message_class_id) { message_class_id_ = message_class_id; } void message_class_id(std::string&& message_class_id) { message_class_id_ = std::move(message_class_id); } const std::string& message_class_id() const { return message_class_id_; } std::string& message_class_id() { return message_class_id_; } void message_data(const DataHolderSeq& message_data) { message_data_ = message_data; } void message_data(DataHolderSeq&& message_data) { message_data_ = std::move(message_data); } const DataHolderSeq& message_data() const { return message_data_; } DataHolderSeq& message_data() { return message_data_; } private: MessageIdentity message_identity_; MessageIdentity related_message_identity_; GUID_t destination_participant_key_; GUID_t destination_endpoint_key_; GUID_t source_endpoint_key_; std::string message_class_id_; DataHolderSeq message_data_; }; class ParticipantGenericMessageHelper { public: static size_t serialized_size(const ParticipantGenericMessage& message, size_t current_alignment = 0) { size_t initial_alignment = current_alignment; current_alignment += MessageIdentityHelper::serialized_size(message.message_identity(), current_alignment); current_alignment += MessageIdentityHelper::serialized_size(message.related_message_identity(), current_alignment); current_alignment += 16 * 3; current_alignment += 4 + alignment(current_alignment, 4) + message.message_class_id().size() + 1; current_alignment += DataHolderHelper::serialized_size(message.message_data(), current_alignment); return current_alignment - initial_alignment; } private: inline static size_t alignment(size_t current_alignment, size_t dataSize) { return (dataSize - (current_alignment % dataSize)) & (dataSize-1);} }; } //namespace security } //namespace rtps } //namespace fastrtps } //namespace eprosima #endif // _RTPS_SECURITY_COMMON_PARTICIPANTGENERICMESSAGE_H_
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/security
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/security/common/Handle.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /*! * @file Handle.h */ #ifndef _RTPS_SECURITY_COMMON_HANDLE_H_ #define _RTPS_SECURITY_COMMON_HANDLE_H_ #include <memory> #include <string> namespace eprosima { namespace fastrtps { namespace rtps { namespace security { class Handle { public: const std::string& get_class_id() const { return class_id_; } virtual bool nil() const = 0; protected: Handle(const std::string& class_id) : class_id_(class_id) {}; virtual ~Handle(){} private: std::string class_id_; }; template<typename T> class HandleImpl : public Handle { public: typedef T type; HandleImpl() : Handle(T::class_id_), impl_(new T) {} static HandleImpl<T>& narrow(Handle& handle) { if(handle.get_class_id().compare(T::class_id_) == 0) return reinterpret_cast<HandleImpl<T>&>(handle); return HandleImpl<T>::nil_handle; } static const HandleImpl<T>& narrow(const Handle& handle) { if(handle.get_class_id().compare(T::class_id_) == 0) return reinterpret_cast<const HandleImpl<T>&>(handle); return HandleImpl<T>::nil_handle; } bool nil() const { return impl_ ? false : true; } T* operator*() { return impl_.get(); } const T* operator*() const { return impl_.get(); } T* operator->() { return impl_.get(); } const T* operator->() const { return impl_.get(); } private: explicit HandleImpl(bool) : Handle(T::class_id_) {} std::unique_ptr<T> impl_; static HandleImpl<T> nil_handle; }; template<typename T> HandleImpl<T> HandleImpl<T>::nil_handle(true); class NilHandle : public Handle { public: NilHandle() : Handle("nil_handle") {} bool nil() const { return true; } }; // Define common handlers typedef Handle IdentityHandle; typedef Handle PermissionsHandle; typedef Handle ParticipantCryptoHandle; typedef Handle DatawriterCryptoHandle; typedef Handle DatareaderCryptoHandle; } //namespace security } //namespace rtps } //namespace fastrtps } //namespace eprosima #endif // _RTPS_SECURITY_COMMON_HANDLE_H_
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/security
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/security/common/SharedSecretHandle.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /*! * @file SharedSecretHandle.h */ #ifndef _RTPS_SECURITY_COMMON_SHAREDSECRETHANDLE_H_ #define _RTPS_SECURITY_COMMON_SHAREDSECRETHANDLE_H_ #include "Handle.h" #include <vector> namespace eprosima { namespace fastrtps { namespace rtps { namespace security { class SharedSecret { public: class BinaryData { public: BinaryData() {} BinaryData(const BinaryData& data) : name_(data.name_), value_(data.value_) {} BinaryData(BinaryData&& data) : name_(std::move(data.name_)), value_(std::move(data.value_)) {} BinaryData(const std::string& name, const std::vector<uint8_t>& value) : name_(name), value_(value) {} BinaryData(std::string&& name, std::vector<uint8_t>&& value) : name_(std::move(name)), value_(std::move(value)) {} BinaryData& operator=(const BinaryData& data) { name_ = data.name_; value_ = data.value_; return *this; } BinaryData& operator=(BinaryData&& data) { name_ = std::move(data.name_); value_ = std::move(data.value_); return *this; } void name(const std::string& name) { name_ = name; } void name(std::string&& name) { name_ = std::move(name); } const std::string& name() const { return name_; } std::string& name() { return name_; } void value(const std::vector<uint8_t>& value) { value_ = value; } void value(std::vector<uint8_t>&& value) { value_ = std::move(value); } const std::vector<uint8_t>& value() const { return value_; } std::vector<uint8_t>& value() { return value_; } private: std::string name_; std::vector<uint8_t> value_; }; static const char* const class_id_; std::vector<BinaryData> data_; }; typedef HandleImpl<SharedSecret> SharedSecretHandle; class SharedSecretHelper { public: static std::vector<uint8_t>* find_data_value(SharedSecret& sharedsecret, const std::string& name); static const std::vector<uint8_t>* find_data_value(const SharedSecret& sharedsecret, const std::string& name); }; } //namespace security } //namespace rtps } //namespace fastrtps } //namespace eprosima #endif // _RTPS_SECURITY_COMMON_SHAREDSECRETHANDLE_H_
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/security
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/security/authentication/Handshake.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /*! * @file Handshake.h */ #ifndef _RTPS_SECURITY_AUTHENTICATION_HANDSHAKE_H_ #define _RTPS_SECURITY_AUTHENTICATION_HANDSHAKE_H_ #include "../common/Handle.h" #include "../../common/Token.h" namespace eprosima { namespace fastrtps { namespace rtps { namespace security { typedef Handle HandshakeHandle; typedef Token HandshakeMessageToken; } //namespace eprosima } //namespace fastrtps } //namespace rtps } //namespace security #endif // _RTPS_SECURITY_AUTHENTICATION_HANDSHAKE_H_
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/security
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/security/authentication/Authentication.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /*! * @file Authentication.h */ #ifndef _RTPS_SECURITY_AUTHENTICATION_AUTHENTICATION_H_ #define _RTPS_SECURITY_AUTHENTICATION_AUTHENTICATION_H_ #include "../common/Handle.h" #include "../common/SharedSecretHandle.h" #include "../../common/Guid.h" #include "../../attributes/RTPSParticipantAttributes.h" #include "../exceptions/SecurityException.h" #include "../../common/Token.h" #include "../../common/CDRMessage_t.h" #include "Handshake.h" #include <cstdint> namespace eprosima { namespace fastrtps { namespace rtps { namespace security { enum ValidationResult_t : uint32_t { VALIDATION_OK = 0, VALIDATION_FAILED, VALIDATION_PENDING_RETRY, VALIDATION_PENDING_HANDSHAKE_REQUEST, VALIDATION_PENDING_HANDSHAKE_MESSAGE, VALIDATION_OK_WITH_FINAL_MESSAGE }; class Authentication; class AuthenticationListener { virtual bool on_revoke_identity(Authentication& plugin, const IdentityHandle& handle, SecurityException& exception) = 0; }; class Authentication { public: virtual ~Authentication() {} /*! * @brief Validates the identity of the local RTPSParticipant. * @param local_identity_handle (out) A handle that can be used to locally refer to the Authenticated * Participant in subsequent interactions with the Authentication plugin. * @param adjusted_participant_key (out) The GUID_t that the implementation shall use to uniquely identify the * RTPSParticipant on the network. * @param domain_id The Domain Id of the RTPSParticipant. * @param participant_attr The RTPSParticipantAttributes of the RTPSParticipant. * @param candidate_participant_key The GUID_t that the DDS implementation would have used to uniquely identify * the RTPSParticipant if the Security plugins were not enabled. * @param exception (out) A SecurityException object. * @return Validation status. */ virtual ValidationResult_t validate_local_identity(IdentityHandle** local_identity_handle, GUID_t& adjusted_participant_key, const uint32_t domain_id, const RTPSParticipantAttributes& participant_attr, const GUID_t& candidate_participant_key, SecurityException& exception) = 0; /*! * @brief Initiates the process of validating the identity of the discovered remote RTPSParticipant, represented * as an IdentityToken object. * @param remote_identity_handle (out) A handle that can be used to locally refer to the remote Authenticated * Participant in subsequent interactions with the AuthenticationPlugin. * @param local_identity_handle A handle to the local RTPSParticipant requesting the remote participant to be * validate. * @param remote_identity_token A token received as part of ParticipantProxyData, representing the * identity of the remote DomainParticipant. * @param remote_participant_key * @param exception (out) A SecurityException object. * @result Validation status. */ virtual ValidationResult_t validate_remote_identity(IdentityHandle** remote_identity_handle, const IdentityHandle& local_identity_handle, IdentityToken&& remote_identity_token, const GUID_t& remote_participant_key, SecurityException& exception) = 0; /*! * @brief This operation is used to initiate a handshake. * @param handshake_handle (out) A handle returned by the Authentication plugin used to keep the state of the * handshake. * @param handshake_message_token (out) A HandshakeMessageToken to be sent using the BuiltinParticipantMessageWriter. * @param initiator_identity_handle Handle to the local participant that originated the handshake. * @param replier_identity_handle Handle to the remote participant whose identity is being validated. * @param exception (out) A SecurityException object. * @result Validation status. */ virtual ValidationResult_t begin_handshake_request(HandshakeHandle** handshake_handle, HandshakeMessageToken** handshake_message, const IdentityHandle& initiator_identity_handle, IdentityHandle& replier_identity_handle, const CDRMessage_t& cdr_participant_data, SecurityException& exception) = 0; /*! * @brief This operation shall be invoked by the implementation in reaction to the reception of the initial * handshake message that originated on a RTPSParticipant that called the begin_handshake_request operation. * @param handshake_handle (out) A handle returned by the Authentication Plugin used to keep the state of the * handshake. * @param handshake_message_out (out) A HandshakeMessageToken containing a message to be sent using the * BuiltinParticipantMessageWriter. * @param handshake_message_in A HandshakeMessageToken containing a message received from the * BuiltinParticipantMessageReader. * @param initiator_identity_handle Handle to the remote participant that originated the handshake. * @param replier_identity_handle Handle to the local participant that is initiaing the handshake. * @param exception (out) A SecurityException object. * @result Validation status. */ virtual ValidationResult_t begin_handshake_reply(HandshakeHandle** handshake_handle, HandshakeMessageToken** handshake_message_out, HandshakeMessageToken&& handshake_message_in, IdentityHandle& initiator_identity_handle, const IdentityHandle& replier_identity_handle, const CDRMessage_t& cdr_participant_data, SecurityException& exception) = 0; /*! * @brief This operation is used to continue a handshake. * @handshake_message_out (out) A HandshakeMessageToken containing the message_data that should be place in a * ParticipantStatelessMessage to be sent using the BuiltinParticipantMessageWriter. * @param handshake_message_in The HandshakeMessageToken contained in the message_data attribute of the * ParticipantStatelessMessage received. * @param handshake_handle Handle returned by a correspoing previous call to begin_handshake_request or * begin_handshake_reply. * @exception (out) A SecurityException object. * @return Validation status. */ virtual ValidationResult_t process_handshake(HandshakeMessageToken** handshake_message_out, HandshakeMessageToken&& handshake_message_in, HandshakeHandle& handshake_handle, SecurityException& exception) = 0; /*! * @brief Retrieve the SharedSecretHandle resulting with a successfully completed handshake. * @param handshake_handle Handle returned bu a corresponding previous call to begin_handshake_request or * begin_handshake_reply, which has successfully complete the handshake operations. * @exception (out) A SecurityException object. * @return SharedSecretHandle. */ virtual SharedSecretHandle* get_shared_secret(const HandshakeHandle& handshake_handle, SecurityException& exception) = 0; /*! * @brief Sets the AuthenticationListener that the Authentication plugin will use to notify the infrastructure * of events relevant to the Authentication of RTPSParticipants. * @param listener An AuthenticationListener object to be attached to the Authentication object. * @param exception (out) A SecurityException object. */ virtual bool set_listener(AuthenticationListener* listener, SecurityException& exception) = 0; virtual bool get_identity_token(IdentityToken** identity_token, const IdentityHandle& handle, SecurityException& exception) = 0; /*! * @brief Returns the IdentityToken object to the plugin so it can be disposed of. * @param token An IdentityToken issued by the plugin on a prior call to get_identity_token. * @param exception (out) A SecurityException object. */ virtual bool return_identity_token(IdentityToken* token, SecurityException& exception) = 0; /*! * @brief Returns the Handshakehandle object to the plugin so it can be disposed of. * @param handshake_handle A HandshakeHandle issued by the plugin on a prior call to begin_handshake_request or * begin_handshake_reply. * @param exception (out) A SecurityException object. */ virtual bool return_handshake_handle(HandshakeHandle* handshake_handle, SecurityException& exception) = 0; /*! * @brief Returns the IdentityHandle object to the plugin so it can be disposed of. * @param identity_handle An IdentityHandle issued by the plugin on a prior call to validate_local_identity or * validate_remote_identity. * @param exception (out) A SecurityException object. */ virtual bool return_identity_handle(IdentityHandle* identity_handle, SecurityException& exception) = 0; /*! * @brief Returns the SharedSecretHandle object to the plugin so it can be disposed of. * @param sharedsecret_handle An SharedSecretHandle issued by the plugin on a prior call to get_shared_secret. * @param exception (out) A SecurityException object. */ virtual bool return_sharedsecret_handle(SharedSecretHandle* sharedsecret_handle, SecurityException& exception) = 0; }; } //namespace security } //namespace rtps } //namespace fastrtps } //namespace eprosima #endif // _RTPS_SECURITY_AUTHENTICATION_AUTHENTICATION_H_
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/participant/RTPSParticipant.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file RTPSParticipant.h */ #ifndef RTPSParticipant_H_ #define RTPSParticipant_H_ #include <cstdlib> #include <memory> #include "../../fastrtps_dll.h" #include "../common/Guid.h" #include <fastrtps/rtps/reader/StatefulReader.h> #include <fastrtps/rtps/attributes/RTPSParticipantAttributes.h> namespace eprosima { namespace fastrtps{ class TopicAttributes; class WriterQos; class ReaderQos; namespace rtps { class RTPSParticipantImpl; class RTPSWriter; class RTPSReader; /** * @brief Class RTPSParticipant, contains the public API for a RTPSParticipant. * @ingroup RTPS_MODULE */ class RTPS_DllAPI RTPSParticipant { friend class RTPSParticipantImpl; friend class RTPSDomain; private: /** * Constructor. Requires a pointer to the implementation. * @param pimpl Implementation. */ RTPSParticipant(RTPSParticipantImpl* pimpl); virtual ~ RTPSParticipant(); public: //!Get the GUID_t of the RTPSParticipant. const GUID_t& getGuid() const ; //!Force the announcement of the RTPSParticipant state. void announceRTPSParticipantState(); // //!Method to loose the next change (ONLY FOR TEST). //TODO remove this method because is only for testing // void loose_next_change(); //!Stop the RTPSParticipant announcement period. //TODO remove this method because is only for testing void stopRTPSParticipantAnnouncement(); //!Reset the RTPSParticipant announcement period. //TODO remove this method because is only for testing void resetRTPSParticipantAnnouncement(); /** * Indicate the Participant that you have discovered a new Remote Writer. * This method can be used by the user to implements its own Static Endpoint * Discovery Protocol * @param pguid GUID_t of the discovered Writer. * @param userDefinedId ID of the discovered Writer. * @return True if correctly added. */ bool newRemoteWriterDiscovered(const GUID_t& pguid, int16_t userDefinedId); /** * Indicate the Participant that you have discovered a new Remote Reader. * This method can be used by the user to implements its own Static Endpoint * Discovery Protocol * @param pguid GUID_t of the discovered Reader. * @param userDefinedId ID of the discovered Reader. * @return True if correctly added. */ bool newRemoteReaderDiscovered(const GUID_t& pguid, int16_t userDefinedId); /** * Get the Participant ID. * @return Participant ID. */ uint32_t getRTPSParticipantID() const; /** * Register a RTPSWriter in the builtin Protocols. * @param Writer Pointer to the RTPSWriter. * @param topicAtt Topic Attributes where you want to register it. * @param wqos WriterQos. * @return True if correctly registered. */ bool registerWriter(RTPSWriter* Writer,TopicAttributes& topicAtt,WriterQos& wqos); /** * Register a RTPSReader in the builtin Protocols. * @param Reader Pointer to the RTPSReader. * @param topicAtt Topic Attributes where you want to register it. * @param rqos ReaderQos. * @return True if correctly registered. */ bool registerReader(RTPSReader* Reader,TopicAttributes& topicAtt,ReaderQos& rqos); /** * Update writer QOS * @param Writer to update * @param wqos New writer QoS * @return true on success */ bool updateWriter(RTPSWriter* Writer,WriterQos& wqos); /** * Update reader QOS * @param Reader to update * @param rqos New reader QoS * @return true on success */ bool updateReader(RTPSReader* Reader,ReaderQos& rqos); /** * Get a pointer to the built-in to the RTPSReaders of the Endpoint Discovery Protocol. * @return std::pair of pointers to StatefulReader. First is for Subscribers and Second is for Publishers. */ std::pair<StatefulReader*,StatefulReader*> getEDPReaders(); std::vector<std::string> getParticipantNames(); /** * Get a copy of the actual state of the RTPSParticipantParameters * @return RTPSParticipantAttributes copy of the params. */ RTPSParticipantAttributes getRTPSParticipantAttributes(); uint32_t getMaxMessageSize() const; uint32_t getMaxDataSize() const; private: //!Pointer to the implementation. RTPSParticipantImpl* mp_impl; }; } } /* namespace rtps */ } /* namespace eprosima */ #endif /* RTPSParticipant_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/participant/RTPSParticipantListener.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file RTPSParticipantListener.h * */ #ifndef RTPSPARTICIPANTLISTENER_H_ #define RTPSPARTICIPANTLISTENER_H_ #include "RTPSParticipantDiscoveryInfo.h" namespace eprosima{ namespace fastrtps{ namespace rtps{ class RTPSParticipant; /** * Class RTPSParticipantListener with virtual method that the user can overload to respond to certain events. * @ingroup RTPS_MODULE */ class RTPS_DllAPI RTPSParticipantListener { public: RTPSParticipantListener(){}; virtual ~RTPSParticipantListener(){}; /** * This method is invoked when a new participant is discovered * @param part Discovered participant * @param info Discovery information of the participant */ virtual void onRTPSParticipantDiscovery(RTPSParticipant* part, RTPSParticipantDiscoveryInfo info){(void)part; (void)info;} #if HAVE_SECURITY virtual void onRTPSParticipantAuthentication(RTPSParticipant* part, const RTPSParticipantAuthenticationInfo& info) {(void)part; (void)info;} #endif }; } } } #endif /* RTPSPARTICIPANTLISTENER_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/participant/RTPSParticipantDiscoveryInfo.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file RTPSParticipantDiscoveryInfo.h * */ #ifndef RTPSPARTICIPANTDISCOVERYINFO_H_ #define RTPSPARTICIPANTDISCOVERYINFO_H_ #include "../../fastrtps_dll.h" #include "../common/Types.h" #include "../common/Guid.h" #include <vector> namespace eprosima{ namespace fastrtps{ namespace rtps{ //!Enum DISCOVERY_STATUS, three different status for discovered participants. //!@ingroup RTPS_MODULE #if defined(_WIN32) enum RTPS_DllAPI DISCOVERY_STATUS #else enum DISCOVERY_STATUS #endif { DISCOVERED_RTPSPARTICIPANT, CHANGED_QOS_RTPSPARTICIPANT, REMOVED_RTPSPARTICIPANT }; typedef std::vector<std::pair<std::string,std::string>> PropertyList; typedef std::vector<octet> UserData; /** * Class RTPSParticipantDiscoveryInfo with discovery information of the RTPS Participant. * @ingroup RTPS_MODULE */ class RTPSParticipantDiscoveryInfo { public: RTPSParticipantDiscoveryInfo():m_status(DISCOVERED_RTPSPARTICIPANT){} virtual ~RTPSParticipantDiscoveryInfo(){} //!Status DISCOVERY_STATUS m_status; //!Associated GUID GUID_t m_guid; //!Property list PropertyList m_propertyList; //!User data UserData m_userData; //!Participant name std::string m_RTPSParticipantName; }; #if HAVE_SECURITY enum RTPS_DllAPI AUTHENTICATION_STATUS { AUTHORIZED_RTPSPARTICIPANT, UNAUTHORIZED_RTPSPARTICIPANT }; class RTPSParticipantAuthenticationInfo { public: RTPSParticipantAuthenticationInfo() : status_(UNAUTHORIZED_RTPSPARTICIPANT) {} RTPSParticipantAuthenticationInfo(const RTPSParticipantAuthenticationInfo& info) : status_(info.status_), guid_(info.guid_) {} ~RTPSParticipantAuthenticationInfo() {} RTPSParticipantAuthenticationInfo* operator=(const RTPSParticipantAuthenticationInfo& info) { status_ = info.status_; guid_ = info.guid_; return this; } void status(AUTHENTICATION_STATUS status) { status_ = status; } AUTHENTICATION_STATUS status() const { return status_; } AUTHENTICATION_STATUS& status() { return status_; } void guid(const GUID_t& guid) { guid_ = guid; } void guid(GUID_t&& guid) { guid_ = std::move(guid); } const GUID_t& guid() const { return guid_; } GUID_t& guid() { return guid_; } bool operator==(const RTPSParticipantAuthenticationInfo& info) const { return status_ == info.status_ && guid_ == info.guid_; } private: //! Status AUTHENTICATION_STATUS status_; //! Associated GUID GUID_t guid_; }; #endif } } } #endif /* RTPSPARTICIPANTDISCOVERYINFO_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/resources/AsyncInterestTree.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef ASYNC_INTEREST_TREE_H #define ASYNC_INTEREST_TREE_H #include <fastrtps/rtps/writer/RTPSWriter.h> #include <mutex> #include <set> namespace eprosima { namespace fastrtps{ namespace rtps { class AsyncInterestTree { public: AsyncInterestTree(); /** * Registers a writer in a hidden set. * Threadsafe thanks to set swap. */ void RegisterInterest(const RTPSWriter*); /** * Registers all writers from participant in a hidden set. * Threadsafe thanks to set swap. */ void RegisterInterest(const RTPSParticipantImpl*); /** * Clears the visible set and swaps * with the hidden set. */ void Swap(); //! Extracts from the visible set std::set<const RTPSWriter*> GetInterestedWriters() const; private: std::set<const RTPSWriter*> mInterestAlpha, mInterestBeta; mutable std::mutex mMutexActive, mMutexHidden; std::set<const RTPSWriter*>* mActiveInterest; std::set<const RTPSWriter*>* mHiddenInterest; }; } /* namespace rtps */ } /* namespace fastrtps */ } /* namespace eprosima */ #endif
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/resources/TimedEvent.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file TimedEvent.h * */ #ifndef TIMEDEVENT_H_ #define TIMEDEVENT_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include <thread> #include <cstdint> #include <asio.hpp> #include "../common/Time_t.h" namespace eprosima { namespace fastrtps{ namespace rtps { class TimedEventImpl; /** * Timed Event class used to define any timed events. * @ingroup MANAGEMENT_MODULE */ class TimedEvent { public: /** * Enum representing event statuses */ enum EventCode { EVENT_SUCCESS, EVENT_ABORT, EVENT_MSG }; enum AUTODESTRUCTION_MODE { NONE, ON_SUCCESS, ALLWAYS }; /** * @param service IO service to run the event. * @param event_thread starting thread for identification. * @param milliseconds Interval of the timedEvent. * @param autodestruction Self-destruct mode flag. */ TimedEvent(asio::io_service &service, const std::thread& event_thread, double milliseconds, TimedEvent::AUTODESTRUCTION_MODE autodestruction = TimedEvent::NONE); virtual ~TimedEvent(); /** * Method invoked when the event occurs. Abstract method. * * @param code Code representing the status of the event * @param msg Message associated to the event. It can be nullptr. */ virtual void event(EventCode code, const char* msg) = 0; void cancel_timer(); //!Method to restart the timer. void restart_timer(); /** * Update event interval. * When updating the interval, the timer is not restarted and the new interval will only be used the next time you call restart_timer(). * * @param inter New interval for the timedEvent * @return true on success */ bool update_interval(const Duration_t& inter); /** * Update event interval. * When updating the interval, the timer is not restarted and the new interval will only be used the next time you call restart_timer(). * * @param time_millisec New interval for the timedEvent * @return true on success */ bool update_interval_millisec(double time_millisec); /** * Get the milliseconds interval * @return Mulliseconds interval */ double getIntervalMilliSec(); /** * Get the remaining milliseconds for the timer to expire * @return Remaining milliseconds for the timer to expire */ double getRemainingTimeMilliSec(); protected: void destroy(); private: TimedEventImpl* mp_impl; }; } } /* namespace rtps */ } /* namespace eprosima */ #endif #endif
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/resources/ResourceManagement.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file ResourceManagement.h * */ #ifndef RESOURCE_MANAGEMENT_H_ #define RESOURCE_MANAGEMENT_H_ namespace eprosima{ namespace fastrtps{ namespace rtps{ /** * Enum MemoryuManagementPolicy_t, indicated the way memory is managed in terms of dealing with CacheChanges */ typedef enum MemoryManagementPolicy{ PREALLOCATED_MEMORY_MODE, //!< Preallocated memory. Size set to the data type maximum. Largest memory footprint but smalles allocation count. PREALLOCATED_WITH_REALLOC_MEMORY_MODE, //!< Default size preallocated, requires reallocation when a bigger message arrives. Smaller memory footprint at the cost of an increased allocation count. DYNAMIC_RESERVE_MEMORY_MODE //< Dynamic allocation at the time of message arrival. Least memory footprint but highest allocation count. }MemoryManagementPolicy_t; } // end namespaces } } #endif /* RESOURCE_MANAGEMENT_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/resources/ResourceEvent.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file ResourceEvent.h * */ #ifndef RESOURCEEVENT_H_ #define RESOURCEEVENT_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include <thread> #include <asio.hpp> namespace eprosima { namespace fastrtps{ namespace rtps { class RTPSParticipantImpl; /** * Class ResourceEvent used to manage the temporal events. *@ingroup MANAGEMENT_MODULE */ class ResourceEvent { public: ResourceEvent(); virtual ~ResourceEvent(); /** * Method to initialize the thread. * @param p */ void init_thread(RTPSParticipantImpl*p); /** * Get the associated IO service * @return Associated IO service */ asio::io_service& getIOService() { return *mp_io_service; } std::thread& getThread() { return *mp_b_thread; } private: //!Thread std::thread* mp_b_thread; //!IO service asio::io_service* mp_io_service; //! void * mp_work; /** * Task to announce the correctness of the thread. */ void announce_thread(); //!Method to run the tasks void run_io_service(); //!Pointer to the RTPSParticipantImpl. RTPSParticipantImpl* mp_RTPSParticipantImpl; }; } } } /* namespace eprosima */ #endif #endif /* RESOURCEEVENT_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/resources/AsyncWriterThread.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file AsyncWriterThread.h * */ #ifndef _RTPS_RESOURCES_ASYNCWRITERTHREAD_H_ #define _RTPS_RESOURCES_ASYNCWRITERTHREAD_H_ #include <thread> #include <atomic> #include <mutex> #include <condition_variable> #include <list> #include <fastrtps/rtps/resources/AsyncInterestTree.h> namespace eprosima{ namespace fastrtps{ namespace rtps{ class RTPSWriter; /** * @brief This static class owns a thread that manages asynchronous writes. * Asynchronous writes happen directly (when using an async writer) and * indirectly (when responding to a NACK). * @ingroup COMMON_MODULE */ class AsyncWriterThread { public: /** * @brief Adds a writer to be managed by this thread. * Only asynchronous writers are permitted. * @param writer Asynchronous writer to be added. * @return Result of the operation. */ static bool addWriter(RTPSWriter& writer); /** * @brief Removes a writer. * @param writer Asynchronous writer to be removed. * @return Result of the operation. */ static bool removeWriter(RTPSWriter& writer); /** * Wakes the thread up. * @param interestedParticipant The participant interested in an async write. */ static void wakeUp(const RTPSParticipantImpl* interestedParticipant); /** * Wakes the thread up. * @param interestedParticipant The writer interested in an async write. */ static void wakeUp(const RTPSWriter* interestedWriter); private: AsyncWriterThread() = delete; ~AsyncWriterThread() = delete; AsyncWriterThread(const AsyncWriterThread&) = delete; const AsyncWriterThread& operator=(const AsyncWriterThread&) = delete; //! @brief runs main method static void run(); static std::thread* thread_; static std::mutex data_structure_mutex_; static std::mutex condition_variable_mutex_; //! List of asynchronous writers. static std::list<RTPSWriter*> async_writers; static AsyncInterestTree interestTree; static bool running_; static bool run_scheduled_; static std::condition_variable cv_; }; } // namespace rtps } // namespace fastrtps } // namespace eprosima #endif // _RTPS_RESOURCES_ASYNCWRITERTHREAD_H_
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/network/SenderResource.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef SENDER_RESOURCE_H #define SENDER_RESOURCE_H #include <functional> #include <vector> #include <fastrtps/transport/TransportInterface.h> namespace eprosima{ namespace fastrtps{ namespace rtps{ /** * RAII object that encapsulates the Send operation over one chanel in an unknown transport. * A Sender resource is always univocally associated to a transport channel; the * act of constructing a Sender Resource opens the channel and its destruction * closes it. * @ingroup NETWORK_MODULE */ class SenderResource { //! Only NetworkFactory is ever allowed to construct a SenderResource from scratch. //! In doing so, it guarantees the transport and channel are in a valid state for //! this resource to exist. friend class NetworkFactory; public: /** * Sends to a destination locator, through the channel managed by this resource. * @param data Raw data slice to be sent. * @param dataLength Length of the data to be sent. Will be used as a boundary for * the previous parameter. * @param destinationLocator Locator describing the destination endpoint. * @return Success of the send operation. */ bool Send(const octet* data, uint32_t dataLength, const Locator_t& destinationLocator); /** * Reports whether this resource supports the given local locator (i.e., said locator * maps to the transport channel managed by this resource). */ bool SupportsLocator(const Locator_t& local); /** * Reports whether this resource supports the given remote locator (i.e., this resource * maps to a transport channel capable of sending to it). */ bool CanSendToRemoteLocator(const Locator_t& remote); /** * Resources can only be transfered through move semantics. Copy, assignment, and * construction outside of the factory are forbidden. */ SenderResource(SenderResource&&); ~SenderResource(); private: SenderResource() = delete; SenderResource(const SenderResource&) = delete; SenderResource& operator=(const SenderResource&) = delete; SenderResource(TransportInterface&, Locator_t&); std::function<void()> Cleanup; std::function<bool(const octet* data, uint32_t dataLength, const Locator_t&)> SendThroughAssociatedChannel; std::function<bool(const Locator_t&)> LocatorMapsToManagedChannel; std::function<bool(const Locator_t&)> ManagedChannelMapsToRemote; bool mValid; // Post-construction validity check for the NetworkFactory }; } // namespace rtps } // namespace fastrtps } // namespace eprosima #endif
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/network/ReceiverResource.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef RECEIVER_RESOURCE_H #define RECEIVER_RESOURCE_H #include <functional> #include <vector> #include <fastrtps/transport/TransportInterface.h> namespace eprosima{ namespace fastrtps{ namespace rtps{ /** * RAII object that encapsulates the Receive operation over one chanel in an unknown transport. * A Receiver resource is always univocally associated to a transport channel; the * act of constructing a Receiver Resource opens the channel and its destruction * closes it. * @ingroup NETWORK_MODULE */ class ReceiverResource { //! Only NetworkFactory is ever allowed to construct a ReceiverResource from scratch. //! In doing so, it guarantees the transport and channel are in a valid state for //! this resource to exist. friend class NetworkFactory; public: /** * Performs a blocking receive through the channel managed by this resource, * notifying about the origin locator. * @param receiveBuffer Pointer to a buffer where to store the received message. * @param receiveBufferCapacity Capacity of the reception buffer. * Will be used as a boundary check for the previous parameter. * @param[out] receiveBufferSize Final size of the received message. * @param[out] originLocator Address of the remote sender. * @return Success of the managed Receive operation. */ bool Receive(octet* receiveBuffer, uint32_t receiveBufferCapacity, uint32_t& receiveBufferSize, Locator_t& originLocator); /** * Reports whether this resource supports the given local locator (i.e., said locator * maps to the transport channel managed by this resource). */ bool SupportsLocator(const Locator_t& localLocator); /** * Aborts a blocking receive (thread safe). */ void Abort(); /** * Resources can only be transfered through move semantics. Copy, assignment, and * construction outside of the factory are forbidden. */ ReceiverResource(ReceiverResource&&); ~ReceiverResource(); private: ReceiverResource() = delete; ReceiverResource(const ReceiverResource&) = delete; ReceiverResource& operator=(const ReceiverResource&) = delete; ReceiverResource(TransportInterface&, const Locator_t&); std::function<void()> Cleanup; std::function<bool(octet*, uint32_t, uint32_t&, Locator_t&)> ReceiveFromAssociatedChannel; std::function<bool(const Locator_t&)> LocatorMapsToManagedChannel; bool mValid; // Post-construction validity check for the NetworkFactory }; } // namespace rtps } // namespace fastrtps } // namespace eprosima #endif
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/network/NetworkFactory.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef NETWORK_FACTORY_HPP #define NETWORK_FACTORY_HPP #include <fastrtps/transport/TransportInterface.h> #include <fastrtps/rtps/network/ReceiverResource.h> #include <fastrtps/rtps/network/SenderResource.h> #include <vector> #include <memory> namespace eprosima{ namespace fastrtps{ namespace rtps{ /** * Provides the FastRTPS library with abstract resources, which * in turn manage the SEND and RECEIVE operations over some transport. * Once a transport is registered, it becomes invisible to the library * and is abstracted away for good. * @ingroup NETWORK_MODULE. */ class NetworkFactory { public: /** * Allows registration of a transport statically, by specifying the transport type and * its associated descriptor type. This is particularly useful for user-defined transports. */ template<class T, class D> void RegisterTransport(const D& descriptor) { std::unique_ptr<T> transport(new T(descriptor)); if(transport->init()) mRegisteredTransports.emplace_back(std::move(transport)); } /** * Allows registration of a transport dynamically. Only the transports built into FastRTPS * are supported here (although it can be easily extended at NetworkFactory.cpp) * @param descriptor Structure that defines all initial configuration for a given transport. */ void RegisterTransport(const TransportDescriptorInterface* descriptor); /** * Walks over the list of transports, opening every possible channel that can send through * the given locator and returning a vector of Sender Resources associated with it. * @param local Locator through which to send. */ std::vector<SenderResource> BuildSenderResources (Locator_t& local); /** * Walks over the list of transports, opening every possible channel that can send to the * given remote locator and returning a vector of Sender Resources associated with it. * @param local Destination locator that we intend to send to. */ std::vector<SenderResource> BuildSenderResourcesForRemoteLocator (const Locator_t& remote); /** * Walks over the list of transports, opening every possible channel that we can listen to * from the given locator, and returns a vector of Receiver Resources for this goal. * @param local Locator from which to listen. */ bool BuildReceiverResources (const Locator_t& local, std::vector<ReceiverResource>& returned_resources_list); void NormalizeLocators(LocatorList_t& locators); size_t numberOfRegisteredTransports() const; private: std::vector<std::unique_ptr<TransportInterface> > mRegisteredTransports; }; } // namespace rtps } // namespace fastrtps } // namespace eprosima #endif
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/exceptions/Exception.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef _RTPS_EXCEPTIONS_EXCEPTION_H_ #define _RTPS_EXCEPTIONS_EXCEPTION_H_ #include "../../fastrtps_dll.h" #include <exception> #include <string> #include <cstdint> namespace eprosima { namespace fastrtps { namespace rtps { /** * @brief This abstract class is used to create exceptions. * @ingroup EXCEPTIONMODULE */ class Exception : public std::exception { public: RTPS_DllAPI Exception(){}; /// @brief Default destructor. virtual RTPS_DllAPI ~Exception() throw(); /** * @brief This function returns the number associated with the system exception. * @return The number associated with the system exception. */ RTPS_DllAPI const int32_t& minor() const; /** * @brief This function sets the number that will be associated with the system exception. * @param minor The number that will be associated with the system exception. */ RTPS_DllAPI void minor(const int32_t &minor); /// @brief This function throws the object as exception. virtual RTPS_DllAPI void raise() const = 0; /** * @brief This function returns the error message. * @param message An error message. This message is copied. * @return The error message. */ virtual RTPS_DllAPI const char* what() const throw(); protected: /** * @brief Default constructor. */ RTPS_DllAPI explicit Exception(const char* const& message); /** * @brief Default copy constructor. * @param ex Exception that will be copied. */ RTPS_DllAPI Exception(const Exception &ex); /** * @brief Default move constructor. * @param ex Exception that will be moved. */ RTPS_DllAPI Exception(Exception&& ex); /** * @brief Constructor. * @param message An error message. This message is copied. * @param minor The number that will be associated with the system exception. */ RTPS_DllAPI explicit Exception(const char* const& message, const int32_t minor); /** * @brief Assigment operation. * @param ex Exception that will be copied. */ RTPS_DllAPI Exception& operator=(const Exception& ex); /** * @brief Assigment operation. * @param ex Exception that will be moved. */ RTPS_DllAPI Exception& operator=(Exception&& ex); private: std::string message_; int32_t minor_; }; } // namespace rtps } // namespace fastrtps } // namespace eprosima #endif // _RTPS_EXCEPTIONS_EXCEPTION_H_
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/attributes/ReaderAttributes.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file ReaderAttributes.h * */ #ifndef READERATTRIBUTES_H_ #define READERATTRIBUTES_H_ #include "../common/Time_t.h" #include "../common/Guid.h" #include "EndpointAttributes.h" namespace eprosima{ namespace fastrtps{ namespace rtps{ /** * Class ReaderTimes, defining the times associated with the Reliable Readers events. * @ingroup RTPS_ATTRIBUTES_MODULE */ class ReaderTimes { public: ReaderTimes() { initialAcknackDelay.fraction = 200*1000*1000; heartbeatResponseDelay.fraction = 500*1000*1000; }; virtual ~ReaderTimes(){}; //!Initial AckNack delay. Default value ~45ms. Duration_t initialAcknackDelay; //!Delay to be applied when a hearbeat message is received, default value ~116ms. Duration_t heartbeatResponseDelay; }; /** * Class ReaderAttributes, to define the attributes of a RTPSReader. * @ingroup RTPS_ATTRIBUTES_MODULE */ class ReaderAttributes { public: ReaderAttributes() { endpoint.endpointKind = READER; endpoint.durabilityKind = VOLATILE; endpoint.reliabilityKind = BEST_EFFORT; expectsInlineQos = false; }; virtual ~ReaderAttributes(){}; //!Attributes of the associated endpoint. EndpointAttributes endpoint; //!Times associated with this reader. ReaderTimes times; //!Indicates if the reader expects Inline qos, default value 0. bool expectsInlineQos; }; /** * Class RemoteWriterAttributes, to define the attributes of a Remote Writer. * @ingroup RTPS_ATTRIBUTES_MODULE */ class RemoteWriterAttributes { public: RemoteWriterAttributes() { endpoint.endpointKind = WRITER; livelinessLeaseDuration = c_TimeInfinite; ownershipStrength = 0; }; virtual ~RemoteWriterAttributes() { }; //!Attributes of the associated endpoint. EndpointAttributes endpoint; //!GUID_t of the writer, can be unknown if the reader is best effort. GUID_t guid; //!Liveliness lease duration, default value c_TimeInfinite. Duration_t livelinessLeaseDuration; //!Ownership Strength of the associated writer. uint16_t ownershipStrength; }; } } } #endif /* WRITERATTRIBUTES_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/attributes/PropertyPolicy.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /*! * @file PropertyPolicy.h */ #ifndef _RTPS_ATTRIBUTES_PROPERTYPOLICY_H_ #define _RTPS_ATTRIBUTES_PROPERTYPOLICY_H_ #include "../common/Property.h" #include "../common/BinaryProperty.h" #include "../../fastrtps_dll.h" namespace eprosima { namespace fastrtps { namespace rtps { class PropertyPolicy { public: RTPS_DllAPI PropertyPolicy() {} RTPS_DllAPI PropertyPolicy(const PropertyPolicy& property_policy) : properties_(property_policy.properties_), binary_properties_(property_policy.binary_properties_) {} RTPS_DllAPI PropertyPolicy(PropertyPolicy&& property_policy) : properties_(std::move(property_policy.properties_)), binary_properties_(std::move(property_policy.binary_properties_)) {} RTPS_DllAPI PropertyPolicy& operator=(const PropertyPolicy& property_policy) { properties_ = property_policy.properties_; binary_properties_ = property_policy.binary_properties_; return *this; } RTPS_DllAPI PropertyPolicy& operator=(PropertyPolicy&& property_policy) { properties_ = std::move(property_policy.properties_); binary_properties_= std::move(property_policy.binary_properties_); return *this; } RTPS_DllAPI const PropertySeq& properties() const { return properties_; } RTPS_DllAPI PropertySeq& properties() { return properties_; } RTPS_DllAPI const BinaryPropertySeq& binary_properties() const { return binary_properties_; } RTPS_DllAPI BinaryPropertySeq& binary_properties() { return binary_properties_; } private: PropertySeq properties_; BinaryPropertySeq binary_properties_; }; class PropertyPolicyHelper { public: /*! * @brief Returns only the properties whose name starts with the prefix. * Prefix is removed in returned properties. * @param property_policy PropertyPolicy where properties will be searched. * @param prefix Prefix used to search properties. * @return A copy of properties whose name starts with the prefix. */ RTPS_DllAPI static PropertyPolicy get_properties_with_prefix(const PropertyPolicy& property_policy, const std::string& prefix); RTPS_DllAPI static size_t length(const PropertyPolicy& property_policy); RTPS_DllAPI static std::string* find_property(PropertyPolicy& property_policy, const std::string& name); RTPS_DllAPI static const std::string* find_property(const PropertyPolicy& property_policy, const std::string& name); }; } //namespace rtps } //namespace fastrtps } //namespace eprosima #endif // _RTPS_ATTRIBUTES_PROPERTYPOLICY_H_
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/attributes/EndpointAttributes.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file EndpointAttributes.h */ #ifndef ENDPOINTATTRIBUTES_H_ #define ENDPOINTATTRIBUTES_H_ #include "../common/Types.h" #include "../common/Locator.h" #include "PropertyPolicy.h" namespace eprosima { namespace fastrtps{ namespace rtps { /** * Structure EndpointAttributes, describing the attributes associated with an RTPS Endpoint. * @ingroup RTPS_ATTRIBUTES_MODULE */ class EndpointAttributes { public: EndpointAttributes() { topicKind = NO_KEY; reliabilityKind = BEST_EFFORT; durabilityKind = VOLATILE; m_userDefinedID = -1; m_entityID = -1; endpointKind = WRITER; }; virtual ~EndpointAttributes(){}; //!Endpoint kind, default value WRITER EndpointKind_t endpointKind; //!Topic kind, default value NO_KEY TopicKind_t topicKind; //!Reliability kind, default value BEST_EFFORT ReliabilityKind_t reliabilityKind; //!Durability kind, default value VOLATILE DurabilityKind_t durabilityKind; //!Unicast locator list LocatorList_t unicastLocatorList; //!Multicast locator list LocatorList_t multicastLocatorList; LocatorList_t outLocatorList; PropertyPolicy properties; /** * Get the user defined ID * @return User defined ID */ inline int16_t getUserDefinedID() const {return m_userDefinedID;} /** * Get the entity defined ID * @return Entity ID */ inline int16_t getEntityID() const {return m_entityID;} /** * Set the user defined ID * @param id User defined ID to be set */ inline void setUserDefinedID(uint8_t id){m_userDefinedID = id;}; /** * Set the entity ID * @param id Entity ID to be set */ inline void setEntityID(uint8_t id){m_entityID = id;}; private: //!User Defined ID, used for StaticEndpointDiscovery, default value -1. int16_t m_userDefinedID; //!Entity ID, if the user want to specify the EntityID of the enpoint, default value -1. int16_t m_entityID; }; } } /* namespace rtps */ } /* namespace eprosima */ #endif /* */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/attributes/WriterAttributes.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file WriterAttributes.h * */ #ifndef WRITERATTRIBUTES_H_ #define WRITERATTRIBUTES_H_ #include "../common/Time_t.h" #include "../common/Guid.h" #include "../flowcontrol/ThroughputControllerDescriptor.h" #include "EndpointAttributes.h" namespace eprosima{ namespace fastrtps{ namespace rtps{ typedef enum RTPSWriterPublishMode : octet { SYNCHRONOUS_WRITER, ASYNCHRONOUS_WRITER } RTPSWriterPublishMode; /** * Class WriterTimes, defining the times associated with the Reliable Writers events. * @ingroup RTPS_ATTRIBUTES_MODULE */ class WriterTimes { public: WriterTimes() { initialHeartbeatDelay.fraction = 200*1000*1000; heartbeatPeriod.seconds = 3; nackResponseDelay.fraction = 200*1000*1000; }; virtual ~WriterTimes(){}; //! Initial heartbeat delay. Default value ~45ms. Duration_t initialHeartbeatDelay; //! Periodic HB period, default value 3s. Duration_t heartbeatPeriod; //!Delay to apply to the response of a ACKNACK message, default value ~45ms. Duration_t nackResponseDelay; //!This time allows the RTPSWriter to ignore nack messages too soon after the data as sent, default value 0s. Duration_t nackSupressionDuration; }; /** * Class WriterAttributes, defining the attributes of a RTPSWriter. * @ingroup RTPS_ATTRIBUTES_MODULE */ class WriterAttributes { public: WriterAttributes() : mode(SYNCHRONOUS_WRITER) { endpoint.endpointKind = WRITER; endpoint.durabilityKind = TRANSIENT_LOCAL; endpoint.reliabilityKind = RELIABLE; }; virtual ~WriterAttributes(){}; //!Attributes of the associated endpoint. EndpointAttributes endpoint; //!Writer Times (only used for RELIABLE). WriterTimes times; //!Indicates if the Writer is synchronous or asynchronous RTPSWriterPublishMode mode; // Throughput controller, always the last one to apply ThroughputControllerDescriptor throughputController; }; /** * Class RemoteReaderAttributes, to define the attributes of a Remote Reader. * @ingroup RTPS_ATTRIBUTES_MODULE */ class RemoteReaderAttributes { public: RemoteReaderAttributes() { endpoint.endpointKind = READER; expectsInlineQos = false; }; virtual ~RemoteReaderAttributes() { }; //!Attributes of the associated endpoint. EndpointAttributes endpoint; //!GUID_t of the reader. GUID_t guid; //!Expects inline QOS. bool expectsInlineQos; }; } } } #endif /* WRITERATTRIBUTES_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/attributes/RTPSParticipantAttributes.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file RTPSParticipantAttributes.h */ #ifndef _RTPSPARTICIPANTPARAMETERS_H_ #define _RTPSPARTICIPANTPARAMETERS_H_ #include "../common/Time_t.h" #include "../common/Locator.h" #include "PropertyPolicy.h" #include "../flowcontrol/ThroughputControllerDescriptor.h" #include "../../transport/TransportInterface.h" #include <memory> namespace eprosima { namespace fastrtps{ namespace rtps { /** * Class SimpleEDPAttributes, to define the attributes of the Simple Endpoint Discovery Protocol. * @ingroup RTPS_ATTRIBUTES_MODULE */ class SimpleEDPAttributes { public: //!Default value true. bool use_PublicationWriterANDSubscriptionReader; //!Default value true. bool use_PublicationReaderANDSubscriptionWriter; SimpleEDPAttributes(): use_PublicationWriterANDSubscriptionReader(true), use_PublicationReaderANDSubscriptionWriter(true) { } }; /** * Class PortParameters, to define the port parameters and gains related with the RTPS protocol. * @ingroup RTPS_ATTRIBUTES_MODULE */ class PortParameters { public: PortParameters() { portBase = 7400; participantIDGain = 2; domainIDGain = 250; offsetd0 = 0; offsetd1 = 10; offsetd2 = 1; offsetd3 = 11; }; virtual ~PortParameters(){} /** * Get a multicast port based on the domain ID. * * @param domainId Domain ID. * @return Multicast port */ inline uint32_t getMulticastPort(uint32_t domainId) { return portBase+ domainIDGain * domainId+ offsetd0; } /** * Get a unicast port baes on the domain ID and the participant ID. * * @param domainId Domain ID. * @param RTPSParticipantID Participant ID. * @return Unicast port */ inline uint32_t getUnicastPort(uint32_t domainId,uint32_t RTPSParticipantID) { return portBase+ domainIDGain * domainId + offsetd1 + participantIDGain * RTPSParticipantID; } //!PortBase, default value 7400. uint16_t portBase; //!DomainID gain, default value 250. uint16_t domainIDGain; //!ParticipantID gain, default value 2. uint16_t participantIDGain; //!Offset d0, default value 0. uint16_t offsetd0; //!Offset d1, default value 10. uint16_t offsetd1; //!Offset d2, default value 1. uint16_t offsetd2; //!Offset d3, default value 11. uint16_t offsetd3; }; /** * Class BuiltinAttributes, to define the behavior of the RTPSParticipant builtin protocols. * @ingroup RTPS_ATTRIBUTES_MODULE */ class BuiltinAttributes{ public: /** * If set to false, NO discovery whatsoever would be used. * Publisher and Subscriber defined with the same topic name would NOT be linked. All matching must be done * manually through the addReaderLocator, addReaderProxy, addWriterProxy methods. */ bool use_SIMPLE_RTPSParticipantDiscoveryProtocol; //!Indicates to use the WriterLiveliness protocol. bool use_WriterLivelinessProtocol; /** * If set to true, SimpleEDP would be used. */ bool use_SIMPLE_EndpointDiscoveryProtocol; /** * If set to true, StaticEDP based on an XML file would be implemented. * The XML filename must be provided. */ bool use_STATIC_EndpointDiscoveryProtocol; /** * DomainId to be used by the RTPSParticipant (80 by default). */ uint32_t domainId; //!Lease Duration of the RTPSParticipant, indicating how much time remote RTPSParticipants should consider this RTPSParticipant alive. Duration_t leaseDuration; /** * The period for the RTPSParticipant to send its Discovery Message to all other discovered RTPSParticipants * as well as to all Multicast ports. */ Duration_t leaseDuration_announcementperiod; //!Attributes of the SimpleEDP protocol SimpleEDPAttributes m_simpleEDP; //!Metatraffic Unicast Locator List LocatorList_t metatrafficUnicastLocatorList; //!Metatraffic Multicast Locator List. LocatorList_t metatrafficMulticastLocatorList; //! Initial peers. LocatorList_t initialPeersList; BuiltinAttributes() { use_SIMPLE_RTPSParticipantDiscoveryProtocol = true; use_SIMPLE_EndpointDiscoveryProtocol = true; use_STATIC_EndpointDiscoveryProtocol = false; m_staticEndpointXMLFilename = ""; domainId = 0; leaseDuration.seconds = 500; leaseDuration_announcementperiod.seconds = 250; use_WriterLivelinessProtocol = true; }; virtual ~BuiltinAttributes(){}; /** * Get the static endpoint XML filename * @return Static endpoint XML filename */ const char* getStaticEndpointXMLFilename(){ return m_staticEndpointXMLFilename.c_str(); }; /** * Set the static endpoint XML filename * @param str Static endpoint XML filename */ void setStaticEndpointXMLFilename(const char* str){ m_staticEndpointXMLFilename = std::string(str); }; private: //! StaticEDP XML filename, only necessary if use_STATIC_EndpointDiscoveryProtocol=true std::string m_staticEndpointXMLFilename; }; /** * Class RTPSParticipantAttributes used to define different aspects of a RTPSParticipant. *@ingroup RTPS_ATTRIBUTES_MODULE */ class RTPSParticipantAttributes { public: RTPSParticipantAttributes() { defaultSendPort = 10040; setName("RTPSParticipant"); sendSocketBufferSize = 65536; listenSocketBufferSize = 65536; use_IP4_to_send = true; use_IP6_to_send = false; participantID = -1; useBuiltinTransports = true; } virtual ~RTPSParticipantAttributes(){}; /** * Default list of Unicast Locators to be used for any Endpoint defined inside this RTPSParticipant in the case * that it was defined with NO UnicastLocators. At least ONE locator should be included in this list. */ LocatorList_t defaultUnicastLocatorList; /** * Default list of Multicast Locators to be used for any Endpoint defined inside this RTPSParticipant in the case * that it was defined with NO UnicastLocators. This is usually left empty. */ LocatorList_t defaultMulticastLocatorList; /** * Default list of Locators used to send messages through. Used to link with SenderResources in the case and * Endpoint is created with NO outLocators. This list contains the default outLocators for the Transports implemented * by eProsima. */ LocatorList_t defaultOutLocatorList; /** * Default send port that all Endpoints in the RTPSParticipant would use to send messages, default value 10040. * In this release all Endpoints use the same resource (socket) to send messages. */ uint32_t defaultSendPort; //!Send socket buffer size for the send resource, default value 65536. uint32_t sendSocketBufferSize; //!Listen socket buffer for all listen resources, default value 65536. uint32_t listenSocketBufferSize; //! Builtin parameters. BuiltinAttributes builtin; //!Port Parameters PortParameters port; //!User Data of the participant std::vector<octet> userData; //!Participant ID int32_t participantID; //!Use IP4 to send messages. bool use_IP4_to_send; //!Use IP6 to send messages. bool use_IP6_to_send; //!Set the name of the participant. inline void setName(const char* nam){name = nam;} //!Get the name of the participant. inline const char* getName() const {return name.c_str();} //!Throughput controller parameters. Leave default for uncontrolled flow. ThroughputControllerDescriptor throughputController; //!User defined transports to use alongside or in place of builtins. std::vector<std::shared_ptr<TransportDescriptorInterface> > userTransports; //!Set as false to disable the default UDPv4 implementation. bool useBuiltinTransports; //! Property policies PropertyPolicy properties; private: //!Name of the participant. std::string name; }; } } /* namespace rtps */ } /* namespace eprosima */ #endif /* _RTPSPARTICIPANTPARAMETERS_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/attributes/HistoryAttributes.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file HistoryAttributes.h * */ #ifndef HISTORYATTRIBUTES_H_ #define HISTORYATTRIBUTES_H_ #include "../resources/ResourceManagement.h" #include "../../fastrtps_dll.h" #include <cstdint> namespace eprosima{ namespace fastrtps{ namespace rtps{ /** * Class HistoryAttributes, to specify the attributes of a WriterHistory or a ReaderHistory. * This class is only intended to be used with the RTPS API. * The Publsiher-Subscriber API has other fields to define this values (HistoryQosPolicy and ResourceLimitsQosPolicy). * @ingroup RTPS_ATTRIBUTES_MODULE */ class RTPS_DllAPI HistoryAttributes { public: HistoryAttributes(): memoryPolicy(PREALLOCATED_MEMORY_MODE), payloadMaxSize(500), initialReservedCaches(500), maximumReservedCaches(0) {} /** Constructor * @param memoryPolicy Set wether memory can be dynamically reallocated or not * @param payload Maximum payload size. It is used when memory management polycy is * PREALLOCATED_MEMORY_MODE or PREALLOCATED_WITH_REALLOC_MEMORY_MODE. * @param initial Initial reserved caches. It is used when memory management policy is * PREALLOCATED_MEMORY_MODE or PREALLOCATED_WITH_REALLOC_MEMORY_MODE. * @param maxRes Maximum reserved caches. */ HistoryAttributes(MemoryManagementPolicy_t memoryPolicy, uint32_t payload, int32_t initial, int32_t maxRes): memoryPolicy(memoryPolicy), payloadMaxSize(payload),initialReservedCaches(initial), maximumReservedCaches(maxRes){} virtual ~HistoryAttributes(){} //!Memory management policy. MemoryManagementPolicy_t memoryPolicy; //!Maximum payload size of the history, default value 500. uint32_t payloadMaxSize; //!Number of the initial Reserved Caches, default value 500. int32_t initialReservedCaches; //!Maximum number of reserved caches. Default value is 0 that indicates to keep reserving until something breaks. int32_t maximumReservedCaches; }; } } } #endif /* HISTORYATTRIBUTES_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/common/CDRMessage_t.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file CDRMessage_t.h */ #ifndef CDRMESSAGE_T_H_ #define CDRMESSAGE_T_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include "Types.h" #include <stdlib.h> #include <cstring> namespace eprosima{ namespace fastrtps{ namespace rtps{ //!Max size of RTPS message in bytes. #define RTPSMESSAGE_DEFAULT_SIZE 10500 //max size of rtps message in bytes #define RTPSMESSAGE_COMMON_RTPS_PAYLOAD_SIZE 536 //common payload a rtps message has TODO(Ricardo) It is necessary? #define RTPSMESSAGE_COMMON_DATA_PAYLOAD_SIZE 10000 //common data size #define RTPSMESSAGE_HEADER_SIZE 20 //header size in bytes #define RTPSMESSAGE_SUBMESSAGEHEADER_SIZE 4 #define RTPSMESSAGE_DATA_EXTRA_INLINEQOS_SIZE 4 #define RTPSMESSAGE_INFOTS_SIZE 12 #define RTPSMESSAGE_OCTETSTOINLINEQOS_DATASUBMSG 16 //may change in future versions #define RTPSMESSAGE_OCTETSTOINLINEQOS_DATAFRAGSUBMSG 28 //may change in future versions #define RTPSMESSAGE_DATA_MIN_LENGTH 24 /** * @brief Structure CDRMessage_t, contains a serialized message. * @ingroup COMMON_MODULE */ struct RTPS_DllAPI CDRMessage_t{ //! Default constructor CDRMessage_t():wraps(false){ pos = 0; length = 0; buffer = (octet*) malloc(RTPSMESSAGE_DEFAULT_SIZE); max_size = RTPSMESSAGE_DEFAULT_SIZE; #if EPROSIMA_BIG_ENDIAN msg_endian = BIGEND; #else msg_endian = LITTLEEND; #endif } ~CDRMessage_t() { if(buffer != nullptr && !wraps) free(buffer); } /** * Constructor with maximum size * @param size Maximum size */ CDRMessage_t(uint32_t size) { wraps = false; pos = 0; length = 0; if(size != 0) buffer = (octet*)malloc(size); else buffer = nullptr; max_size = size; #if EPROSIMA_BIG_ENDIAN msg_endian = BIGEND; #else msg_endian = LITTLEEND; #endif } CDRMessage_t(const CDRMessage_t& message) { wraps = false; pos = 0; length = message.length; max_size = message.max_size; msg_endian = message.msg_endian; if(max_size != 0) { buffer = (octet*)malloc(max_size); memcpy(buffer, message.buffer, length); } else buffer = nullptr; } CDRMessage_t(CDRMessage_t&& message) { wraps = message.wraps; message.wraps = false; pos = message.pos; message.pos = 0; length = message.length; message.length = 0; max_size = message.max_size; message.max_size = 0; msg_endian = message.msg_endian; #if EPROSIMA_BIG_ENDIAN message.msg_endian = BIGEND; #else message.msg_endian = LITTLEEND; #endif buffer = message.buffer; message.buffer = nullptr; } //!Pointer to the buffer where the data is stored. octet* buffer; //!Read or write position. uint32_t pos; //!Max size of the message. uint32_t max_size; //!Current length of the message. uint32_t length; //!Endianness of the message. Endianness_t msg_endian; //Whether this message is wrapping a buffer managed elsewhere. bool wraps; }; } } } #endif #endif /* CDRMESSAGE_T_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/common/CacheChange.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file CacheChange.h */ #ifndef CACHECHANGE_H_ #define CACHECHANGE_H_ #include "Types.h" #include "WriteParams.h" #include "SerializedPayload.h" #include "Time_t.h" #include "InstanceHandle.h" #include <fastrtps/rtps/common/FragmentNumber.h> #include <vector> namespace eprosima { namespace fastrtps { namespace rtps { /** * @enum ChangeKind_t, different types of CacheChange_t. * @ingroup COMMON_MODULE */ #if defined(_WIN32) enum RTPS_DllAPI ChangeKind_t{ #else enum ChangeKind_t{ #endif ALIVE, //!< ALIVE NOT_ALIVE_DISPOSED, //!< NOT_ALIVE_DISPOSED NOT_ALIVE_UNREGISTERED,//!< NOT_ALIVE_UNREGISTERED NOT_ALIVE_DISPOSED_UNREGISTERED //!<NOT_ALIVE_DISPOSED_UNREGISTERED }; enum ChangeFragmentStatus_t { NOT_PRESENT = 0, PRESENT = 1 }; /** * Structure CacheChange_t, contains information on a specific CacheChange. * @ingroup COMMON_MODULE */ struct RTPS_DllAPI CacheChange_t { //!Kind of change, default value ALIVE. ChangeKind_t kind; //!GUID_t of the writer that generated this change. GUID_t writerGUID; //!Handle of the data associated wiht this change. InstanceHandle_t instanceHandle; //!SequenceNumber of the change SequenceNumber_t sequenceNumber; //!Serialized Payload associated with the change. SerializedPayload_t serializedPayload; //!Indicates if the cache has been read (only used in READERS) bool isRead; //!Source TimeStamp (only used in Readers) Time_t sourceTimestamp; WriteParams write_params; bool is_untyped_; /*! * @brief Default constructor. * Creates an empty CacheChange_t. */ CacheChange_t(): kind(ALIVE), isRead(false), is_untyped_(true), dataFragments_(new std::vector<uint32_t>()), fragment_size_(0) { } CacheChange_t(const CacheChange_t&) = delete; const CacheChange_t& operator=(const CacheChange_t&) = delete; /** * Constructor with payload size * @param payload_size Serialized payload size */ // TODO Check pass uint32_t to serializedPayload that needs int16_t. CacheChange_t(uint32_t payload_size, bool is_untyped = false): kind(ALIVE), serializedPayload(payload_size), isRead(false), is_untyped_(is_untyped), dataFragments_(new std::vector<uint32_t>()), fragment_size_(0) { } /*! * Copy a different change into this one. All the elements are copied, included the data, allocating new memory. * @param[in] ch_ptr Pointer to the change. * @return True if correct. */ bool copy(const CacheChange_t* ch_ptr) { kind = ch_ptr->kind; writerGUID = ch_ptr->writerGUID; instanceHandle = ch_ptr->instanceHandle; sequenceNumber = ch_ptr->sequenceNumber; sourceTimestamp = ch_ptr->sourceTimestamp; write_params = ch_ptr->write_params; bool ret = serializedPayload.copy(&ch_ptr->serializedPayload, (ch_ptr->is_untyped_ ? false : true)); setFragmentSize(ch_ptr->fragment_size_); dataFragments_->assign(ch_ptr->dataFragments_->begin(), ch_ptr->dataFragments_->end()); isRead = ch_ptr->isRead; return ret; } void copy_not_memcpy(const CacheChange_t* ch_ptr) { kind = ch_ptr->kind; writerGUID = ch_ptr->writerGUID; instanceHandle = ch_ptr->instanceHandle; sequenceNumber = ch_ptr->sequenceNumber; sourceTimestamp = ch_ptr->sourceTimestamp; write_params = ch_ptr->write_params; // Copy certain values from serializedPayload serializedPayload.encapsulation = ch_ptr->serializedPayload.encapsulation; setFragmentSize(ch_ptr->fragment_size_); dataFragments_->assign(ch_ptr->dataFragments_->begin(), ch_ptr->dataFragments_->end()); isRead = ch_ptr->isRead; } ~CacheChange_t() { if (dataFragments_) delete dataFragments_; } uint32_t getFragmentCount() const { return (uint32_t)dataFragments_->size(); } std::vector<uint32_t>* getDataFragments() { return dataFragments_; } uint16_t getFragmentSize() const { return fragment_size_; } void setFragmentSize(uint16_t fragment_size) { this->fragment_size_ = fragment_size; if (fragment_size == 0) { dataFragments_->clear(); } else { //TODO Mirar si cuando se compatibilice con RTI funciona el calculo, porque ellos //en el sampleSize incluyen el padding. uint32_t size = (serializedPayload.length + fragment_size - 1) / fragment_size; dataFragments_->assign(size, ChangeFragmentStatus_t::NOT_PRESENT); } } private: // Data fragments std::vector<uint32_t>* dataFragments_; // Fragment size uint16_t fragment_size_; }; #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC /** * Enum ChangeForReaderStatus_t, possible states for a CacheChange_t in a ReaderProxy. * @ingroup COMMON_MODULE */ enum ChangeForReaderStatus_t{ UNSENT = 0, //!< UNSENT UNACKNOWLEDGED = 1,//!< UNACKNOWLEDGED REQUESTED = 2, //!< REQUESTED ACKNOWLEDGED = 3, //!< ACKNOWLEDGED UNDERWAY = 4 //!< UNDERWAY }; /** * Enum ChangeFromWriterStatus_t, possible states for a CacheChange_t in a WriterProxy. * @ingroup COMMON_MODULE */ enum ChangeFromWriterStatus_t{ UNKNOWN = 0, MISSING = 1, //REQUESTED_WITH_NACK, RECEIVED = 2, LOST = 3 }; /** * Struct ChangeForReader_t used to represent the state of a specific change with respect to a specific reader, as well as its relevance. * @ingroup COMMON_MODULE */ class ChangeForReader_t { friend struct ChangeForReaderCmp; public: ChangeForReader_t() : status_(UNSENT), is_relevant_(true), change_(nullptr) { } ChangeForReader_t(const ChangeForReader_t& ch) : status_(ch.status_), is_relevant_(ch.is_relevant_), seq_num_(ch.seq_num_), change_(ch.change_), unsent_fragments_(ch.unsent_fragments_) { } //TODO(Ricardo) Temporal //ChangeForReader_t(const CacheChange_t* change) : status_(UNSENT), ChangeForReader_t(CacheChange_t* change) : status_(UNSENT), is_relevant_(true), seq_num_(change->sequenceNumber), change_(change) { if (change->getFragmentSize() != 0) for (uint32_t i = 1; i != change->getFragmentCount() + 1; i++) unsent_fragments_.insert(i); // Indexed on 1 } ChangeForReader_t(const SequenceNumber_t& seq_num) : status_(UNSENT), is_relevant_(true), seq_num_(seq_num), change_(nullptr) { } ~ChangeForReader_t(){} ChangeForReader_t& operator=(const ChangeForReader_t& ch) { status_ = ch.status_; is_relevant_ = ch.is_relevant_; seq_num_ = ch.seq_num_; change_ = ch.change_; unsent_fragments_ = ch.unsent_fragments_; return *this; } /** * Get the cache change * @return Cache change */ // TODO(Ricardo) Temporal //const CacheChange_t* getChange() const CacheChange_t* getChange() const { return change_; } void setStatus(const ChangeForReaderStatus_t status) { status_ = status; } ChangeForReaderStatus_t getStatus() const { return status_; } void setRelevance(const bool relevance) { is_relevant_ = relevance; } bool isRelevant() const { return is_relevant_; } const SequenceNumber_t getSequenceNumber() const { return seq_num_; } //! Set change as not valid void notValid() { is_relevant_ = false; change_ = nullptr; } //! Set change as valid bool isValid() const { return change_ != nullptr; } FragmentNumberSet_t getUnsentFragments() const { return unsent_fragments_; } void markAllFragmentsAsUnsent() { if (change_->getFragmentSize() != 0) for (uint32_t i = 1; i != change_->getFragmentCount() + 1; i++) unsent_fragments_.insert(i); // Indexed on 1 } void markFragmentsAsSent(const FragmentNumber_t& sentFragment) { unsent_fragments_.erase(sentFragment); } void markFragmentsAsUnsent(const FragmentNumberSet_t& unsentFragments) { for(auto element : unsentFragments.set) unsent_fragments_.insert(element); } private: //!Status ChangeForReaderStatus_t status_; //!Boolean specifying if this change is relevant bool is_relevant_; //!Sequence number SequenceNumber_t seq_num_; // TODO(Ricardo) Temporal //const CacheChange_t* change_; CacheChange_t* change_; std::set<FragmentNumber_t> unsent_fragments_; }; struct ChangeForReaderCmp { bool operator()(const ChangeForReader_t& a, const ChangeForReader_t& b) const { return a.seq_num_ < b.seq_num_; } }; /** * Struct ChangeFromWriter_t used to indicate the state of a specific change with respect to a specific writer, as well as its relevance. * @ingroup COMMON_MODULE */ class ChangeFromWriter_t { friend struct ChangeFromWriterCmp; public: ChangeFromWriter_t() : status_(UNKNOWN), is_relevant_(true) { } ChangeFromWriter_t(const ChangeFromWriter_t& ch) : status_(ch.status_), is_relevant_(ch.is_relevant_), seq_num_(ch.seq_num_) { } ChangeFromWriter_t(const SequenceNumber_t& seq_num) : status_(UNKNOWN), is_relevant_(true), seq_num_(seq_num) { } ~ChangeFromWriter_t(){}; ChangeFromWriter_t& operator=(const ChangeFromWriter_t& ch) { status_ = ch.status_; is_relevant_ = ch.is_relevant_; seq_num_ = ch.seq_num_; return *this; } void setStatus(const ChangeFromWriterStatus_t status) { status_ = status; } ChangeFromWriterStatus_t getStatus() const { return status_; } void setRelevance(const bool relevance) { is_relevant_ = relevance; } bool isRelevant() const { return is_relevant_; } const SequenceNumber_t getSequenceNumber() const { return seq_num_; } //! Set change as not valid void notValid() { is_relevant_ = false; } private: //! Status ChangeFromWriterStatus_t status_; //! Boolean specifying if this change is relevant bool is_relevant_; //! Sequence number SequenceNumber_t seq_num_; }; struct ChangeFromWriterCmp { bool operator()(const ChangeFromWriter_t& a, const ChangeFromWriter_t& b) const { return a.seq_num_ < b.seq_num_; } }; #endif } } } #endif /* CACHECHANGE_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/common/Types.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file Types.h */ #ifndef COMMON_TYPES_H_ #define COMMON_TYPES_H_ #include <stddef.h> #include <iostream> #include <cstdint> #include <stdint.h> #include "../../fastrtps_dll.h" namespace eprosima{ namespace fastrtps{ namespace rtps{ /*! * @brief This enumeration represents endianness types. * @ingroup COMMON_MODULE */ enum Endianness_t{ //! @brief Big endianness. BIGEND = 0x1, //! @brief Little endianness. LITTLEEND = 0x0 }; //!Reliability enum used for internal purposes //!@ingroup COMMON_MODULE typedef enum ReliabilityKind_t{ RELIABLE, BEST_EFFORT }ReliabilityKind_t; //!Durability kind //!@ingroup COMMON_MODULE typedef enum DurabilityKind_t { VOLATILE, TRANSIENT_LOCAL }DurabilityKind_t; //!Endpoint kind //!@ingroup COMMON_MODULE typedef enum EndpointKind_t{ READER, WRITER }EndpointKind_t; //!Topic kind typedef enum TopicKind_t{ NO_KEY, WITH_KEY }TopicKind_t; #if __BIG_ENDIAN__ const Endianness_t DEFAULT_ENDIAN = BIGEND; #else const Endianness_t DEFAULT_ENDIAN = LITTLEEND; #endif #define EPROSIMA_BIG_ENDIAN 0 typedef unsigned char octet; //typedef unsigned int uint; //typedef unsigned short ushort; typedef unsigned char SubmessageFlag; typedef uint32_t BuiltinEndpointSet_t; typedef uint32_t Count_t; #define BIT0 0x1 #define BIT1 0x2 #define BIT2 0x4 #define BIT3 0x8 #define BIT4 0x10 #define BIT5 0x20 #define BIT6 0x40 #define BIT7 0x80 #define BIT(i) ((i==0) ? BIT0 : (i==1) ? BIT1 :(i==2)?BIT2:(i==3)?BIT3:(i==4)?BIT4:(i==5)?BIT5:(i==6)?BIT6:(i==7)?BIT7:0x0) //!@brief Structure ProtocolVersion_t, contains the protocol version. struct RTPS_DllAPI ProtocolVersion_t{ octet m_major; octet m_minor; ProtocolVersion_t(): m_major(2), m_minor(1) { }; ProtocolVersion_t(octet maj,octet min): m_major(maj), m_minor(min) { } }; const ProtocolVersion_t c_ProtocolVersion_2_0(2,0); const ProtocolVersion_t c_ProtocolVersion_2_1(2,1); const ProtocolVersion_t c_ProtocolVersion_2_2(2,2); const ProtocolVersion_t c_ProtocolVersion(2,1); //!@brief Structure VendorId_t, specifying the vendor Id of the implementation. typedef octet VendorId_t[2]; const VendorId_t c_VendorId_Unknown={0x00,0x00}; const VendorId_t c_VendorId_eProsima={0x01,0x0F}; static inline void set_VendorId_Unknown(VendorId_t& id) { id[0]=0x0;id[1]=0x0; } static inline void set_VendorId_eProsima(VendorId_t& id) { id[0]=0x01;id[1]=0x0F; } } } } #endif /* COMMON_TYPES_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/common/Guid.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file Guid.h */ #ifndef RTPS_GUID_H_ #define RTPS_GUID_H_ #include "../../fastrtps_dll.h" #include "Types.h" #include <cstdint> #include <cstring> namespace eprosima{ namespace fastrtps{ namespace rtps{ //!@brief Structure GuidPrefix_t, Guid Prefix of GUID_t. //!@ingroup COMMON_MODULE struct RTPS_DllAPI GuidPrefix_t { static const unsigned int size = 12; octet value[size]; //!Default constructor. Set the Guid prefix to 0. GuidPrefix_t() { memset(value, 0, size); } /** * Guid prefix constructor * @param guid Guid prefix */ GuidPrefix_t(octet guid[size]) { memcpy(value, guid, size); } /*! * Guid prefix copy constructor. * @param g Guid prefix to copy the values from */ GuidPrefix_t(const GuidPrefix_t &g) { memcpy(value, g.value, size); } /*! * Guid prefix move constructor. * @param g Guid prefix to copy the values from */ GuidPrefix_t(GuidPrefix_t &&g) { memmove(value, g.value, size); } /** * Guid prefix assignment operator * @param guidpre Guid prefix to copy the values from */ GuidPrefix_t& operator=(const GuidPrefix_t &guidpre) { memcpy(value, guidpre.value, size); return *this; } /** * Guid prefix assignment operator * @param guidpre Guid prefix to copy the values from */ GuidPrefix_t& operator=(GuidPrefix_t &&guidpre) { memmove(value, guidpre.value, size); return *this; } static GuidPrefix_t unknown() { return GuidPrefix_t(); } #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC /** * Guid prefix comparison operator * @param prefix guid prefix to compare * @return True if the guid prefixes are equal */ bool operator==(const GuidPrefix_t& prefix) const { return (memcmp(value, prefix.value, size) == 0); } /** * Guid prefix comparison operator * @param prefix Second guid prefix to compare * @return True if the guid prefixes are not equal */ bool operator!=(const GuidPrefix_t& prefix) const { return (memcmp(value, prefix.value, size) != 0); } #endif }; const GuidPrefix_t c_GuidPrefix_Unknown; inline std::ostream& operator<<(std::ostream& output,const GuidPrefix_t& guiP){ output << std::hex; for(uint8_t i =0;i<11;++i) output<<(int)guiP.value[i]<<"."; output << (int)guiP.value[11]; return output<<std::dec; } #define ENTITYID_UNKNOWN 0x00000000 #define ENTITYID_RTPSParticipant 0x000001c1 #define ENTITYID_SEDP_BUILTIN_TOPIC_WRITER 0x000002c2 #define ENTITYID_SEDP_BUILTIN_TOPIC_READER 0x000002c7 #define ENTITYID_SEDP_BUILTIN_PUBLICATIONS_WRITER 0x000003c2 #define ENTITYID_SEDP_BUILTIN_PUBLICATIONS_READER 0x000003c7 #define ENTITYID_SEDP_BUILTIN_SUBSCRIPTIONS_WRITER 0x000004c2 #define ENTITYID_SEDP_BUILTIN_SUBSCRIPTIONS_READER 0x000004c7 #define ENTITYID_SPDP_BUILTIN_RTPSParticipant_WRITER 0x000100c2 #define ENTITYID_SPDP_BUILTIN_RTPSParticipant_READER 0x000100c7 #define ENTITYID_P2P_BUILTIN_RTPSParticipant_MESSAGE_WRITER 0x000200C2 #define ENTITYID_P2P_BUILTIN_RTPSParticipant_MESSAGE_READER 0x000200C7 #define ENTITYID_P2P_BUILTIN_PARTICIPANT_STATELESS_WRITER 0x000201C3 #define ENTITYID_P2P_BUILTIN_PARTICIPANT_STATELESS_READER 0x000201C4 #define ENTITYID_P2P_BUILTIN_PARTICIPANT_VOLATILE_MESSAGE_SECURE_WRITER 0xff0202C3 #define ENTITYID_P2P_BUILTIN_PARTICIPANT_VOLATILE_MESSAGE_SECURE_READER 0xff0202C4 //!@brief Structure EntityId_t, entity id part of GUID_t. //!@ingroup COMMON_MODULE struct RTPS_DllAPI EntityId_t{ static const unsigned int size = 4; octet value[size]; //! Default constructor. Uknown entity. EntityId_t(){ *this = ENTITYID_UNKNOWN; } /** * Main constructor. * @param id Entity id */ EntityId_t(uint32_t id) { uint32_t* aux = (uint32_t*)(value); *aux = id; reverse(); } /*! * @brief Copy constructor */ EntityId_t(const EntityId_t &id) { memcpy(value, id.value, size); } /*! * @brief Move constructor */ EntityId_t(EntityId_t &&id) { memmove(value, id.value, size); } EntityId_t& operator=(const EntityId_t &id) { memcpy(value, id.value, size); return *this; } EntityId_t& operator=(EntityId_t &&id) { memmove(value, id.value, size); return *this; } /** * Assignment operator. * @param id Entity id to copy */ EntityId_t& operator=(uint32_t id){ uint32_t* aux = (uint32_t*)(value); *aux = id; #if !__BIG_ENDIAN__ reverse(); #endif return *this; //return id; } //! void reverse(){ octet oaux; oaux = value[3]; value[3] = value[0]; value[0] = oaux; oaux = value[2]; value[2] = value[1]; value[1] = oaux; } static EntityId_t unknown() { return EntityId_t(); } }; #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC /** * Guid prefix comparison operator * @param id1 EntityId to compare * @param id2 ID prefix to compare * @return True if equal */ inline bool operator==(EntityId_t& id1,const uint32_t id2) { #if !__BIG_ENDIAN__ id1.reverse(); #endif uint32_t* aux1 = (uint32_t*)(id1.value); bool result = true; if(*aux1 == id2) result = true; else result = false; #if !__BIG_ENDIAN__ id1.reverse(); #endif return result; } /** * Guid prefix comparison operator * @param id1 First EntityId to compare * @param id2 Second EntityId to compare * @return True if equal */ inline bool operator==(const EntityId_t& id1,const EntityId_t& id2) { for(uint8_t i =0;i<4;++i) { if(id1.value[i] != id2.value[i]) return false; } return true; } /** * Guid prefix comparison operator * @param id1 First EntityId to compare * @param id2 Second EntityId to compare * @return True if not equal */ inline bool operator!=(const EntityId_t& id1,const EntityId_t& id2) { for(uint8_t i =0;i<4;++i) { if(id1.value[i] != id2.value[i]) return true; } return false; } #endif inline std::ostream& operator<<(std::ostream& output,const EntityId_t& enI){ output << std::hex; output<<(int)enI.value[0]<<"."<<(int)enI.value[1]<<"."<<(int)enI.value[2]<<"."<<(int)enI.value[3]; return output << std::dec; } const EntityId_t c_EntityId_Unknown = ENTITYID_UNKNOWN; const EntityId_t c_EntityId_SPDPReader = ENTITYID_SPDP_BUILTIN_RTPSParticipant_READER; const EntityId_t c_EntityId_SPDPWriter = ENTITYID_SPDP_BUILTIN_RTPSParticipant_WRITER; const EntityId_t c_EntityId_SEDPPubWriter = ENTITYID_SEDP_BUILTIN_PUBLICATIONS_WRITER; const EntityId_t c_EntityId_SEDPPubReader = ENTITYID_SEDP_BUILTIN_PUBLICATIONS_READER; const EntityId_t c_EntityId_SEDPSubWriter = ENTITYID_SEDP_BUILTIN_SUBSCRIPTIONS_WRITER; const EntityId_t c_EntityId_SEDPSubReader = ENTITYID_SEDP_BUILTIN_SUBSCRIPTIONS_READER; const EntityId_t c_EntityId_RTPSParticipant = ENTITYID_RTPSParticipant; const EntityId_t c_EntityId_WriterLiveliness = ENTITYID_P2P_BUILTIN_RTPSParticipant_MESSAGE_WRITER; const EntityId_t c_EntityId_ReaderLiveliness = ENTITYID_P2P_BUILTIN_RTPSParticipant_MESSAGE_READER; const EntityId_t participant_stateless_message_writer_entity_id = ENTITYID_P2P_BUILTIN_PARTICIPANT_STATELESS_WRITER; const EntityId_t participant_stateless_message_reader_entity_id = ENTITYID_P2P_BUILTIN_PARTICIPANT_STATELESS_READER; const EntityId_t participant_volatile_message_secure_writer_entity_id = ENTITYID_P2P_BUILTIN_PARTICIPANT_VOLATILE_MESSAGE_SECURE_WRITER; const EntityId_t participant_volatile_message_secure_reader_entity_id = ENTITYID_P2P_BUILTIN_PARTICIPANT_VOLATILE_MESSAGE_SECURE_READER; //!@brief Structure GUID_t, entity identifier, unique in DDS-RTPS Domain. //!@ingroup COMMON_MODULE struct RTPS_DllAPI GUID_t{ //!Guid prefix GuidPrefix_t guidPrefix; //!Entity id EntityId_t entityId; /*! * DDefault constructor. Contructs an unknown GUID. */ GUID_t(){}; /*! * Copy constructor. */ GUID_t(const GUID_t &g) : guidPrefix(g.guidPrefix), entityId(g.entityId) { } /*! * Move constructor. */ GUID_t(GUID_t &&g) : guidPrefix(std::move(g.guidPrefix)), entityId(std::move(g.entityId)) { } /** * Assignment operator * @param guid GUID to copy the data from. */ GUID_t& operator=(const GUID_t &guid) { guidPrefix = guid.guidPrefix; entityId = guid.entityId; return *this; } /** * Assignment operator * @param guid GUID to copy the data from. */ GUID_t& operator=(GUID_t &&guid) { guidPrefix = std::move(guid.guidPrefix); entityId = std::move(guid.entityId); return *this; } /** * @param guidP Guid prefix * @param id Entity id */ GUID_t(const GuidPrefix_t& guidP,uint32_t id): guidPrefix(guidP),entityId(id) {} /** * @param guidP Guid prefix * @param entId Entity id */ GUID_t(const GuidPrefix_t& guidP,const EntityId_t& entId): guidPrefix(guidP),entityId(entId) {} static GUID_t unknown() { return GUID_t(); }; }; #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC /** * GUID comparison operator * @param g1 First GUID to compare * @param g2 Second GUID to compare * @return True if equal */ inline bool operator==(const GUID_t& g1,const GUID_t& g2){ if(g1.guidPrefix == g2.guidPrefix && g1.entityId==g2.entityId) return true; else return false; } /** * GUID comparison operator * @param g1 First GUID to compare * @param g2 Second GUID to compare * @return True if not equal */ inline bool operator!=(const GUID_t& g1,const GUID_t& g2){ if(g1.guidPrefix != g2.guidPrefix || g1.entityId!=g2.entityId) return true; else return false; } inline bool operator<(const GUID_t& g1, const GUID_t& g2){ for (uint8_t i = 0; i < 12; ++i) { if(g1.guidPrefix.value[i] < g2.guidPrefix.value[i]) return true; else if(g1.guidPrefix.value[i] > g2.guidPrefix.value[i]) return false; } for (uint8_t i = 0; i < 4; ++i) { if(g1.entityId.value[i] < g2.entityId.value[i]) return true; else if(g1.entityId.value[i] > g2.entityId.value[i]) return false; } return false; } #endif const GUID_t c_Guid_Unknown; #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC /** * Stream operator, prints a GUID. * @param output Output stream. * @param guid GUID_t to print. * @return Stream operator. */ inline std::ostream& operator<<(std::ostream& output,const GUID_t& guid) { if(guid !=c_Guid_Unknown) output<<guid.guidPrefix<<"|"<<guid.entityId; else output << "|GUID UNKNOWN|"; return output; } #endif } } } #endif /* RTPS_GUID_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/common/SampleIdentity.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file SampleIdentity.h */ #ifndef _FASTRTPS_RTPS_COMMON_SAMPLEIDENTITY_H_ #define _FASTRTPS_RTPS_COMMON_SAMPLEIDENTITY_H_ #include "Guid.h" #include "SequenceNumber.h" namespace eprosima { namespace fastrtps { namespace rtps { /*! * @brief This class is used to specify a sample * @ingroup COMMON_MODULE */ class RTPS_DllAPI SampleIdentity { public: /*! * @brief Default constructor. Constructs an unknown SampleIdentity. */ SampleIdentity() : writer_guid_(GUID_t::unknown()), sequence_number_(SequenceNumber_t::unknown()) { } /*! * @brief Copy constructor. */ SampleIdentity(const SampleIdentity &sample_id) : writer_guid_(sample_id.writer_guid_), sequence_number_(sample_id.sequence_number_) { } /*! * @brief Move constructor. */ SampleIdentity(SampleIdentity &&sample_id) : writer_guid_(std::move(sample_id.writer_guid_)), sequence_number_(std::move(sample_id.sequence_number_)) { } /*! * @brief Assignment operator. */ SampleIdentity& operator=(const SampleIdentity &sample_id) { writer_guid_ = sample_id.writer_guid_; sequence_number_ = sample_id.sequence_number_; return *this; } /*! * @brief Move constructor. */ SampleIdentity& operator=(SampleIdentity &&sample_id) { writer_guid_ = std::move(sample_id.writer_guid_); sequence_number_ = std::move(sample_id.sequence_number_); return *this; } /*! * @brief */ bool operator==(const SampleIdentity &sample_id) const { return (writer_guid_ == sample_id.writer_guid_) && (sequence_number_ == sample_id.sequence_number_); } /*! * @brief */ bool operator!=(const SampleIdentity &sample_id) const { return !(*this == sample_id); } SampleIdentity& writer_guid(const GUID_t &guid) { writer_guid_ = guid; return *this; } SampleIdentity& writer_guid(GUID_t &&guid) { writer_guid_ = std::move(guid); return *this; } const GUID_t& writer_guid() const { return writer_guid_; } GUID_t& writer_guid() { return writer_guid_; } SampleIdentity& sequence_number(const SequenceNumber_t &seq) { sequence_number_ = seq; return *this; } SampleIdentity& sequence_number(SequenceNumber_t &&seq) { sequence_number_ = std::move(seq); return *this; } const SequenceNumber_t& sequence_number() const { return sequence_number_; } SequenceNumber_t& sequence_number() { return sequence_number_; } static SampleIdentity unknown() { return SampleIdentity(); } private: GUID_t writer_guid_; SequenceNumber_t sequence_number_; }; } //namespace rtps } //namespace fastrtps } //namespace eprosima #endif // _FASTRTPS_RTPS_COMMON_SAMPLEIDENTITY_H_
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/common/SequenceNumber.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file SequenceNumber.h */ #ifndef RPTS_ELEM_SEQNUM_H_ #define RPTS_ELEM_SEQNUM_H_ #include "../../fastrtps_dll.h" #include "Types.h" #include <vector> #include <algorithm> #include <sstream> #include <limits.h> #include <cassert> namespace eprosima{ namespace fastrtps{ namespace rtps{ //!@brief Structure SequenceNumber_t, different for each change in the same writer. //!@ingroup COMMON_MODULE struct RTPS_DllAPI SequenceNumber_t { //! int32_t high; //! uint32_t low; //!Default constructor SequenceNumber_t() { high = 0; low = 0; } /*! * @brief Copy constructor. */ SequenceNumber_t(const SequenceNumber_t& seq) : high(seq.high), low(seq.low) { } /*! * @param hi * @param lo */ SequenceNumber_t(int32_t hi, uint32_t lo): high(hi),low(lo) { } // Check the target support 64bits. #ifdef LLONG_MAX /*! Convert the number to 64 bit. * @return 64 bit representation of the SequenceNumber */ uint64_t to64long() const { return (((uint64_t)high) << 32) + low; } #endif /*! * Assignment operator * @param seq SequenceNumber_t to copy the data from */ SequenceNumber_t& operator=(const SequenceNumber_t& seq) { high = seq.high; low = seq.low; return *this; } //! Increase SequenceNumber in 1. SequenceNumber_t& operator++() { if(low == UINT32_MAX) { ++high; low = 0; } else ++low; return *this; } SequenceNumber_t operator++(int) { SequenceNumber_t result(*this); ++(*this); return result; } /** * Increase SequenceNumber. * @param inc Number to add to the SequenceNumber */ SequenceNumber_t& operator+=(int inc) { uint32_t aux_low = low; low += inc; if(low < aux_low) { // Being the type of the parameter an 'int', the increment of 'high' will be as much as 1. ++high; } return *this; } static SequenceNumber_t unknown() { return SequenceNumber_t(-1, 0); } }; #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC /** * Compares two SequenceNumber_t. * @param sn1 First SequenceNumber_t to compare * @param sn2 Second SequenceNumber_t to compare * @return True if equal */ inline bool operator==(const SequenceNumber_t& sn1, const SequenceNumber_t& sn2) { if(sn1.high != sn2.high || sn1.low != sn2.low) return false; return true; } /** * Compares two SequenceNumber_t. * @param sn1 First SequenceNumber_t to compare * @param sn2 Second SequenceNumber_t to compare * @return True if not equal */ inline bool operator!=(const SequenceNumber_t& sn1, const SequenceNumber_t& sn2) { if(sn1.high == sn2.high && sn1.low == sn2.low) return false; return true; } /** * Checks if a SequenceNumber_t is greater than other. * @param seq1 First SequenceNumber_t to compare * @param seq2 Second SequenceNumber_t to compare * @return True if the first SequenceNumber_t is greater than the second */ inline bool operator>(const SequenceNumber_t& seq1, const SequenceNumber_t& seq2) { if(seq1.high > seq2.high) return true; else if(seq1.high < seq2.high) return false; else { if(seq1.low > seq2.low) return true; } return false; } /** * Checks if a SequenceNumber_t is less than other. * @param seq1 First SequenceNumber_t to compare * @param seq2 Second SequenceNumber_t to compare * @return True if the first SequenceNumber_t is less than the second */ inline bool operator<(const SequenceNumber_t& seq1, const SequenceNumber_t& seq2) { if(seq1.high > seq2.high) return false; else if(seq1.high < seq2.high) return true; else { if(seq1.low < seq2.low) return true; } return false; } /** * Checks if a SequenceNumber_t is greater or equal than other. * @param seq1 First SequenceNumber_t to compare * @param seq2 Second SequenceNumber_t to compare * @return True if the first SequenceNumber_t is greater or equal than the second */ inline bool operator>=(const SequenceNumber_t& seq1, const SequenceNumber_t& seq2) { if(seq1.high > seq2.high) return true; else if(seq1.high < seq2.high) return false; else { if(seq1.low >= seq2.low) return true; } return false; } /** * Checks if a SequenceNumber_t is less or equal than other. * @param seq1 First SequenceNumber_t to compare * @param seq2 Second SequenceNumber_t to compare * @return True if the first SequenceNumber_t is less or equal than the second */ inline bool operator<=( const SequenceNumber_t& seq1, const SequenceNumber_t& seq2) { if(seq1.high > seq2.high) return false; else if(seq1.high < seq2.high) return true; else { if(seq1.low <= seq2.low) return true; } return false; } /** * Subtract one SequenceNumber_t from another * @param seq Base SequenceNumber_t * @param inc SequenceNumber_t to substract * @return Result of the substraction */ inline SequenceNumber_t operator-(const SequenceNumber_t& seq, const uint32_t inc) { SequenceNumber_t res(seq.high, seq.low - inc); if(inc > seq.low) { // Being the type of the parameter an 'uint32_t', the decrement of 'high' will be as much as 1. --res.high; } return res; } /** * Add one SequenceNumber_t to another * @param[in] seq Base sequence number * @param inc value to add to the base * @return Result of the addition */ inline SequenceNumber_t operator+(const SequenceNumber_t& seq, const uint32_t inc) { SequenceNumber_t res(seq.high, seq.low + inc); if(res.low < seq.low) { // Being the type of the parameter an 'uint32_t', the increment of 'high' will be as much as 1. ++res.high; } return res; } /** * Subtract one SequenceNumber_t to another * @param minuend Minuend. Has to be greater than or equal to subtrahend. * @param subtrahend Subtrahend. * @return Result of the subtraction */ inline SequenceNumber_t operator-(const SequenceNumber_t& minuend, const SequenceNumber_t& subtrahend) { assert(minuend >= subtrahend); SequenceNumber_t res(minuend.high - subtrahend.high, minuend.low - subtrahend.low); if(minuend.low < subtrahend.low) --res.high; return res; } #endif const SequenceNumber_t c_SequenceNumber_Unknown(-1,0); #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC /** * Sorts two instances of SequenceNumber_t * @param s1 First SequenceNumber_t to compare * @param s2 First SequenceNumber_t to compare * @return True if s1 is less than s2 */ inline bool sort_seqNum(const SequenceNumber_t& s1, const SequenceNumber_t& s2) { return(s1 < s2); } /** * * @param output * @param seqNum * @return */ inline std::ostream& operator<<(std::ostream& output, const SequenceNumber_t& seqNum) { #ifdef LLONG_MAX return output << seqNum.to64long(); #else return output << "{high: " << seqNum.high << ", low: " << seqNum.low << "}"; #endif } inline std::ostream& operator<<(std::ostream& output, std::vector<SequenceNumber_t>& seqNumSet) { for(std::vector<SequenceNumber_t>::iterator sit = seqNumSet.begin(); sit != seqNumSet.end(); ++sit) { output << *sit << " "; } return output; } /*! * @brief Defines the STL hash function for type SequenceNumber_t. */ struct SequenceNumberHash { std::size_t operator()(const SequenceNumber_t& sequence_number) const { #ifdef LLONG_MAX return static_cast<std::size_t>(sequence_number.to64long()); #else return static_cast<std::size_t>(sequence_number.low); #endif }; }; #endif //!Structure SequenceNumberSet_t, contains a group of sequencenumbers. //!@ingroup COMMON_MODULE class SequenceNumberSet_t { public: //!Base sequence number SequenceNumber_t base; /** * Assignment operator * @param set2 SequenceNumberSet_t to copy the data from */ SequenceNumberSet_t& operator=(const SequenceNumberSet_t& set2) { base = set2.base; set = set2.set; return *this; } /** * Add a sequence number to the set * @param in SequenceNumberSet_t to add * @return True on success */ bool add(const SequenceNumber_t& in) { if(in >= base && in < base + 255) set.push_back(in); else return false; return true; } /** * Get the maximum sequence number in the set * @return maximum sequence number in the set */ SequenceNumber_t get_maxSeqNum() const { return *std::max_element(set.begin(),set.end(),sort_seqNum); } /** * Check if the set is empty * @return True if the set is empty */ bool isSetEmpty() const { return set.empty(); } /** * Get the begin of the set * @return Vector iterator pointing to the begin of the set */ std::vector<SequenceNumber_t>::const_iterator get_begin() const { return set.begin(); } /** * Get the end of the set * @return Vector iterator pointing to the end of the set */ std::vector<SequenceNumber_t>::const_iterator get_end() const { return set.end(); } /** * Get the number of SequenceNumbers in the set * @return Size of the set */ size_t get_size() { return set.size(); } /** * Get the set of SequenceNumbers * @return Set of SequenceNumbers */ std::vector<SequenceNumber_t> get_set() { return set; } /** * Get a string representation of the set * @return string representation of the set */ std::string print() { std::stringstream ss; #ifdef LLONG_MAX ss << base.to64long() << ":"; #else ss << "{high: " << base.high << ", low: " << base.low << "} :"; #endif for(std::vector<SequenceNumber_t>::iterator it = set.begin(); it != set.end(); ++it) { #ifdef LLONG_MAX ss << it->to64long() << "-"; #else ss << "{high: " << it->high << ", low: " << it->low << "} -"; #endif } return ss.str(); } private: std::vector<SequenceNumber_t> set; }; #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC /** * Prints a sequence Number set * @param output Output Stream * @param sns SequenceNumber set * @return OStream. */ inline std::ostream& operator<<(std::ostream& output, SequenceNumberSet_t& sns) { return output << sns.print(); } #endif } } } #endif /* RPTS_ELEM_SEQNUM_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/common/all_common.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file all_common.h */ #ifndef FASTRTPS_ALL_COMMON_H_ #define FASTRTPS_ALL_COMMON_H_ #include "Types.h" #include "CDRMessage_t.h" #include "Guid.h" #include "InstanceHandle.h" #include "Locator.h" #include "SequenceNumber.h" #include "FragmentNumber.h" #include "SerializedPayload.h" #include "Time_t.h" #include "CacheChange.h" #include "MatchingInfo.h" #endif /* FASTRTPS_ALL_COMMON_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/common/WriteParams.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file WriteParams.h */ #ifndef _FASTRTPS_RTPS_COMMON_WRITEPARAMS_H_ #define _FASTRTPS_RTPS_COMMON_WRITEPARAMS_H_ #include "SampleIdentity.h" namespace eprosima { namespace fastrtps { namespace rtps { /*! * @brief This class contains additional information of a CacheChange. * @ingroup COMMON_MODULE */ class RTPS_DllAPI WriteParams { public: /*! * @brief Default constructor. */ WriteParams() { } /*! * @brief Copy constructor. */ WriteParams(const WriteParams &wparam) : sample_identity_(wparam.sample_identity_), related_sample_identity_(wparam.related_sample_identity_) { } /*! * @brief Move constructor. */ WriteParams(WriteParams &&wparam) : sample_identity_(std::move(wparam.sample_identity_)), related_sample_identity_(std::move(wparam.related_sample_identity_)) { } /*! * @brief Assignment operator */ WriteParams& operator=(const WriteParams &wparam) { sample_identity_ = wparam.sample_identity_; related_sample_identity_ = wparam.related_sample_identity_; return *this; } /*! * @brief Assignment operator */ WriteParams& operator=(WriteParams &&wparam) { sample_identity_ = std::move(wparam.sample_identity_); related_sample_identity_ = std::move(wparam.related_sample_identity_); return *this; } WriteParams& sample_identity(const SampleIdentity &sample_id) { sample_identity_ = sample_id; return *this; } WriteParams& sample_identity(SampleIdentity &&sample_id) { sample_identity_ = std::move(sample_id); return *this; } const SampleIdentity& sample_identity() const { return sample_identity_; } SampleIdentity& sample_identity() { return sample_identity_; } WriteParams& related_sample_identity(const SampleIdentity &sample_id) { related_sample_identity_ = sample_id; return *this; } WriteParams& related_sample_identity(SampleIdentity &&sample_id) { related_sample_identity_ = std::move(sample_id); return *this; } const SampleIdentity& related_sample_identity() const { return related_sample_identity_; } SampleIdentity& related_sample_identity() { return related_sample_identity_; } private: SampleIdentity sample_identity_; SampleIdentity related_sample_identity_; }; } //namespace rtps } //namespace fastrtps } //namespace eprosima #endif //_FASTRTPS_RTPS_COMMON_WRITEPARAMS_H_
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/common/BinaryProperty.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /*! * @file BinaryProperty.h */ #ifndef _RTPS_COMMON_BINARYPROPERTY_H_ #define _RTPS_COMMON_BINARYPROPERTY_H_ #include <string> #include <vector> #include <iostream> #include <cstdint> namespace eprosima { namespace fastrtps { namespace rtps { class BinaryProperty { public: BinaryProperty() : propagate_(false) {} BinaryProperty(const BinaryProperty& property) : name_(property.name_), value_(property.value_), propagate_(property.propagate_) {} BinaryProperty(BinaryProperty&& property) : name_(std::move(property.name_)), value_(std::move(property.value_)), propagate_(property.propagate_) {} BinaryProperty(const std::string& name, const std::vector<uint8_t>& value) : name_(name), value_(value) {} BinaryProperty(std::string&& name, std::vector<uint8_t>&& value) : name_(std::move(name)), value_(std::move(value)) {} BinaryProperty& operator=(const BinaryProperty& property) { name_ = property.name_; value_ = property.value_; propagate_ = property.propagate_; return *this; } BinaryProperty& operator=(BinaryProperty&& property) { name_ = std::move(property.name_); value_ = std::move(property.value_); propagate_ = property.propagate_; return *this; } void name(const std::string& name) { name_ = name; } void name(std::string&& name) { name_ = std::move(name); } const std::string& name() const { return name_; } std::string& name() { return name_; } void value(const std::vector<uint8_t>& value) { value_ = value; } void value(std::vector<uint8_t>&& value) { value_ = std::move(value); } const std::vector<uint8_t>& value() const { return value_; } std::vector<uint8_t>& value() { return value_; } void propagate(bool propagate) { propagate_ = propagate; } bool propagate() const { return propagate_; } bool& propagate() { return propagate_; } private: std::string name_; std::vector<uint8_t> value_; bool propagate_; }; typedef std::vector<BinaryProperty> BinaryPropertySeq; class BinaryPropertyHelper { public: static size_t serialized_size(const BinaryProperty& binary_property, size_t current_alignment = 0) { if(binary_property.propagate()) { size_t initial_alignment = current_alignment; current_alignment += 4 + alignment(current_alignment, 4) + binary_property.name().size() + 1; current_alignment += 4 + alignment(current_alignment, 4) + binary_property.value().size(); return current_alignment - initial_alignment; } else return 0; } static size_t serialized_size(const BinaryPropertySeq& binary_properties, size_t current_alignment = 0) { size_t initial_alignment = current_alignment; current_alignment += 4 + alignment(current_alignment, 4); for(auto binary_property = binary_properties.begin(); binary_property != binary_properties.end(); ++binary_property) current_alignment += serialized_size(*binary_property, current_alignment); return current_alignment - initial_alignment; } private: inline static size_t alignment(size_t current_alignment, size_t dataSize) { return (dataSize - (current_alignment % dataSize)) & (dataSize-1);} }; } //namespace rtps } //namespace fastrtps } //namespace eprosima #endif // _RTPS_COMMON_BINARYPROPERTY_H_
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/common/Locator.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file Locator.h */ #ifndef RTPS_ELEM_LOCATOR_H_ #define RTPS_ELEM_LOCATOR_H_ #include "../../fastrtps_dll.h" #include "Types.h" #include <sstream> #include <vector> #include <cstdint> #include <cstring> #include <iomanip> #include <algorithm> namespace eprosima{ namespace fastrtps{ namespace rtps{ #define LOCATOR_INVALID(loc) {loc.kind=LOCATOR_KIND_INVALID;loc.port= LOCATOR_PORT_INVALID;LOCATOR_ADDRESS_INVALID(loc.address);} #define LOCATOR_KIND_INVALID -1 #define LOCATOR_ADDRESS_INVALID(a) {std::memset(a,0x00,16*sizeof(octet));} #define LOCATOR_PORT_INVALID 0 #define LOCATOR_KIND_RESERVED 0 #define LOCATOR_KIND_UDPv4 1 #define LOCATOR_KIND_UDPv6 2 //!@brief Class Locator_t, uniquely identifies a communication channel for a particular transport. //For example, an address+port combination in the case of UDP. //!@ingroup COMMON_MODULE class RTPS_DllAPI Locator_t { public: /*! * @brief Specifies the locator type. Valid values are: * LOCATOR_KIND_UDPv4 * LOCATOR_KIND_UDPv6 */ int32_t kind; uint32_t port; octet address[16]; //!Default constructor Locator_t():kind(1),port(0) { LOCATOR_ADDRESS_INVALID(address); } Locator_t(Locator_t&& loc): kind(loc.kind), port(loc.port) { std::memcpy(address,loc.address,16*sizeof(octet)); } Locator_t(const Locator_t& loc) : kind(loc.kind), port(loc.port) { std::memcpy(address,loc.address,16*sizeof(octet)); } Locator_t(uint32_t portin):kind(1),port(portin) { LOCATOR_ADDRESS_INVALID(address); } Locator_t& operator=(const Locator_t& loc) { kind = loc.kind; port = loc.port; std::memcpy(address,loc.address,16*sizeof(octet)); return *this; } bool set_IP4_address(octet o1,octet o2,octet o3,octet o4){ LOCATOR_ADDRESS_INVALID(address); address[12] = o1; address[13] = o2; address[14] = o3; address[15] = o4; return true; } bool set_IP4_address(const std::string& in_address) { std::stringstream ss(in_address); int a,b,c,d; //to store the 4 ints char ch; //to temporarily store the '.' ss >> a >> ch >> b >> ch >> c >> ch >> d; LOCATOR_ADDRESS_INVALID(address); address[12] = (octet)a; address[13] = (octet)b; address[14] = (octet)c; address[15] = (octet)d; return true; } std::string to_IP4_string() const { std::stringstream ss; ss << (int)address[12] << "." << (int)address[13] << "." << (int)address[14]<< "." << (int)address[15]; return ss.str(); } uint32_t to_IP4_long() { uint32_t addr; octet* oaddr = (octet*)&addr; #if __BIG_ENDIAN__ std::memcpy(oaddr,address+12,4*sizeof(octet)); #else // TODO (Santi) - Are we sure we want to flip this? oaddr[0] = address[15]; oaddr[1] = address[14]; oaddr[2] = address[13]; oaddr[3] = address[12]; #endif return addr; } bool set_IP6_address(uint16_t group0, uint16_t group1, uint16_t group2, uint16_t group3, uint16_t group4, uint16_t group5, uint16_t group6, uint16_t group7) { address[0] = (octet) (group0 >> 8); address[1] = (octet) group0; address[2] = (octet) (group1 >> 8); address[3] = (octet) group1; address[4] = (octet) (group2 >> 8); address[5] = (octet) group2; address[6] = (octet) (group3 >> 8); address[7] = (octet) group3; address[8] = (octet) (group4 >> 8); address[9] = (octet) group4; address[10] = (octet) (group5 >> 8); address[11] = (octet) group5; address[12] = (octet) (group6 >> 8); address[13] = (octet) group6; address[14] = (octet) (group7 >> 8); address[15] = (octet) group7; return true; } std::string to_IP6_string() const{ std::stringstream ss; ss << std::hex; for (int i = 0; i != 14; i+= 2) { auto field = (address[i] << 8) + address[i+1]; ss << field << ":"; } auto field = address[14] + (address[15] << 8); ss << field; return ss.str(); } }; inline bool IsAddressDefined(const Locator_t& loc) { if(loc.kind == LOCATOR_KIND_UDPv4) { for(uint8_t i = 12; i < 16; ++i) { if(loc.address[i] != 0) return true; } } else if (loc.kind == LOCATOR_KIND_UDPv6) { for(uint8_t i = 0; i < 16; ++i) { if(loc.address[i] != 0) return true; } } return false; } inline bool IsLocatorValid(const Locator_t&loc) { if(loc.kind<0) return false; return true; } inline bool operator==(const Locator_t&loc1,const Locator_t& loc2) { if(loc1.kind!=loc2.kind) return false; if(loc1.port !=loc2.port) return false; //for(uint8_t i =0;i<16;i++){ // if(loc1.address[i] !=loc2.address[i]) // return false; //} if(!std::equal(loc1.address,loc1.address+16,loc2.address)) return false; return true; } inline std::ostream& operator<<(std::ostream& output,const Locator_t& loc) { if(loc.kind == LOCATOR_KIND_UDPv4) { output<<(int)loc.address[12] << "." << (int)loc.address[13] << "." << (int)loc.address[14]<< "." << (int)loc.address[15]<<":"<<loc.port; } else if(loc.kind == LOCATOR_KIND_UDPv6) { for(uint8_t i =0;i<16;++i) { output<<(int)loc.address[i]; if(i<15) output<<"."; } output<<":"<<loc.port; } return output; } typedef std::vector<Locator_t>::iterator LocatorListIterator; typedef std::vector<Locator_t>::const_iterator LocatorListConstIterator; /** * Class LocatorList_t, a Locator_t vector that doesn't avoid duplicates. * @ingroup COMMON_MODULE */ class LocatorList_t { public: RTPS_DllAPI LocatorList_t(){}; RTPS_DllAPI ~LocatorList_t(){}; RTPS_DllAPI LocatorList_t(const LocatorList_t& list) : m_locators(list.m_locators) {} RTPS_DllAPI LocatorList_t(LocatorList_t&& list) : m_locators(std::move(list.m_locators)) {} RTPS_DllAPI LocatorList_t& operator=(const LocatorList_t& list) { m_locators = list.m_locators; return *this; } RTPS_DllAPI LocatorList_t& operator=(LocatorList_t&& list) { m_locators = std::move(list.m_locators); return *this; } RTPS_DllAPI bool operator==(const LocatorList_t& locator_list) const { if(locator_list.m_locators.size() == m_locators.size()) { bool returnedValue = true; for(auto it = locator_list.m_locators.begin(); returnedValue && it != locator_list.m_locators.end(); ++it) { returnedValue = false; for(auto it2 = m_locators.begin(); !returnedValue && it2 != m_locators.end(); ++it2) { if(*it == *it2) returnedValue = true; } } return returnedValue; } return false; } RTPS_DllAPI LocatorListIterator begin(){ return m_locators.begin(); } RTPS_DllAPI LocatorListIterator end(){ return m_locators.end(); } RTPS_DllAPI LocatorListConstIterator begin() const { return m_locators.begin(); } RTPS_DllAPI LocatorListConstIterator end() const { return m_locators.end(); } RTPS_DllAPI size_t size(){ return m_locators.size(); } RTPS_DllAPI void clear(){ return m_locators.clear();} RTPS_DllAPI void reserve(size_t num){ return m_locators.reserve(num);} RTPS_DllAPI void resize(size_t num) { return m_locators.resize(num);} RTPS_DllAPI void push_back(const Locator_t& loc) { bool already = false; for(LocatorListIterator it=this->begin(); it!=this->end(); ++it) { if(loc == *it) { already = true; break; } } if(!already) m_locators.push_back(loc); } RTPS_DllAPI void push_back(const LocatorList_t& locList) { for(auto it = locList.m_locators.begin(); it!=locList.m_locators.end(); ++it) { this->push_back(*it); } } RTPS_DllAPI bool empty(){ return m_locators.empty(); } RTPS_DllAPI void erase(const Locator_t& loc) { m_locators.erase(std::remove(m_locators.begin(), m_locators.end(), loc), m_locators.end()); } RTPS_DllAPI bool contains(const Locator_t& loc) { for(LocatorListIterator it=this->begin();it!=this->end();++it) { if(IsAddressDefined(*it)) { if(loc == *it) return true; } else { if(loc.kind == (*it).kind && loc.port == (*it).port) return true; } } return false; } RTPS_DllAPI bool isValid() { for(LocatorListIterator it=this->begin();it!=this->end();++it) { if(!IsLocatorValid(*it)) return false; } return true; } RTPS_DllAPI void swap(LocatorList_t& locatorList) { this->m_locators.swap(locatorList.m_locators); } friend std::ostream& operator <<(std::ostream& output,const LocatorList_t& loc); private: std::vector<Locator_t> m_locators; }; inline std::ostream& operator<<(std::ostream& output,const LocatorList_t& locList) { for(auto it = locList.m_locators.begin();it!=locList.m_locators.end();++it) { output << *it << ","; } return output; } } } } #endif /* RTPS_ELEM_LOCATOR_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/common/InstanceHandle.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file InstanceHandle.h */ #ifndef INSTANCEHANDLE_H_ #define INSTANCEHANDLE_H_ #include "../../fastrtps_dll.h" #include "Types.h" #include "Guid.h" namespace eprosima{ namespace fastrtps{ namespace rtps{ /** * Struct InstanceHandle_t, used to contain the key for WITH_KEY topics. * @ingroup COMMON_MODULE */ struct RTPS_DllAPI InstanceHandle_t{ //!Value octet value[16]; InstanceHandle_t() { for(uint8_t i=0;i<16;i++) value[i] = 0; } InstanceHandle_t(const InstanceHandle_t& ihandle) { for(uint8_t i = 0; i < 16; i++) value[i] = ihandle.value[i]; } /** * Assingment operator * @param ihandle Instance handle to copy the data from */ InstanceHandle_t& operator=(const InstanceHandle_t& ihandle){ for(uint8_t i =0;i<16;i++) { value[i] = ihandle.value[i]; } return *this; } /** * Assingment operator * @param guid GUID to copy the data from */ InstanceHandle_t& operator=(const GUID_t& guid) { for(uint8_t i =0;i<16;i++) { if(i<12) value[i] = guid.guidPrefix.value[i]; else value[i] = guid.entityId.value[i-12]; } return *this; } /** * Know if the instance handle is defined * @return True if the values are not zero. */ bool isDefined() { for(uint8_t i=0;i<16;++i) { if(value[i]!=0) return true; } return false; } }; const InstanceHandle_t c_InstanceHandle_Unknown; #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC /** * Comparison operator * @param ihandle1 First InstanceHandle_t to compare * @param ihandle2 Second InstanceHandle_t to compare * @return True if equal */ inline bool operator==(const InstanceHandle_t & ihandle1, const InstanceHandle_t& ihandle2) { for(uint8_t i =0;i<16;++i) { if(ihandle1.value[i] != ihandle2.value[i]) return false; } return true; } #endif /** * Convert InstanceHandle_t to GUID * @param guid GUID to store the results * @param ihandle InstanceHandle_t to copy */ inline void iHandle2GUID(GUID_t& guid,const InstanceHandle_t& ihandle) { for(uint8_t i = 0;i<16;++i) { if(i<12) guid.guidPrefix.value[i] = ihandle.value[i]; else guid.entityId.value[i-12] = ihandle.value[i]; } return; } /** * Convert GUID to InstanceHandle_t * @param ihandle InstanceHandle_t to store the results * @return GUID_t */ inline GUID_t iHandle2GUID(const InstanceHandle_t& ihandle) { GUID_t guid; for(uint8_t i = 0;i<16;++i) { if(i<12) guid.guidPrefix.value[i] = ihandle.value[i]; else guid.entityId.value[i-12] = ihandle.value[i]; } return guid; } #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC /** * * @param output * @param iHandle */ inline std::ostream& operator<<(std::ostream& output,const InstanceHandle_t& iHandle) { output << std::hex; for(uint8_t i =0;i<15;++i) output << (int)iHandle.value[i] << "."; output << (int)iHandle.value[15] << std::dec; return output; } #endif } } } #endif /* INSTANCEHANDLE_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/common/SerializedPayload.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file SerializedPayload.h */ #ifndef SERIALIZEDPAYLOAD_H_ #define SERIALIZEDPAYLOAD_H_ #include "../../fastrtps_dll.h" #include "Types.h" #include <cstring> #include <new> #include <stdexcept> #include <stdint.h> #include <stdlib.h> /*! * @brief Maximum payload is maximum of UDP packet size minus 536bytes (RTPSMESSAGE_COMMON_RTPS_PAYLOAD_SIZE) * With those 536 bytes (RTPSMESSAGE_COMMON_RTPS_PAYLOAD_SIZE) bytes is posible to send RTPS Header plus RTPS Data submessage plus RTPS Heartbeat submessage. */ namespace eprosima{ namespace fastrtps{ namespace rtps{ //Pre define data encapsulation schemes #define CDR_BE 0x0000 #define CDR_LE 0x0001 #define PL_CDR_BE 0x0002 #define PL_CDR_LE 0x0003 //!@brief Structure SerializedPayload_t. //!@ingroup COMMON_MODULE struct RTPS_DllAPI SerializedPayload_t { //!Encapsulation of the data as suggested in the RTPS 2.1 specification chapter 10. uint16_t encapsulation; //!Actual length of the data uint32_t length; //!Pointer to the data. octet* data; //!Maximum size of the payload uint32_t max_size; //!Position when reading uint32_t pos; //!Default constructor SerializedPayload_t() : encapsulation(CDR_BE), length(0), data(nullptr), max_size(0), pos(0) { } /** * @param len Maximum size of the payload */ SerializedPayload_t(uint32_t len) : SerializedPayload_t() { this->reserve(len); } ~SerializedPayload_t() { this->empty(); } /*! * Copy another structure (including allocating new space for the data.) * @param[in] serData Pointer to the structure to copy * @param with_limit if true, the function will fail when providing a payload too big * @return True if correct */ bool copy(const SerializedPayload_t* serData, bool with_limit = true) { length = serData->length; if(serData->length > max_size) { if(with_limit) return false; else this->reserve(serData->length); } encapsulation = serData->encapsulation; memcpy(data, serData->data, length); return true; } /*! * Allocate new space for fragmented data * @param[in] serData Pointer to the structure to copy * @return True if correct */ bool reserve_fragmented(SerializedPayload_t* serData) { length = serData->length; max_size = serData->length; encapsulation = serData->encapsulation; data = (octet*)calloc(length, sizeof(octet)); return true; } //! Empty the payload void empty() { length= 0; encapsulation = CDR_BE; max_size = 0; if(data!=nullptr) free(data); data = nullptr; } void reserve(uint32_t new_size) { if (new_size <= this->max_size) { return; } if(data == nullptr) { data = (octet*)calloc(new_size, sizeof(octet)); if (!data) { throw std::bad_alloc(); } } else { void * old_data = data; data = (octet*)realloc(data, new_size); if (!data) { free(old_data); throw std::bad_alloc(); } } max_size = new_size; } }; } } } #endif /* SERIALIZEDPAYLOAD_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/common/Token.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /*! * @file Token.h */ #ifndef _RTPS_COMMON_TOKEN_H_ #define _RTPS_COMMON_TOKEN_H_ #include "../../fastrtps_dll.h" #include "Property.h" #include "BinaryProperty.h" namespace eprosima { namespace fastrtps { namespace rtps { class DataHolder { public: DataHolder() {} DataHolder(const DataHolder& data_holder) : class_id_(data_holder.class_id_), properties_(data_holder.properties_), binary_properties_(data_holder.binary_properties_) {} DataHolder(DataHolder&& data_holder) : class_id_(data_holder.class_id_), properties_(data_holder.properties_), binary_properties_(data_holder.binary_properties_) {} DataHolder& operator=(const DataHolder& data_holder) { class_id_ = data_holder.class_id_; properties_ = data_holder.properties_; binary_properties_ = data_holder.binary_properties_; return *this; } DataHolder& operator=(DataHolder&& data_holder) { class_id_ = std::move(data_holder.class_id_); properties_ = std::move(data_holder.properties_); binary_properties_ = std::move(data_holder.binary_properties_); return *this; } void class_id(const std::string& class_id) { class_id_ = class_id; } void class_id(std::string&& class_id) { class_id_ = std::move(class_id); } std::string& class_id() { return class_id_; } const std::string& class_id() const { return class_id_; } const PropertySeq& properties() const { return properties_; } PropertySeq& properties() { return properties_; } const BinaryPropertySeq& binary_properties() const { return binary_properties_; } BinaryPropertySeq& binary_properties() { return binary_properties_; } private: std::string class_id_; PropertySeq properties_; BinaryPropertySeq binary_properties_; }; typedef std::vector<DataHolder> DataHolderSeq; typedef DataHolder Token; typedef Token IdentityToken; class DataHolderHelper { public: static std::string* find_property_value(DataHolder& data_holder, const std::string& name); static const std::string* find_property_value(const DataHolder& data_holder, const std::string& name); static Property* find_property(DataHolder& data_holder, const std::string& name); static const Property* find_property(const DataHolder& data_holder, const std::string& name); static std::vector<uint8_t>* find_binary_property_value(DataHolder& data_holder, const std::string& name); static const std::vector<uint8_t>* find_binary_property_value(const DataHolder& data_holder, const std::string& name); static BinaryProperty* find_binary_property(DataHolder& data_holder, const std::string& name); static const BinaryProperty* find_binary_property(const DataHolder& data_holder, const std::string& name); static size_t serialized_size(const DataHolder& data_holder, size_t current_alignment = 0); static size_t serialized_size(const DataHolderSeq& data_holders, size_t current_alignment = 0); private: inline static size_t alignment(size_t current_alignment, size_t dataSize) { return (dataSize - (current_alignment % dataSize)) & (dataSize-1);} }; } //namespace rtps } //namespace fastrtps } //namespace eprosima #endif // _RTPS_COMMON_TOKEN_H_
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/common/FragmentNumber.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file FragmentNumber.h */ #ifndef RPTS_ELEM_FRAGNUM_H_ #define RPTS_ELEM_FRAGNUM_H_ #include "../../fastrtps_dll.h" #include "Types.h" #include <set> #include <cmath> #include <algorithm> #include <sstream> namespace eprosima{ namespace fastrtps{ namespace rtps{ typedef uint32_t FragmentNumber_t; //!Structure FragmentNumberSet_t, contains a group of fragmentnumbers. //!@ingroup COMMON_MODULE class FragmentNumberSet_t { public: //!Base fragment number FragmentNumber_t base; /** * Assignment operator * @param set2 FragmentNumberSet_t to copy the data from */ FragmentNumberSet_t& operator=(const FragmentNumberSet_t& set2) { base = set2.base; set = set2.set; return *this; } FragmentNumberSet_t(): base(0), set() {} FragmentNumberSet_t(const std::set<FragmentNumber_t>& set2) : base(0) { set = set2; auto min = set.begin(); if (min != set.end()) base = *min; } /** * Compares object with other FragmentNumberSet_t. * @param other FragmentNumberSet_t to compare * @return True if equal */ bool operator==(const FragmentNumberSet_t& other) { if (base != other.base) return false; return other.set == set; } /** * Add a fragment number to the set * @param in FragmentNumberSet_t to add * @return True on success */ bool add(FragmentNumber_t in) { if (in >= base && in <= base + 255) set.insert(in); else return false; return true; } /** * Check if the set is empty * @return True if the set is empty */ bool isSetEmpty() const { return set.empty(); } /** * Get the begin of the set * @return Vector iterator pointing to the begin of the set */ std::set<FragmentNumber_t>::const_iterator get_begin() const { return set.begin(); } /** * Get the end of the set * @return Vector iterator pointing to the end of the set */ std::set<FragmentNumber_t>::const_iterator get_end() const { return set.end(); } /** * Get the number of FragmentNumbers in the set * @return Size of the set */ size_t get_size() { return set.size(); } /** * Get a string representation of the set * @return string representation of the set */ std::string print() { std::stringstream ss; ss << base << ":"; for (auto it = set.begin(); it != set.end(); ++it) ss << *it << "-"; return ss.str(); } FragmentNumberSet_t& operator-=(const FragmentNumberSet_t& rhs) { for ( auto element : rhs.set) set.erase(element); return *this; } FragmentNumberSet_t& operator-=(const FragmentNumber_t& fragment_number) { set.erase(fragment_number); return *this; } FragmentNumberSet_t& operator+=(const FragmentNumberSet_t& rhs) { for ( auto element : rhs.set ) add(element); return *this; } std::set<FragmentNumber_t> set; }; /** * Prints a Fragment Number set * @param output Output Stream * @param sns SequenceNumber set * @return OStream. */ inline std::ostream& operator<<(std::ostream& output, FragmentNumberSet_t& sns){ return output << sns.print(); } inline FragmentNumberSet_t operator-(FragmentNumberSet_t lhs, const FragmentNumberSet_t& rhs) { for ( auto element : rhs.set) lhs.set.erase(element); return lhs; } inline FragmentNumberSet_t operator+(FragmentNumberSet_t lhs, const FragmentNumberSet_t& rhs) { for ( auto element : rhs.set) lhs.add(element); return lhs; } } } } #endif /* RPTS_ELEM_FRAGNUM_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/common/Property.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /*! * @file PropertyQos.h */ #ifndef _RTPS_COMMON_PROPERTYQOS_H_ #define _RTPS_COMMON_PROPERTYQOS_H_ #include <string> #include <vector> namespace eprosima { namespace fastrtps { namespace rtps { class Property { public: Property() : propagate_(false) {} Property(const Property& property) : name_(property.name_), value_(property.value_), propagate_(property.propagate_) {} Property(Property&& property) : name_(std::move(property.name_)), value_(std::move(property.value_)), propagate_(property.propagate_) {} Property(const std::string& name, const std::string& value) : name_(name), value_(value) {} Property(std::string&& name, std::string&& value) : name_(std::move(name)), value_(std::move(value)) {} Property& operator=(const Property& property) { name_ = property.name_; value_ = property.value_; propagate_ = property.propagate_; return *this; } Property& operator=(Property&& property) { name_ = std::move(property.name_); value_ = std::move(property.value_); propagate_ = property.propagate_; return *this; } void name(const std::string& name) { name_ = name; } void name(std::string&& name) { name_ = std::move(name); } const std::string& name() const { return name_; } std::string& name() { return name_; } void value(const std::string& value) { value_ = value; } void value(std::string&& value) { value_ = std::move(value); } const std::string& value() const { return value_; } std::string& value() { return value_; } void propagate(bool propagate) { propagate_ = propagate; } bool propagate() const { return propagate_; } bool& propagate() { return propagate_; } private: std::string name_; std::string value_; bool propagate_; }; typedef std::vector<Property> PropertySeq; class PropertyHelper { public: static size_t serialized_size(const Property& property, size_t current_alignment = 0) { if(property.propagate()) { size_t initial_alignment = current_alignment; current_alignment += 4 + alignment(current_alignment, 4) + property.name().size() + 1; current_alignment += 4 + alignment(current_alignment, 4) + property.value().size() + 1; return current_alignment - initial_alignment; } else return 0; } static size_t serialized_size(const PropertySeq& properties, size_t current_alignment = 0) { size_t initial_alignment = current_alignment; current_alignment += 4 + alignment(current_alignment, 4); for(auto property = properties.begin(); property != properties.end(); ++property) current_alignment += serialized_size(*property, current_alignment); return current_alignment - initial_alignment; } private: inline static size_t alignment(size_t current_alignment, size_t dataSize) { return (dataSize - (current_alignment % dataSize)) & (dataSize-1);} }; } //namespace eprosima } //namespace fastrtps } //namespace rtps #endif // _RTPS_COMMON_PROPERTYQOS_H_
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/common/Time_t.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file Time_t.h */ #ifndef TIME_T_H_ #define TIME_T_H_ #include "../../fastrtps_dll.h" #include <cmath> #include <cstdint> #include <iostream> namespace eprosima{ namespace fastrtps{ namespace rtps{ /** * Structure Time_t, used to describe times. * @ingroup COMMON_MODULE */ struct RTPS_DllAPI Time_t{ //!Seconds int32_t seconds; //!Fraction of second (1 fraction = 1/(2^32) seconds) uint32_t fraction; //! Default constructor. Sets values to zero. Time_t() { seconds = 0; fraction = 0; } /** * @param sec Seconds * @param frac Fraction of second */ Time_t(int32_t sec,uint32_t frac) { seconds = sec; fraction = frac; } }; #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC /** * Comparison assignment * @param t1 First Time_t to compare * @param t2 Second Time_t to compare * @return True if equal */ static inline bool operator==(const Time_t& t1,const Time_t& t2) { if(t1.seconds!=t2.seconds) return false; if(t1.fraction!=t2.fraction) return false; return true; } /** * Comparison assignment * @param t1 First Time_t to compare * @param t2 Second Time_t to compare * @return True if not equal */ static inline bool operator!=(const Time_t& t1,const Time_t& t2) { if(t1.seconds!=t2.seconds) return true; if(t1.fraction!=t2.fraction) return true; return false; } /** * Checks if a Time_t is less than other. * @param t1 First Time_t to compare * @param t2 Second Time_t to compare * @return True if the first Time_t is less than the second */ static inline bool operator<(const Time_t& t1,const Time_t& t2) { if(t1.seconds < t2.seconds) return true; else if(t1.seconds > t2.seconds) return false; else { if(t1.fraction < t2.fraction) return true; else return false; } } /** * Checks if a Time_t is less or equal than other. * @param t1 First Time_t to compare * @param t2 Second Time_t to compare * @return True if the first Time_t is less or equal than the second */ static inline bool operator<=(const Time_t& t1,const Time_t& t2) { if(t1.seconds < t2.seconds) return true; else if(t1.seconds > t2.seconds) return false; else { if(t1.fraction <= t2.fraction) return true; else return false; } } inline std::ostream& operator<<(std::ostream& output,const Time_t& t) { return output << t.seconds<<"."<<t.fraction; } #endif const Time_t c_TimeInfinite(0x7fffffff,0xffffffff); const Time_t c_TimeZero(0,0); const Time_t c_TimeInvalid(-1,0xffffffff); typedef Time_t Duration_t; } } } #endif /* TIME_T_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/common/MatchingInfo.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file MatchingInfo.h * */ #ifndef MATCHINGINFO_H_ #define MATCHINGINFO_H_ #include "Guid.h" namespace eprosima{ namespace fastrtps{ namespace rtps{ /** * @enum MatchingStatus, indicates whether the matched publication/subscription method of the PublisherListener or SubscriberListener has * been called for a matching or a removal of a remote endpoint. * @ingroup COMMON_MODULE */ #if defined(_WIN32) enum RTPS_DllAPI MatchingStatus{ #else enum MatchingStatus{ #endif MATCHED_MATCHING,//!< MATCHED_MATCHING, new publisher/subscriber found REMOVED_MATCHING //!< REMOVED_MATCHING, publisher/subscriber removed }; /** * Class MatchingInfo contains information about the matching between two endpoints. * @ingroup COMMON_MODULE */ class RTPS_DllAPI MatchingInfo { public: //!Default constructor MatchingInfo():status(MATCHED_MATCHING){}; /** * @param stat Status * @param guid GUID */ MatchingInfo(MatchingStatus stat,const GUID_t&guid):status(stat),remoteEndpointGuid(guid){}; ~MatchingInfo(){}; //!Status MatchingStatus status; //!Remote endpoint GUID GUID_t remoteEndpointGuid; }; } } } #endif /* MATCHINGINFO_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/writer/WriterListener.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file WriterListener.h * */ #ifndef WRITERLISTENER_H_ #define WRITERLISTENER_H_ #include "../common/MatchingInfo.h" namespace eprosima{ namespace fastrtps{ namespace rtps{ class RTPSWriter; /** * Class WriterListener with virtual method so the user can implement callbacks to certain events. * @ingroup WRITER_MODULE */ class RTPS_DllAPI WriterListener { public: WriterListener(){}; virtual ~WriterListener(){}; /** * This method is called when a new Reader is matched with this Writer by hte builtin protocols * @param writer Pointer to the RTPSWriter. * @param info Matching Information. */ virtual void onWriterMatched(RTPSWriter* writer,MatchingInfo& info){(void)writer; (void)info;}; }; } } } #endif /* WRITERLISTENER_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/writer/RTPSWriter.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file RTPSWriter.h */ #ifndef RTPSWRITER_H_ #define RTPSWRITER_H_ #include "../Endpoint.h" #include "../messages/RTPSMessageGroup.h" #include "../attributes/WriterAttributes.h" #include "../flowcontrol/FlowController.h" #include <vector> #include <memory> namespace eprosima { namespace fastrtps{ namespace rtps { class WriterListener; class WriterHistory; struct CacheChange_t; /** * Class RTPSWriter, manages the sending of data to the readers. Is always associated with a HistoryCache. * @ingroup WRITER_MODULE */ class RTPSWriter : public Endpoint { friend class WriterHistory; friend class RTPSParticipantImpl; friend class RTPSMessageGroup; protected: RTPSWriter(RTPSParticipantImpl*,GUID_t& guid,WriterAttributes& att,WriterHistory* hist,WriterListener* listen=nullptr); virtual ~RTPSWriter(); public: /** * Create a new change based with the provided changeKind. * @param changeKind The type of change. * @param handle InstanceHandle to assign. * @return Pointer to the CacheChange or nullptr if incorrect. */ template<typename T> CacheChange_t* new_change(T &data, ChangeKind_t changeKind, InstanceHandle_t handle = c_InstanceHandle_Unknown) { return new_change([data]() -> uint32_t {return (uint32_t)T::getCdrSerializedSize(data);}, changeKind, handle); } RTPS_DllAPI CacheChange_t* new_change(const std::function<uint32_t()>& dataCdrSerializedSize, ChangeKind_t changeKind, InstanceHandle_t handle = c_InstanceHandle_Unknown); /** * Add a matched reader. * @param ratt Pointer to the ReaderProxyData object added. * @return True if added. */ RTPS_DllAPI virtual bool matched_reader_add(RemoteReaderAttributes& ratt) = 0; /** * Remove a matched reader. * @param ratt Pointer to the object to remove. * @return True if removed. */ RTPS_DllAPI virtual bool matched_reader_remove(RemoteReaderAttributes& ratt) = 0; /** * Tells us if a specific Reader is matched against this writer * @param ratt Pointer to the ReaderProxyData object * @return True if it was matched. */ RTPS_DllAPI virtual bool matched_reader_is_matched(RemoteReaderAttributes& ratt) = 0; /** * Check if a specific change has been acknowledged by all Readers. * Is only useful in reliable Writer. In BE Writers always returns true; * @return True if acknowledged by all. */ RTPS_DllAPI virtual bool is_acked_by_all(CacheChange_t* /*a_change*/){ return true; } RTPS_DllAPI virtual bool wait_for_all_acked(const Duration_t& /*max_wait*/){ return true; } /** * Update the Attributes of the Writer. * @param att New attributes */ RTPS_DllAPI virtual void updateAttributes(WriterAttributes& att) = 0; /** * This method triggers the send operation for unsent changes. * @return number of messages sent */ RTPS_DllAPI virtual void send_any_unsent_changes() = 0; /** * Get Min Seq Num in History. * @return Minimum sequence number in history */ RTPS_DllAPI SequenceNumber_t get_seq_num_min(); /** * Get Max Seq Num in History. * @return Maximum sequence number in history */ RTPS_DllAPI SequenceNumber_t get_seq_num_max(); /** * Get maximum size of the serialized type * @return Maximum size of the serialized type */ RTPS_DllAPI uint32_t getTypeMaxSerialized(); uint32_t getMaxDataSize(); uint32_t calculateMaxDataSize(uint32_t length); /** * Get listener * @return Listener */ RTPS_DllAPI inline WriterListener* getListener(){ return mp_listener; }; /** * Get the asserted liveliness * @return Asserted liveliness */ RTPS_DllAPI inline bool getLivelinessAsserted() { return m_livelinessAsserted; }; /** * Get the asserted liveliness * @return asserted liveliness */ RTPS_DllAPI inline void setLivelinessAsserted(bool l){ m_livelinessAsserted = l; }; /** * Get the publication mode * @return publication mode */ RTPS_DllAPI inline bool isAsync(){ return is_async_; }; virtual bool clean_history(unsigned int max = 0) = 0; bool remove_older_changes(unsigned int max = 0); /* * Adds a flow controller that will apply to this writer exclusively. */ virtual void add_flow_controller(std::unique_ptr<FlowController> controller) = 0; /** * Get RTPS participant * @return RTPS participant */ inline RTPSParticipantImpl* getRTPSParticipant() const {return mp_RTPSParticipant;} protected: //!Is the data sent directly or announced by HB and THEN send to the ones who ask for it?. bool m_pushMode; //!Group created to send messages more efficiently RTPSMessageGroup_t m_cdrmessages; //!INdicates if the liveliness has been asserted bool m_livelinessAsserted; //!WriterHistory WriterHistory* mp_history; //!Listener WriterListener* mp_listener; //Asynchronout publication activated bool is_async_; /** * Initialize the header of hte CDRMessages. */ void init_header(); /** * Add a change to the unsent list. * @param change Pointer to the change to add. */ virtual void unsent_change_added_to_history(CacheChange_t* change)=0; /** * Indicate the writer that a change has been removed by the history due to some HistoryQos requirement. * @param a_change Pointer to the change that is going to be removed. * @return True if removed correctly. */ virtual bool change_removed_by_history(CacheChange_t* a_change)=0; private: RTPSWriter& operator=(const RTPSWriter&) NON_COPYABLE_CXX11; }; } } /* namespace rtps */ } /* namespace eprosima */ #endif /* RTPSWRITER_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/writer/StatefulWriter.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file StatefulWriter.h * */ #ifndef STATEFULWRITER_H_ #define STATEFULWRITER_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include "RTPSWriter.h" #include "timedevent/PeriodicHeartbeat.h" #include <condition_variable> #include <mutex> namespace eprosima { namespace fastrtps { namespace rtps { class ReaderProxy; /** * Class StatefulWriter, specialization of RTPSWriter that maintains information of each matched Reader. * @ingroup WRITER_MODULE */ class StatefulWriter: public RTPSWriter { friend class RTPSParticipantImpl; public: //!Destructor virtual ~StatefulWriter(); //!Timed Event to manage the periodic HB to the Reader. // TODO Change to public because a bug. Refactor. PeriodicHeartbeat* mp_periodicHB; private: //!Constructor StatefulWriter(RTPSParticipantImpl*,GUID_t& guid,WriterAttributes& att,WriterHistory* hist,WriterListener* listen=nullptr); //!Count of the sent heartbeats. Count_t m_heartbeatCount; //!WriterTimes WriterTimes m_times; std::vector<ReaderProxy*>::iterator m_reader_iterator; size_t m_readers_to_walk; bool wrap_around_readers(); //! Vector containin all the associated ReaderProxies. std::vector<ReaderProxy*> matched_readers; //!EntityId used to send the HB.(only for builtin types performance) EntityId_t m_HBReaderEntityId; // TODO Join this mutex when main mutex would not be recursive. std::mutex* all_acked_mutex_; // TODO Also remove when main mutex not recursive. bool all_acked_; //! Conditional variable for detect all acked. std::condition_variable* all_acked_cond_; public: /** * Add a specific change to all ReaderLocators. * @param p Pointer to the change. */ void unsent_change_added_to_history(CacheChange_t* p); /** * Indicate the writer that a change has been removed by the history due to some HistoryQos requirement. * @param a_change Pointer to the change that is going to be removed. * @return True if removed correctly. */ bool change_removed_by_history(CacheChange_t* a_change); /** * Method to indicate that there are changes not sent in some of all ReaderProxy. */ void send_any_unsent_changes(); //!Increment the HB count. inline void incrementHBCount(){ ++m_heartbeatCount; }; /** * Add a matched reader. * @param ratt Attributes of the reader to add. * @return True if added. */ bool matched_reader_add(RemoteReaderAttributes& ratt); /** * Remove a matched reader. * @param ratt Attributes of the reader to remove. * @return True if removed. */ bool matched_reader_remove(RemoteReaderAttributes& ratt); /** * Tells us if a specific Reader is matched against this writer * @param ratt Attributes of the reader to remove. * @return True if it was matched. */ bool matched_reader_is_matched(RemoteReaderAttributes& ratt); /** * Remove the change with the minimum SequenceNumber * @return True if removed. */ bool is_acked_by_all(CacheChange_t* a_change); bool wait_for_all_acked(const Duration_t& max_wait); void check_for_all_acked(); bool clean_history(unsigned int max = 0); /** * Update the Attributes of the Writer. * @param att New attributes */ void updateAttributes(WriterAttributes& att); /** * Find a Reader Proxy in this writer. * @param[in] readerGuid The GUID_t of the reader. * @param[out] RP Pointer to pointer to return the ReaderProxy. * @return True if correct. */ bool matched_reader_lookup(GUID_t& readerGuid,ReaderProxy** RP); /** Get count of heartbeats * @return count of heartbeats */ inline Count_t getHeartbeatCount() const {return this->m_heartbeatCount;}; /** Get heartbeat reader entity id * @return heartbeat reader entity id */ inline EntityId_t getHBReaderEntityId() {return this->m_HBReaderEntityId;}; /** * Get the begin of the matched readers * @return A vector iterator pointing to de begin of the matched readers list */ inline std::vector<ReaderProxy*>::iterator matchedReadersBegin(){return this->matched_readers.begin();}; /** * Get the end of the matched readers * @return A vector iterator pointing to de end of the matched readers list */ inline std::vector<ReaderProxy*>::iterator matchedReadersEnd(){return this->matched_readers.end();}; /** * Get the RTPS participant * @return RTPS participant */ inline RTPSParticipantImpl* getRTPSParticipant() const {return mp_RTPSParticipant;} /** * Get the number of matched readers * @return Number of the matched readers */ inline size_t getMatchedReadersSize() const {return matched_readers.size();}; /** * Update the WriterTimes attributes of all associated ReaderProxy. * @param times WriterTimes parameter. */ void updateTimes(WriterTimes& times); void add_flow_controller(std::unique_ptr<FlowController> controller); SequenceNumber_t next_sequence_number() const; /*! * @brief Sends a heartbeat to a remote reader. * @remarks This function is non thread-safe. */ void send_heartbeat_to(ReaderProxy& remoteReaderProxy); private: std::vector<std::unique_ptr<FlowController> > m_controllers; StatefulWriter& operator=(const StatefulWriter&) NON_COPYABLE_CXX11; }; } /* namespace rtps */ } /* namespace fastrtps */ } /* namespace eprosima */ #endif #endif /* STATEFULWRITER_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/writer/ReaderProxy.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file ReaderProxy.h * */ #ifndef READERPROXY_H_ #define READERPROXY_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include <algorithm> #include <mutex> #include <set> #include "../common/Types.h" #include "../common/Locator.h" #include "../common/SequenceNumber.h" #include "../common/CacheChange.h" #include "../common/FragmentNumber.h" #include "../attributes/WriterAttributes.h" #include <set> namespace eprosima { namespace fastrtps { namespace rtps { class StatefulWriter; class NackResponseDelay; class NackSupressionDuration; class InitialHeartbeat; /** * ReaderProxy class that helps to keep the state of a specific Reader with respect to the RTPSWriter. * @ingroup WRITER_MODULE */ class ReaderProxy { public: ~ReaderProxy(); /** * Constructor. * @param rdata RemoteWriterAttributes to use in the creation. * @param times WriterTimes to use in the ReaderProxy. * @param SW Pointer to the StatefulWriter. */ ReaderProxy(RemoteReaderAttributes& rdata,const WriterTimes& times,StatefulWriter* SW); void destroy_timers(); void addChange(const ChangeForReader_t&); size_t countChangesForReader() const; bool change_is_acked(const SequenceNumber_t& sequence_number); /** * Mark all changes up to the one indicated by the seqNum as Acknowledged. * If seqNum == 30, changes 1-29 are marked as ack. * @param seqNum Pointer to the seqNum * @return True if all changes are acknowledge and anyone with other state. */ bool acked_changes_set(const SequenceNumber_t& seqNum); /** * Mark all changes in the vector as requested. * @param seqNumSet Vector of sequenceNumbers * @return False if any change was set REQUESTED. */ bool requested_changes_set(std::vector<SequenceNumber_t>& seqNumSet); /*! * @brief Lists all unsent changes. These changes are also relevants and valid. * @return STL vector with the unsent change list. */ //TODO(Ricardo) Temporal //std::vector<const ChangeForReader_t*> get_unsent_changes() const; std::vector<ChangeForReader_t*> get_unsent_changes(); /*! * @brief Lists all requested changes. * @return STL vector with the requested change list. */ std::vector<const ChangeForReader_t*> get_requested_changes() const; /*! * @brief Sets a change to a particular status (if present in the ReaderProxy) * @param change change to search and set. * @param status Status to apply. */ void set_change_to_status(const SequenceNumber_t& seq_num, ChangeForReaderStatus_t status); void mark_fragment_as_sent_for_change(const CacheChange_t* change, FragmentNumber_t fragment); /* * Converts all changes with a given status to a different status. * @param previous Status to change. * @param next Status to adopt. */ void convert_status_on_all_changes(ChangeForReaderStatus_t previous, ChangeForReaderStatus_t next); //void setNotValid(const CacheChange_t* change); void setNotValid(CacheChange_t* change); /*! * @brief Returns there is some UNACKNOWLEDGED change. * @return There is some UNACKNOWLEDGED change. */ bool thereIsUnacknowledged() const; /** * Get a vector of all unacked changes by this Reader. * @param reqChanges Pointer to a vector of pointers. * @return True if correct. */ bool unacked_changes(std::vector<const ChangeForReader_t*>* reqChanges); //!Attributes of the Remote Reader RemoteReaderAttributes m_att; //!Pointer to the associated StatefulWriter. StatefulWriter* mp_SFW; /** * Return the minimum change in a vector of CacheChange_t. * @param Changes Pointer to a vector of CacheChange_t. * @param changeForReader Pointer to the CacheChange_t. * @return True if correct. */ bool minChange(std::vector<ChangeForReader_t*>* Changes, ChangeForReader_t* changeForReader); /*! * @brief Adds requested fragments. These fragments will be sent in next NackResponseDelay. * @param[in] frag_set set containing the requested fragments to be sent. * @param[in] sequence_number Sequence number to be paired with the requested fragments. * @return True if there is at least one requested fragment. False in other case. */ bool requested_fragment_set(SequenceNumber_t sequence_number, const FragmentNumberSet_t& frag_set); /*! * @brief Returns the last NACKFRAG count. * @return Last NACKFRAG count. */ uint32_t getLastNackfragCount() const { return lastNackfragCount_; } /*! * @brief Sets the last NACKFRAG count. * @param lastNackfragCount New value for last NACKFRAG count. */ void setLastNackfragCount(uint32_t lastNackfragCount) { lastNackfragCount_ = lastNackfragCount; } //! Timed Event to manage the Acknack response delay. NackResponseDelay* mp_nackResponse; //! Timed Event to manage the delay to mark a change as UNACKED after sending it. NackSupressionDuration* mp_nackSupression; //! Timed Event to send initial heartbeat. InitialHeartbeat* mp_initialHeartbeat; //! Last ack/nack count uint32_t m_lastAcknackCount; /** * Filter a CacheChange_t, in this version always returns true. * @param change * @return */ inline bool rtps_is_relevant(CacheChange_t* change){(void)change; return true;}; //!Mutex std::recursive_mutex* mp_mutex; std::set<ChangeForReader_t, ChangeForReaderCmp> m_changesForReader; //!Set of the changes and its state. private: //! Last NACKFRAG count. uint32_t lastNackfragCount_; SequenceNumber_t changesFromRLowMark_; }; } } /* namespace rtps */ } /* namespace eprosima */ #endif #endif /* READERPROXY_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/writer/ReaderLocator.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file ReaderLocator.h */ #ifndef READERLOCATOR_H_ #define READERLOCATOR_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include <vector> #include "../common/Locator.h" #include "../common/Guid.h" #include "../common/SequenceNumber.h" #include "../messages/RTPSMessageGroup.h" namespace eprosima { namespace fastrtps{ namespace rtps { struct CacheChange_t; /** * Class ReaderLocator, contains information about a locator, without saving its state. * @ingroup WRITER_MODULE */ class ReaderLocator { public: ReaderLocator(); /** * Constructor. * @param locator Locator to create the ReaderLocator. * @param expectsInlineQos Indicate that the ReaderLocator expects inline QOS. */ ReaderLocator(Locator_t& locator, bool expectsInlineQos); virtual ~ReaderLocator(); //!Address of this ReaderLocator. Locator_t locator; //!Whether the Reader expects inlineQos with its data messages. bool expectsInlineQos; std::vector<ChangeForReader_t> unsent_changes; //!Number of times this locator has been used (in case different readers use the same locator). uint32_t n_used; /** * Remove change from requested list. * @param cpoin Pointer to change. * @return True if correct */ //bool remove_requested_change(const CacheChange_t* cpoin); }; } } /* namespace rtps */ } /* namespace eprosima */ #endif #endif /* READERLOCATOR_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/writer/StatelessWriter.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file StatelessWriter.h */ #ifndef STATELESSWRITER_H_ #define STATELESSWRITER_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include "../common/Time_t.h" #include "RTPSWriter.h" #include "ReaderLocator.h" #include <list> namespace eprosima { namespace fastrtps{ namespace rtps { /** * Class StatelessWriter, specialization of RTPSWriter that manages writers that don't keep state of the matched readers. * @ingroup WRITER_MODULE */ class StatelessWriter : public RTPSWriter { friend class RTPSParticipantImpl; StatelessWriter(RTPSParticipantImpl*,GUID_t& guid,WriterAttributes& att,WriterHistory* hist,WriterListener* listen=nullptr); public: virtual ~StatelessWriter(); /** * Add a specific change to all ReaderLocators. * @param p Pointer to the change. */ void unsent_change_added_to_history(CacheChange_t* p); /** * Indicate the writer that a change has been removed by the history due to some HistoryQos requirement. * @param a_change Pointer to the change that is going to be removed. * @return True if removed correctly. */ bool change_removed_by_history(CacheChange_t* a_change); /** * Add a matched reader. * @param ratt Attributes of the reader to add. * @return True if added. */ bool matched_reader_add(RemoteReaderAttributes& ratt); /** * Remove a matched reader. * @param ratt Attributes of the reader to remove. * @return True if removed. */ bool matched_reader_remove(RemoteReaderAttributes& ratt); /** * Tells us if a specific Reader is matched against this writer * @param ratt Attributes of the reader to check. * @return True if it was matched. */ bool matched_reader_is_matched(RemoteReaderAttributes& ratt); /** * Method to indicate that there are changes not sent in some of all ReaderProxy. */ void send_any_unsent_changes(); /** * Update the Attributes of the Writer. * @param att New attributes */ void updateAttributes(WriterAttributes& att){ (void)att; //FOR NOW THERE IS NOTHING TO UPDATE. }; /** * Add a remote locator. * * @param rdata RemoteReaderAttributes necessary to create a new locator. * @param loc Locator to add. * @return True on success. */ bool add_locator(RemoteReaderAttributes& rdata,Locator_t& loc); void update_unsent_changes(ReaderLocator& reader_locator, const std::vector<CacheChange_t*>& changes); /** * Remove a remote locator from the writer. * * @param loc Locator to remove. * @return True on success. */ bool remove_locator(Locator_t& loc); //!Reset the unsent changes. void unsent_changes_reset(); /** * Get the number of matched readers * @return Number of matched readers */ inline size_t getMatchedReadersSize() const {return m_matched_readers.size();}; bool clean_history(unsigned int max = 0) { return remove_older_changes(max); } void add_flow_controller(std::unique_ptr<FlowController> controller); private: std::vector<GUID_t> get_remote_readers(); //Duration_t resendDataPeriod; //FIXME: Not used yet. std::vector<ReaderLocator> reader_locators; std::vector<RemoteReaderAttributes> m_matched_readers; std::vector<std::unique_ptr<FlowController> > m_controllers; }; } } /* namespace rtps */ } /* namespace eprosima */ #endif #endif /* STATELESSWRITER_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/writer
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/writer/timedevent/NackResponseDelay.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file NackResponseDelay.h * */ #ifndef NACKRESPONSEDELAY_H_ #define NACKRESPONSEDELAY_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include "../../resources/TimedEvent.h" #include "../../messages/RTPSMessageGroup.h" namespace eprosima { namespace fastrtps{ namespace rtps { class StatefulWriter; class ReaderProxy; /** * NackResponseDelay class use to delay the response to an NACK message. * @ingroup WRITER_MODULE */ class NackResponseDelay:public TimedEvent { public: /** * * @param p_RP * @param intervalmillisec */ NackResponseDelay(ReaderProxy* p_RP,double intervalmillisec); virtual ~NackResponseDelay(); /** * Method invoked when the event occurs * * @param code Code representing the status of the event * @param msg Message associated to the event */ void event(EventCode code, const char* msg= nullptr); //!Associated reader proxy ReaderProxy* mp_RP; }; } } } /* namespace eprosima */ #endif #endif /* NACKRESPONSEDELAY_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/writer
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/writer/timedevent/PeriodicHeartbeat.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file PeriodicHeartbeat.h * */ #ifndef PERIODICHEARTBEAT_H_ #define PERIODICHEARTBEAT_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include "../../resources/TimedEvent.h" #include "../../common/CDRMessage_t.h" #include "../../messages/RTPSMessageGroup.h" namespace eprosima { namespace fastrtps{ namespace rtps{ class StatefulWriter; /** * PeriodicHeartbeat class, controls the periodic send operation of HB. * @ingroup WRITER_MODULE */ class PeriodicHeartbeat: public TimedEvent { public: /** * * @param p_RP * @param interval */ PeriodicHeartbeat(StatefulWriter* p_RP,double interval); virtual ~PeriodicHeartbeat(); /** * Method invoked when the event occurs * * @param code Code representing the status of the event * @param msg Message associated to the event */ void event(EventCode code, const char* msg= nullptr); //! RTPSMessageGroup_t m_cdrmessages; //! StatefulWriter* mp_SFW; }; } } } /* namespace eprosima */ #endif #endif /* PERIODICHEARTBEAT_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/writer
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/writer/timedevent/NackSupressionDuration.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file NackSupressionDuration.h * */ #ifndef NACKSUPRESSIONDURATION_H_ #define NACKSUPRESSIONDURATION_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include "../../resources/TimedEvent.h" namespace eprosima { namespace fastrtps{ namespace rtps { class StatefulWriter; class ReaderProxy; /** * NackSupressionDuration class, used to avoid too "recent" NACK messages. * @ingroup WRITER_MODULE */ class NackSupressionDuration : public TimedEvent { public: virtual ~NackSupressionDuration(); /** * * @param p_RP * @param intervalmillisec */ NackSupressionDuration(ReaderProxy* p_RP,double intervalmillisec); /** * Method invoked when the event occurs * * @param code Code representing the status of the event * @param msg Message associated to the event */ void event(EventCode code, const char* msg= nullptr); //!Reader proxy ReaderProxy* mp_RP; }; } } } /* namespace eprosima */ #endif #endif /* NACKSUPRESSIONDURATION_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/writer
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/writer/timedevent/InitialHeartbeat.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file InitialHeartbeat.h * */ #ifndef INITIALHEARTBEAT_H_ #define INITIALHEARTBEAT_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include <fastrtps/rtps/resources/TimedEvent.h> #include <fastrtps/rtps/common/CDRMessage_t.h> #include <fastrtps/rtps/common/Guid.h> #include <fastrtps/rtps/common/Locator.h> #include <fastrtps/rtps/messages/RTPSMessageGroup.h> namespace eprosima { namespace fastrtps{ namespace rtps{ class ReaderProxy; /** * InitialHeartbeat class, controls the initial send operation of HB. * @ingroup WRITER_MODULE */ class InitialHeartbeat: public TimedEvent { public: /** * * @param p_RP * @param interval */ InitialHeartbeat(ReaderProxy* rp, double interval); virtual ~InitialHeartbeat(); /** * Method invoked when the event occurs * * @param code Code representing the status of the event * @param msg Message associated to the event */ void event(EventCode code, const char* msg= nullptr); //! RTPSMessageGroup_t m_cdrmessages; //! ReaderProxy* rp_; }; } } } /* namespace eprosima */ #endif #endif /* INITIALHEARTBEAT_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/history/CacheChangePool.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file CacheChangePool.h * */ #ifndef CACHECHANGEPOOL_H_ #define CACHECHANGEPOOL_H_ #include "../resources/ResourceManagement.h" #include <vector> #include <functional> #include <cstdint> #include <cstddef> #include <mutex> namespace eprosima { namespace fastrtps{ namespace rtps { struct CacheChange_t; /** * Class CacheChangePool, used by the HistoryCache to pre-reserve a number of CacheChange_t to avoid dynamically reserving memory in the middle of execution loops. * @ingroup COMMON_MODULE */ class CacheChangePool { public: virtual ~CacheChangePool(); /** * Constructor. * @param pool_size The initial pool size * @param payload_size The initial payload size associated with the pool. * @param max_pool_size Maximum payload size. If set to 0 the pool will keep reserving until something breaks. * @param memoryPolicy Memory management policy. */ CacheChangePool(int32_t pool_size, uint32_t payload_size, int32_t max_pool_size, MemoryManagementPolicy_t memoryPolicy); /*! * @brief Reserves a CacheChange from the pool. * @param chan Returned pointer to the reserved CacheChange. * @param calculateSizeFunc Function that returns the size of the data which will go into the CacheChange. * This function is executed depending on the memory management policy (DYNAMIC_RESERVE_MEMORY_MODE and * PREALLOCATED_WITH_REALLOC_MEMORY_MODE) * @return True whether the CacheChange could be allocated. In other case returns false. */ bool reserve_Cache(CacheChange_t** chan, const std::function<uint32_t()>& calculateSizeFunc); /*! * @brief Reserves a CacheChange from the pool. * @param chan Returned pointer to the reserved CacheChange. * @param dataSize Size of the data which will go into the CacheChange if it is necessary (on memory management * policy DYNAMIC_RESERVE_MEMORY_MODE and PREALLOCATED_WITH_REALLOC_MEMORY_MODE). In other case this variable is not used. * @return True whether the CacheChange could be allocated. In other case returns false. */ bool reserve_Cache(CacheChange_t** chan, uint32_t dataSize); //!Release a Cache back to the pool. void release_Cache(CacheChange_t*); //!Get the size of the cache vector; all of them (reserved and not reserved). size_t get_allCachesSize(){return m_allCaches.size();} //!Get the number of frre caches. size_t get_freeCachesSize(){return m_freeCaches.size();} //!Get the initial payload size associated with the Pool. inline uint32_t getInitialPayloadSize(){return m_initial_payload_size;}; private: uint32_t m_initial_payload_size; uint32_t m_payload_size; uint32_t m_pool_size; uint32_t m_max_pool_size; std::vector<CacheChange_t*> m_freeCaches; std::vector<CacheChange_t*> m_allCaches; bool allocateGroup(uint32_t pool_size); CacheChange_t* allocateSingle(uint32_t dataSize); std::mutex* mp_mutex; MemoryManagementPolicy_t memoryMode; }; } } /* namespace rtps */ } /* namespace eprosima */ #endif /* CACHECHANGEPOOL_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/history/ReaderHistory.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file ReaderHistory.h * */ #ifndef READERHISTORY_H_ #define READERHISTORY_H_ #include "History.h" #include "../common/CacheChange.h" #include <map> #include <set> #include <fastrtps/utils/Semaphore.h> namespace eprosima { namespace fastrtps{ namespace rtps { //struct FirstLastSeqNum //{ // GUID_t wGuid; // SequenceNumber_t first; // SequenceNumber_t last; //}; class WriterProxy; class RTPSReader; /** * Class ReaderHistory, container of the different CacheChanges of a reader * @ingroup READER_MODULE */ class ReaderHistory : public History { friend class RTPSReader; public: /** * Constructor of the ReaderHistory. It needs a HistoryAttributes. */ RTPS_DllAPI ReaderHistory(const HistoryAttributes& att); RTPS_DllAPI virtual ~ReaderHistory(); /** * Virtual method that is called when a new change is received. * In this implementation this method just calls add_change. The suer can overload this method in case * he needs to perform additional checks before adding the change. * @param change Pointer to the change * @return True if added. */ RTPS_DllAPI virtual bool received_change(CacheChange_t* change, size_t); /** * Add a CacheChange_t to the ReaderHistory. * @param a_change Pointer to the CacheChange to add. * @return True if added. */ RTPS_DllAPI bool add_change(CacheChange_t* a_change); /** * Remove a CacheChange_t from the ReaderHistory. * @param a_change Pointer to the CacheChange to remove. * @return True if removed. */ RTPS_DllAPI bool remove_change(CacheChange_t* a_change); /** * Remove all changes from the History that have a certain guid. * @param a_guid Pointer to the target guid to search for. * @return True if succesful, even if no changes have been removed. * */ RTPS_DllAPI bool remove_changes_with_guid(GUID_t* a_guid); /** * Sort the CacheChange_t from the History. */ RTPS_DllAPI void sortCacheChanges(); /** * Update the maximum and minimum sequenceNumber cacheChanges. */ RTPS_DllAPI void updateMaxMinSeqNum(); //!Post to the semaphore RTPS_DllAPI void postSemaphore(); //!Wait for the semaphore RTPS_DllAPI void waitSemaphore(); RTPS_DllAPI bool thereIsRecordOf(GUID_t& guid, SequenceNumber_t& seq); RTPS_DllAPI bool thereIsUpperRecordOf(GUID_t& guid, SequenceNumber_t& seq); protected: //!Pointer to the reader RTPSReader* mp_reader; //!Pointer to the semaphore, used to halt execution until new message arrives. Semaphore* mp_semaphore; //!Information about changes already in History private: std::map<GUID_t, std::set<SequenceNumber_t>> m_historyRecord;//TODO sustituir por una clase que sea más efectiva, //que no guarde todos los numeros de secuencia rebidiso sino los que falten // std::set<SequenceNumber_t>* m_cachedRecordLocation; GUID_t m_cachedGUID; }; } } /* namespace rtps */ } /* namespace eprosima */ #endif /* READERHISTORY_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/history/History.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file History.h * */ #ifndef HISTORY_H_ #define HISTORY_H_ #include <mutex> #include "../../fastrtps_dll.h" #include "CacheChangePool.h" #include "../common/SequenceNumber.h" #include "../common/Guid.h" #include "../attributes/HistoryAttributes.h" #include <cassert> namespace eprosima { namespace fastrtps{ namespace rtps { /** * Class History, container of the different CacheChanges and the methods to access them. * @ingroup COMMON_MODULE */ class History { protected: History(const HistoryAttributes& att); virtual ~History(); public: //!Attributes of the History HistoryAttributes m_att; /** * Reserve a CacheChange_t from the CacheChange pool. * @param[out] change Pointer to pointer to the CacheChange_t to reserve * @return True is reserved */ RTPS_DllAPI inline bool reserve_Cache(CacheChange_t** change, const std::function<uint32_t()>& calculateSizeFunc) { return m_changePool.reserve_Cache(change, calculateSizeFunc); } RTPS_DllAPI inline bool reserve_Cache(CacheChange_t** change, uint32_t dataSize) { return m_changePool.reserve_Cache(change, dataSize); } /** * release a previously reserved CacheChange_t. * @param ch Pointer to the CacheChange_t. */ RTPS_DllAPI inline void release_Cache(CacheChange_t* ch) { return m_changePool.release_Cache(ch); } /** * Check if the history is full * @return true if the History is full. */ RTPS_DllAPI bool isFull() { return m_isHistoryFull; } /** * Get the History size. * @return Size of the history. */ RTPS_DllAPI size_t getHistorySize(){ return m_changes.size(); } /** * Remove all changes from the History * @return True if everything was correctly removed. */ RTPS_DllAPI bool remove_all_changes(); /** * Update the maximum and minimum sequenceNumbers. */ virtual void updateMaxMinSeqNum()=0; /** * Remove a specific change from the history. * @param ch Pointer to the CacheChange_t. * @return True if removed. */ virtual bool remove_change(CacheChange_t* ch) = 0; /** * Get the beginning of the changes history iterator. * @return Iterator to the beginning of the vector. */ RTPS_DllAPI std::vector<CacheChange_t*>::iterator changesBegin(){ return m_changes.begin(); } /** * Get the end of the changes history iterator. * @return Iterator to the end of the vector. */ RTPS_DllAPI std::vector<CacheChange_t*>::iterator changesEnd(){ return m_changes.end(); } /** * Get the minimum CacheChange_t. * @param min_change Pointer to pointer to the minimum change. * @return True if correct. */ RTPS_DllAPI bool get_min_change(CacheChange_t** min_change); /** * Get the maximum CacheChange_t. * @param max_change Pointer to pointer to the maximum change. * @return True if correct. */ RTPS_DllAPI bool get_max_change(CacheChange_t** max_change); /** * Get the maximum serialized payload size * @return Maximum serialized payload size */ RTPS_DllAPI inline uint32_t getTypeMaxSerialized(){ return m_changePool.getInitialPayloadSize(); } /*! * Get the mutex * @return Mutex */ RTPS_DllAPI inline std::recursive_mutex* getMutex() { assert(mp_mutex != nullptr); return mp_mutex; } RTPS_DllAPI bool get_change(SequenceNumber_t& seq, GUID_t& guid,CacheChange_t** change); protected: //!Vector of pointers to the CacheChange_t. std::vector<CacheChange_t*> m_changes; //!Variable to know if the history is full without needing to block the History mutex. bool m_isHistoryFull; //!Pointer to and invalid cacheChange used to return the maximum and minimum when no changes are stored in the history. CacheChange_t* mp_invalidCache; //!Pool of cache changes reserved when the History is created. CacheChangePool m_changePool; //!Pointer to the minimum sequeceNumber CacheChange. CacheChange_t* mp_minSeqCacheChange; //!Pointer to the maximum sequeceNumber CacheChange. CacheChange_t* mp_maxSeqCacheChange; //!Print the seqNum of the changes in the History (for debugging purposes). void print_changes_seqNum2(); //!Mutex for the History. std::recursive_mutex* mp_mutex; }; } } /* namespace rtps */ } /* namespace eprosima */ #endif /* HISTORY_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/history/WriterHistory.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file WriterHistory.h * */ #ifndef WRITERHISTORY_H_ #define WRITERHISTORY_H_ #include "History.h" namespace eprosima { namespace fastrtps{ namespace rtps { class RTPSWriter; /** * Class WriterHistory, container of the different CacheChanges of a writer * @ingroup WRITER_MODULE */ class WriterHistory : public History { friend class RTPSWriter; public: /** * Constructor of the WriterHistory. */ RTPS_DllAPI WriterHistory(const HistoryAttributes& att); RTPS_DllAPI virtual ~WriterHistory(); /** * Update the maximum and minimum sequenceNumber cacheChanges. */ RTPS_DllAPI void updateMaxMinSeqNum(); /** * Add a CacheChange_t to the ReaderHistory. * @param a_change Pointer to the CacheChange to add. * @return True if added. */ RTPS_DllAPI bool add_change(CacheChange_t* a_change); /** * Remove a specific change from the history. * @param a_change Pointer to the CacheChange_t. * @return True if removed. */ RTPS_DllAPI bool remove_change(CacheChange_t* a_change); virtual bool remove_change_g(CacheChange_t* a_change); RTPS_DllAPI bool remove_change(const SequenceNumber_t& sequence_number); RTPS_DllAPI CacheChange_t* remove_change_and_reuse(const SequenceNumber_t& sequence_number); /** * Remove the CacheChange_t with the minimum sequenceNumber. * @return True if correctly removed. */ RTPS_DllAPI bool remove_min_change(); RTPS_DllAPI SequenceNumber_t next_sequence_number() const { return m_lastCacheChangeSeqNum + 1; } protected: //!Last CacheChange Sequence Number added to the History. SequenceNumber_t m_lastCacheChangeSeqNum; //!Pointer to the associated RTPSWriter; RTPSWriter* mp_writer; }; } } /* namespace fastrtps */ } /* namespace eprosima */ #endif /* WRITERHISTORY_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/builtin/BuiltinProtocols.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file BuiltinProtocols.h * */ #ifndef BUILTINPROTOCOLS_H_ #define BUILTINPROTOCOLS_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include "../attributes/RTPSParticipantAttributes.h" namespace eprosima { namespace fastrtps{ class WriterQos; class ReaderQos; class TopicAttributes; namespace rtps { class PDPSimple; class WLP; class RTPSParticipantImpl; class RTPSWriter; class RTPSReader; /** * Class BuiltinProtocols that contains builtin endpoints implementing the discovery and liveliness protocols. * *@ingroup BUILTIN_MODULE */ class BuiltinProtocols { friend class RTPSParticipantImpl; private: BuiltinProtocols(); virtual ~BuiltinProtocols(); public: /** * Initialize the builtin protocols. * @param attributes Discovery configuration attributes * @param p_part Pointer to the Participant implementation * @return True if correct. */ bool initBuiltinProtocols(RTPSParticipantImpl* p_part, BuiltinAttributes& attributes); /** * Update the metatraffic locatorlist after it was created. Because when you create the EDP readers you are not sure the selected endpoints can be used. * @param loclist LocatorList to update * @return True on success */ bool updateMetatrafficLocators(LocatorList_t& loclist); //!BuiltinAttributes of the builtin protocols. BuiltinAttributes m_att; //!Pointer to the RTPSParticipantImpl. RTPSParticipantImpl* mp_participantImpl; //!Pointer to the PDPSimple. PDPSimple* mp_PDP; //!Pointer to the WLP WLP* mp_WLP; //!Locator list for metatraffic LocatorList_t m_metatrafficMulticastLocatorList; //!Locator List for metatraffic unicast LocatorList_t m_metatrafficUnicastLocatorList; //! Initial peers LocatorList_t m_initialPeersList; /** * Add a local Writer to the BuiltinProtocols. * @param w Pointer to the RTPSWriter * @param topicAtt Attributes of the associated topic * @param wqos QoS policies dictated by the publisher * @return True if correct. */ bool addLocalWriter(RTPSWriter* w,TopicAttributes& topicAtt,WriterQos& wqos); /** * Add a local Reader to the BuiltinProtocols. * @param R Pointer to the RTPSReader. * @param topicAtt Attributes of the associated topic * @param rqos QoS policies dictated by the subscriber * @return True if correct. */ bool addLocalReader(RTPSReader* R,TopicAttributes& topicAtt, ReaderQos& rqos); /** * Update a local Writer QOS * @param W Writer to update * @param wqos New Writer QoS * @return */ bool updateLocalWriter(RTPSWriter* W,WriterQos& wqos); /** * Update a local Reader QOS * @param R Reader to update * @param qos New Reader QoS * @return */ bool updateLocalReader(RTPSReader* R,ReaderQos& qos); /** * Remove a local Writer from the builtinProtocols. * @param W Pointer to the writer. * @return True if correctly removed. */ bool removeLocalWriter(RTPSWriter* W); /** * Remove a local Reader from the builtinProtocols. * @param R Pointer to the reader. * @return True if correctly removed. */ bool removeLocalReader(RTPSReader* R); //! Announce RTPSParticipantState (force the sending of a DPD message.) void announceRTPSParticipantState(); //!Stop the RTPSParticipant Announcement (used in tests to avoid multiple packets being send) void stopRTPSParticipantAnnouncement(); //!Reset to timer to make periodic RTPSParticipant Announcements. void resetRTPSParticipantAnnouncement(); }; } } /* namespace rtps */ } /* namespace eprosima */ #endif #endif /* BUILTINPROTOCOLS_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/builtin/discovery
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/builtin/discovery/participant/PDPSimple.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file PDPSimple.h * */ #ifndef PDPSIMPLE_H_ #define PDPSIMPLE_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include <mutex> #include "../../../common/Guid.h" #include "../../../attributes/RTPSParticipantAttributes.h" #include "../../../../qos/QosPolicies.h" using namespace eprosima::fastrtps; namespace eprosima { namespace fastrtps{ namespace rtps { class StatelessWriter; class StatelessReader; class WriterHistory; class ReaderHistory; class RTPSParticipantImpl; class BuiltinProtocols; class EDP; class ResendParticipantProxyDataPeriod; class RemoteParticipantLeaseDuration; class ReaderProxyData; class WriterProxyData; class ParticipantProxyData; class PDPSimpleListener; /** * Class PDPSimple that implements the SimpleRTPSParticipantDiscoveryProtocol as defined in the RTPS specification. *@ingroup DISCOVERY_MODULE */ class PDPSimple { friend class ResendRTPSParticipantProxyDataPeriod; friend class RemoteRTPSParticipantLeaseDuration; friend class PDPSimpleListener; public: /** * Constructor * @param builtin Pointer to the BuiltinProcols object. */ PDPSimple(BuiltinProtocols* builtin); virtual ~PDPSimple(); void initializeParticipantProxyData(ParticipantProxyData* participant_data); /** * Initialize the PDP. * @param part Pointer to the RTPSParticipant. * @return True on success */ bool initPDP(RTPSParticipantImpl* part); /** * Force the sending of our local DPD to all remote RTPSParticipants and multicast Locators. * @param new_change If true a new change (with new seqNum) is created and sent; if false the last change is re-sent * @param dispose Sets change kind to NOT_ALIVE_DISPOSED_UNREGISTERED */ void announceParticipantState(bool new_change, bool dispose = false); //!Stop the RTPSParticipantAnnouncement (only used in tests). void stopParticipantAnnouncement(); //!Reset the RTPSParticipantAnnouncement (only used in tests). void resetParticipantAnnouncement(); /** * Add a ReaderProxyData to the correct ParticipantProxyData. * @param rdata Pointer to the ReaderProxyData objectr to add. * @param copydata Boolean variable indicating the need to copy the passed object. * @param returnReaderProxyData Pointer to pointer in case you wanted the data copied. * @param pdata Pointer to the associated ParticipantProxyData. * @return True if correct. */ bool addReaderProxyData(ReaderProxyData* rdata,bool copydata=false, ReaderProxyData** returnReaderProxyData=nullptr, ParticipantProxyData** pdata = nullptr); /** * Add a WriterProxyData to the correct ParticipantProxyData. * @param wdata Pointer to the WriterProxyData objectr to add. * @param copydata Boolean variable indicating the need to copy the passed object. * @param returnWriterProxyData Pointer to pointer in case you wanted the data copied. * @param pdata Pointer to the associated ParticipantProxyData. * @return True if correct. */ bool addWriterProxyData(WriterProxyData* wdata,bool copydata=false, WriterProxyData** returnWriterProxyData=nullptr, ParticipantProxyData** pdata = nullptr); /** * This method returns a pointer to a ReaderProxyData object if it is found among the registered RTPSParticipants (including the local RTPSParticipant). * @param[in] reader GUID_t of the reader we are looking for. * @param rdata Pointer to pointer of the ReaderProxyData object. * @param pdata Pointer to pointer of the ParticipantProxyData object. * @return True if found. */ bool lookupReaderProxyData(const GUID_t& reader, ReaderProxyData** rdata, ParticipantProxyData** pdata); /** * This method returns a pointer to a WriterProxyData object if it is found among the registered RTPSParticipants (including the local RTPSParticipant). * @param[in] writer GUID_t of the writer we are looking for. * @param wdata Pointer to pointer of the WriterProxyData object. * @param pdata Pointer to pointer of the ParticipantProxyData object. * @return True if found. */ bool lookupWriterProxyData(const GUID_t& writer, WriterProxyData** wdata, ParticipantProxyData** pdata); /** * This method returns a pointer to a RTPSParticipantProxyData object if it is found among the registered RTPSParticipants. * @param[in] pguid GUID_t of the RTPSParticipant we are looking for. * @param pdata Pointer to pointer of the ParticipantProxyData object. * @return True if found. */ bool lookupParticipantProxyData(const GUID_t& pguid,ParticipantProxyData** pdata); /** * This method removes and deletes a ReaderProxyData object from its corresponding RTPSParticipant. * @param rdata Pointer to the ReaderProxyData object. * @param pdata Pointer to pointer of the ParticipantProxyData object. * @return true if found and deleted. */ bool removeReaderProxyData(ParticipantProxyData* pdata, ReaderProxyData* rdata); /** * This method removes and deletes a WriterProxyData object from its corresponding RTPSParticipant. * @param wdata Pointer to the WriterProxyData object. * @param pdata Pointer to pointer of the ParticipantProxyData object. * @return true if found and deleted. */ bool removeWriterProxyData(ParticipantProxyData* pdata, WriterProxyData* wdata); /** * This method assigns remtoe endpoints to the builtin endpoints defined in this protocol. It also calls the corresponding methods in EDP and WLP. * @param pdata Pointer to the RTPSParticipantProxyData object. */ void assignRemoteEndpoints(ParticipantProxyData* pdata); void notifyAboveRemoteEndpoints(ParticipantProxyData* pdata); /** * Remove remote endpoints from the participant discovery protocol * @param pdata Pointer to the ParticipantProxyData to remove */ void removeRemoteEndpoints(ParticipantProxyData* pdata); /** * This method removes a remote RTPSParticipant and all its writers and readers. * @param partGUID GUID_t of the remote RTPSParticipant. * @return true if correct. */ bool removeRemoteParticipant(GUID_t& partGUID); //!Pointer to the builtin protocols object. BuiltinProtocols* mp_builtin; /** * Get a pointer to the local RTPSParticipant RTPSParticipantProxyData object. * @return Pointer to the local RTPSParticipant RTPSParticipantProxyData object. */ ParticipantProxyData* getLocalParticipantProxyData() { return m_participantProxies.front(); } /** * Get a pointer to the EDP object. * @return pointer to the EDP object. */ inline EDP* getEDP(){return mp_EDP;} /** * Get a cons_iterator to the beginning of the RTPSParticipant Proxies. * @return const_iterator. */ std::vector<ParticipantProxyData*>::const_iterator ParticipantProxiesBegin(){return m_participantProxies.begin();}; /** * Get a cons_iterator to the end RTPSParticipant Proxies. * @return const_iterator. */ std::vector<ParticipantProxyData*>::const_iterator ParticipantProxiesEnd(){return m_participantProxies.end();}; /** * Assert the liveliness of a Remote Participant. * @param guidP GuidPrefix_t of the participant whose liveliness is being asserted. */ void assertRemoteParticipantLiveliness(const GuidPrefix_t& guidP); /** * Assert the liveliness of a Local Writer. * @param kind LivilinessQosPolicyKind to be asserted. */ void assertLocalWritersLiveliness(LivelinessQosPolicyKind kind); /** * Assert the liveliness of remote writers. * @param guidP GuidPrefix_t of the participant whose writers liveliness is begin asserted. * @param kind LivelinessQosPolicyKind of the writers. */ void assertRemoteWritersLiveliness(GuidPrefix_t& guidP,LivelinessQosPolicyKind kind); /** * Activate a new Remote Endpoint that has been statically discovered. * @param pguid GUID_t of the participant. * @param userDefinedId User Defined ID. * @param kind Kind of endpoint. */ bool newRemoteEndpointStaticallyDiscovered(const GUID_t& pguid, int16_t userDefinedId,EndpointKind_t kind); /** * Get the RTPS participant * @return RTPS participant */ inline RTPSParticipantImpl* getRTPSParticipant() const {return mp_RTPSParticipant;}; /** * Get the mutex. * @return Pointer to the Mutex */ inline std::recursive_mutex* getMutex() const {return mp_mutex;} CDRMessage_t get_participant_proxy_data_serialized(Endianness_t endian); private: //!Pointer to the local RTPSParticipant. RTPSParticipantImpl* mp_RTPSParticipant; //!Discovery attributes. BuiltinAttributes m_discovery; //!Pointer to the SPDPWriter. StatelessWriter* mp_SPDPWriter; //!Pointer to the SPDPReader. StatelessReader* mp_SPDPReader; //!Pointer to the EDP object. EDP* mp_EDP; //!Registered RTPSParticipants (including the local one, that is the first one.) std::vector<ParticipantProxyData*> m_participantProxies; //!Variable to indicate if any parameter has changed. bool m_hasChangedLocalPDP; //!TimedEvent to periodically resend the local RTPSParticipant information. ResendParticipantProxyDataPeriod* mp_resendParticipantTimer; //!Listener for the SPDP messages. PDPSimpleListener* mp_listener; //!WriterHistory WriterHistory* mp_SPDPWriterHistory; //!Reader History ReaderHistory* mp_SPDPReaderHistory; /** * Create the SPDP Writer and Reader * @return True if correct. */ bool createSPDPEndpoints(); std::recursive_mutex* mp_mutex; }; } } /* namespace rtps */ } /* namespace eprosima */ #endif #endif /* PDPSIMPLE_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/builtin/discovery
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/builtin/discovery/participant/PDPSimpleListener.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file PDPSimpleListener.h * */ #ifndef PDPSIMPLELISTENER_H_ #define PDPSIMPLELISTENER_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include "../../../reader/ReaderListener.h" #include "../../../../qos/ParameterList.h" #include "../../data/ParticipantProxyData.h" using namespace eprosima::fastrtps; namespace eprosima { namespace fastrtps{ namespace rtps { class PDPSimple; class DiscoveredParticipantData; class RTPSReader; /** * Class PDPSimpleListener, specification of SubscriberListener used by the SPDP to perform the History check when a new message is received. * This class is implemented in order to use the same structure than with any other RTPSReader. *@ingroup DISCOVERY_MODULE */ class PDPSimpleListener: public ReaderListener { public: /** * @param in_SPDP */ PDPSimpleListener(PDPSimple* in_SPDP) : mp_SPDP(in_SPDP) { } virtual ~PDPSimpleListener() {} //!Pointer to the associated mp_SPDP; PDPSimple* mp_SPDP; /** * New added cache * @param reader * @param change */ void onNewCacheChangeAdded(RTPSReader* reader,const CacheChange_t* const change); /** * Process a new added cache with this method. * @return True on success */ bool newAddedCache(); /** * Get the key of a CacheChange_t * @param change Pointer to the CacheChange_t * @return True on success */ bool getKey(CacheChange_t* change); //!Temporal RTPSParticipantProxyData object used to read the messages. ParticipantProxyData m_ParticipantProxyData; //!Auxiliary message. CDRMessage_t aux_msg; }; } } /* namespace rtps */ } /* namespace eprosima */ #endif #endif /* PDPSIMPLELISTENER_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/builtin/discovery/participant
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/builtin/discovery/participant/timedevent/RemoteParticipantLeaseDuration.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file RemoteParticipantLeaseDuration.h * */ #ifndef RTPSPARTICIPANTLEASEDURATION_H_ #define RTPSPARTICIPANTLEASEDURATION_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include "fastrtps/rtps/resources/TimedEvent.h" namespace eprosima { namespace fastrtps{ namespace rtps { class PDPSimple; class ParticipantProxyData; /** * Class RemoteRTPSParticipantLeaseDuration, TimedEvent designed to remove a * remote RTPSParticipant and all its Readers and Writers from the local RTPSParticipant if it fails to * announce its liveliness each leaseDuration period. *@ingroup DISCOVERY_MODULE */ class RemoteParticipantLeaseDuration:public TimedEvent { public: /** * Constructor * @param p_SPDP Pointer to the PDPSimple object. * @param pdata Pointer to the ParticipantProxyData associated with this TimedEvent. * @param interval Interval in ms. */ RemoteParticipantLeaseDuration(PDPSimple* p_SPDP, ParticipantProxyData* pdata, double interval); virtual ~RemoteParticipantLeaseDuration(); /** * Temporal event that check if the RTPSParticipant is alive, and removes it if not. * @param code Code representing the status of the event * @param msg Message associated to the event */ void event(EventCode code, const char* msg= nullptr); //!Pointer to the PDPSimple object. PDPSimple* mp_PDP; //!Pointer to the RTPSParticipantProxyData object that contains this temporal event. ParticipantProxyData* mp_participantProxyData; }; } } /* namespace rtps */ } /* namespace eprosima */ #endif #endif /* RTPSPARTICIPANTLEASEDURATION_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/builtin/discovery/participant
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/builtin/discovery/participant/timedevent/ResendParticipantProxyDataPeriod.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file ResendParticipantProxyDataPeriod.h * */ #ifndef RESENDDATAPERIOD_H_ #define RESENDDATAPERIOD_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include "fastrtps/rtps/resources/TimedEvent.h" #include "fastrtps/rtps/common/CDRMessage_t.h" namespace eprosima { namespace fastrtps{ namespace rtps { class PDPSimple; /** * Class ResendParticipantProxyDataPeriod, TimedEvent used to periodically send the RTPSParticipantDiscovery Data. *@ingroup DISCOVERY_MODULE */ class ResendParticipantProxyDataPeriod: public TimedEvent { public: /** * Constructor. * @param p_SPDP Pointer to the PDPSimple. * @param interval Interval in ms. */ ResendParticipantProxyDataPeriod(PDPSimple* p_SPDP, double interval); virtual ~ResendParticipantProxyDataPeriod(); /** * Method invoked when the event occurs. * This temporal event resends the RTPSParticipantProxyData to all remote RTPSParticipants. * @param code Code representing the status of the event * @param msg Message associated to the event */ void event(EventCode code, const char* msg= nullptr); //!Auxiliar data message. CDRMessage_t m_data_msg; //!Pointer to the PDPSimple object. PDPSimple* mp_PDP; }; } } /* namespace rtps */ } /* namespace eprosima */ #endif #endif /* RESENDDATAPERIOD_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/builtin/discovery
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/builtin/discovery/endpoint/EDPSimple.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file EDPSimple.h * */ #ifndef EDPSIMPLE_H_ #define EDPSIMPLE_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include "EDP.h" namespace eprosima { namespace fastrtps{ namespace rtps { class StatefulReader; class StatefulWriter; class RTPSWriter; class RTPSReader; class EDPSimplePUBListener; class EDPSimpleSUBListener; class ReaderHistory; class WriterHistory; /** * Class EDPSimple, implements the Simple Endpoint Discovery Protocol defined in the RTPS specification. * Inherits from EDP class. *@ingroup DISCOVERY_MODULE */ class EDPSimple : public EDP { typedef std::pair<StatefulWriter*,WriterHistory*> t_p_StatefulWriter; typedef std::pair<StatefulReader*,ReaderHistory*> t_p_StatefulReader; public: /** * Constructor. * @param p Pointer to the PDPSimple * @param part Pointer to the RTPSParticipantImpl */ EDPSimple(PDPSimple* p,RTPSParticipantImpl* part); virtual ~EDPSimple(); //!Discovery attributes. BuiltinAttributes m_discovery; //!Pointer to the Publications Writer (only created if indicated in the DiscoveryAtributes). t_p_StatefulWriter mp_PubWriter; //!Pointer to the Subscriptions Writer (only created if indicated in the DiscoveryAtributes). t_p_StatefulWriter mp_SubWriter; //!Pointer to the Publications Reader (only created if indicated in the DiscoveryAtributes). t_p_StatefulReader mp_PubReader; //!Pointer to the Subscriptions Reader (only created if indicated in the DiscoveryAtributes). t_p_StatefulReader mp_SubReader; //!Pointer to the ReaderListener associated with PubReader EDPSimplePUBListener* mp_pubListen; //!Pointer to the ReaderListener associated with SubReader EDPSimpleSUBListener* mp_subListen; /** * Initialization method. * @param attributes Reference to the DiscoveryAttributes. * @return True if correct. */ bool initEDP(BuiltinAttributes& attributes); /** * This method assigns the remote builtin endpoints that the remote RTPSParticipant indicates is using to our local builtin endpoints. * @param pdata Pointer to the RTPSParticipantProxyData object. */ void assignRemoteEndpoints(ParticipantProxyData* pdata); /** * Remove remote endpoints from the endpoint discovery protocol * @param pdata Pointer to the ParticipantProxyData to remove */ void removeRemoteEndpoints(ParticipantProxyData* pdata); /** * Create local SEDP Endpoints based on the DiscoveryAttributes. * @return True if correct. */ bool createSEDPEndpoints(); /** * This method generates the corresponding change in the subscription writer and send it to all known remote endpoints. * @param rdata Pointer to the ReaderProxyData object. * @return true if correct. */ bool processLocalReaderProxyData(ReaderProxyData* rdata); /** * This method generates the corresponding change in the publciations writer and send it to all known remote endpoints. * @param wdata Pointer to the WriterProxyData object. * @return true if correct. */ bool processLocalWriterProxyData(WriterProxyData* wdata); /** * This methods generates the change disposing of the local Reader and calls the unpairing and removal methods of the base class. * @param R Pointer to the RTPSReader object. * @return True if correct. */ bool removeLocalReader(RTPSReader*R); /** * This methods generates the change disposing of the local Writer and calls the unpairing and removal methods of the base class. * @param W Pointer to the RTPSWriter object. * @return True if correct. */ bool removeLocalWriter(RTPSWriter*W); }; } } /* namespace rtps */ } /* namespace eprosima */ #endif #endif /* EDPSIMPLE_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/builtin/discovery
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/builtin/discovery/endpoint/EDPStaticXML.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file EDPStaticXML.h * */ #ifndef EDPSTATICXML_H_ #define EDPSTATICXML_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include <set> #include <vector> #include <cstdint> #include <tinyxml2.h> namespace eprosima { namespace fastrtps{ namespace rtps { class ReaderProxyData; class WriterProxyData; /** * Class StaticRTPSParticipantInfo, contains the information of writers and readers loaded from the XML file. *@ingroup DISCOVERY_MODULE */ class StaticRTPSParticipantInfo{ public: StaticRTPSParticipantInfo(){}; virtual ~StaticRTPSParticipantInfo(){}; //!RTPS PArticipant name std::string m_RTPSParticipantName; //!Vector of ReaderProxyData pointer std::vector<ReaderProxyData*> m_readers; //!Vector of ReaderProxyData pointer std::vector<WriterProxyData*> m_writers; }; /** * Class EDPStaticXML used to parse the XML file that contains information about remote endpoints. * @ingroup DISCVOERYMODULE */ class EDPStaticXML { public: EDPStaticXML(); virtual ~EDPStaticXML(); /** * Load the XML file * @param filename Name of the file to load and parse. * @return True if correct. */ bool loadXMLFile(std::string& filename); void loadXMLParticipantEndpoint(tinyxml2::XMLElement* xml_endpoint, StaticRTPSParticipantInfo* pdata); /** * Load a Reader endpoint. * @param xml_endpoint Reference of a tree child for a reader. * @param pdata Pointer to the RTPSParticipantInfo where the reader must be added. * @return True if correctly added. */ bool loadXMLReaderEndpoint(tinyxml2::XMLElement* xml_endpoint,StaticRTPSParticipantInfo* pdata); /** * Load a Writer endpoint. * @param xml_endpoint Reference of a tree child for a writer. * @param pdata Pointer to the RTPSParticipantInfo where the reader must be added. * @return True if correctly added. */ bool loadXMLWriterEndpoint(tinyxml2::XMLElement* xml_endpoint,StaticRTPSParticipantInfo* pdata); /** * Look for a reader in the previously loaded endpoints. * @param[in] partname RTPSParticipant name * @param[in] id Id of the reader * @param[out] rdataptr Pointer to pointer to return the information. * @return True if found. */ bool lookforReader(std::string partname,uint16_t id,ReaderProxyData** rdataptr); /** * Look for a writer in the previously loaded endpoints. * @param[in] partname RTPSParticipant name * @param[in] id Id of the writer * @param[out] wdataptr Pointer to pointer to return the information. * @return True if found */ bool lookforWriter(std::string partname,uint16_t id,WriterProxyData** wdataptr); private: std::set<int16_t> m_endpointIds; std::set<uint32_t> m_entityIds; std::vector<StaticRTPSParticipantInfo*> m_RTPSParticipants; }; } } /* namespace rtps */ } /* namespace eprosima */ #endif #endif /* EDPSTATICXML_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/builtin/discovery
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/builtin/discovery/endpoint/EDPStatic.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file EDPStatic.h * */ #ifndef EDPSTATIC_H_ #define EDPSTATIC_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include "EDP.h" namespace eprosima { namespace fastrtps{ namespace rtps { class EDPStaticXML; /** * Class EDPStaticProperty, used to read and write the strings from the properties used to transmit the EntityId_t. *@ingroup DISCOVERY_MODULE */ class EDPStaticProperty { public: EDPStaticProperty():m_userId(0){}; ~EDPStaticProperty(){}; //!Endpoint type std::string m_endpointType; //!Status std::string m_status; //!User ID as string std::string m_userIdStr; //!User ID uint16_t m_userId; //!Entity ID EntityId_t m_entityId; /** * Convert information to a property * @param type Type of endpoint * @param status Status of the endpoint * @param id User Id * @param ent EntityId * @return Pair of two strings. */ static std::pair<std::string,std::string> toProperty(std::string type,std::string status,uint16_t id,const EntityId_t& ent); /** * @param in_property Input property- * @return True if correctly read */ bool fromProperty(std::pair<std::string,std::string> in_property); }; /** * Class EDPStatic, implements a static endpoint discovery module. * @ingroup DISCOVERYMODULE */ class EDPStatic : public EDP { public: /** * Constructor. * @param p Pointer to the PDPSimple. * @param part Pointer to the RTPSParticipantImpl. */ EDPStatic(PDPSimple* p,RTPSParticipantImpl* part); virtual ~EDPStatic(); /** * Abstract method to initialize the EDP. * @param attributes DiscoveryAttributes structure. * @return True if correct. */ bool initEDP(BuiltinAttributes& attributes); /** * Abstract method that assigns remote endpoints when a new RTPSParticipantProxyData is discovered. * @param pdata Pointer to the ParticipantProxyData. */ void assignRemoteEndpoints(ParticipantProxyData* pdata); /** * Abstract method that removes a local Reader from the discovery method * @param R Pointer to the Reader to remove. * @return True if correctly removed. */ bool removeLocalReader(RTPSReader* R); /** * Abstract method that removes a local Writer from the discovery method * @param W Pointer to the Writer to remove. * @return True if correctly removed. */ bool removeLocalWriter(RTPSWriter*W); /** * After a new local ReaderProxyData has been created some processing is needed (depends on the implementation). * @param rdata Pointer to the ReaderProxyData object. * @return True if correct. */ bool processLocalReaderProxyData(ReaderProxyData* rdata); /** * After a new local WriterProxyData has been created some processing is needed (depends on the implementation). * @param wdata Pointer to the Writer ProxyData object. * @return True if correct. */ bool processLocalWriterProxyData(WriterProxyData* wdata); /** * New Remote Writer has been found and this method process it and calls the pairing methods. * @param pdata Pointer to the RTPSParticipantProxyData object. * @param userId UserId. * @param entId EntityId. * @return True if correct. */ bool newRemoteWriter(ParticipantProxyData*pdata,uint16_t userId, EntityId_t entId=c_EntityId_Unknown); /** * New Remote Reader has been found and this method process it and calls the pairing methods. * @param pdata Pointer to the RTPSParticipantProxyData object. * @param userId UserId. * @param entId EntityId. * @return true if correct. */ bool newRemoteReader(ParticipantProxyData*pdata,uint16_t userId, EntityId_t entId=c_EntityId_Unknown); /** * This method checks the provided entityId against the topic type to see if it matches * @param rdata Pointer to the readerProxyData * @return True if its correct. **/ bool checkEntityId(ReaderProxyData* rdata); /** * This method checks the provided entityId against the topic type to see if it matches * @param wdata Pointer to the writerProxyData * @return True if its correct. **/ bool checkEntityId(WriterProxyData* wdata); private: EDPStaticXML* mp_edpXML; BuiltinAttributes m_attributes; }; } } /* namespace rtps */ } /* namespace eprosima */ #endif #endif /* EDPSTATIC_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/builtin/discovery
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/builtin/discovery/endpoint/EDP.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file EDP.h * */ #ifndef EDP_H_ #define EDP_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include "../../../attributes/RTPSParticipantAttributes.h" #include "../../../common/Guid.h" namespace eprosima { namespace fastrtps{ class TopicAttributes; class ReaderQos; class WriterQos; namespace rtps { class PDPSimple; class ParticipantProxyData; class RTPSWriter; class RTPSReader; class ReaderProxyData; class WriterProxyData; class RTPSParticipantImpl; /** * Class EDP, base class for Endpoint Discovery Protocols. It contains generic methods used by the two EDP implemented (EDPSimple and EDPStatic), as well as abstract methods * definitions required by the specific implementations. * @ingroup DISCOVERY_MODULE */ class EDP { public: /** * Constructor. * @param p Pointer to the PDPSimple * @param part Pointer to the RTPSParticipantImpl */ EDP(PDPSimple* p,RTPSParticipantImpl* part); virtual ~EDP(); /** * Abstract method to initialize the EDP. * @param attributes DiscoveryAttributes structure. * @return True if correct. */ virtual bool initEDP(BuiltinAttributes& attributes)=0; /** * Abstract method that assigns remote endpoints when a new RTPSParticipantProxyData is discovered. * @param pdata Discovered ParticipantProxyData */ virtual void assignRemoteEndpoints(ParticipantProxyData* pdata)=0; /** * Remove remote endpoints from the endpoint discovery protocol * @param pdata Pointer to the ParticipantProxyData to remove */ virtual void removeRemoteEndpoints(ParticipantProxyData* pdata){(void) pdata;}; /** * Abstract method that removes a local Reader from the discovery method * @param R Pointer to the Reader to remove. * @return True if correctly removed. */ virtual bool removeLocalReader(RTPSReader* R)=0; /** * Abstract method that removes a local Writer from the discovery method * @param W Pointer to the Writer to remove. * @return True if correctly removed. */ virtual bool removeLocalWriter(RTPSWriter*W)=0; /** * After a new local ReaderProxyData has been created some processing is needed (depends on the implementation). * @param rdata Pointer to the ReaderProxyData object. * @return True if correct. */ virtual bool processLocalReaderProxyData(ReaderProxyData* rdata)= 0; /** * After a new local WriterProxyData has been created some processing is needed (depends on the implementation). * @param wdata Pointer to the Writer ProxyData object. * @return True if correct. */ virtual bool processLocalWriterProxyData(WriterProxyData* wdata)= 0; /** * Create a new ReaderPD for a local Reader. * @param R Pointer to the RTPSReader. * @param att Attributes of the associated topic * @param qos QoS policies dictated by the subscriber * @return True if correct. */ bool newLocalReaderProxyData(RTPSReader* R,TopicAttributes& att, ReaderQos& qos); /** * Create a new ReaderPD for a local Writer. * @param W Pointer to the RTPSWriter. * @param att Attributes of the associated topic * @param qos QoS policies dictated by the publisher * @return True if correct. */ bool newLocalWriterProxyData(RTPSWriter* W,TopicAttributes& att, WriterQos& qos); /** * A previously created Reader has been updated * @param R Pointer to the reader; * @param qos QoS policies dictated by the subscriber * @return True if correctly updated */ bool updatedLocalReader(RTPSReader* R,ReaderQos& qos); /** * A previously created Writer has been updated * @param W Pointer to the Writer * @param qos QoS policies dictated by the publisher * @return True if correctly updated */ bool updatedLocalWriter(RTPSWriter* W,WriterQos& qos); /** * Check the validity of a matching between a RTPSWriter and a ReaderProxyData object. * @param wdata Pointer to the WriterProxyData object. * @param rdata Pointer to the ReaderProxyData object. * @return True if the two can be matched. */ bool validMatching(WriterProxyData* wdata,ReaderProxyData* rdata); /** * Check the validity of a matching between a RTPSReader and a WriterProxyData object. * @param rdata Pointer to the ReaderProxyData object. * @param wdata Pointer to the WriterProxyData object. * @return True if the two can be matched. */ bool validMatching(ReaderProxyData* rdata,WriterProxyData* wdata); /** * Remove a WriterProxyDataObject based on its GUID_t. * @param writer Reference to the writer GUID. * @return True if correct. */ bool removeWriterProxy(const GUID_t& writer); /** * Remove a ReaderProxyDataObject based on its GUID_t. * @param reader Reference to the reader GUID. * @return True if correct. */ bool removeReaderProxy(const GUID_t& reader); /** * Unpair a WriterProxyData object from all local readers. * @param pdata Pointer to the participant proxy data. * @param wdata Pointer to the WriterProxyData object. * @return True if correct. */ bool unpairWriterProxy(ParticipantProxyData* pdata, WriterProxyData* wdata); /** * Unpair a ReaderProxyData object from all local writers. * @param rdata Pointer to the ReaderProxyData object. * @param pdata Pointer to the participant proxy data. * @return True if correct. */ bool unpairReaderProxy(ParticipantProxyData* pdata, ReaderProxyData* rdata); /** * Try to pair/unpair ReaderProxyData. * @param pdata Pointer to the participant proxy data. * @param rdata Pointer to the ReaderProxyData object. * @return True. */ bool pairingReaderProxy(ParticipantProxyData* pdata, ReaderProxyData* rdata); #if HAVE_SECURITY bool pairingLaterReaderProxy(const GUID_t local_writer, ParticipantProxyData& pdata, ReaderProxyData& rdata); #endif /** * Try to pair/unpair WriterProxyData. * @param pdata Pointer to the participant proxy data. * @param wdata Pointer to the WriterProxyData. * @return True. */ bool pairingWriterProxy(ParticipantProxyData* pdata, WriterProxyData* wdata); #if HAVE_SECURITY bool pairingLaterWriterProxy(const GUID_t local_reader, ParticipantProxyData& pdata, WriterProxyData& wdata); #endif //! Pointer to the PDPSimple object that contains the endpoint discovery protocol. PDPSimple* mp_PDP; //! Pointer to the RTPSParticipant. RTPSParticipantImpl* mp_RTPSParticipant; private: /** * Try to pair/unpair a local Reader against all possible writerProxy Data. * @param R Pointer to the Reader * @return True */ bool pairingReader(RTPSReader* R); /**l * Try to pair/unpair a local Writer against all possible readerProxy Data. * @param W Pointer to the Writer * @return True */ bool pairingWriter(RTPSWriter* W); }; } } /* namespace rtps */ } /* namespace eprosima */ #endif #endif /* EDP_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/builtin
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/builtin/liveliness/WLPListener.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file WLPListener.h * */ #ifndef WLPLISTENER_H_ #define WLPLISTENER_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include "../../reader/ReaderListener.h" #include "../../common/Guid.h" #include "../../common/InstanceHandle.h" #include "../../../qos/QosPolicies.h" #include "../../../qos/ParameterList.h" using namespace eprosima::fastrtps; namespace eprosima { namespace fastrtps{ namespace rtps { class WLP; class RTPSReader; struct CacheChange_t; /** * Class WLPListener that receives the liveliness messages asserting the liveliness of remote endpoints. * @ingroup LIVELINESS_MODULE */ class WLPListener: public ReaderListener { public: /** * Constructor * @param pwlp Pointer to the WLP object. */ WLPListener(WLP* pwlp); virtual ~WLPListener(); /** * * @param reader * @param change */ void onNewCacheChangeAdded(RTPSReader* reader,const CacheChange_t* const change); /** * Separate the Key between the GuidPrefix_t and the liveliness Kind * @param key InstanceHandle_t to separate. * @param guidP GuidPrefix_t pointer to store the info. * @param liveliness Liveliness Kind Pointer. * @return True if correctly separated. */ bool separateKey(InstanceHandle_t& key, GuidPrefix_t* guidP, LivelinessQosPolicyKind* liveliness); /** * Compute the key from a CacheChange_t * @param change */ bool computeKey(CacheChange_t* change); //!Auxiliary message. CDRMessage_t aux_msg; private: WLP* mp_WLP; }; } /* namespace rtps */ } /* namespace eprosima */ } #endif #endif /* WLPLISTENER_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/builtin
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/builtin/liveliness/WLP.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file WLP.h * */ #ifndef WLP_H_ #define WLP_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include <vector> #include "../../common/Time_t.h" #include "../../common/Locator.h" namespace eprosima { namespace fastrtps{ class WriterQos; namespace rtps { class RTPSParticipantImpl; class StatefulWriter; class StatefulReader; class RTPSWriter; class BuiltinProtocols; class ParticipantProxyData; class WLivelinessPeriodicAssertion; class WLPListener; class WriterHistory; class ReaderHistory; /** * Class WLP that implements the Writer Liveliness Protocol described in the RTPS specification. * @ingroup LIVELINESS_MODULE */ class WLP { friend class WLPListener; friend class WLivelinessPeriodicAssertion; public: /** * Constructor * @param prot Pointer to the BuiltinProtocols object. */ WLP(BuiltinProtocols* prot); virtual ~WLP(); /** * Initialize the WLP protocol. * @param p Pointer to the RTPS participant implementation. * @return true if the initialziacion was succesful. */ bool initWL(RTPSParticipantImpl* p); /** * Create the endpoitns used in the WLP. * @return true if correct. */ bool createEndpoints(); /** * Assign the remote endpoints for a newly discovered RTPSParticipant. * @param pdata Pointer to the RTPSParticipantProxyData object. * @return True if correct. */ bool assignRemoteEndpoints(ParticipantProxyData* pdata); /** * Remove remote endpoints from the liveliness protocol. * @param pdata Pointer to the ParticipantProxyData to remove */ void removeRemoteEndpoints(ParticipantProxyData* pdata); /** * Add a local writer to the liveliness protocol. * @param W Pointer to the RTPSWriter. * @param wqos Quality of service policies for the writer. * @return True if correct. */ bool addLocalWriter(RTPSWriter* W,WriterQos& wqos); /** * Remove a local writer from the liveliness protocol. * @param W Pointer to the RTPSWriter. * @return True if removed. */ bool removeLocalWriter(RTPSWriter* W); //!MInimum time of the automatic writers liveliness period. double m_minAutomatic_MilliSec; //!Minimum time of the manual by participant writers liveliness period. double m_minManRTPSParticipant_MilliSec; /** * Get the builtin protocols * @return Builtin protocols */ BuiltinProtocols* getBuiltinProtocols(){return mp_builtinProtocols;}; /** * Update local writer. * @param W Writer to update * @param wqos New writer QoS * @return True on success */ bool updateLocalWriter(RTPSWriter* W,WriterQos& wqos); /** * Get the RTPS participant * @return RTPS participant */ inline RTPSParticipantImpl* getRTPSParticipant(){return mp_participant;} private: //!Pointer to the local RTPSParticipant. RTPSParticipantImpl* mp_participant; //!Pointer to the builtinprotocol class. BuiltinProtocols* mp_builtinProtocols; //!Pointer to the builtinRTPSParticipantMEssageWriter. StatefulWriter* mp_builtinWriter; //!Pointer to the builtinRTPSParticipantMEssageReader. StatefulReader* mp_builtinReader; //!Writer History WriterHistory* mp_builtinWriterHistory; //!Reader History ReaderHistory* mp_builtinReaderHistory; //!Listener object. WLPListener* mp_listener; //!Pointer to the periodic assertion timer object for the automatic liveliness writers. WLivelinessPeriodicAssertion* mp_livelinessAutomatic; //!Pointer to the periodic assertion timer object for the manual by RTPSParticipant liveliness writers. WLivelinessPeriodicAssertion* mp_livelinessManRTPSParticipant; //!List of the writers using automatic liveliness. std::vector<RTPSWriter*> m_livAutomaticWriters; //!List of the writers using manual by RTPSParticipant liveliness. std::vector<RTPSWriter*> m_livManRTPSParticipantWriters; }; } } /* namespace rtps */ } /* namespace eprosima */ #endif #endif /* WLP_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/builtin/liveliness
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/builtin/liveliness/timedevent/WLivelinessPeriodicAssertion.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file WLivelinessPeriodicAssertion.h * */ #ifndef WLIVELINESSPERIODICASSERTION_H_ #define WLIVELINESSPERIODICASSERTION_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include "../../../../qos/QosPolicies.h" #include "../../../resources/TimedEvent.h" #include "../../../../qos/ParameterList.h" using namespace eprosima::fastrtps; namespace eprosima { namespace fastrtps{ namespace rtps { class WLP; /** * Class WLivelinessPeriodicAssertion, used to assert the liveliness of the writers in a RTPSParticipant. * @ingroup LIVELINESS_MODULE */ class WLivelinessPeriodicAssertion: public TimedEvent { public: /** * Constructor * @param pwlp Pointer to the WLP object. * @param kind Kind of the periodic assertion timed event */ WLivelinessPeriodicAssertion(WLP* pwlp,LivelinessQosPolicyKind kind); virtual ~WLivelinessPeriodicAssertion(); /** * Method invoked when the event occurs * @param code Code representing the status of the event * @param msg Message associated to the event */ void event(EventCode code, const char* msg= nullptr); //!Liveliness Kind that is being asserted by this object. LivelinessQosPolicyKind m_livelinessKind; //!Pointer to the WLP object. WLP* mp_WLP; //!Assert the liveliness of AUTOMATIC kind Writers. bool AutomaticLivelinessAssertion(); //!Assert the liveliness of MANUAL_BY_PARTICIPANT kind writers. bool ManualByRTPSParticipantLivelinessAssertion(); //!Message to store the data. CDRMessage_t m_msg; //!Instance Handle InstanceHandle_t m_iHandle; //!GuidPrefix_t GuidPrefix_t m_guidP; }; } /* namespace rtps */ } /* namespace eprosima */ } #endif #endif /* WLIVELINESSPERIODICASSERTION_H_ */
0
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/builtin
apollo_public_repos/apollo-platform/ros/third_party/fast-rtps_aarch64/include/fastrtps/rtps/builtin/data/ParticipantProxyData.h
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @file ParticipantProxyData.h * */ #ifndef PARTICIPANTPROXYDATA_H_ #define PARTICIPANTPROXYDATA_H_ #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include <mutex> #include "../../../qos/QosList.h" #include "../../../qos/ParameterList.h" #include "../../attributes/WriterAttributes.h" #include "../../attributes/ReaderAttributes.h" #include "../../common/Token.h" #define DISCOVERY_PARTICIPANT_DATA_MAX_SIZE 5000 #define DISCOVERY_TOPIC_DATA_MAX_SIZE 500 #define DISCOVERY_PUBLICATION_DATA_MAX_SIZE 5000 #define DISCOVERY_SUBSCRIPTION_DATA_MAX_SIZE 5000 #define BUILTIN_PARTICIPANT_DATA_MAX_SIZE 100 #define DISC_BUILTIN_ENDPOINT_PARTICIPANT_ANNOUNCER 0x00000001 << 0; #define DISC_BUILTIN_ENDPOINT_PARTICIPANT_DETECTOR 0x00000001 << 1; #define DISC_BUILTIN_ENDPOINT_PUBLICATION_ANNOUNCER 0x00000001 << 2; #define DISC_BUILTIN_ENDPOINT_PUBLICATION_DETECTOR 0x00000001 << 3; #define DISC_BUILTIN_ENDPOINT_SUBSCRIPTION_ANNOUNCER 0x00000001 << 4; #define DISC_BUILTIN_ENDPOINT_SUBSCRIPTION_DETECTOR 0x00000001 << 5; #define DISC_BUILTIN_ENDPOINT_PARTICIPANT_PROXY_ANNOUNCER 0x00000001 << 6; #define DISC_BUILTIN_ENDPOINT_PARTICIPANT_PROXY_DETECTOR 0x00000001 << 7; #define DISC_BUILTIN_ENDPOINT_PARTICIPANT_STATE_ANNOUNCER 0x00000001 << 8; #define DISC_BUILTIN_ENDPOINT_PARTICIPANT_STATE_DETECTOR 0x00000001 << 9; #define BUILTIN_ENDPOINT_PARTICIPANT_MESSAGE_DATA_WRITER 0x00000001 << 10; #define BUILTIN_ENDPOINT_PARTICIPANT_MESSAGE_DATA_READER 0x00000001 << 11; namespace eprosima { namespace fastrtps{ namespace rtps { struct CDRMessage_t; class PDPSimple; class RemoteParticipantLeaseDuration; class RTPSParticipantImpl; class ReaderProxyData; class WriterProxyData; /** * ParticipantProxyData class is used to store and convert the information Participants send to each other during the PDP phase. *@ingroup BUILTIN_MODULE */ class ParticipantProxyData { public: ParticipantProxyData(); virtual ~ParticipantProxyData(); //!Protocol version ProtocolVersion_t m_protocolVersion; //!GUID GUID_t m_guid; //!Vendor ID VendorId_t m_VendorId; //!Expects Inline QOS. bool m_expectsInlineQos; //!Available builtin endpoints BuiltinEndpointSet_t m_availableBuiltinEndpoints; //!Metatraffic unicast locator list LocatorList_t m_metatrafficUnicastLocatorList; //!Metatraffic multicast locator list LocatorList_t m_metatrafficMulticastLocatorList; //!Default unicast locator list LocatorList_t m_defaultUnicastLocatorList; //!Default multicast locator list LocatorList_t m_defaultMulticastLocatorList; //!Manual liveliness count Count_t m_manualLivelinessCount; //!Participant name std::string m_participantName; //! InstanceHandle_t m_key; //! Duration_t m_leaseDuration; //! IdentityToken identity_token_; //! bool isAlive; //! QosList_t m_QosList; //! ParameterPropertyList_t m_properties; //! std::vector<octet> m_userData; //! bool m_hasChanged; //! RemoteParticipantLeaseDuration* mp_leaseDurationTimer; //! std::vector<ReaderProxyData*> m_readers; //! std::vector<WriterProxyData*> m_writers; //! std::vector<RemoteReaderAttributes> m_builtinReaders; //! std::vector<RemoteWriterAttributes> m_builtinWriters; std::recursive_mutex* mp_mutex; /** * Initialize the object with the data of the lcoal RTPSParticipant. * @param part Pointer to the RTPSParticipant. * @param pdp Pointer to the PDPSimple object. * @return True if correctly initialized. */ bool initializeData(RTPSParticipantImpl* part, PDPSimple* pdp); /** * Update the data. * @param pdata Object to copy the data from * @return True on success */ bool updateData(ParticipantProxyData& pdata); /** * Convert information to parameter list. * @return True on success */ bool toParameterList(); /** * Read the parameter list from a recevied CDRMessage_t * @return True on success */ bool readFromCDRMessage(CDRMessage_t* msg); //!Clear the data (restore to default state.) void clear(); /** * Copy the data from another object. * @param pdata Object to copy the data from */ void copy(ParticipantProxyData& pdata); }; } } /* namespace rtps */ } /* namespace eprosima */ #endif #endif /* RTPSParticipantPROXYDATA_H_ */
0