diff --git a/ddspipe_core/CMakeLists.txt b/ddspipe_core/CMakeLists.txt index 0670face..ba9bd015 100644 --- a/ddspipe_core/CMakeLists.txt +++ b/ddspipe_core/CMakeLists.txt @@ -70,15 +70,6 @@ file( "${PROJECT_SOURCE_DIR}/include/*.h*" ) -# Exclude types' files depending on the Fast DDS version -if ("${fastrtps_VERSION}" VERSION_LESS 2.13) - list(FILTER SOURCES_FILES EXCLUDE REGEX "v2/") - list(FILTER HEADERS_FILES EXCLUDE REGEX "v2/") -else() - list(FILTER SOURCES_FILES EXCLUDE REGEX "v1/") - list(FILTER HEADERS_FILES EXCLUDE REGEX "v1/") -endif() - # Compile C++ library compile_library( "${PROJECT_SOURCE_DIR}/src/cpp" # Source directory diff --git a/ddspipe_core/include/ddspipe_core/communication/rpc/ServiceRegistry.hpp b/ddspipe_core/include/ddspipe_core/communication/rpc/ServiceRegistry.hpp index 21cce137..3a55d85c 100644 --- a/ddspipe_core/include/ddspipe_core/communication/rpc/ServiceRegistry.hpp +++ b/ddspipe_core/include/ddspipe_core/communication/rpc/ServiceRegistry.hpp @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include @@ -28,9 +28,9 @@ namespace eprosima { namespace ddspipe { namespace core { -using SampleIdentity = eprosima::fastrtps::rtps::SampleIdentity; +using SampleIdentity = eprosima::fastdds::rtps::SampleIdentity; -using SequenceNumber = eprosima::fastrtps::rtps::SequenceNumber_t; +using SequenceNumber = eprosima::fastdds::rtps::SequenceNumber_t; /** * Class used to store the information associated to a service request, so its reply can be forwarded through the diff --git a/ddspipe_core/include/ddspipe_core/configuration/DdsPublishingConfiguration.hpp b/ddspipe_core/include/ddspipe_core/configuration/DdsPublishingConfiguration.hpp index ffcb2224..18841f30 100644 --- a/ddspipe_core/include/ddspipe_core/configuration/DdsPublishingConfiguration.hpp +++ b/ddspipe_core/include/ddspipe_core/configuration/DdsPublishingConfiguration.hpp @@ -56,9 +56,6 @@ struct DdsPublishingConfiguration : public IConfiguration //! The DDS topic name to publish in. std::string topic_name{}; - - //! Whether the LogEntry type should be published or not. - bool publish_type = false; }; } /* namespace core */ diff --git a/ddspipe_core/include/ddspipe_core/dynamic/DiscoveryDatabase.hpp b/ddspipe_core/include/ddspipe_core/dynamic/DiscoveryDatabase.hpp index 3aedc661..cc324875 100644 --- a/ddspipe_core/include/ddspipe_core/dynamic/DiscoveryDatabase.hpp +++ b/ddspipe_core/include/ddspipe_core/dynamic/DiscoveryDatabase.hpp @@ -23,11 +23,11 @@ #include #include -#include +#include +#include #include #include -#include #include namespace eprosima { @@ -263,7 +263,7 @@ class DiscoveryDatabase mutable std::mutex callbacks_mutex_; //! Queue storing database operations to be performed in a dedicated thread - fastrtps::DBQueue> entities_to_process_; + utils::event::DBQueue> entities_to_process_; //! Handle of thread dedicated to performing database operations std::thread queue_processing_thread_; diff --git a/ddspipe_core/include/ddspipe_core/efficiency/payload/CopyPayloadPool.hpp b/ddspipe_core/include/ddspipe_core/efficiency/payload/CopyPayloadPool.hpp index 0dd16a70..23643de7 100644 --- a/ddspipe_core/include/ddspipe_core/efficiency/payload/CopyPayloadPool.hpp +++ b/ddspipe_core/include/ddspipe_core/efficiency/payload/CopyPayloadPool.hpp @@ -35,17 +35,16 @@ class CopyPayloadPool : public PayloadPool //! Reserve a new memory space bool get_payload( uint32_t size, - types::Payload& payload) override; + eprosima::fastdds::rtps::SerializedPayload_t& payload) override; //! Reserve a new memory space and copy the data from \c src_payload to \c target_payload bool get_payload( - const types::Payload& src_payload, - IPayloadPool*& data_owner, - types::Payload& target_payload) override; + const eprosima::fastdds::rtps::SerializedPayload_t& src_payload, + eprosima::fastdds::rtps::SerializedPayload_t& target_payload) override; //! Release data in \c payload bool release_payload( - types::Payload& payload) override; + eprosima::fastdds::rtps::SerializedPayload_t& payload) override; }; } /* namespace core */ diff --git a/ddspipe_core/include/ddspipe_core/efficiency/payload/FastPayloadPool.hpp b/ddspipe_core/include/ddspipe_core/efficiency/payload/FastPayloadPool.hpp index c338e1ff..3690acae 100644 --- a/ddspipe_core/include/ddspipe_core/efficiency/payload/FastPayloadPool.hpp +++ b/ddspipe_core/include/ddspipe_core/efficiency/payload/FastPayloadPool.hpp @@ -38,7 +38,7 @@ typedef std::atomic MetaInfoType; * This class is used to manage the allocation and release of the payloads used within the Router. * The main target is not to copy or alloc data that is already in memory, but to reuse it safely. * - * This implementation uses an idea get from TopicPayloadPool from fastrtps. + * This implementation uses an idea get from TopicPayloadPool from fastdds. * This is, to alloc more space than required whenever a new payload is needed, and in this extra space (at the * beginning of the data) stores the number of references this data has. * As long as this number does not reach 0, the data is not deleted. @@ -76,7 +76,7 @@ class FastPayloadPool : public PayloadPool DDSPIPE_CORE_DllAPI bool get_payload( uint32_t size, - types::Payload& payload) override; + eprosima::fastdds::rtps::SerializedPayload_t& payload) override; /** * Reserve in \c target_payload the payload in \c src_payload . @@ -95,9 +95,8 @@ class FastPayloadPool : public PayloadPool */ DDSPIPE_CORE_DllAPI bool get_payload( - const types::Payload& src_payload, - IPayloadPool*& data_owner, - types::Payload& target_payload) override; + const eprosima::fastdds::rtps::SerializedPayload_t& src_payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload) override; /** * Release a payload that has been reserved from this pool. @@ -113,7 +112,7 @@ class FastPayloadPool : public PayloadPool */ DDSPIPE_CORE_DllAPI bool release_payload( - types::Payload& payload) override; + eprosima::fastdds::rtps::SerializedPayload_t& payload) override; protected: @@ -132,7 +131,7 @@ class FastPayloadPool : public PayloadPool DDSPIPE_CORE_DllAPI virtual bool reserve_( uint32_t size, - types::Payload& payload) override; + eprosima::fastdds::rtps::SerializedPayload_t& payload) override; /** * @brief Reimplement parent \c release_ method @@ -146,7 +145,7 @@ class FastPayloadPool : public PayloadPool */ DDSPIPE_CORE_DllAPI virtual bool release_( - types::Payload& payload) override; + eprosima::fastdds::rtps::SerializedPayload_t& payload) override; }; } /* namespace core */ diff --git a/ddspipe_core/include/ddspipe_core/efficiency/payload/MapPayloadPool.hpp b/ddspipe_core/include/ddspipe_core/efficiency/payload/MapPayloadPool.hpp index ee2a3801..27ac2737 100644 --- a/ddspipe_core/include/ddspipe_core/efficiency/payload/MapPayloadPool.hpp +++ b/ddspipe_core/include/ddspipe_core/efficiency/payload/MapPayloadPool.hpp @@ -59,7 +59,7 @@ class MapPayloadPool : public PayloadPool */ bool get_payload( uint32_t size, - types::Payload& payload) override; + eprosima::fastdds::rtps::SerializedPayload_t& payload) override; /** * @brief Set \c target_payload data to \c src_payload . @@ -78,9 +78,8 @@ class MapPayloadPool : public PayloadPool * @throw utils::InconsistencyException if \c data_owner is \c this but the data in \c src_payload is not from this pool. */ bool get_payload( - const types::Payload& src_payload, - IPayloadPool*& data_owner, - types::Payload& target_payload) override; + const eprosima::fastdds::rtps::SerializedPayload_t& src_payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload) override; /** * @brief Decrease reference counter for data in \c payload . @@ -96,7 +95,7 @@ class MapPayloadPool : public PayloadPool * @throw utils::InconsistencyException if the data in \c payload is not from this pool. */ bool release_payload( - types::Payload& payload) override; + eprosima::fastdds::rtps::SerializedPayload_t& payload) override; protected: diff --git a/ddspipe_core/include/ddspipe_core/efficiency/payload/PayloadPool.hpp b/ddspipe_core/include/ddspipe_core/efficiency/payload/PayloadPool.hpp index bc3ca8b6..a5c3fe1d 100644 --- a/ddspipe_core/include/ddspipe_core/efficiency/payload/PayloadPool.hpp +++ b/ddspipe_core/include/ddspipe_core/efficiency/payload/PayloadPool.hpp @@ -16,9 +16,7 @@ #include -#include -#include -#include +#include #include @@ -38,7 +36,7 @@ namespace core { * Then, this payload will be moved to the Track. As the payload is already in the pool, there will be no copy. * Finally, the payload will be moved to every Writer that has to send the data (ideally without copy). */ -class PayloadPool : public eprosima::fastrtps::rtps::IPayloadPool +class PayloadPool : public eprosima::fastdds::rtps::IPayloadPool { public: @@ -50,153 +48,6 @@ class PayloadPool : public eprosima::fastrtps::rtps::IPayloadPool DDSPIPE_CORE_DllAPI virtual ~PayloadPool(); - ///// - // FAST DDS PART - - /** - * @brief Reserve in \c cache_change a new payload of max size \c size . - * - * It sets values to the serialized payload inside \c cache_change . - * This method calls \c get_payload for the serialized payload. - * The \c cache_change owner is set to \c this . - * - * @warning length value in \c payload is not modified. - * - * @note This method may reserve new memory. - * - * @param [in] size : Size in bytes of the payload that will be reserved - * @param [out] cache_change : the cache change which SerializedPayload will be set - * - * @return true if everything ok - * @return false if something went wrong - * - * @pre Fields @c cache_change must not have the serialized payload initialized. - */ - DDSPIPE_CORE_DllAPI - virtual bool get_payload( - uint32_t size, - eprosima::fastrtps::rtps::CacheChange_t& cache_change) override; // TODO add noexcept once is implemented - - /** - * @brief Store in \c cache_change the \c data payload. - * - * This method set \c cache_change serialized payload to the same data in \c data . - * This method should reuse \c data and not copy it in case the owner of \c data is \c this . - * It sets values to the serialized payload inside \c cache_change . - * - * This method calls \c get_payload for the serialized payload. - * The \c cache_change owner is set to \c this . - * - * @note This method may reserve new memory in case the owner is not \c this . - * - * @param [in,out] data Serialized payload received - * @param [in,out] data_owner Payload pool owning incoming data \c data - * @param [in,out] cache_change Cache change to assign the payload to - * - * @warning @c data_owner can only be changed from @c nullptr to @c this. If a value different from - * @c nullptr is received it should be left unchanged. - * - * @return true if everything ok - * @return false if something went wrong - * - * @pre Fields @c cache_change must not have the serialized payload initialized. - */ - DDSPIPE_CORE_DllAPI - virtual bool get_payload( - eprosima::fastrtps::rtps::SerializedPayload_t& data, - IPayloadPool*& data_owner, - eprosima::fastrtps::rtps::CacheChange_t& cache_change) override; // TODO add noexcept once is implemented - - /** - * @brief Release the data from the serialized payload inside \c cache_change . - * - * @note This method must only release the actual memory of a data in case nobody is referencing it anymore. - * - * This method calls \c release_payload for the serialized payload. - * The \c cache_change owner is set to \c nullptr . - * - * @param [in,out] cache_change Cache change to release the payload from - * - * @return true if everything ok - * @return false if something went wrong - * - * @throw IncosistencyException if cache change owner is other than this - */ - DDSPIPE_CORE_DllAPI - virtual bool release_payload( - eprosima::fastrtps::rtps::CacheChange_t& cache_change) override; // TODO add noexcept once is implemented - - ///// - // DDSPIPE PART - - /** - * @brief Reserve a new data in \c payload of size \c size. - * - * It sets value \c max_size and \c data of \c payload . - * - * @note This method may reserve new memory. - * - * @warning length value in \c payload is not modified. - * - * @param [in] size : Size in bytes of the payload that will be reserved - * @param [out] payload : the SerializedPayload that will be set - * - * @return true if everything ok - * @return false if something went wrong - * - * @pre Fields @c payload must not have been initialized. - */ - DDSPIPE_CORE_DllAPI - virtual bool get_payload( - uint32_t size, - types::Payload& payload) = 0; - - /** - * @brief Store in \c target_payload the data from \c src_payload . - * - * This method set \c target_payload fields \c max_size , \c lenght and \c data . - * This method "should" reuse data in \c src_payload and not copy it in case \c data_owner is \c this . - * - * @note This method may reserve new memory in case the owner is not \c this . - * - * @param [in] src_payload Payload to move to target - * @param [in,out] data_owner Payload pool owning incoming data \c src_payload - * @param [out] target_payload Payload to assign the payload to - * - * @warning @c data_owner can only be changed from @c nullptr to @c this. If a value different from - * @c nullptr is received it must be left unchanged. - * - * @return true if everything ok - * @return false if something went wrong - * - * @pre Fields @c target_payload must not have been initialized. - */ - DDSPIPE_CORE_DllAPI - virtual bool get_payload( - const types::Payload& src_payload, - IPayloadPool*& data_owner, - types::Payload& target_payload) = 0; - - /** - * @brief Release the data from the \c payload . - * - * @note This method must only release the actual memory of a data in case nobody is referencing it anymore. - * - * @note This method should use method \c reserve_ to reserve new memory. - * - * Reset the \c payload info. - * - * @param [in,out] payload Payload to release data from - * - * @return true if everything ok - * @return false if something went wrong - * - * @pre @c payload must have been initialized from this pool. - */ - DDSPIPE_CORE_DllAPI - virtual bool release_payload( - types::Payload& payload) = 0; - //! Wether every payload get has been released. DDSPIPE_CORE_DllAPI virtual bool is_clean() const noexcept; diff --git a/ddspipe_core/include/ddspipe_core/efficiency/payload/PayloadPoolMediator.hpp b/ddspipe_core/include/ddspipe_core/efficiency/payload/PayloadPoolMediator.hpp index ee4d3bc1..0c36e91f 100644 --- a/ddspipe_core/include/ddspipe_core/efficiency/payload/PayloadPoolMediator.hpp +++ b/ddspipe_core/include/ddspipe_core/efficiency/payload/PayloadPoolMediator.hpp @@ -18,12 +18,12 @@ #include #include -#include - #include -#include -#include -#include +#include +#include +#include + +#include #include #include @@ -39,7 +39,7 @@ namespace core { * This class works as a mediator between the \c FastPayloadPool and the DataWriter's write functions, to avoid making * the extra copy. */ -class PayloadPoolMediator : public fastrtps::rtps::IPayloadPool +class PayloadPoolMediator : public fastdds::rtps::IPayloadPool { public: @@ -66,11 +66,10 @@ class PayloadPoolMediator : public fastrtps::rtps::IPayloadPool * @param writer the writer who has to write the \c data. * @param data the data to be written by the \c writer. * - * @return true if everything OK - * @return false if something went wrong + * @return ReturnCode::OK if the data is correctly sent or a ReturnCode related to the specific error otherwise. */ DDSPIPE_CORE_DllAPI - bool write( + utils::ReturnCode write( fastdds::dds::DataWriter* writer, types::RtpsPayloadData* data); @@ -90,14 +89,13 @@ class PayloadPoolMediator : public fastrtps::rtps::IPayloadPool * @param data the data to be written by the \c writer. * @param params the data to be written by the \c writer. * - * @return true if everything OK - * @return false if something went wrong + * @return ReturnCode::OK if the data is correctly sent or a ReturnCode related to the specific error otherwise. */ DDSPIPE_CORE_DllAPI - bool write( + utils::ReturnCode write( fastdds::dds::DataWriter* writer, types::RtpsPayloadData* data, - fastrtps::rtps::WriteParams& params); + fastdds::rtps::WriteParams& params); /** * @brief write \c data with a \c writer with a \c handle but avoiding copying the \c data from and to the same @@ -115,14 +113,13 @@ class PayloadPoolMediator : public fastrtps::rtps::IPayloadPool * @param data the data to be written by the \c writer. * @param handle the data to be used by the \c writer. * - * @return true if everything OK - * @return false if something went wrong + * @return ReturnCode::OK if the data is correctly sent, ReturnCode::PRECONDITION_NOT_MET or ReturnCode::ERROR otherwise. */ DDSPIPE_CORE_DllAPI utils::ReturnCode write( fastdds::dds::DataWriter* writer, types::RtpsPayloadData* data, - const fastrtps::rtps::InstanceHandle_t& handle); + const fastdds::rtps::InstanceHandle_t& handle); /** * Instead of reserving a block of memory of \c size in the \c payload_pool, we can redirect the call to @@ -137,7 +134,7 @@ class PayloadPoolMediator : public fastrtps::rtps::IPayloadPool DDSPIPE_CORE_DllAPI virtual bool get_payload( uint32_t size, - fastrtps::rtps::CacheChange_t& cache_change) override; + eprosima::fastdds::rtps::SerializedPayload_t& payload) override; /** * @brief redirect the call to the \c release_payload in the \c payload_pool. @@ -151,9 +148,8 @@ class PayloadPoolMediator : public fastrtps::rtps::IPayloadPool */ DDSPIPE_CORE_DllAPI virtual bool get_payload( - fastrtps::rtps::SerializedPayload_t& data, - fastrtps::rtps::IPayloadPool*& data_owner, - fastrtps::rtps::CacheChange_t& cache_change) override; + const eprosima::fastdds::rtps::SerializedPayload_t& src_payload, + eprosima::fastdds::rtps::SerializedPayload_t& target_payload) override; /** * @brief redirect the call to the \c release_payload in the \c payload_pool. @@ -164,7 +160,7 @@ class PayloadPoolMediator : public fastrtps::rtps::IPayloadPool */ DDSPIPE_CORE_DllAPI virtual bool release_payload( - fastrtps::rtps::CacheChange_t& cache_change) override; + eprosima::fastdds::rtps::SerializedPayload_t& payload) override; protected: @@ -172,7 +168,7 @@ class PayloadPoolMediator : public fastrtps::rtps::IPayloadPool std::mutex mutex_; //! A pointer to the payload_ we want to write down in the PayloadPool. - types::Payload* payload_; + eprosima::fastdds::rtps::SerializedPayload_t* payload_; //! The \c PayloadPool the \c PayloadPoolMediator is mediating for. const std::shared_ptr& payload_pool_; diff --git a/ddspipe_core/include/ddspipe_core/interface/IReader.hpp b/ddspipe_core/include/ddspipe_core/interface/IReader.hpp index 71153ef9..9bf2a359 100644 --- a/ddspipe_core/include/ddspipe_core/interface/IReader.hpp +++ b/ddspipe_core/include/ddspipe_core/interface/IReader.hpp @@ -16,7 +16,7 @@ #include -#include +#include #include @@ -121,7 +121,7 @@ class IReader //! Get internal RTPS reader mutex DDSPIPE_CORE_DllAPI - virtual fastrtps::RecursiveTimedMutex& get_rtps_mutex() const = 0; + virtual fastdds::RecursiveTimedMutex& get_rtps_mutex() const = 0; //! Get number of unread cache changes in internal RTPS reader DDSPIPE_CORE_DllAPI diff --git a/ddspipe_core/include/ddspipe_core/logging/DdsLogConsumer.hpp b/ddspipe_core/include/ddspipe_core/logging/DdsLogConsumer.hpp index 2e90a149..13a1a703 100644 --- a/ddspipe_core/include/ddspipe_core/logging/DdsLogConsumer.hpp +++ b/ddspipe_core/include/ddspipe_core/logging/DdsLogConsumer.hpp @@ -21,23 +21,16 @@ #include #include -#include -#include - #include #include #include #include -#if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) - #include - #include - #include -#else - #include - #include - #include -#endif // if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) +#include +#include +#include +#include +#include namespace eprosima { namespace ddspipe { diff --git a/ddspipe_core/include/ddspipe_core/monitoring/consumers/impl/DdsMonitorConsumer.ipp b/ddspipe_core/include/ddspipe_core/monitoring/consumers/impl/DdsMonitorConsumer.ipp index 4c0f7b6d..00fab462 100644 --- a/ddspipe_core/include/ddspipe_core/monitoring/consumers/impl/DdsMonitorConsumer.ipp +++ b/ddspipe_core/include/ddspipe_core/monitoring/consumers/impl/DdsMonitorConsumer.ipp @@ -68,7 +68,7 @@ DdsMonitorConsumer::DdsMonitorConsumer( participant_->guid() << " in topic " << topic_ << "."); } - logInfo(DDSPIPE_MONITOR, "MONITOR | Created DataWriter " << writer_ << " for Participant " << + EPROSIMA_LOG_INFO(DDSPIPE_MONITOR, "MONITOR | Created DataWriter " << writer_ << " for Participant " << participant_->guid() << " in topic " << topic_ << "."); } @@ -95,7 +95,7 @@ template void DdsMonitorConsumer::consume( const T& data) const { - writer_->write(&const_cast(data)); + writer_->write(&data); } template diff --git a/ddspipe_core/include/ddspipe_core/monitoring/consumers/impl/LogMonitorConsumer.ipp b/ddspipe_core/include/ddspipe_core/monitoring/consumers/impl/LogMonitorConsumer.ipp index f9856dc5..8e0b0ac2 100644 --- a/ddspipe_core/include/ddspipe_core/monitoring/consumers/impl/LogMonitorConsumer.ipp +++ b/ddspipe_core/include/ddspipe_core/monitoring/consumers/impl/LogMonitorConsumer.ipp @@ -25,7 +25,7 @@ template void LogMonitorConsumer::consume( const T& data) const { - logInfo(DDSPIPE_MONITOR, "MONITOR_DATA | " << data); + EPROSIMA_LOG_INFO(DDSPIPE_MONITOR, "MONITOR_DATA | " << data); } template diff --git a/ddspipe_core/include/ddspipe_core/monitoring/producers/StatusMonitorProducer.hpp b/ddspipe_core/include/ddspipe_core/monitoring/producers/StatusMonitorProducer.hpp index 7e169cd2..869ec33a 100644 --- a/ddspipe_core/include/ddspipe_core/monitoring/producers/StatusMonitorProducer.hpp +++ b/ddspipe_core/include/ddspipe_core/monitoring/producers/StatusMonitorProducer.hpp @@ -17,21 +17,13 @@ #include #include #include +#include #include #include #include #include - -#if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) - #include - #include - #include -#else - #include - #include - #include -#endif // if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) +#include // DDSPIPE MONITOR MACROS diff --git a/ddspipe_core/include/ddspipe_core/monitoring/producers/TopicsMonitorProducer.hpp b/ddspipe_core/include/ddspipe_core/monitoring/producers/TopicsMonitorProducer.hpp index f97ebe1a..733ca247 100644 --- a/ddspipe_core/include/ddspipe_core/monitoring/producers/TopicsMonitorProducer.hpp +++ b/ddspipe_core/include/ddspipe_core/monitoring/producers/TopicsMonitorProducer.hpp @@ -26,19 +26,10 @@ #include #include #include +#include #include #include -#if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) - #include - #include - #include -#else - #include - #include - #include -#endif // if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) - // Macro to notify that a message has been received in a topic by a participant. #define monitor_msg_rx(topic, participant_id) MONITOR_MSG_RX_IMPL_(topic, participant_id) diff --git a/ddspipe_core/include/ddspipe_core/types/data/RpcPayloadData.hpp b/ddspipe_core/include/ddspipe_core/types/data/RpcPayloadData.hpp index ed5777f1..ad661066 100644 --- a/ddspipe_core/include/ddspipe_core/types/data/RpcPayloadData.hpp +++ b/ddspipe_core/include/ddspipe_core/types/data/RpcPayloadData.hpp @@ -15,8 +15,8 @@ #pragma once -#include -#include +#include +#include #include @@ -45,13 +45,13 @@ struct RpcPayloadData : public RtpsPayloadData virtual types::TopicInternalTypeDiscriminator internal_type_discriminator() const noexcept override; //! Write params associated to the received cache change - utils::Fuzzy write_params{}; + utils::Fuzzy write_params{}; //! Sequence number of the received cache change - eprosima::fastrtps::rtps::SequenceNumber_t origin_sequence_number{}; + eprosima::fastdds::rtps::SequenceNumber_t origin_sequence_number{}; //! Sequence Number with which the internal writer (ddspipe rpc writer) has sent this message - eprosima::fastrtps::rtps::SequenceNumber_t sent_sequence_number; + eprosima::fastdds::rtps::SequenceNumber_t sent_sequence_number; }; /** diff --git a/ddspipe_core/include/ddspipe_core/types/data/RtpsPayloadData.hpp b/ddspipe_core/include/ddspipe_core/types/data/RtpsPayloadData.hpp index dea8eede..47c7ff3f 100644 --- a/ddspipe_core/include/ddspipe_core/types/data/RtpsPayloadData.hpp +++ b/ddspipe_core/include/ddspipe_core/types/data/RtpsPayloadData.hpp @@ -15,8 +15,8 @@ #pragma once -#include -#include +#include +#include #include #include diff --git a/ddspipe_core/include/ddspipe_core/types/dds/DomainId.hpp b/ddspipe_core/include/ddspipe_core/types/dds/DomainId.hpp index aff1ee13..365c05de 100644 --- a/ddspipe_core/include/ddspipe_core/types/dds/DomainId.hpp +++ b/ddspipe_core/include/ddspipe_core/types/dds/DomainId.hpp @@ -14,7 +14,7 @@ #pragma once -#include +#include #include #include diff --git a/ddspipe_core/include/ddspipe_core/types/dds/Guid.hpp b/ddspipe_core/include/ddspipe_core/types/dds/Guid.hpp index 053adf6c..d6e41249 100644 --- a/ddspipe_core/include/ddspipe_core/types/dds/Guid.hpp +++ b/ddspipe_core/include/ddspipe_core/types/dds/Guid.hpp @@ -14,7 +14,7 @@ #pragma once -#include +#include #include #include @@ -25,12 +25,12 @@ namespace core { namespace types { //! Unique Id of every Endpoint -class Guid : public fastrtps::rtps::GUID_t +class Guid : public fastdds::rtps::GUID_t { public: //! Using parent constructors - using fastrtps::rtps::GUID_t::GUID_t; + using fastdds::rtps::GUID_t::GUID_t; //! Default constructor DDSPIPE_CORE_DllAPI @@ -44,17 +44,17 @@ class Guid : public fastrtps::rtps::GUID_t //! Copy constructor DDSPIPE_CORE_DllAPI Guid( - const fastrtps::rtps::GUID_t& x); + const fastdds::rtps::GUID_t& x); //! Move constructor DDSPIPE_CORE_DllAPI Guid( - fastrtps::rtps::GUID_t&& x); + fastdds::rtps::GUID_t&& x); //! Equal operator (inherited from GUID_t) DDSPIPE_CORE_DllAPI Guid& operator = ( - const fastrtps::rtps::GUID_t& other) noexcept; + const fastdds::rtps::GUID_t& other) noexcept; /** * Whether the guid is a valid one diff --git a/ddspipe_core/include/ddspipe_core/types/dds/GuidPrefix.hpp b/ddspipe_core/include/ddspipe_core/types/dds/GuidPrefix.hpp index b9dc4c3b..5a344c14 100644 --- a/ddspipe_core/include/ddspipe_core/types/dds/GuidPrefix.hpp +++ b/ddspipe_core/include/ddspipe_core/types/dds/GuidPrefix.hpp @@ -14,7 +14,6 @@ #pragma once -#include #include #include @@ -30,12 +29,13 @@ namespace types { * This class extends the \c GuidPrefix_t class in FastDDS, which is a RTPS Participant Unique Id. * This class does not belong to class \c Guid due to a design flaw in OOP (parallel hierarchy is the future). */ -class GuidPrefix : public fastrtps::rtps::GuidPrefix_t +class GuidPrefix : public fastdds::rtps::GuidPrefix_t { public: //! Using parent constructors - using fastrtps::rtps::GuidPrefix_t::GuidPrefix_t; + DDSPIPE_CORE_DllAPI + GuidPrefix () = default; //! Constructor from Parent class DDSPIPE_CORE_DllAPI @@ -76,12 +76,12 @@ class GuidPrefix : public fastrtps::rtps::GuidPrefix_t * * @todo use the seed of \c id to modify the whole guid and not only one of the 12 values. * - * @param ros : whether to use the Discovery Server ROS2 specific guid [Default: false] + * @param ros : whether to use the Discovery Server ROS2 specific guid * @param id : number to seed for the final Guid Prefix [Default: 0] */ DDSPIPE_CORE_DllAPI GuidPrefix ( - bool ros = false, + bool ros, uint32_t id = 0) noexcept; /** @@ -95,7 +95,7 @@ class GuidPrefix : public fastrtps::rtps::GuidPrefix_t DDSPIPE_CORE_DllAPI GuidPrefix& operator = ( - const fastrtps::rtps::GuidPrefix_t& other) noexcept; + const fastdds::rtps::GuidPrefix_t& other) noexcept; /** * Whether the guid prefix is a valid one diff --git a/ddspipe_core/include/ddspipe_core/types/dds/Payload.hpp b/ddspipe_core/include/ddspipe_core/types/dds/Payload.hpp index 6ff5904e..d3be4b83 100644 --- a/ddspipe_core/include/ddspipe_core/types/dds/Payload.hpp +++ b/ddspipe_core/include/ddspipe_core/types/dds/Payload.hpp @@ -17,12 +17,11 @@ #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include @@ -31,26 +30,26 @@ namespace ddspipe { namespace core { namespace types { -//! Durability kind enumeration -using PartitionQosPolicy = eprosima::fastdds::dds::PartitionQosPolicy; +//! Change kind +using ChangeKind = eprosima::fastdds::rtps::ChangeKind_t; -//! Partition configuration -using OwnershipStrengthQosPolicy = eprosima::fastdds::dds::OwnershipStrengthQosPolicy; +//! Fast DDS Time +using DataTime = eprosima::fastdds::rtps::Time_t; -//! Instance Handler type -using InstanceHandle = eprosima::fastrtps::rtps::InstanceHandle_t; +//! Instance Handle type +using InstanceHandle = eprosima::fastdds::rtps::InstanceHandle_t; -//! Instance Handler type -using ChangeKind = eprosima::fastrtps::rtps::ChangeKind_t; +//! Ownership Strength configuration +using OwnershipStrengthQosPolicy = eprosima::fastdds::dds::OwnershipStrengthQosPolicy; -//! Fast DDS Time -using DataTime = eprosima::fastrtps::rtps::Time_t; +//! Payload references the raw data received. +using Payload = eprosima::fastdds::rtps::SerializedPayload_t; //! Kind of every unit that creates a Payload -using PayloadUnit = eprosima::fastrtps::rtps::octet; +using PayloadUnit = eprosima::fastdds::rtps::octet; -//! Payload references the raw data received. -using Payload = eprosima::fastrtps::rtps::SerializedPayload_t; +//! Partition configuration +using PartitionQosPolicy = eprosima::fastdds::dds::PartitionQosPolicy; //! \c octet to stream serializator DDSPIPE_CORE_DllAPI diff --git a/ddspipe_core/include/ddspipe_core/types/dds/SpecificEndpointQoS.hpp b/ddspipe_core/include/ddspipe_core/types/dds/SpecificEndpointQoS.hpp index 793aaa10..bfa479d0 100644 --- a/ddspipe_core/include/ddspipe_core/types/dds/SpecificEndpointQoS.hpp +++ b/ddspipe_core/include/ddspipe_core/types/dds/SpecificEndpointQoS.hpp @@ -15,8 +15,6 @@ #pragma once #include -#include -#include #include diff --git a/ddspipe_core/include/ddspipe_core/types/dds/TopicQoS.hpp b/ddspipe_core/include/ddspipe_core/types/dds/TopicQoS.hpp index 899212a7..44a7b813 100644 --- a/ddspipe_core/include/ddspipe_core/types/dds/TopicQoS.hpp +++ b/ddspipe_core/include/ddspipe_core/types/dds/TopicQoS.hpp @@ -17,7 +17,7 @@ #include #include -#include +#include #include @@ -27,10 +27,7 @@ namespace core { namespace types { //! Durability kind enumeration -using DurabilityKind = eprosima::fastrtps::rtps::DurabilityKind_t; - -//! Reliability kind enumeration -using ReliabilityKind = eprosima::fastrtps::rtps::ReliabilityKind_t; +using DurabilityKind = eprosima::fastdds::rtps::DurabilityKind_t; //! History kind enumeration using HistoryDepthType = unsigned int; @@ -38,6 +35,9 @@ using HistoryDepthType = unsigned int; //! Ownership configuration using OwnershipQosPolicyKind = eprosima::fastdds::dds::OwnershipQosPolicyKind; +//! Reliability kind enumeration +using ReliabilityKind = eprosima::fastdds::rtps::ReliabilityKind_t; + /** * The collection of QoS related to a Topic. * diff --git a/ddspipe_core/include/ddspipe_core/types/dynamic_types/schema.hpp b/ddspipe_core/include/ddspipe_core/types/dynamic_types/schema.hpp index b61b64ba..69a261ab 100644 --- a/ddspipe_core/include/ddspipe_core/types/dynamic_types/schema.hpp +++ b/ddspipe_core/include/ddspipe_core/types/dynamic_types/schema.hpp @@ -18,7 +18,7 @@ #pragma once -#include +#include #include @@ -26,23 +26,13 @@ namespace eprosima { namespace ddspipe { namespace core { namespace types { - -namespace idl { - -DDSPIPE_CORE_DllAPI -std::string generate_idl_schema( - const fastrtps::types::DynamicType_ptr& dynamic_type); - -} /* namespace idl */ - namespace msg { DDSPIPE_CORE_DllAPI std::string generate_ros2_schema( - const fastrtps::types::DynamicType_ptr& dynamic_type); + const fastdds::dds::DynamicType::_ref_type& dynamic_type); } /* namespace msg */ - } /* namespace types */ } /* namespace core */ } /* namespace ddspipe */ diff --git a/ddspipe_core/include/ddspipe_core/types/dynamic_types/types.hpp b/ddspipe_core/include/ddspipe_core/types/dynamic_types/types.hpp index b16c371b..275fe5bd 100644 --- a/ddspipe_core/include/ddspipe_core/types/dynamic_types/types.hpp +++ b/ddspipe_core/include/ddspipe_core/types/dynamic_types/types.hpp @@ -14,12 +14,13 @@ #pragma once -#include +#include +#include #include #include -#include #include +#include namespace eprosima { namespace ddspipe { @@ -35,7 +36,11 @@ struct DynamicTypeData : public core::IRoutingData DDSPIPE_CORE_DllAPI virtual types::TopicInternalTypeDiscriminator internal_type_discriminator() const noexcept override; - fastrtps::types::DynamicType_ptr dynamic_type{nullptr}; + // DynamicType created from a complete TypeObject + fastdds::dds::DynamicType::_ref_type dynamic_type{nullptr}; + + // Complete TypeIdentifier of the DynamicType + fastdds::dds::xtypes::TypeIdentifier type_identifier{}; }; DDSPIPE_CORE_DllAPI diff --git a/ddspipe_core/include/ddspipe_core/types/logging/v2/LogEntry.h b/ddspipe_core/include/ddspipe_core/types/logging/LogEntry.hpp similarity index 64% rename from ddspipe_core/include/ddspipe_core/types/logging/v2/LogEntry.h rename to ddspipe_core/include/ddspipe_core/types/logging/LogEntry.hpp index 5f8932b8..f916c76b 100644 --- a/ddspipe_core/include/ddspipe_core/types/logging/v2/LogEntry.h +++ b/ddspipe_core/include/ddspipe_core/types/logging/LogEntry.hpp @@ -13,32 +13,19 @@ // limitations under the License. /*! - * @file LogEntry.h + * @file LogEntry.hpp * This header file contains the declaration of the described types in the IDL file. * * This file was generated by the tool fastddsgen. */ -#include -#include "LogEntryv1.h" +#ifndef FAST_DDS_GENERATED__LOGENTRY_HPP +#define FAST_DDS_GENERATED__LOGENTRY_HPP -#if FASTCDR_VERSION_MAJOR > 1 - -#ifndef _FAST_DDS_GENERATED_LOGENTRY_H_ -#define _FAST_DDS_GENERATED_LOGENTRY_H_ - -#include -#include #include -#include #include -#include - +#include #include -#include -#include - - #if defined(_WIN32) #if defined(EPROSIMA_USER_DLL_EXPORT) @@ -64,15 +51,6 @@ #define LOGENTRY_DllAPI #endif // _WIN32 -namespace eprosima { -namespace fastcdr { -class Cdr; -class CdrSizeCalculator; -} // namespace fastcdr -} // namespace eprosima - - - const int32_t UNDEFINED = 0x10000000; const int32_t SAMPLE_LOST = 0x10000001; const int32_t TOPIC_MISMATCH_TYPE = 0x10000002; @@ -81,14 +59,12 @@ const int32_t TOPIC_MISMATCH_QOS = 0x10000003; * @brief This class represents the enumeration Kind defined by the user in the IDL file. * @ingroup LogEntry */ -enum Kind : uint32_t +enum class Kind : int32_t { Info, Warning, Error }; - - /*! * @brief This class represents the structure LogEntry defined by the user in the IDL file. * @ingroup LogEntry @@ -100,73 +76,138 @@ class LogEntry /*! * @brief Default constructor. */ - eProsima_user_DllExport LogEntry(); + eProsima_user_DllExport LogEntry() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~LogEntry(); + eProsima_user_DllExport ~LogEntry() + { + } /*! * @brief Copy constructor. * @param x Reference to the object LogEntry that will be copied. */ eProsima_user_DllExport LogEntry( - const LogEntry& x); + const LogEntry& x) + { + m_event = x.m_event; + + m_kind = x.m_kind; + + m_category = x.m_category; + + m_message = x.m_message; + + m_timestamp = x.m_timestamp; + + } /*! * @brief Move constructor. * @param x Reference to the object LogEntry that will be copied. */ eProsima_user_DllExport LogEntry( - LogEntry&& x) noexcept; + LogEntry&& x) noexcept + { + m_event = x.m_event; + m_kind = x.m_kind; + m_category = std::move(x.m_category); + m_message = std::move(x.m_message); + m_timestamp = std::move(x.m_timestamp); + } /*! * @brief Copy assignment. * @param x Reference to the object LogEntry that will be copied. */ eProsima_user_DllExport LogEntry& operator =( - const LogEntry& x); + const LogEntry& x) + { + + m_event = x.m_event; + + m_kind = x.m_kind; + + m_category = x.m_category; + + m_message = x.m_message; + + m_timestamp = x.m_timestamp; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object LogEntry that will be copied. */ eProsima_user_DllExport LogEntry& operator =( - LogEntry&& x) noexcept; + LogEntry&& x) noexcept + { + + m_event = x.m_event; + m_kind = x.m_kind; + m_category = std::move(x.m_category); + m_message = std::move(x.m_message); + m_timestamp = std::move(x.m_timestamp); + return *this; + } /*! * @brief Comparison operator. * @param x LogEntry object to compare. */ eProsima_user_DllExport bool operator ==( - const LogEntry& x) const; + const LogEntry& x) const + { + return (m_event == x.m_event && + m_kind == x.m_kind && + m_category == x.m_category && + m_message == x.m_message && + m_timestamp == x.m_timestamp); + } /*! * @brief Comparison operator. * @param x LogEntry object to compare. */ eProsima_user_DllExport bool operator !=( - const LogEntry& x) const; + const LogEntry& x) const + { + return !(*this == x); + } /*! * @brief This function sets a value in member event * @param _event New value for member event */ eProsima_user_DllExport void event( - int32_t _event); + int32_t _event) + { + m_event = _event; + } /*! * @brief This function returns the value of member event * @return Value of member event */ - eProsima_user_DllExport int32_t event() const; + eProsima_user_DllExport int32_t event() const + { + return m_event; + } /*! * @brief This function returns a reference to member event * @return Reference to member event */ - eProsima_user_DllExport int32_t& event(); + eProsima_user_DllExport int32_t& event() + { + return m_event; + } /*! @@ -174,19 +215,28 @@ class LogEntry * @param _kind New value for member kind */ eProsima_user_DllExport void kind( - Kind _kind); + Kind _kind) + { + m_kind = _kind; + } /*! * @brief This function returns the value of member kind * @return Value of member kind */ - eProsima_user_DllExport Kind kind() const; + eProsima_user_DllExport Kind kind() const + { + return m_kind; + } /*! * @brief This function returns a reference to member kind * @return Reference to member kind */ - eProsima_user_DllExport Kind& kind(); + eProsima_user_DllExport Kind& kind() + { + return m_kind; + } /*! @@ -194,26 +244,38 @@ class LogEntry * @param _category New value to be copied in member category */ eProsima_user_DllExport void category( - const std::string& _category); + const std::string& _category) + { + m_category = _category; + } /*! * @brief This function moves the value in member category * @param _category New value to be moved in member category */ eProsima_user_DllExport void category( - std::string&& _category); + std::string&& _category) + { + m_category = std::move(_category); + } /*! * @brief This function returns a constant reference to member category * @return Constant reference to member category */ - eProsima_user_DllExport const std::string& category() const; + eProsima_user_DllExport const std::string& category() const + { + return m_category; + } /*! * @brief This function returns a reference to member category * @return Reference to member category */ - eProsima_user_DllExport std::string& category(); + eProsima_user_DllExport std::string& category() + { + return m_category; + } /*! @@ -221,26 +283,38 @@ class LogEntry * @param _message New value to be copied in member message */ eProsima_user_DllExport void message( - const std::string& _message); + const std::string& _message) + { + m_message = _message; + } /*! * @brief This function moves the value in member message * @param _message New value to be moved in member message */ eProsima_user_DllExport void message( - std::string&& _message); + std::string&& _message) + { + m_message = std::move(_message); + } /*! * @brief This function returns a constant reference to member message * @return Constant reference to member message */ - eProsima_user_DllExport const std::string& message() const; + eProsima_user_DllExport const std::string& message() const + { + return m_message; + } /*! * @brief This function returns a reference to member message * @return Reference to member message */ - eProsima_user_DllExport std::string& message(); + eProsima_user_DllExport std::string& message() + { + return m_message; + } /*! @@ -248,39 +322,51 @@ class LogEntry * @param _timestamp New value to be copied in member timestamp */ eProsima_user_DllExport void timestamp( - const std::string& _timestamp); + const std::string& _timestamp) + { + m_timestamp = _timestamp; + } /*! * @brief This function moves the value in member timestamp * @param _timestamp New value to be moved in member timestamp */ eProsima_user_DllExport void timestamp( - std::string&& _timestamp); + std::string&& _timestamp) + { + m_timestamp = std::move(_timestamp); + } /*! * @brief This function returns a constant reference to member timestamp * @return Constant reference to member timestamp */ - eProsima_user_DllExport const std::string& timestamp() const; + eProsima_user_DllExport const std::string& timestamp() const + { + return m_timestamp; + } /*! * @brief This function returns a reference to member timestamp * @return Reference to member timestamp */ - eProsima_user_DllExport std::string& timestamp(); + eProsima_user_DllExport std::string& timestamp() + { + return m_timestamp; + } + + private: int32_t m_event{0}; - Kind m_kind{::Info}; + Kind m_kind{Kind::Info}; std::string m_category; std::string m_message; std::string m_timestamp; }; -#endif // _FAST_DDS_GENERATED_LOGENTRY_H_ - +#endif // _FAST_DDS_GENERATED_LOGENTRY_HPP_ -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddspipe_core/include/ddspipe_core/types/logging/v1/LogEntryCdrAux.hpp b/ddspipe_core/include/ddspipe_core/types/logging/LogEntryCdrAux.hpp similarity index 84% rename from ddspipe_core/include/ddspipe_core/types/logging/v1/LogEntryCdrAux.hpp rename to ddspipe_core/include/ddspipe_core/types/logging/LogEntryCdrAux.hpp index 84c5a1d5..51af1ab7 100644 --- a/ddspipe_core/include/ddspipe_core/types/logging/v1/LogEntryCdrAux.hpp +++ b/ddspipe_core/include/ddspipe_core/types/logging/LogEntryCdrAux.hpp @@ -19,10 +19,10 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_LOGENTRYCDRAUX_HPP_ -#define _FAST_DDS_GENERATED_LOGENTRYCDRAUX_HPP_ +#ifndef FAST_DDS_GENERATED__LOGENTRYCDRAUX_HPP +#define FAST_DDS_GENERATED__LOGENTRYCDRAUX_HPP -#include +#include "LogEntry.hpp" constexpr uint32_t LogEntry_max_cdr_typesize {792UL}; constexpr uint32_t LogEntry_max_key_cdr_typesize {4UL}; @@ -34,17 +34,6 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; - - - - - - - - - - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const LogEntry& data); @@ -53,4 +42,5 @@ eProsima_user_DllExport void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_LOGENTRYCDRAUX_HPP_ +#endif // FAST_DDS_GENERATED__LOGENTRYCDRAUX_HPP + diff --git a/ddspipe_core/include/ddspipe_core/types/logging/v2/LogEntryCdrAux.ipp b/ddspipe_core/include/ddspipe_core/types/logging/LogEntryCdrAux.ipp similarity index 66% rename from ddspipe_core/include/ddspipe_core/types/logging/v2/LogEntryCdrAux.ipp rename to ddspipe_core/include/ddspipe_core/types/logging/LogEntryCdrAux.ipp index f7f8a6b4..b7485cdc 100644 --- a/ddspipe_core/include/ddspipe_core/types/logging/v2/LogEntryCdrAux.ipp +++ b/ddspipe_core/include/ddspipe_core/types/logging/LogEntryCdrAux.ipp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_LOGENTRYCDRAUX_IPP_ -#define _FAST_DDS_GENERATED_LOGENTRYCDRAUX_IPP_ +#ifndef FAST_DDS_GENERATED__LOGENTRYCDRAUX_IPP +#define FAST_DDS_GENERATED__LOGENTRYCDRAUX_IPP #include "LogEntryCdrAux.hpp" @@ -34,17 +34,6 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { - - - - - - - - - - - template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -61,20 +50,20 @@ eProsima_user_DllExport size_t calculate_serialized_size( current_alignment)}; - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.event(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), + data.event(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), - data.kind(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), + data.kind(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(2), - data.category(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(2), + data.category(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(3), - data.message(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(3), + data.message(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(4), - data.timestamp(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(4), + data.timestamp(), current_alignment); calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); @@ -99,7 +88,7 @@ eProsima_user_DllExport void serialize( << eprosima::fastcdr::MemberId(2) << data.category() << eprosima::fastcdr::MemberId(3) << data.message() << eprosima::fastcdr::MemberId(4) << data.timestamp() - ; +; scdr.end_serialize_type(current_state); } @@ -116,25 +105,25 @@ eProsima_user_DllExport void deserialize( bool ret_value = true; switch (mid.id) { - case 0: - dcdr >> data.event(); - break; + case 0: + dcdr >> data.event(); + break; - case 1: - dcdr >> data.kind(); - break; + case 1: + dcdr >> data.kind(); + break; - case 2: - dcdr >> data.category(); - break; + case 2: + dcdr >> data.category(); + break; - case 3: - dcdr >> data.message(); - break; + case 3: + dcdr >> data.message(); + break; - case 4: - dcdr >> data.timestamp(); - break; + case 4: + dcdr >> data.timestamp(); + break; default: ret_value = false; @@ -148,9 +137,10 @@ void serialize_key( eprosima::fastcdr::Cdr& scdr, const LogEntry& data) { + static_cast(scdr); static_cast(data); - scdr << data.event(); + scdr << data.event(); @@ -158,8 +148,10 @@ void serialize_key( } + + } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_LOGENTRYCDRAUX_IPP_ +#endif // FAST_DDS_GENERATED__LOGENTRYCDRAUX_IPP diff --git a/ddspipe_core/include/ddspipe_core/types/logging/v2/LogEntryPubSubTypes.h b/ddspipe_core/include/ddspipe_core/types/logging/LogEntryPubSubTypes.hpp similarity index 61% rename from ddspipe_core/include/ddspipe_core/types/logging/v2/LogEntryPubSubTypes.h rename to ddspipe_core/include/ddspipe_core/types/logging/LogEntryPubSubTypes.hpp index 4f0b8130..8f821932 100644 --- a/ddspipe_core/include/ddspipe_core/types/logging/v2/LogEntryPubSubTypes.h +++ b/ddspipe_core/include/ddspipe_core/types/logging/LogEntryPubSubTypes.hpp @@ -13,40 +13,29 @@ // limitations under the License. /*! - * @file LogEntryPubSubTypes.h + * @file LogEntryPubSubTypes.hpp * This header file contains the declaration of the serialization functions. * * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_LOGENTRY_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_LOGENTRY_PUBSUBTYPES_H_ +#ifndef FAST_DDS_GENERATED__LOGENTRY_PUBSUBTYPES_HPP +#define FAST_DDS_GENERATED__LOGENTRY_PUBSUBTYPES_HPP #include #include -#include -#include -#include +#include +#include +#include -#include +#include "LogEntry.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated LogEntry is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER - - - - - - - - - - - +#endif // FASTDDS_GEN_API_VER /*! @@ -64,41 +53,36 @@ class LogEntryPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport ~LogEntryPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t& payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + eProsima_user_DllExport uint32_t calculate_serialized_size( + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + eProsima_user_DllExport bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport bool compute_key( + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -108,10 +92,6 @@ class LogEntryPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -132,9 +112,12 @@ class LogEntryPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; -#endif // _FAST_DDS_GENERATED_LOGENTRY_PUBSUBTYPES_H_ +#endif // FAST_DDS_GENERATED__LOGENTRY_PUBSUBTYPES_HPP + diff --git a/ddspipe_core/include/ddspipe_core/types/logging/LogEntryTypeObjectSupport.hpp b/ddspipe_core/include/ddspipe_core/types/logging/LogEntryTypeObjectSupport.hpp new file mode 100644 index 00000000..7e321396 --- /dev/null +++ b/ddspipe_core/include/ddspipe_core/types/logging/LogEntryTypeObjectSupport.hpp @@ -0,0 +1,68 @@ +// 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 LogEntryTypeObjectSupport.hpp + * Header file containing the API required to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef FAST_DDS_GENERATED__LOGENTRY_TYPE_OBJECT_SUPPORT_HPP +#define FAST_DDS_GENERATED__LOGENTRY_TYPE_OBJECT_SUPPORT_HPP + +#include + + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +/** + * @brief Register Kind related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_Kind_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); +/** + * @brief Register LogEntry related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_LogEntry_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); + + +#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +#endif // FAST_DDS_GENERATED__LOGENTRY_TYPE_OBJECT_SUPPORT_HPP diff --git a/ddspipe_core/include/ddspipe_core/types/logging/v1/LogEntry.h b/ddspipe_core/include/ddspipe_core/types/logging/v1/LogEntry.h deleted file mode 100644 index d8e458bf..00000000 --- a/ddspipe_core/include/ddspipe_core/types/logging/v1/LogEntry.h +++ /dev/null @@ -1,332 +0,0 @@ -// 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 LogEntry.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_LOGENTRY_H_ -#define _FAST_DDS_GENERATED_LOGENTRY_H_ - - -#include - -#include -#include -#include -#include -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(LOGENTRY_SOURCE) -#define LOGENTRY_DllAPI __declspec( dllexport ) -#else -#define LOGENTRY_DllAPI __declspec( dllimport ) -#endif // LOGENTRY_SOURCE -#else -#define LOGENTRY_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define LOGENTRY_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - - -const int32_t UNDEFINED = 0x10000000; - -const int32_t SAMPLE_LOST = 0x10000001; - -const int32_t TOPIC_MISMATCH_TYPE = 0x10000002; - -const int32_t TOPIC_MISMATCH_QOS = 0x10000003; - -/*! - * @brief This class represents the enumeration Kind defined by the user in the IDL file. - * @ingroup LogEntry - */ -enum Kind : uint32_t -{ - Info, - Warning, - Error -}; - - -/*! - * @brief This class represents the structure LogEntry defined by the user in the IDL file. - * @ingroup LogEntry - */ -class LogEntry -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport LogEntry(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~LogEntry(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object LogEntry that will be copied. - */ - eProsima_user_DllExport LogEntry( - const LogEntry& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object LogEntry that will be copied. - */ - eProsima_user_DllExport LogEntry( - LogEntry&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object LogEntry that will be copied. - */ - eProsima_user_DllExport LogEntry& operator =( - const LogEntry& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object LogEntry that will be copied. - */ - eProsima_user_DllExport LogEntry& operator =( - LogEntry&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x LogEntry object to compare. - */ - eProsima_user_DllExport bool operator ==( - const LogEntry& x) const; - - /*! - * @brief Comparison operator. - * @param x LogEntry object to compare. - */ - eProsima_user_DllExport bool operator !=( - const LogEntry& x) const; - - /*! - * @brief This function sets a value in member event - * @param _event New value for member event - */ - eProsima_user_DllExport void event( - int32_t _event); - - /*! - * @brief This function returns the value of member event - * @return Value of member event - */ - eProsima_user_DllExport int32_t event() const; - - /*! - * @brief This function returns a reference to member event - * @return Reference to member event - */ - eProsima_user_DllExport int32_t& event(); - - - /*! - * @brief This function sets a value in member kind - * @param _kind New value for member kind - */ - eProsima_user_DllExport void kind( - Kind _kind); - - /*! - * @brief This function returns the value of member kind - * @return Value of member kind - */ - eProsima_user_DllExport Kind kind() const; - - /*! - * @brief This function returns a reference to member kind - * @return Reference to member kind - */ - eProsima_user_DllExport Kind& kind(); - - - /*! - * @brief This function copies the value in member category - * @param _category New value to be copied in member category - */ - eProsima_user_DllExport void category( - const std::string& _category); - - /*! - * @brief This function moves the value in member category - * @param _category New value to be moved in member category - */ - eProsima_user_DllExport void category( - std::string&& _category); - - /*! - * @brief This function returns a constant reference to member category - * @return Constant reference to member category - */ - eProsima_user_DllExport const std::string& category() const; - - /*! - * @brief This function returns a reference to member category - * @return Reference to member category - */ - eProsima_user_DllExport std::string& category(); - - - /*! - * @brief This function copies the value in member message - * @param _message New value to be copied in member message - */ - eProsima_user_DllExport void message( - const std::string& _message); - - /*! - * @brief This function moves the value in member message - * @param _message New value to be moved in member message - */ - eProsima_user_DllExport void message( - std::string&& _message); - - /*! - * @brief This function returns a constant reference to member message - * @return Constant reference to member message - */ - eProsima_user_DllExport const std::string& message() const; - - /*! - * @brief This function returns a reference to member message - * @return Reference to member message - */ - eProsima_user_DllExport std::string& message(); - - - /*! - * @brief This function copies the value in member timestamp - * @param _timestamp New value to be copied in member timestamp - */ - eProsima_user_DllExport void timestamp( - const std::string& _timestamp); - - /*! - * @brief This function moves the value in member timestamp - * @param _timestamp New value to be moved in member timestamp - */ - eProsima_user_DllExport void timestamp( - std::string&& _timestamp); - - /*! - * @brief This function returns a constant reference to member timestamp - * @return Constant reference to member timestamp - */ - eProsima_user_DllExport const std::string& timestamp() const; - - /*! - * @brief This function returns a reference to member timestamp - * @return Reference to member timestamp - */ - eProsima_user_DllExport std::string& timestamp(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const LogEntry& data, - size_t current_alignment = 0); - - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - -private: - - int32_t m_event; - Kind m_kind; - std::string m_category; - std::string m_message; - std::string m_timestamp; - -}; - - -#endif // _FAST_DDS_GENERATED_LOGENTRY_H_ - - - diff --git a/ddspipe_core/include/ddspipe_core/types/logging/v1/LogEntryCdrAux.ipp b/ddspipe_core/include/ddspipe_core/types/logging/v1/LogEntryCdrAux.ipp deleted file mode 100644 index f7f8a6b4..00000000 --- a/ddspipe_core/include/ddspipe_core/types/logging/v1/LogEntryCdrAux.ipp +++ /dev/null @@ -1,165 +0,0 @@ -// 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 LogEntryCdrAux.ipp - * This source file contains some declarations of CDR related functions. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_LOGENTRYCDRAUX_IPP_ -#define _FAST_DDS_GENERATED_LOGENTRYCDRAUX_IPP_ - -#include "LogEntryCdrAux.hpp" - -#include -#include - - -#include -using namespace eprosima::fastcdr::exception; - -namespace eprosima { -namespace fastcdr { - - - - - - - - - - - - -template<> -eProsima_user_DllExport size_t calculate_serialized_size( - eprosima::fastcdr::CdrSizeCalculator& calculator, - const LogEntry& data, - size_t& current_alignment) -{ - static_cast(data); - - eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); - size_t calculated_size {calculator.begin_calculate_type_serialized_size( - eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, - current_alignment)}; - - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.event(), current_alignment); - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), - data.kind(), current_alignment); - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(2), - data.category(), current_alignment); - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(3), - data.message(), current_alignment); - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(4), - data.timestamp(), current_alignment); - - - calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); - - return calculated_size; -} - -template<> -eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& scdr, - const LogEntry& data) -{ - eprosima::fastcdr::Cdr::state current_state(scdr); - scdr.begin_serialize_type(current_state, - eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR); - - scdr - << eprosima::fastcdr::MemberId(0) << data.event() - << eprosima::fastcdr::MemberId(1) << data.kind() - << eprosima::fastcdr::MemberId(2) << data.category() - << eprosima::fastcdr::MemberId(3) << data.message() - << eprosima::fastcdr::MemberId(4) << data.timestamp() - ; - scdr.end_serialize_type(current_state); -} - -template<> -eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr, - LogEntry& data) -{ - cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, - [&data](eprosima::fastcdr::Cdr& dcdr, const eprosima::fastcdr::MemberId& mid) -> bool - { - bool ret_value = true; - switch (mid.id) - { - case 0: - dcdr >> data.event(); - break; - - case 1: - dcdr >> data.kind(); - break; - - case 2: - dcdr >> data.category(); - break; - - case 3: - dcdr >> data.message(); - break; - - case 4: - dcdr >> data.timestamp(); - break; - - default: - ret_value = false; - break; - } - return ret_value; - }); -} - -void serialize_key( - eprosima::fastcdr::Cdr& scdr, - const LogEntry& data) -{ - static_cast(scdr); - static_cast(data); - scdr << data.event(); - - - - - -} - -} // namespace fastcdr -} // namespace eprosima - -#endif // _FAST_DDS_GENERATED_LOGENTRYCDRAUX_IPP_ - diff --git a/ddspipe_core/include/ddspipe_core/types/logging/v1/LogEntryPubSubTypes.h b/ddspipe_core/include/ddspipe_core/types/logging/v1/LogEntryPubSubTypes.h deleted file mode 100644 index 4b61e892..00000000 --- a/ddspipe_core/include/ddspipe_core/types/logging/v1/LogEntryPubSubTypes.h +++ /dev/null @@ -1,140 +0,0 @@ -// 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 LogEntryPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#ifndef _FAST_DDS_GENERATED_LOGENTRY_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_LOGENTRY_PUBSUBTYPES_H_ - -#include -#include -#include -#include -#include - -#include - - -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) -#error \ - Generated LogEntry is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER - - - - - - - - - - - - - -/*! - * @brief This class represents the TopicDataType of the type LogEntry defined by the user in the IDL file. - * @ingroup LogEntry - */ -class LogEntryPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef LogEntry type; - - eProsima_user_DllExport LogEntryPubSubType(); - - eProsima_user_DllExport ~LogEntryPubSubType() override; - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport void* createData() override; - - eProsima_user_DllExport void deleteData( - void* data) override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } - - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - static_cast(memory); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - -#endif // _FAST_DDS_GENERATED_LOGENTRY_PUBSUBTYPES_H_ diff --git a/ddspipe_core/include/ddspipe_core/types/logging/v1/LogEntryTypeObject.h b/ddspipe_core/include/ddspipe_core/types/logging/v1/LogEntryTypeObject.h deleted file mode 100644 index 57b79909..00000000 --- a/ddspipe_core/include/ddspipe_core/types/logging/v1/LogEntryTypeObject.h +++ /dev/null @@ -1,82 +0,0 @@ -// 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 LogEntryTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_LOGENTRY_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_LOGENTRY_TYPE_OBJECT_H_ - - -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define eProsima_user_DllExport -#endif // if defined(_WIN32) - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(LogEntry_SOURCE) -#define LogEntry_DllAPI __declspec( dllexport ) -#else -#define LogEntry_DllAPI __declspec( dllimport ) -#endif // LogEntry_SOURCE -#else -#define LogEntry_DllAPI -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define LogEntry_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registerLogEntryTypes(); - - - - - - - - - -eProsima_user_DllExport const TypeIdentifier* GetKindIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetKindObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalKindObject(); -eProsima_user_DllExport const TypeObject* GetCompleteKindObject(); - - - -eProsima_user_DllExport const TypeIdentifier* GetLogEntryIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetLogEntryObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalLogEntryObject(); -eProsima_user_DllExport const TypeObject* GetCompleteLogEntryObject(); - - -#endif // _FAST_DDS_GENERATED_LOGENTRY_TYPE_OBJECT_H_ \ No newline at end of file diff --git a/ddspipe_core/include/ddspipe_core/types/logging/v2/LogEntryCdrAux.hpp b/ddspipe_core/include/ddspipe_core/types/logging/v2/LogEntryCdrAux.hpp deleted file mode 100644 index 1bf441e6..00000000 --- a/ddspipe_core/include/ddspipe_core/types/logging/v2/LogEntryCdrAux.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// 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 LogEntryCdrAux.hpp - * This source file contains some definitions of CDR related functions. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_LOGENTRYCDRAUX_HPP_ -#define _FAST_DDS_GENERATED_LOGENTRYCDRAUX_HPP_ - -#include - -constexpr uint32_t LogEntry_max_cdr_typesize {792UL}; -constexpr uint32_t LogEntry_max_key_cdr_typesize {4UL}; - - -namespace eprosima { -namespace fastcdr { - -class Cdr; -class CdrSizeCalculator; - - - - - - - - - - - - -eProsima_user_DllExport void serialize_key( - eprosima::fastcdr::Cdr& scdr, - const LogEntry& data); - - -} // namespace fastcdr -} // namespace eprosima - -#endif // _FAST_DDS_GENERATED_LOGENTRYCDRAUX_HPP_ diff --git a/ddspipe_core/include/ddspipe_core/types/logging/v2/LogEntryTypeObject.h b/ddspipe_core/include/ddspipe_core/types/logging/v2/LogEntryTypeObject.h deleted file mode 100644 index 57b79909..00000000 --- a/ddspipe_core/include/ddspipe_core/types/logging/v2/LogEntryTypeObject.h +++ /dev/null @@ -1,82 +0,0 @@ -// 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 LogEntryTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_LOGENTRY_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_LOGENTRY_TYPE_OBJECT_H_ - - -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define eProsima_user_DllExport -#endif // if defined(_WIN32) - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(LogEntry_SOURCE) -#define LogEntry_DllAPI __declspec( dllexport ) -#else -#define LogEntry_DllAPI __declspec( dllimport ) -#endif // LogEntry_SOURCE -#else -#define LogEntry_DllAPI -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define LogEntry_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registerLogEntryTypes(); - - - - - - - - - -eProsima_user_DllExport const TypeIdentifier* GetKindIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetKindObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalKindObject(); -eProsima_user_DllExport const TypeObject* GetCompleteKindObject(); - - - -eProsima_user_DllExport const TypeIdentifier* GetLogEntryIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetLogEntryObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalLogEntryObject(); -eProsima_user_DllExport const TypeObject* GetCompleteLogEntryObject(); - - -#endif // _FAST_DDS_GENERATED_LOGENTRY_TYPE_OBJECT_H_ \ No newline at end of file diff --git a/ddspipe_core/include/ddspipe_core/types/logging/v2/LogEntryv1.h b/ddspipe_core/include/ddspipe_core/types/logging/v2/LogEntryv1.h deleted file mode 100644 index 6919f542..00000000 --- a/ddspipe_core/include/ddspipe_core/types/logging/v2/LogEntryv1.h +++ /dev/null @@ -1,337 +0,0 @@ -// 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 LogEntry.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#include - -#if FASTCDR_VERSION_MAJOR == 1 - -#ifndef _FAST_DDS_GENERATED_LOGENTRY_H_ -#define _FAST_DDS_GENERATED_LOGENTRY_H_ - - -#include - -#include -#include -#include -#include -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(LOGENTRY_SOURCE) -#define LOGENTRY_DllAPI __declspec( dllexport ) -#else -#define LOGENTRY_DllAPI __declspec( dllimport ) -#endif // LOGENTRY_SOURCE -#else -#define LOGENTRY_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define LOGENTRY_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - - -const int32_t UNDEFINED = 0x10000000; - -const int32_t SAMPLE_LOST = 0x10000001; - -const int32_t TOPIC_MISMATCH_TYPE = 0x10000002; - -const int32_t TOPIC_MISMATCH_QOS = 0x10000003; - -/*! - * @brief This class represents the enumeration Kind defined by the user in the IDL file. - * @ingroup LogEntry - */ -enum Kind : uint32_t -{ - Info, - Warning, - Error -}; - - -/*! - * @brief This class represents the structure LogEntry defined by the user in the IDL file. - * @ingroup LogEntry - */ -class LogEntry -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport LogEntry(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~LogEntry(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object LogEntry that will be copied. - */ - eProsima_user_DllExport LogEntry( - const LogEntry& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object LogEntry that will be copied. - */ - eProsima_user_DllExport LogEntry( - LogEntry&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object LogEntry that will be copied. - */ - eProsima_user_DllExport LogEntry& operator =( - const LogEntry& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object LogEntry that will be copied. - */ - eProsima_user_DllExport LogEntry& operator =( - LogEntry&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x LogEntry object to compare. - */ - eProsima_user_DllExport bool operator ==( - const LogEntry& x) const; - - /*! - * @brief Comparison operator. - * @param x LogEntry object to compare. - */ - eProsima_user_DllExport bool operator !=( - const LogEntry& x) const; - - /*! - * @brief This function sets a value in member event - * @param _event New value for member event - */ - eProsima_user_DllExport void event( - int32_t _event); - - /*! - * @brief This function returns the value of member event - * @return Value of member event - */ - eProsima_user_DllExport int32_t event() const; - - /*! - * @brief This function returns a reference to member event - * @return Reference to member event - */ - eProsima_user_DllExport int32_t& event(); - - - /*! - * @brief This function sets a value in member kind - * @param _kind New value for member kind - */ - eProsima_user_DllExport void kind( - Kind _kind); - - /*! - * @brief This function returns the value of member kind - * @return Value of member kind - */ - eProsima_user_DllExport Kind kind() const; - - /*! - * @brief This function returns a reference to member kind - * @return Reference to member kind - */ - eProsima_user_DllExport Kind& kind(); - - - /*! - * @brief This function copies the value in member category - * @param _category New value to be copied in member category - */ - eProsima_user_DllExport void category( - const std::string& _category); - - /*! - * @brief This function moves the value in member category - * @param _category New value to be moved in member category - */ - eProsima_user_DllExport void category( - std::string&& _category); - - /*! - * @brief This function returns a constant reference to member category - * @return Constant reference to member category - */ - eProsima_user_DllExport const std::string& category() const; - - /*! - * @brief This function returns a reference to member category - * @return Reference to member category - */ - eProsima_user_DllExport std::string& category(); - - - /*! - * @brief This function copies the value in member message - * @param _message New value to be copied in member message - */ - eProsima_user_DllExport void message( - const std::string& _message); - - /*! - * @brief This function moves the value in member message - * @param _message New value to be moved in member message - */ - eProsima_user_DllExport void message( - std::string&& _message); - - /*! - * @brief This function returns a constant reference to member message - * @return Constant reference to member message - */ - eProsima_user_DllExport const std::string& message() const; - - /*! - * @brief This function returns a reference to member message - * @return Reference to member message - */ - eProsima_user_DllExport std::string& message(); - - - /*! - * @brief This function copies the value in member timestamp - * @param _timestamp New value to be copied in member timestamp - */ - eProsima_user_DllExport void timestamp( - const std::string& _timestamp); - - /*! - * @brief This function moves the value in member timestamp - * @param _timestamp New value to be moved in member timestamp - */ - eProsima_user_DllExport void timestamp( - std::string&& _timestamp); - - /*! - * @brief This function returns a constant reference to member timestamp - * @return Constant reference to member timestamp - */ - eProsima_user_DllExport const std::string& timestamp() const; - - /*! - * @brief This function returns a reference to member timestamp - * @return Reference to member timestamp - */ - eProsima_user_DllExport std::string& timestamp(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const LogEntry& data, - size_t current_alignment = 0); - - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - -private: - - int32_t m_event; - Kind m_kind; - std::string m_category; - std::string m_message; - std::string m_timestamp; - -}; - - -#endif // _FAST_DDS_GENERATED_LOGENTRY_H_ - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddspipe_core/include/ddspipe_core/types/monitoring/status/v2/MonitoringStatus.h b/ddspipe_core/include/ddspipe_core/types/monitoring/status/MonitoringStatus.hpp similarity index 65% rename from ddspipe_core/include/ddspipe_core/types/monitoring/status/v2/MonitoringStatus.h rename to ddspipe_core/include/ddspipe_core/types/monitoring/status/MonitoringStatus.hpp index b83b01ec..4a7b6f14 100644 --- a/ddspipe_core/include/ddspipe_core/types/monitoring/status/v2/MonitoringStatus.h +++ b/ddspipe_core/include/ddspipe_core/types/monitoring/status/MonitoringStatus.hpp @@ -13,32 +13,17 @@ // limitations under the License. /*! - * @file MonitoringStatus.h + * @file MonitoringStatus.hpp * This header file contains the declaration of the described types in the IDL file. * * This file was generated by the tool fastddsgen. */ -#include -#include "MonitoringStatusv1.h" +#ifndef FAST_DDS_GENERATED__MONITORINGSTATUS_HPP +#define FAST_DDS_GENERATED__MONITORINGSTATUS_HPP -#if FASTCDR_VERSION_MAJOR > 1 - -#ifndef _FAST_DDS_GENERATED_MONITORINGSTATUS_H_ -#define _FAST_DDS_GENERATED_MONITORINGSTATUS_H_ - -#include -#include #include -#include -#include -#include - -#include -#include -#include - - +#include #if defined(_WIN32) #if defined(EPROSIMA_USER_DLL_EXPORT) @@ -64,17 +49,6 @@ #define MONITORINGSTATUS_DllAPI #endif // _WIN32 -namespace eprosima { -namespace fastcdr { -class Cdr; -class CdrSizeCalculator; -} // namespace fastcdr -} // namespace eprosima - - - - - /*! * @brief This class represents the structure MonitoringErrorStatus defined by the user in the IDL file. * @ingroup MonitoringStatus @@ -86,73 +60,117 @@ class MonitoringErrorStatus /*! * @brief Default constructor. */ - eProsima_user_DllExport MonitoringErrorStatus(); + eProsima_user_DllExport MonitoringErrorStatus() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~MonitoringErrorStatus(); + eProsima_user_DllExport ~MonitoringErrorStatus() + { + } /*! * @brief Copy constructor. * @param x Reference to the object MonitoringErrorStatus that will be copied. */ eProsima_user_DllExport MonitoringErrorStatus( - const MonitoringErrorStatus& x); + const MonitoringErrorStatus& x) + { + m_type_mismatch = x.m_type_mismatch; + + m_qos_mismatch = x.m_qos_mismatch; + + } /*! * @brief Move constructor. * @param x Reference to the object MonitoringErrorStatus that will be copied. */ eProsima_user_DllExport MonitoringErrorStatus( - MonitoringErrorStatus&& x) noexcept; + MonitoringErrorStatus&& x) noexcept + { + m_type_mismatch = x.m_type_mismatch; + m_qos_mismatch = x.m_qos_mismatch; + } /*! * @brief Copy assignment. * @param x Reference to the object MonitoringErrorStatus that will be copied. */ eProsima_user_DllExport MonitoringErrorStatus& operator =( - const MonitoringErrorStatus& x); + const MonitoringErrorStatus& x) + { + + m_type_mismatch = x.m_type_mismatch; + + m_qos_mismatch = x.m_qos_mismatch; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object MonitoringErrorStatus that will be copied. */ eProsima_user_DllExport MonitoringErrorStatus& operator =( - MonitoringErrorStatus&& x) noexcept; + MonitoringErrorStatus&& x) noexcept + { + + m_type_mismatch = x.m_type_mismatch; + m_qos_mismatch = x.m_qos_mismatch; + return *this; + } /*! * @brief Comparison operator. * @param x MonitoringErrorStatus object to compare. */ eProsima_user_DllExport bool operator ==( - const MonitoringErrorStatus& x) const; + const MonitoringErrorStatus& x) const + { + return (m_type_mismatch == x.m_type_mismatch && + m_qos_mismatch == x.m_qos_mismatch); + } /*! * @brief Comparison operator. * @param x MonitoringErrorStatus object to compare. */ eProsima_user_DllExport bool operator !=( - const MonitoringErrorStatus& x) const; + const MonitoringErrorStatus& x) const + { + return !(*this == x); + } /*! * @brief This function sets a value in member type_mismatch * @param _type_mismatch New value for member type_mismatch */ eProsima_user_DllExport void type_mismatch( - bool _type_mismatch); + bool _type_mismatch) + { + m_type_mismatch = _type_mismatch; + } /*! * @brief This function returns the value of member type_mismatch * @return Value of member type_mismatch */ - eProsima_user_DllExport bool type_mismatch() const; + eProsima_user_DllExport bool type_mismatch() const + { + return m_type_mismatch; + } /*! * @brief This function returns a reference to member type_mismatch * @return Reference to member type_mismatch */ - eProsima_user_DllExport bool& type_mismatch(); + eProsima_user_DllExport bool& type_mismatch() + { + return m_type_mismatch; + } /*! @@ -160,19 +178,30 @@ class MonitoringErrorStatus * @param _qos_mismatch New value for member qos_mismatch */ eProsima_user_DllExport void qos_mismatch( - bool _qos_mismatch); + bool _qos_mismatch) + { + m_qos_mismatch = _qos_mismatch; + } /*! * @brief This function returns the value of member qos_mismatch * @return Value of member qos_mismatch */ - eProsima_user_DllExport bool qos_mismatch() const; + eProsima_user_DllExport bool qos_mismatch() const + { + return m_qos_mismatch; + } /*! * @brief This function returns a reference to member qos_mismatch * @return Reference to member qos_mismatch */ - eProsima_user_DllExport bool& qos_mismatch(); + eProsima_user_DllExport bool& qos_mismatch() + { + return m_qos_mismatch; + } + + private: @@ -180,8 +209,6 @@ class MonitoringErrorStatus bool m_qos_mismatch{false}; }; - - /*! * @brief This class represents the structure MonitoringStatus defined by the user in the IDL file. * @ingroup MonitoringStatus @@ -193,80 +220,127 @@ class MonitoringStatus /*! * @brief Default constructor. */ - eProsima_user_DllExport MonitoringStatus(); + eProsima_user_DllExport MonitoringStatus() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~MonitoringStatus(); + eProsima_user_DllExport ~MonitoringStatus() + { + } /*! * @brief Copy constructor. * @param x Reference to the object MonitoringStatus that will be copied. */ eProsima_user_DllExport MonitoringStatus( - const MonitoringStatus& x); + const MonitoringStatus& x) + { + m_error_status = x.m_error_status; + + m_has_errors = x.m_has_errors; + + } /*! * @brief Move constructor. * @param x Reference to the object MonitoringStatus that will be copied. */ eProsima_user_DllExport MonitoringStatus( - MonitoringStatus&& x) noexcept; + MonitoringStatus&& x) noexcept + { + m_error_status = std::move(x.m_error_status); + m_has_errors = x.m_has_errors; + } /*! * @brief Copy assignment. * @param x Reference to the object MonitoringStatus that will be copied. */ eProsima_user_DllExport MonitoringStatus& operator =( - const MonitoringStatus& x); + const MonitoringStatus& x) + { + + m_error_status = x.m_error_status; + + m_has_errors = x.m_has_errors; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object MonitoringStatus that will be copied. */ eProsima_user_DllExport MonitoringStatus& operator =( - MonitoringStatus&& x) noexcept; + MonitoringStatus&& x) noexcept + { + + m_error_status = std::move(x.m_error_status); + m_has_errors = x.m_has_errors; + return *this; + } /*! * @brief Comparison operator. * @param x MonitoringStatus object to compare. */ eProsima_user_DllExport bool operator ==( - const MonitoringStatus& x) const; + const MonitoringStatus& x) const + { + return (m_error_status == x.m_error_status && + m_has_errors == x.m_has_errors); + } /*! * @brief Comparison operator. * @param x MonitoringStatus object to compare. */ eProsima_user_DllExport bool operator !=( - const MonitoringStatus& x) const; + const MonitoringStatus& x) const + { + return !(*this == x); + } /*! * @brief This function copies the value in member error_status * @param _error_status New value to be copied in member error_status */ eProsima_user_DllExport void error_status( - const MonitoringErrorStatus& _error_status); + const MonitoringErrorStatus& _error_status) + { + m_error_status = _error_status; + } /*! * @brief This function moves the value in member error_status * @param _error_status New value to be moved in member error_status */ eProsima_user_DllExport void error_status( - MonitoringErrorStatus&& _error_status); + MonitoringErrorStatus&& _error_status) + { + m_error_status = std::move(_error_status); + } /*! * @brief This function returns a constant reference to member error_status * @return Constant reference to member error_status */ - eProsima_user_DllExport const MonitoringErrorStatus& error_status() const; + eProsima_user_DllExport const MonitoringErrorStatus& error_status() const + { + return m_error_status; + } /*! * @brief This function returns a reference to member error_status * @return Reference to member error_status */ - eProsima_user_DllExport MonitoringErrorStatus& error_status(); + eProsima_user_DllExport MonitoringErrorStatus& error_status() + { + return m_error_status; + } /*! @@ -274,19 +348,30 @@ class MonitoringStatus * @param _has_errors New value for member has_errors */ eProsima_user_DllExport void has_errors( - bool _has_errors); + bool _has_errors) + { + m_has_errors = _has_errors; + } /*! * @brief This function returns the value of member has_errors * @return Value of member has_errors */ - eProsima_user_DllExport bool has_errors() const; + eProsima_user_DllExport bool has_errors() const + { + return m_has_errors; + } /*! * @brief This function returns a reference to member has_errors * @return Reference to member has_errors */ - eProsima_user_DllExport bool& has_errors(); + eProsima_user_DllExport bool& has_errors() + { + return m_has_errors; + } + + private: @@ -295,8 +380,6 @@ class MonitoringStatus }; -#endif // _FAST_DDS_GENERATED_MONITORINGSTATUS_H_ - +#endif // _FAST_DDS_GENERATED_MONITORINGSTATUS_HPP_ -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddspipe_core/include/ddspipe_core/types/monitoring/status/v1/MonitoringStatusCdrAux.hpp b/ddspipe_core/include/ddspipe_core/types/monitoring/status/MonitoringStatusCdrAux.hpp similarity index 85% rename from ddspipe_core/include/ddspipe_core/types/monitoring/status/v1/MonitoringStatusCdrAux.hpp rename to ddspipe_core/include/ddspipe_core/types/monitoring/status/MonitoringStatusCdrAux.hpp index 569809f1..019e6148 100644 --- a/ddspipe_core/include/ddspipe_core/types/monitoring/status/v1/MonitoringStatusCdrAux.hpp +++ b/ddspipe_core/include/ddspipe_core/types/monitoring/status/MonitoringStatusCdrAux.hpp @@ -19,10 +19,10 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_MONITORINGSTATUSCDRAUX_HPP_ -#define _FAST_DDS_GENERATED_MONITORINGSTATUSCDRAUX_HPP_ +#ifndef FAST_DDS_GENERATED__MONITORINGSTATUSCDRAUX_HPP +#define FAST_DDS_GENERATED__MONITORINGSTATUSCDRAUX_HPP -#include +#include "MonitoringStatus.hpp" constexpr uint32_t MonitoringErrorStatus_max_cdr_typesize {6UL}; constexpr uint32_t MonitoringErrorStatus_max_key_cdr_typesize {0UL}; @@ -37,14 +37,10 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const MonitoringErrorStatus& data); - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const MonitoringStatus& data); @@ -53,4 +49,5 @@ eProsima_user_DllExport void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_MONITORINGSTATUSCDRAUX_HPP_ +#endif // FAST_DDS_GENERATED__MONITORINGSTATUSCDRAUX_HPP + diff --git a/ddspipe_core/include/ddspipe_core/types/monitoring/status/v2/MonitoringStatusCdrAux.ipp b/ddspipe_core/include/ddspipe_core/types/monitoring/status/MonitoringStatusCdrAux.ipp similarity index 75% rename from ddspipe_core/include/ddspipe_core/types/monitoring/status/v2/MonitoringStatusCdrAux.ipp rename to ddspipe_core/include/ddspipe_core/types/monitoring/status/MonitoringStatusCdrAux.ipp index 897ab6ca..21d359ab 100644 --- a/ddspipe_core/include/ddspipe_core/types/monitoring/status/v2/MonitoringStatusCdrAux.ipp +++ b/ddspipe_core/include/ddspipe_core/types/monitoring/status/MonitoringStatusCdrAux.ipp @@ -19,10 +19,10 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_MONITORINGSTATUSCDRAUX_IPP_ -#define _FAST_DDS_GENERATED_MONITORINGSTATUSCDRAUX_IPP_ +#ifndef FAST_DDS_GENERATED__MONITORINGSTATUSCDRAUX_IPP +#define FAST_DDS_GENERATED__MONITORINGSTATUSCDRAUX_IPP -#include +#include "MonitoringStatusCdrAux.hpp" #include #include @@ -34,8 +34,6 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { - - template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -52,11 +50,11 @@ eProsima_user_DllExport size_t calculate_serialized_size( current_alignment)}; - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.type_mismatch(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), + data.type_mismatch(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), - data.qos_mismatch(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), + data.qos_mismatch(), current_alignment); calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); @@ -78,7 +76,7 @@ eProsima_user_DllExport void serialize( scdr << eprosima::fastcdr::MemberId(0) << data.type_mismatch() << eprosima::fastcdr::MemberId(1) << data.qos_mismatch() - ; +; scdr.end_serialize_type(current_state); } @@ -95,13 +93,13 @@ eProsima_user_DllExport void deserialize( bool ret_value = true; switch (mid.id) { - case 0: - dcdr >> data.type_mismatch(); - break; + case 0: + dcdr >> data.type_mismatch(); + break; - case 1: - dcdr >> data.qos_mismatch(); - break; + case 1: + dcdr >> data.qos_mismatch(); + break; default: ret_value = false; @@ -115,10 +113,16 @@ void serialize_key( eprosima::fastcdr::Cdr& scdr, const MonitoringErrorStatus& data) { + static_cast(scdr); static_cast(data); + scdr << data.type_mismatch(); + + scdr << data.qos_mismatch(); + } + template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -135,11 +139,11 @@ eProsima_user_DllExport size_t calculate_serialized_size( current_alignment)}; - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.error_status(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), + data.error_status(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), - data.has_errors(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), + data.has_errors(), current_alignment); calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); @@ -161,7 +165,7 @@ eProsima_user_DllExport void serialize( scdr << eprosima::fastcdr::MemberId(0) << data.error_status() << eprosima::fastcdr::MemberId(1) << data.has_errors() - ; +; scdr.end_serialize_type(current_state); } @@ -178,13 +182,13 @@ eProsima_user_DllExport void deserialize( bool ret_value = true; switch (mid.id) { - case 0: - dcdr >> data.error_status(); - break; + case 0: + dcdr >> data.error_status(); + break; - case 1: - dcdr >> data.has_errors(); - break; + case 1: + dcdr >> data.has_errors(); + break; default: ret_value = false; @@ -198,11 +202,24 @@ void serialize_key( eprosima::fastcdr::Cdr& scdr, const MonitoringStatus& data) { + extern void serialize_key( + Cdr& scdr, + const MonitoringErrorStatus& data); + + + static_cast(scdr); static_cast(data); + serialize_key(scdr, data.error_status()); + + scdr << data.has_errors(); + } + + } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_MONITORINGSTATUSCDRAUX_IPP_ +#endif // FAST_DDS_GENERATED__MONITORINGSTATUSCDRAUX_IPP + diff --git a/ddspipe_core/include/ddspipe_core/types/monitoring/status/v1/MonitoringStatusPubSubTypes.h b/ddspipe_core/include/ddspipe_core/types/monitoring/status/MonitoringStatusPubSubTypes.hpp similarity index 60% rename from ddspipe_core/include/ddspipe_core/types/monitoring/status/v1/MonitoringStatusPubSubTypes.h rename to ddspipe_core/include/ddspipe_core/types/monitoring/status/MonitoringStatusPubSubTypes.hpp index 8d3c7fdd..acd5e220 100644 --- a/ddspipe_core/include/ddspipe_core/types/monitoring/status/v1/MonitoringStatusPubSubTypes.h +++ b/ddspipe_core/include/ddspipe_core/types/monitoring/status/MonitoringStatusPubSubTypes.hpp @@ -13,31 +13,29 @@ // limitations under the License. /*! - * @file MonitoringStatusPubSubTypes.h + * @file MonitoringStatusPubSubTypes.hpp * This header file contains the declaration of the serialization functions. * * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_MONITORINGSTATUS_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_MONITORINGSTATUS_PUBSUBTYPES_H_ +#ifndef FAST_DDS_GENERATED__MONITORINGSTATUS_PUBSUBTYPES_HPP +#define FAST_DDS_GENERATED__MONITORINGSTATUS_PUBSUBTYPES_HPP #include #include -#include -#include -#include +#include +#include +#include -#include +#include "MonitoringStatus.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated MonitoringStatus is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER - - +#endif // FASTDDS_GEN_API_VER /*! @@ -55,41 +53,36 @@ class MonitoringErrorStatusPubSubType : public eprosima::fastdds::dds::TopicData eProsima_user_DllExport ~MonitoringErrorStatusPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t& payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + eProsima_user_DllExport uint32_t calculate_serialized_size( + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + eProsima_user_DllExport bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport bool compute_key( + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -99,10 +92,6 @@ class MonitoringErrorStatusPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -123,12 +112,12 @@ class MonitoringErrorStatusPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; +private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; +}; /*! * @brief This class represents the TopicDataType of the type MonitoringStatus defined by the user in the IDL file. @@ -145,41 +134,36 @@ class MonitoringStatusPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport ~MonitoringStatusPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t& payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + eProsima_user_DllExport uint32_t calculate_serialized_size( + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + eProsima_user_DllExport bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport bool compute_key( + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -189,10 +173,6 @@ class MonitoringStatusPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -213,9 +193,12 @@ class MonitoringStatusPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; -#endif // _FAST_DDS_GENERATED_MONITORINGSTATUS_PUBSUBTYPES_H_ +#endif // FAST_DDS_GENERATED__MONITORINGSTATUS_PUBSUBTYPES_HPP + diff --git a/ddspipe_core/include/ddspipe_core/types/monitoring/status/MonitoringStatusTypeObjectSupport.hpp b/ddspipe_core/include/ddspipe_core/types/monitoring/status/MonitoringStatusTypeObjectSupport.hpp new file mode 100644 index 00000000..cfd3150c --- /dev/null +++ b/ddspipe_core/include/ddspipe_core/types/monitoring/status/MonitoringStatusTypeObjectSupport.hpp @@ -0,0 +1,68 @@ +// 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 MonitoringStatusTypeObjectSupport.hpp + * Header file containing the API required to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef FAST_DDS_GENERATED__MONITORINGSTATUS_TYPE_OBJECT_SUPPORT_HPP +#define FAST_DDS_GENERATED__MONITORINGSTATUS_TYPE_OBJECT_SUPPORT_HPP + +#include + + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +/** + * @brief Register MonitoringErrorStatus related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_MonitoringErrorStatus_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); +/** + * @brief Register MonitoringStatus related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_MonitoringStatus_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); + + +#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +#endif // FAST_DDS_GENERATED__MONITORINGSTATUS_TYPE_OBJECT_SUPPORT_HPP diff --git a/ddspipe_core/include/ddspipe_core/types/monitoring/status/v1/MonitoringStatus.h b/ddspipe_core/include/ddspipe_core/types/monitoring/status/v1/MonitoringStatus.h deleted file mode 100644 index 6b174087..00000000 --- a/ddspipe_core/include/ddspipe_core/types/monitoring/status/v1/MonitoringStatus.h +++ /dev/null @@ -1,396 +0,0 @@ -// 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 MonitoringStatus.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_MONITORINGSTATUS_H_ -#define _FAST_DDS_GENERATED_MONITORINGSTATUS_H_ - - -#include - -#include -#include -#include -#include -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(MONITORINGSTATUS_SOURCE) -#define MONITORINGSTATUS_DllAPI __declspec( dllexport ) -#else -#define MONITORINGSTATUS_DllAPI __declspec( dllimport ) -#endif // MONITORINGSTATUS_SOURCE -#else -#define MONITORINGSTATUS_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define MONITORINGSTATUS_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - - - - -/*! - * @brief This class represents the structure MonitoringErrorStatus defined by the user in the IDL file. - * @ingroup MonitoringStatus - */ -class MonitoringErrorStatus -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport MonitoringErrorStatus(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~MonitoringErrorStatus(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object MonitoringErrorStatus that will be copied. - */ - eProsima_user_DllExport MonitoringErrorStatus( - const MonitoringErrorStatus& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object MonitoringErrorStatus that will be copied. - */ - eProsima_user_DllExport MonitoringErrorStatus( - MonitoringErrorStatus&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object MonitoringErrorStatus that will be copied. - */ - eProsima_user_DllExport MonitoringErrorStatus& operator =( - const MonitoringErrorStatus& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object MonitoringErrorStatus that will be copied. - */ - eProsima_user_DllExport MonitoringErrorStatus& operator =( - MonitoringErrorStatus&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x MonitoringErrorStatus object to compare. - */ - eProsima_user_DllExport bool operator ==( - const MonitoringErrorStatus& x) const; - - /*! - * @brief Comparison operator. - * @param x MonitoringErrorStatus object to compare. - */ - eProsima_user_DllExport bool operator !=( - const MonitoringErrorStatus& x) const; - - /*! - * @brief This function sets a value in member type_mismatch - * @param _type_mismatch New value for member type_mismatch - */ - eProsima_user_DllExport void type_mismatch( - bool _type_mismatch); - - /*! - * @brief This function returns the value of member type_mismatch - * @return Value of member type_mismatch - */ - eProsima_user_DllExport bool type_mismatch() const; - - /*! - * @brief This function returns a reference to member type_mismatch - * @return Reference to member type_mismatch - */ - eProsima_user_DllExport bool& type_mismatch(); - - - /*! - * @brief This function sets a value in member qos_mismatch - * @param _qos_mismatch New value for member qos_mismatch - */ - eProsima_user_DllExport void qos_mismatch( - bool _qos_mismatch); - - /*! - * @brief This function returns the value of member qos_mismatch - * @return Value of member qos_mismatch - */ - eProsima_user_DllExport bool qos_mismatch() const; - - /*! - * @brief This function returns a reference to member qos_mismatch - * @return Reference to member qos_mismatch - */ - eProsima_user_DllExport bool& qos_mismatch(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const MonitoringErrorStatus& data, - size_t current_alignment = 0); - - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - -private: - - bool m_type_mismatch; - bool m_qos_mismatch; - -}; - - - -/*! - * @brief This class represents the structure MonitoringStatus defined by the user in the IDL file. - * @ingroup MonitoringStatus - */ -class MonitoringStatus -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport MonitoringStatus(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~MonitoringStatus(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object MonitoringStatus that will be copied. - */ - eProsima_user_DllExport MonitoringStatus( - const MonitoringStatus& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object MonitoringStatus that will be copied. - */ - eProsima_user_DllExport MonitoringStatus( - MonitoringStatus&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object MonitoringStatus that will be copied. - */ - eProsima_user_DllExport MonitoringStatus& operator =( - const MonitoringStatus& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object MonitoringStatus that will be copied. - */ - eProsima_user_DllExport MonitoringStatus& operator =( - MonitoringStatus&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x MonitoringStatus object to compare. - */ - eProsima_user_DllExport bool operator ==( - const MonitoringStatus& x) const; - - /*! - * @brief Comparison operator. - * @param x MonitoringStatus object to compare. - */ - eProsima_user_DllExport bool operator !=( - const MonitoringStatus& x) const; - - /*! - * @brief This function copies the value in member error_status - * @param _error_status New value to be copied in member error_status - */ - eProsima_user_DllExport void error_status( - const MonitoringErrorStatus& _error_status); - - /*! - * @brief This function moves the value in member error_status - * @param _error_status New value to be moved in member error_status - */ - eProsima_user_DllExport void error_status( - MonitoringErrorStatus&& _error_status); - - /*! - * @brief This function returns a constant reference to member error_status - * @return Constant reference to member error_status - */ - eProsima_user_DllExport const MonitoringErrorStatus& error_status() const; - - /*! - * @brief This function returns a reference to member error_status - * @return Reference to member error_status - */ - eProsima_user_DllExport MonitoringErrorStatus& error_status(); - - - /*! - * @brief This function sets a value in member has_errors - * @param _has_errors New value for member has_errors - */ - eProsima_user_DllExport void has_errors( - bool _has_errors); - - /*! - * @brief This function returns the value of member has_errors - * @return Value of member has_errors - */ - eProsima_user_DllExport bool has_errors() const; - - /*! - * @brief This function returns a reference to member has_errors - * @return Reference to member has_errors - */ - eProsima_user_DllExport bool& has_errors(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const MonitoringStatus& data, - size_t current_alignment = 0); - - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - -private: - - MonitoringErrorStatus m_error_status; - bool m_has_errors; - -}; - - -#endif // _FAST_DDS_GENERATED_MONITORINGSTATUS_H_ - - - diff --git a/ddspipe_core/include/ddspipe_core/types/monitoring/status/v1/MonitoringStatusCdrAux.ipp b/ddspipe_core/include/ddspipe_core/types/monitoring/status/v1/MonitoringStatusCdrAux.ipp deleted file mode 100644 index b21edd4a..00000000 --- a/ddspipe_core/include/ddspipe_core/types/monitoring/status/v1/MonitoringStatusCdrAux.ipp +++ /dev/null @@ -1,208 +0,0 @@ -// 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 MonitoringStatusCdrAux.ipp - * This source file contains some declarations of CDR related functions. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_MONITORINGSTATUSCDRAUX_IPP_ -#define _FAST_DDS_GENERATED_MONITORINGSTATUSCDRAUX_IPP_ - -#include - -#include -#include - - -#include -using namespace eprosima::fastcdr::exception; - -namespace eprosima { -namespace fastcdr { - - - -template<> -eProsima_user_DllExport size_t calculate_serialized_size( - eprosima::fastcdr::CdrSizeCalculator& calculator, - const MonitoringErrorStatus& data, - size_t& current_alignment) -{ - static_cast(data); - - eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); - size_t calculated_size {calculator.begin_calculate_type_serialized_size( - eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, - current_alignment)}; - - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.type_mismatch(), current_alignment); - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), - data.qos_mismatch(), current_alignment); - - - calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); - - return calculated_size; -} - -template<> -eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& scdr, - const MonitoringErrorStatus& data) -{ - eprosima::fastcdr::Cdr::state current_state(scdr); - scdr.begin_serialize_type(current_state, - eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR); - - scdr - << eprosima::fastcdr::MemberId(0) << data.type_mismatch() - << eprosima::fastcdr::MemberId(1) << data.qos_mismatch() - ; - scdr.end_serialize_type(current_state); -} - -template<> -eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr, - MonitoringErrorStatus& data) -{ - cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, - [&data](eprosima::fastcdr::Cdr& dcdr, const eprosima::fastcdr::MemberId& mid) -> bool - { - bool ret_value = true; - switch (mid.id) - { - case 0: - dcdr >> data.type_mismatch(); - break; - - case 1: - dcdr >> data.qos_mismatch(); - break; - - default: - ret_value = false; - break; - } - return ret_value; - }); -} - -void serialize_key( - eprosima::fastcdr::Cdr& scdr, - const MonitoringErrorStatus& data) -{ - static_cast(scdr); - static_cast(data); -} - -template<> -eProsima_user_DllExport size_t calculate_serialized_size( - eprosima::fastcdr::CdrSizeCalculator& calculator, - const MonitoringStatus& data, - size_t& current_alignment) -{ - static_cast(data); - - eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); - size_t calculated_size {calculator.begin_calculate_type_serialized_size( - eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, - current_alignment)}; - - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.error_status(), current_alignment); - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), - data.has_errors(), current_alignment); - - - calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); - - return calculated_size; -} - -template<> -eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& scdr, - const MonitoringStatus& data) -{ - eprosima::fastcdr::Cdr::state current_state(scdr); - scdr.begin_serialize_type(current_state, - eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR); - - scdr - << eprosima::fastcdr::MemberId(0) << data.error_status() - << eprosima::fastcdr::MemberId(1) << data.has_errors() - ; - scdr.end_serialize_type(current_state); -} - -template<> -eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr, - MonitoringStatus& data) -{ - cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, - [&data](eprosima::fastcdr::Cdr& dcdr, const eprosima::fastcdr::MemberId& mid) -> bool - { - bool ret_value = true; - switch (mid.id) - { - case 0: - dcdr >> data.error_status(); - break; - - case 1: - dcdr >> data.has_errors(); - break; - - default: - ret_value = false; - break; - } - return ret_value; - }); -} - -void serialize_key( - eprosima::fastcdr::Cdr& scdr, - const MonitoringStatus& data) -{ - static_cast(scdr); - static_cast(data); -} - -} // namespace fastcdr -} // namespace eprosima - -#endif // _FAST_DDS_GENERATED_MONITORINGSTATUSCDRAUX_IPP_ diff --git a/ddspipe_core/include/ddspipe_core/types/monitoring/status/v1/MonitoringStatusTypeObject.h b/ddspipe_core/include/ddspipe_core/types/monitoring/status/v1/MonitoringStatusTypeObject.h deleted file mode 100644 index 5d5795aa..00000000 --- a/ddspipe_core/include/ddspipe_core/types/monitoring/status/v1/MonitoringStatusTypeObject.h +++ /dev/null @@ -1,76 +0,0 @@ -// 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 MonitoringStatusTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_MONITORINGSTATUS_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_MONITORINGSTATUS_TYPE_OBJECT_H_ - - -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define eProsima_user_DllExport -#endif // if defined(_WIN32) - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(MonitoringStatus_SOURCE) -#define MonitoringStatus_DllAPI __declspec( dllexport ) -#else -#define MonitoringStatus_DllAPI __declspec( dllimport ) -#endif // MonitoringStatus_SOURCE -#else -#define MonitoringStatus_DllAPI -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define MonitoringStatus_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registerMonitoringStatusTypes(); - - - -eProsima_user_DllExport const TypeIdentifier* GetMonitoringErrorStatusIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMonitoringErrorStatusObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalMonitoringErrorStatusObject(); -eProsima_user_DllExport const TypeObject* GetCompleteMonitoringErrorStatusObject(); - - - -eProsima_user_DllExport const TypeIdentifier* GetMonitoringStatusIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMonitoringStatusObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalMonitoringStatusObject(); -eProsima_user_DllExport const TypeObject* GetCompleteMonitoringStatusObject(); - - -#endif // _FAST_DDS_GENERATED_MONITORINGSTATUS_TYPE_OBJECT_H_ \ No newline at end of file diff --git a/ddspipe_core/include/ddspipe_core/types/monitoring/status/v2/MonitoringStatusCdrAux.hpp b/ddspipe_core/include/ddspipe_core/types/monitoring/status/v2/MonitoringStatusCdrAux.hpp deleted file mode 100644 index 67bc022a..00000000 --- a/ddspipe_core/include/ddspipe_core/types/monitoring/status/v2/MonitoringStatusCdrAux.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// 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 MonitoringStatusCdrAux.hpp - * This source file contains some definitions of CDR related functions. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_MONITORINGSTATUSCDRAUX_HPP_ -#define _FAST_DDS_GENERATED_MONITORINGSTATUSCDRAUX_HPP_ - -#include - -constexpr uint32_t MonitoringErrorStatus_max_cdr_typesize {6UL}; -constexpr uint32_t MonitoringErrorStatus_max_key_cdr_typesize {0UL}; - -constexpr uint32_t MonitoringStatus_max_cdr_typesize {11UL}; -constexpr uint32_t MonitoringStatus_max_key_cdr_typesize {0UL}; - - -namespace eprosima { -namespace fastcdr { - -class Cdr; -class CdrSizeCalculator; - - - -eProsima_user_DllExport void serialize_key( - eprosima::fastcdr::Cdr& scdr, - const MonitoringErrorStatus& data); - - - -eProsima_user_DllExport void serialize_key( - eprosima::fastcdr::Cdr& scdr, - const MonitoringStatus& data); - - -} // namespace fastcdr -} // namespace eprosima - -#endif // _FAST_DDS_GENERATED_MONITORINGSTATUSCDRAUX_HPP_ diff --git a/ddspipe_core/include/ddspipe_core/types/monitoring/status/v2/MonitoringStatusPubSubTypes.h b/ddspipe_core/include/ddspipe_core/types/monitoring/status/v2/MonitoringStatusPubSubTypes.h deleted file mode 100644 index cfe9df31..00000000 --- a/ddspipe_core/include/ddspipe_core/types/monitoring/status/v2/MonitoringStatusPubSubTypes.h +++ /dev/null @@ -1,221 +0,0 @@ -// 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 MonitoringStatusPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#ifndef _FAST_DDS_GENERATED_MONITORINGSTATUS_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_MONITORINGSTATUS_PUBSUBTYPES_H_ - -#include -#include -#include -#include -#include - -#include - - -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) -#error \ - Generated MonitoringStatus is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER - - - - -/*! - * @brief This class represents the TopicDataType of the type MonitoringErrorStatus defined by the user in the IDL file. - * @ingroup MonitoringStatus - */ -class MonitoringErrorStatusPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef MonitoringErrorStatus type; - - eProsima_user_DllExport MonitoringErrorStatusPubSubType(); - - eProsima_user_DllExport ~MonitoringErrorStatusPubSubType() override; - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport void* createData() override; - - eProsima_user_DllExport void deleteData( - void* data) override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } - - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - static_cast(memory); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - - - -/*! - * @brief This class represents the TopicDataType of the type MonitoringStatus defined by the user in the IDL file. - * @ingroup MonitoringStatus - */ -class MonitoringStatusPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef MonitoringStatus type; - - eProsima_user_DllExport MonitoringStatusPubSubType(); - - eProsima_user_DllExport ~MonitoringStatusPubSubType() override; - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport void* createData() override; - - eProsima_user_DllExport void deleteData( - void* data) override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } - - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - static_cast(memory); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - -#endif // _FAST_DDS_GENERATED_MONITORINGSTATUS_PUBSUBTYPES_H_ diff --git a/ddspipe_core/include/ddspipe_core/types/monitoring/status/v2/MonitoringStatusTypeObject.h b/ddspipe_core/include/ddspipe_core/types/monitoring/status/v2/MonitoringStatusTypeObject.h deleted file mode 100644 index 5d5795aa..00000000 --- a/ddspipe_core/include/ddspipe_core/types/monitoring/status/v2/MonitoringStatusTypeObject.h +++ /dev/null @@ -1,76 +0,0 @@ -// 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 MonitoringStatusTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_MONITORINGSTATUS_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_MONITORINGSTATUS_TYPE_OBJECT_H_ - - -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define eProsima_user_DllExport -#endif // if defined(_WIN32) - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(MonitoringStatus_SOURCE) -#define MonitoringStatus_DllAPI __declspec( dllexport ) -#else -#define MonitoringStatus_DllAPI __declspec( dllimport ) -#endif // MonitoringStatus_SOURCE -#else -#define MonitoringStatus_DllAPI -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define MonitoringStatus_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registerMonitoringStatusTypes(); - - - -eProsima_user_DllExport const TypeIdentifier* GetMonitoringErrorStatusIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMonitoringErrorStatusObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalMonitoringErrorStatusObject(); -eProsima_user_DllExport const TypeObject* GetCompleteMonitoringErrorStatusObject(); - - - -eProsima_user_DllExport const TypeIdentifier* GetMonitoringStatusIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMonitoringStatusObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalMonitoringStatusObject(); -eProsima_user_DllExport const TypeObject* GetCompleteMonitoringStatusObject(); - - -#endif // _FAST_DDS_GENERATED_MONITORINGSTATUS_TYPE_OBJECT_H_ \ No newline at end of file diff --git a/ddspipe_core/include/ddspipe_core/types/monitoring/status/v2/MonitoringStatusv1.h b/ddspipe_core/include/ddspipe_core/types/monitoring/status/v2/MonitoringStatusv1.h deleted file mode 100644 index fcf2bd97..00000000 --- a/ddspipe_core/include/ddspipe_core/types/monitoring/status/v2/MonitoringStatusv1.h +++ /dev/null @@ -1,401 +0,0 @@ -// 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 MonitoringStatus.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#include - -#if FASTCDR_VERSION_MAJOR == 1 - -#ifndef _FAST_DDS_GENERATED_MONITORINGSTATUS_H_ -#define _FAST_DDS_GENERATED_MONITORINGSTATUS_H_ - - -#include - -#include -#include -#include -#include -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(MONITORINGSTATUS_SOURCE) -#define MONITORINGSTATUS_DllAPI __declspec( dllexport ) -#else -#define MONITORINGSTATUS_DllAPI __declspec( dllimport ) -#endif // MONITORINGSTATUS_SOURCE -#else -#define MONITORINGSTATUS_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define MONITORINGSTATUS_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - - - - -/*! - * @brief This class represents the structure MonitoringErrorStatus defined by the user in the IDL file. - * @ingroup MonitoringStatus - */ -class MonitoringErrorStatus -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport MonitoringErrorStatus(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~MonitoringErrorStatus(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object MonitoringErrorStatus that will be copied. - */ - eProsima_user_DllExport MonitoringErrorStatus( - const MonitoringErrorStatus& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object MonitoringErrorStatus that will be copied. - */ - eProsima_user_DllExport MonitoringErrorStatus( - MonitoringErrorStatus&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object MonitoringErrorStatus that will be copied. - */ - eProsima_user_DllExport MonitoringErrorStatus& operator =( - const MonitoringErrorStatus& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object MonitoringErrorStatus that will be copied. - */ - eProsima_user_DllExport MonitoringErrorStatus& operator =( - MonitoringErrorStatus&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x MonitoringErrorStatus object to compare. - */ - eProsima_user_DllExport bool operator ==( - const MonitoringErrorStatus& x) const; - - /*! - * @brief Comparison operator. - * @param x MonitoringErrorStatus object to compare. - */ - eProsima_user_DllExport bool operator !=( - const MonitoringErrorStatus& x) const; - - /*! - * @brief This function sets a value in member type_mismatch - * @param _type_mismatch New value for member type_mismatch - */ - eProsima_user_DllExport void type_mismatch( - bool _type_mismatch); - - /*! - * @brief This function returns the value of member type_mismatch - * @return Value of member type_mismatch - */ - eProsima_user_DllExport bool type_mismatch() const; - - /*! - * @brief This function returns a reference to member type_mismatch - * @return Reference to member type_mismatch - */ - eProsima_user_DllExport bool& type_mismatch(); - - - /*! - * @brief This function sets a value in member qos_mismatch - * @param _qos_mismatch New value for member qos_mismatch - */ - eProsima_user_DllExport void qos_mismatch( - bool _qos_mismatch); - - /*! - * @brief This function returns the value of member qos_mismatch - * @return Value of member qos_mismatch - */ - eProsima_user_DllExport bool qos_mismatch() const; - - /*! - * @brief This function returns a reference to member qos_mismatch - * @return Reference to member qos_mismatch - */ - eProsima_user_DllExport bool& qos_mismatch(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const MonitoringErrorStatus& data, - size_t current_alignment = 0); - - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - -private: - - bool m_type_mismatch; - bool m_qos_mismatch; - -}; - - - -/*! - * @brief This class represents the structure MonitoringStatus defined by the user in the IDL file. - * @ingroup MonitoringStatus - */ -class MonitoringStatus -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport MonitoringStatus(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~MonitoringStatus(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object MonitoringStatus that will be copied. - */ - eProsima_user_DllExport MonitoringStatus( - const MonitoringStatus& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object MonitoringStatus that will be copied. - */ - eProsima_user_DllExport MonitoringStatus( - MonitoringStatus&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object MonitoringStatus that will be copied. - */ - eProsima_user_DllExport MonitoringStatus& operator =( - const MonitoringStatus& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object MonitoringStatus that will be copied. - */ - eProsima_user_DllExport MonitoringStatus& operator =( - MonitoringStatus&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x MonitoringStatus object to compare. - */ - eProsima_user_DllExport bool operator ==( - const MonitoringStatus& x) const; - - /*! - * @brief Comparison operator. - * @param x MonitoringStatus object to compare. - */ - eProsima_user_DllExport bool operator !=( - const MonitoringStatus& x) const; - - /*! - * @brief This function copies the value in member error_status - * @param _error_status New value to be copied in member error_status - */ - eProsima_user_DllExport void error_status( - const MonitoringErrorStatus& _error_status); - - /*! - * @brief This function moves the value in member error_status - * @param _error_status New value to be moved in member error_status - */ - eProsima_user_DllExport void error_status( - MonitoringErrorStatus&& _error_status); - - /*! - * @brief This function returns a constant reference to member error_status - * @return Constant reference to member error_status - */ - eProsima_user_DllExport const MonitoringErrorStatus& error_status() const; - - /*! - * @brief This function returns a reference to member error_status - * @return Reference to member error_status - */ - eProsima_user_DllExport MonitoringErrorStatus& error_status(); - - - /*! - * @brief This function sets a value in member has_errors - * @param _has_errors New value for member has_errors - */ - eProsima_user_DllExport void has_errors( - bool _has_errors); - - /*! - * @brief This function returns the value of member has_errors - * @return Value of member has_errors - */ - eProsima_user_DllExport bool has_errors() const; - - /*! - * @brief This function returns a reference to member has_errors - * @return Reference to member has_errors - */ - eProsima_user_DllExport bool& has_errors(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const MonitoringStatus& data, - size_t current_alignment = 0); - - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - -private: - - MonitoringErrorStatus m_error_status; - bool m_has_errors; - -}; - - -#endif // _FAST_DDS_GENERATED_MONITORINGSTATUS_H_ - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddspipe_core/include/ddspipe_core/types/monitoring/topics/v2/MonitoringTopics.h b/ddspipe_core/include/ddspipe_core/types/monitoring/topics/MonitoringTopics.hpp similarity index 60% rename from ddspipe_core/include/ddspipe_core/types/monitoring/topics/v2/MonitoringTopics.h rename to ddspipe_core/include/ddspipe_core/types/monitoring/topics/MonitoringTopics.hpp index d5cb1b07..e20c5f27 100644 --- a/ddspipe_core/include/ddspipe_core/types/monitoring/topics/v2/MonitoringTopics.h +++ b/ddspipe_core/include/ddspipe_core/types/monitoring/topics/MonitoringTopics.hpp @@ -13,32 +13,21 @@ // limitations under the License. /*! - * @file MonitoringTopics.h + * @file MonitoringTopics.hpp * This header file contains the declaration of the described types in the IDL file. * * This file was generated by the tool fastddsgen. */ -#include -#include "MonitoringTopicsv1.h" +#ifndef FAST_DDS_GENERATED__MONITORINGTOPICS_HPP +#define FAST_DDS_GENERATED__MONITORINGTOPICS_HPP -#if FASTCDR_VERSION_MAJOR > 1 - -#ifndef _FAST_DDS_GENERATED_MONITORINGTOPICS_H_ -#define _FAST_DDS_GENERATED_MONITORINGTOPICS_H_ - -#include -#include #include -#include #include +#include #include #include -#include -#include - - #if defined(_WIN32) #if defined(EPROSIMA_USER_DLL_EXPORT) @@ -64,17 +53,6 @@ #define MONITORINGTOPICS_DllAPI #endif // _WIN32 -namespace eprosima { -namespace fastcdr { -class Cdr; -class CdrSizeCalculator; -} // namespace fastcdr -} // namespace eprosima - - - - - /*! * @brief This class represents the structure DdsTopicData defined by the user in the IDL file. * @ingroup MonitoringTopics @@ -86,80 +64,141 @@ class DdsTopicData /*! * @brief Default constructor. */ - eProsima_user_DllExport DdsTopicData(); + eProsima_user_DllExport DdsTopicData() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~DdsTopicData(); + eProsima_user_DllExport ~DdsTopicData() + { + } /*! * @brief Copy constructor. * @param x Reference to the object DdsTopicData that will be copied. */ eProsima_user_DllExport DdsTopicData( - const DdsTopicData& x); + const DdsTopicData& x) + { + m_participant_id = x.m_participant_id; + + m_msgs_lost = x.m_msgs_lost; + + m_msgs_received = x.m_msgs_received; + + m_msg_rx_rate = x.m_msg_rx_rate; + + } /*! * @brief Move constructor. * @param x Reference to the object DdsTopicData that will be copied. */ eProsima_user_DllExport DdsTopicData( - DdsTopicData&& x) noexcept; + DdsTopicData&& x) noexcept + { + m_participant_id = std::move(x.m_participant_id); + m_msgs_lost = x.m_msgs_lost; + m_msgs_received = x.m_msgs_received; + m_msg_rx_rate = x.m_msg_rx_rate; + } /*! * @brief Copy assignment. * @param x Reference to the object DdsTopicData that will be copied. */ eProsima_user_DllExport DdsTopicData& operator =( - const DdsTopicData& x); + const DdsTopicData& x) + { + + m_participant_id = x.m_participant_id; + + m_msgs_lost = x.m_msgs_lost; + + m_msgs_received = x.m_msgs_received; + + m_msg_rx_rate = x.m_msg_rx_rate; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object DdsTopicData that will be copied. */ eProsima_user_DllExport DdsTopicData& operator =( - DdsTopicData&& x) noexcept; + DdsTopicData&& x) noexcept + { + + m_participant_id = std::move(x.m_participant_id); + m_msgs_lost = x.m_msgs_lost; + m_msgs_received = x.m_msgs_received; + m_msg_rx_rate = x.m_msg_rx_rate; + return *this; + } /*! * @brief Comparison operator. * @param x DdsTopicData object to compare. */ eProsima_user_DllExport bool operator ==( - const DdsTopicData& x) const; + const DdsTopicData& x) const + { + return (m_participant_id == x.m_participant_id && + m_msgs_lost == x.m_msgs_lost && + m_msgs_received == x.m_msgs_received && + m_msg_rx_rate == x.m_msg_rx_rate); + } /*! * @brief Comparison operator. * @param x DdsTopicData object to compare. */ eProsima_user_DllExport bool operator !=( - const DdsTopicData& x) const; + const DdsTopicData& x) const + { + return !(*this == x); + } /*! * @brief This function copies the value in member participant_id * @param _participant_id New value to be copied in member participant_id */ eProsima_user_DllExport void participant_id( - const std::string& _participant_id); + const std::string& _participant_id) + { + m_participant_id = _participant_id; + } /*! * @brief This function moves the value in member participant_id * @param _participant_id New value to be moved in member participant_id */ eProsima_user_DllExport void participant_id( - std::string&& _participant_id); + std::string&& _participant_id) + { + m_participant_id = std::move(_participant_id); + } /*! * @brief This function returns a constant reference to member participant_id * @return Constant reference to member participant_id */ - eProsima_user_DllExport const std::string& participant_id() const; + eProsima_user_DllExport const std::string& participant_id() const + { + return m_participant_id; + } /*! * @brief This function returns a reference to member participant_id * @return Reference to member participant_id */ - eProsima_user_DllExport std::string& participant_id(); + eProsima_user_DllExport std::string& participant_id() + { + return m_participant_id; + } /*! @@ -167,19 +206,28 @@ class DdsTopicData * @param _msgs_lost New value for member msgs_lost */ eProsima_user_DllExport void msgs_lost( - uint32_t _msgs_lost); + uint32_t _msgs_lost) + { + m_msgs_lost = _msgs_lost; + } /*! * @brief This function returns the value of member msgs_lost * @return Value of member msgs_lost */ - eProsima_user_DllExport uint32_t msgs_lost() const; + eProsima_user_DllExport uint32_t msgs_lost() const + { + return m_msgs_lost; + } /*! * @brief This function returns a reference to member msgs_lost * @return Reference to member msgs_lost */ - eProsima_user_DllExport uint32_t& msgs_lost(); + eProsima_user_DllExport uint32_t& msgs_lost() + { + return m_msgs_lost; + } /*! @@ -187,19 +235,28 @@ class DdsTopicData * @param _msgs_received New value for member msgs_received */ eProsima_user_DllExport void msgs_received( - uint32_t _msgs_received); + uint32_t _msgs_received) + { + m_msgs_received = _msgs_received; + } /*! * @brief This function returns the value of member msgs_received * @return Value of member msgs_received */ - eProsima_user_DllExport uint32_t msgs_received() const; + eProsima_user_DllExport uint32_t msgs_received() const + { + return m_msgs_received; + } /*! * @brief This function returns a reference to member msgs_received * @return Reference to member msgs_received */ - eProsima_user_DllExport uint32_t& msgs_received(); + eProsima_user_DllExport uint32_t& msgs_received() + { + return m_msgs_received; + } /*! @@ -207,19 +264,30 @@ class DdsTopicData * @param _msg_rx_rate New value for member msg_rx_rate */ eProsima_user_DllExport void msg_rx_rate( - double _msg_rx_rate); + double _msg_rx_rate) + { + m_msg_rx_rate = _msg_rx_rate; + } /*! * @brief This function returns the value of member msg_rx_rate * @return Value of member msg_rx_rate */ - eProsima_user_DllExport double msg_rx_rate() const; + eProsima_user_DllExport double msg_rx_rate() const + { + return m_msg_rx_rate; + } /*! * @brief This function returns a reference to member msg_rx_rate * @return Reference to member msg_rx_rate */ - eProsima_user_DllExport double& msg_rx_rate(); + eProsima_user_DllExport double& msg_rx_rate() + { + return m_msg_rx_rate; + } + + private: @@ -229,10 +297,6 @@ class DdsTopicData double m_msg_rx_rate{0.0}; }; - - - - /*! * @brief This class represents the structure DdsTopic defined by the user in the IDL file. * @ingroup MonitoringTopics @@ -244,80 +308,155 @@ class DdsTopic /*! * @brief Default constructor. */ - eProsima_user_DllExport DdsTopic(); + eProsima_user_DllExport DdsTopic() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~DdsTopic(); + eProsima_user_DllExport ~DdsTopic() + { + } /*! * @brief Copy constructor. * @param x Reference to the object DdsTopic that will be copied. */ eProsima_user_DllExport DdsTopic( - const DdsTopic& x); + const DdsTopic& x) + { + m_name = x.m_name; + + m_type_name = x.m_type_name; + + m_type_discovered = x.m_type_discovered; + + m_type_mismatch = x.m_type_mismatch; + + m_qos_mismatch = x.m_qos_mismatch; + + m_data = x.m_data; + + } /*! * @brief Move constructor. * @param x Reference to the object DdsTopic that will be copied. */ eProsima_user_DllExport DdsTopic( - DdsTopic&& x) noexcept; + DdsTopic&& x) noexcept + { + m_name = std::move(x.m_name); + m_type_name = std::move(x.m_type_name); + m_type_discovered = x.m_type_discovered; + m_type_mismatch = x.m_type_mismatch; + m_qos_mismatch = x.m_qos_mismatch; + m_data = std::move(x.m_data); + } /*! * @brief Copy assignment. * @param x Reference to the object DdsTopic that will be copied. */ eProsima_user_DllExport DdsTopic& operator =( - const DdsTopic& x); + const DdsTopic& x) + { + + m_name = x.m_name; + + m_type_name = x.m_type_name; + + m_type_discovered = x.m_type_discovered; + + m_type_mismatch = x.m_type_mismatch; + + m_qos_mismatch = x.m_qos_mismatch; + + m_data = x.m_data; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object DdsTopic that will be copied. */ eProsima_user_DllExport DdsTopic& operator =( - DdsTopic&& x) noexcept; + DdsTopic&& x) noexcept + { + + m_name = std::move(x.m_name); + m_type_name = std::move(x.m_type_name); + m_type_discovered = x.m_type_discovered; + m_type_mismatch = x.m_type_mismatch; + m_qos_mismatch = x.m_qos_mismatch; + m_data = std::move(x.m_data); + return *this; + } /*! * @brief Comparison operator. * @param x DdsTopic object to compare. */ eProsima_user_DllExport bool operator ==( - const DdsTopic& x) const; + const DdsTopic& x) const + { + return (m_name == x.m_name && + m_type_name == x.m_type_name && + m_type_discovered == x.m_type_discovered && + m_type_mismatch == x.m_type_mismatch && + m_qos_mismatch == x.m_qos_mismatch && + m_data == x.m_data); + } /*! * @brief Comparison operator. * @param x DdsTopic object to compare. */ eProsima_user_DllExport bool operator !=( - const DdsTopic& x) const; + const DdsTopic& x) const + { + return !(*this == x); + } /*! * @brief This function copies the value in member name * @param _name New value to be copied in member name */ eProsima_user_DllExport void name( - const std::string& _name); + const std::string& _name) + { + m_name = _name; + } /*! * @brief This function moves the value in member name * @param _name New value to be moved in member name */ eProsima_user_DllExport void name( - std::string&& _name); + std::string&& _name) + { + m_name = std::move(_name); + } /*! * @brief This function returns a constant reference to member name * @return Constant reference to member name */ - eProsima_user_DllExport const std::string& name() const; + eProsima_user_DllExport const std::string& name() const + { + return m_name; + } /*! * @brief This function returns a reference to member name * @return Reference to member name */ - eProsima_user_DllExport std::string& name(); + eProsima_user_DllExport std::string& name() + { + return m_name; + } /*! @@ -325,26 +464,38 @@ class DdsTopic * @param _type_name New value to be copied in member type_name */ eProsima_user_DllExport void type_name( - const std::string& _type_name); + const std::string& _type_name) + { + m_type_name = _type_name; + } /*! * @brief This function moves the value in member type_name * @param _type_name New value to be moved in member type_name */ eProsima_user_DllExport void type_name( - std::string&& _type_name); + std::string&& _type_name) + { + m_type_name = std::move(_type_name); + } /*! * @brief This function returns a constant reference to member type_name * @return Constant reference to member type_name */ - eProsima_user_DllExport const std::string& type_name() const; + eProsima_user_DllExport const std::string& type_name() const + { + return m_type_name; + } /*! * @brief This function returns a reference to member type_name * @return Reference to member type_name */ - eProsima_user_DllExport std::string& type_name(); + eProsima_user_DllExport std::string& type_name() + { + return m_type_name; + } /*! @@ -352,19 +503,28 @@ class DdsTopic * @param _type_discovered New value for member type_discovered */ eProsima_user_DllExport void type_discovered( - bool _type_discovered); + bool _type_discovered) + { + m_type_discovered = _type_discovered; + } /*! * @brief This function returns the value of member type_discovered * @return Value of member type_discovered */ - eProsima_user_DllExport bool type_discovered() const; + eProsima_user_DllExport bool type_discovered() const + { + return m_type_discovered; + } /*! * @brief This function returns a reference to member type_discovered * @return Reference to member type_discovered */ - eProsima_user_DllExport bool& type_discovered(); + eProsima_user_DllExport bool& type_discovered() + { + return m_type_discovered; + } /*! @@ -372,19 +532,28 @@ class DdsTopic * @param _type_mismatch New value for member type_mismatch */ eProsima_user_DllExport void type_mismatch( - bool _type_mismatch); + bool _type_mismatch) + { + m_type_mismatch = _type_mismatch; + } /*! * @brief This function returns the value of member type_mismatch * @return Value of member type_mismatch */ - eProsima_user_DllExport bool type_mismatch() const; + eProsima_user_DllExport bool type_mismatch() const + { + return m_type_mismatch; + } /*! * @brief This function returns a reference to member type_mismatch * @return Reference to member type_mismatch */ - eProsima_user_DllExport bool& type_mismatch(); + eProsima_user_DllExport bool& type_mismatch() + { + return m_type_mismatch; + } /*! @@ -392,19 +561,28 @@ class DdsTopic * @param _qos_mismatch New value for member qos_mismatch */ eProsima_user_DllExport void qos_mismatch( - bool _qos_mismatch); + bool _qos_mismatch) + { + m_qos_mismatch = _qos_mismatch; + } /*! * @brief This function returns the value of member qos_mismatch * @return Value of member qos_mismatch */ - eProsima_user_DllExport bool qos_mismatch() const; + eProsima_user_DllExport bool qos_mismatch() const + { + return m_qos_mismatch; + } /*! * @brief This function returns a reference to member qos_mismatch * @return Reference to member qos_mismatch */ - eProsima_user_DllExport bool& qos_mismatch(); + eProsima_user_DllExport bool& qos_mismatch() + { + return m_qos_mismatch; + } /*! @@ -412,26 +590,40 @@ class DdsTopic * @param _data New value to be copied in member data */ eProsima_user_DllExport void data( - const std::vector& _data); + const std::vector& _data) + { + m_data = _data; + } /*! * @brief This function moves the value in member data * @param _data New value to be moved in member data */ eProsima_user_DllExport void data( - std::vector&& _data); + std::vector&& _data) + { + m_data = std::move(_data); + } /*! * @brief This function returns a constant reference to member data * @return Constant reference to member data */ - eProsima_user_DllExport const std::vector& data() const; + eProsima_user_DllExport const std::vector& data() const + { + return m_data; + } /*! * @brief This function returns a reference to member data * @return Reference to member data */ - eProsima_user_DllExport std::vector& data(); + eProsima_user_DllExport std::vector& data() + { + return m_data; + } + + private: @@ -443,10 +635,6 @@ class DdsTopic std::vector m_data; }; - - - - /*! * @brief This class represents the structure MonitoringTopics defined by the user in the IDL file. * @ingroup MonitoringTopics @@ -458,80 +646,122 @@ class MonitoringTopics /*! * @brief Default constructor. */ - eProsima_user_DllExport MonitoringTopics(); + eProsima_user_DllExport MonitoringTopics() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~MonitoringTopics(); + eProsima_user_DllExport ~MonitoringTopics() + { + } /*! * @brief Copy constructor. * @param x Reference to the object MonitoringTopics that will be copied. */ eProsima_user_DllExport MonitoringTopics( - const MonitoringTopics& x); + const MonitoringTopics& x) + { + m_topics = x.m_topics; + + } /*! * @brief Move constructor. * @param x Reference to the object MonitoringTopics that will be copied. */ eProsima_user_DllExport MonitoringTopics( - MonitoringTopics&& x) noexcept; + MonitoringTopics&& x) noexcept + { + m_topics = std::move(x.m_topics); + } /*! * @brief Copy assignment. * @param x Reference to the object MonitoringTopics that will be copied. */ eProsima_user_DllExport MonitoringTopics& operator =( - const MonitoringTopics& x); + const MonitoringTopics& x) + { + + m_topics = x.m_topics; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object MonitoringTopics that will be copied. */ eProsima_user_DllExport MonitoringTopics& operator =( - MonitoringTopics&& x) noexcept; + MonitoringTopics&& x) noexcept + { + + m_topics = std::move(x.m_topics); + return *this; + } /*! * @brief Comparison operator. * @param x MonitoringTopics object to compare. */ eProsima_user_DllExport bool operator ==( - const MonitoringTopics& x) const; + const MonitoringTopics& x) const + { + return (m_topics == x.m_topics); + } /*! * @brief Comparison operator. * @param x MonitoringTopics object to compare. */ eProsima_user_DllExport bool operator !=( - const MonitoringTopics& x) const; + const MonitoringTopics& x) const + { + return !(*this == x); + } /*! * @brief This function copies the value in member topics * @param _topics New value to be copied in member topics */ eProsima_user_DllExport void topics( - const std::vector& _topics); + const std::vector& _topics) + { + m_topics = _topics; + } /*! * @brief This function moves the value in member topics * @param _topics New value to be moved in member topics */ eProsima_user_DllExport void topics( - std::vector&& _topics); + std::vector&& _topics) + { + m_topics = std::move(_topics); + } /*! * @brief This function returns a constant reference to member topics * @return Constant reference to member topics */ - eProsima_user_DllExport const std::vector& topics() const; + eProsima_user_DllExport const std::vector& topics() const + { + return m_topics; + } /*! * @brief This function returns a reference to member topics * @return Reference to member topics */ - eProsima_user_DllExport std::vector& topics(); + eProsima_user_DllExport std::vector& topics() + { + return m_topics; + } + + private: @@ -539,8 +769,6 @@ class MonitoringTopics }; -#endif // _FAST_DDS_GENERATED_MONITORINGTOPICS_H_ - +#endif // _FAST_DDS_GENERATED_MONITORINGTOPICS_HPP_ -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddspipe_core/include/ddspipe_core/types/monitoring/topics/v1/MonitoringTopicsCdrAux.hpp b/ddspipe_core/include/ddspipe_core/types/monitoring/topics/MonitoringTopicsCdrAux.hpp similarity index 80% rename from ddspipe_core/include/ddspipe_core/types/monitoring/topics/v1/MonitoringTopicsCdrAux.hpp rename to ddspipe_core/include/ddspipe_core/types/monitoring/topics/MonitoringTopicsCdrAux.hpp index ca7db5ed..78583c88 100644 --- a/ddspipe_core/include/ddspipe_core/types/monitoring/topics/v1/MonitoringTopicsCdrAux.hpp +++ b/ddspipe_core/include/ddspipe_core/types/monitoring/topics/MonitoringTopicsCdrAux.hpp @@ -19,18 +19,18 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_MONITORINGTOPICSCDRAUX_HPP_ -#define _FAST_DDS_GENERATED_MONITORINGTOPICSCDRAUX_HPP_ +#ifndef FAST_DDS_GENERATED__MONITORINGTOPICSCDRAUX_HPP +#define FAST_DDS_GENERATED__MONITORINGTOPICSCDRAUX_HPP -#include +#include "MonitoringTopics.hpp" constexpr uint32_t DdsTopicData_max_cdr_typesize {280UL}; constexpr uint32_t DdsTopicData_max_key_cdr_typesize {0UL}; -constexpr uint32_t MonitoringTopics_max_cdr_typesize {2853616UL}; +constexpr uint32_t MonitoringTopics_max_cdr_typesize {12UL}; constexpr uint32_t MonitoringTopics_max_key_cdr_typesize {0UL}; -constexpr uint32_t DdsTopic_max_cdr_typesize {28536UL}; +constexpr uint32_t DdsTopic_max_cdr_typesize {536UL}; constexpr uint32_t DdsTopic_max_key_cdr_typesize {0UL}; @@ -40,24 +40,14 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const DdsTopicData& data); - - - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const DdsTopic& data); - - - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const MonitoringTopics& data); @@ -66,4 +56,5 @@ eProsima_user_DllExport void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_MONITORINGTOPICSCDRAUX_HPP_ +#endif // FAST_DDS_GENERATED__MONITORINGTOPICSCDRAUX_HPP + diff --git a/ddspipe_core/include/ddspipe_core/types/monitoring/topics/v1/MonitoringTopicsCdrAux.ipp b/ddspipe_core/include/ddspipe_core/types/monitoring/topics/MonitoringTopicsCdrAux.ipp similarity index 65% rename from ddspipe_core/include/ddspipe_core/types/monitoring/topics/v1/MonitoringTopicsCdrAux.ipp rename to ddspipe_core/include/ddspipe_core/types/monitoring/topics/MonitoringTopicsCdrAux.ipp index 0ad02f8a..58808316 100644 --- a/ddspipe_core/include/ddspipe_core/types/monitoring/topics/v1/MonitoringTopicsCdrAux.ipp +++ b/ddspipe_core/include/ddspipe_core/types/monitoring/topics/MonitoringTopicsCdrAux.ipp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_MONITORINGTOPICSCDRAUX_IPP_ -#define _FAST_DDS_GENERATED_MONITORINGTOPICSCDRAUX_IPP_ +#ifndef FAST_DDS_GENERATED__MONITORINGTOPICSCDRAUX_IPP +#define FAST_DDS_GENERATED__MONITORINGTOPICSCDRAUX_IPP #include "MonitoringTopicsCdrAux.hpp" @@ -34,8 +34,6 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { - - template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -52,17 +50,17 @@ eProsima_user_DllExport size_t calculate_serialized_size( current_alignment)}; - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.participant_id(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), + data.participant_id(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), - data.msgs_lost(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), + data.msgs_lost(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(2), - data.msgs_received(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(2), + data.msgs_received(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(3), - data.msg_rx_rate(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(3), + data.msg_rx_rate(), current_alignment); calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); @@ -86,7 +84,7 @@ eProsima_user_DllExport void serialize( << eprosima::fastcdr::MemberId(1) << data.msgs_lost() << eprosima::fastcdr::MemberId(2) << data.msgs_received() << eprosima::fastcdr::MemberId(3) << data.msg_rx_rate() - ; +; scdr.end_serialize_type(current_state); } @@ -103,21 +101,21 @@ eProsima_user_DllExport void deserialize( bool ret_value = true; switch (mid.id) { - case 0: - dcdr >> data.participant_id(); - break; + case 0: + dcdr >> data.participant_id(); + break; - case 1: - dcdr >> data.msgs_lost(); - break; + case 1: + dcdr >> data.msgs_lost(); + break; - case 2: - dcdr >> data.msgs_received(); - break; + case 2: + dcdr >> data.msgs_received(); + break; - case 3: - dcdr >> data.msg_rx_rate(); - break; + case 3: + dcdr >> data.msg_rx_rate(); + break; default: ret_value = false; @@ -131,10 +129,20 @@ void serialize_key( eprosima::fastcdr::Cdr& scdr, const DdsTopicData& data) { + static_cast(scdr); static_cast(data); + scdr << data.participant_id(); + + scdr << data.msgs_lost(); + + scdr << data.msgs_received(); + + scdr << data.msg_rx_rate(); + } + template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -151,23 +159,23 @@ eProsima_user_DllExport size_t calculate_serialized_size( current_alignment)}; - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.name(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), + data.name(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), - data.type_name(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), + data.type_name(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(2), - data.type_discovered(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(2), + data.type_discovered(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(3), - data.type_mismatch(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(3), + data.type_mismatch(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(4), - data.qos_mismatch(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(4), + data.qos_mismatch(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(5), - data.data(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(5), + data.data(), current_alignment); calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); @@ -193,7 +201,7 @@ eProsima_user_DllExport void serialize( << eprosima::fastcdr::MemberId(3) << data.type_mismatch() << eprosima::fastcdr::MemberId(4) << data.qos_mismatch() << eprosima::fastcdr::MemberId(5) << data.data() - ; +; scdr.end_serialize_type(current_state); } @@ -210,29 +218,29 @@ eProsima_user_DllExport void deserialize( bool ret_value = true; switch (mid.id) { - case 0: - dcdr >> data.name(); - break; + case 0: + dcdr >> data.name(); + break; - case 1: - dcdr >> data.type_name(); - break; + case 1: + dcdr >> data.type_name(); + break; - case 2: - dcdr >> data.type_discovered(); - break; + case 2: + dcdr >> data.type_discovered(); + break; - case 3: - dcdr >> data.type_mismatch(); - break; + case 3: + dcdr >> data.type_mismatch(); + break; - case 4: - dcdr >> data.qos_mismatch(); - break; + case 4: + dcdr >> data.qos_mismatch(); + break; - case 5: - dcdr >> data.data(); - break; + case 5: + dcdr >> data.data(); + break; default: ret_value = false; @@ -246,10 +254,24 @@ void serialize_key( eprosima::fastcdr::Cdr& scdr, const DdsTopic& data) { + static_cast(scdr); static_cast(data); + scdr << data.name(); + + scdr << data.type_name(); + + scdr << data.type_discovered(); + + scdr << data.type_mismatch(); + + scdr << data.qos_mismatch(); + + scdr << data.data(); + } + template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -266,8 +288,8 @@ eProsima_user_DllExport size_t calculate_serialized_size( current_alignment)}; - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.topics(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), + data.topics(), current_alignment); calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); @@ -288,7 +310,7 @@ eProsima_user_DllExport void serialize( scdr << eprosima::fastcdr::MemberId(0) << data.topics() - ; +; scdr.end_serialize_type(current_state); } @@ -305,9 +327,9 @@ eProsima_user_DllExport void deserialize( bool ret_value = true; switch (mid.id) { - case 0: - dcdr >> data.topics(); - break; + case 0: + dcdr >> data.topics(); + break; default: ret_value = false; @@ -321,11 +343,17 @@ void serialize_key( eprosima::fastcdr::Cdr& scdr, const MonitoringTopics& data) { + static_cast(scdr); static_cast(data); + scdr << data.topics(); + } + + } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_MONITORINGTOPICSCDRAUX_IPP_ +#endif // FAST_DDS_GENERATED__MONITORINGTOPICSCDRAUX_IPP + diff --git a/ddspipe_core/include/ddspipe_core/types/monitoring/topics/v2/MonitoringTopicsPubSubTypes.h b/ddspipe_core/include/ddspipe_core/types/monitoring/topics/MonitoringTopicsPubSubTypes.hpp similarity index 59% rename from ddspipe_core/include/ddspipe_core/types/monitoring/topics/v2/MonitoringTopicsPubSubTypes.h rename to ddspipe_core/include/ddspipe_core/types/monitoring/topics/MonitoringTopicsPubSubTypes.hpp index e1e842a4..e5065783 100644 --- a/ddspipe_core/include/ddspipe_core/types/monitoring/topics/v2/MonitoringTopicsPubSubTypes.h +++ b/ddspipe_core/include/ddspipe_core/types/monitoring/topics/MonitoringTopicsPubSubTypes.hpp @@ -13,31 +13,29 @@ // limitations under the License. /*! - * @file MonitoringTopicsPubSubTypes.h + * @file MonitoringTopicsPubSubTypes.hpp * This header file contains the declaration of the serialization functions. * * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_MONITORINGTOPICS_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_MONITORINGTOPICS_PUBSUBTYPES_H_ +#ifndef FAST_DDS_GENERATED__MONITORINGTOPICS_PUBSUBTYPES_HPP +#define FAST_DDS_GENERATED__MONITORINGTOPICS_PUBSUBTYPES_HPP #include #include -#include -#include -#include +#include +#include +#include -#include +#include "MonitoringTopics.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated MonitoringTopics is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER - - +#endif // FASTDDS_GEN_API_VER /*! @@ -55,41 +53,36 @@ class DdsTopicDataPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport ~DdsTopicDataPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t& payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + eProsima_user_DllExport uint32_t calculate_serialized_size( + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + eProsima_user_DllExport bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport bool compute_key( + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -99,10 +92,6 @@ class DdsTopicDataPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -123,14 +112,12 @@ class DdsTopicDataPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - - +private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; +}; /*! * @brief This class represents the TopicDataType of the type DdsTopic defined by the user in the IDL file. @@ -147,41 +134,36 @@ class DdsTopicPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport ~DdsTopicPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t& payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + eProsima_user_DllExport uint32_t calculate_serialized_size( + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + eProsima_user_DllExport bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport bool compute_key( + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -191,10 +173,6 @@ class DdsTopicPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -215,14 +193,12 @@ class DdsTopicPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - - +private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; +}; /*! * @brief This class represents the TopicDataType of the type MonitoringTopics defined by the user in the IDL file. @@ -239,41 +215,36 @@ class MonitoringTopicsPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport ~MonitoringTopicsPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t& payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + eProsima_user_DllExport uint32_t calculate_serialized_size( + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + eProsima_user_DllExport bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport bool compute_key( + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -283,10 +254,6 @@ class MonitoringTopicsPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override @@ -307,9 +274,12 @@ class MonitoringTopicsPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; -#endif // _FAST_DDS_GENERATED_MONITORINGTOPICS_PUBSUBTYPES_H_ +#endif // FAST_DDS_GENERATED__MONITORINGTOPICS_PUBSUBTYPES_HPP + diff --git a/ddspipe_core/include/ddspipe_core/types/monitoring/topics/MonitoringTopicsTypeObjectSupport.hpp b/ddspipe_core/include/ddspipe_core/types/monitoring/topics/MonitoringTopicsTypeObjectSupport.hpp new file mode 100644 index 00000000..9398dc0f --- /dev/null +++ b/ddspipe_core/include/ddspipe_core/types/monitoring/topics/MonitoringTopicsTypeObjectSupport.hpp @@ -0,0 +1,80 @@ +// 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 MonitoringTopicsTypeObjectSupport.hpp + * Header file containing the API required to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef FAST_DDS_GENERATED__MONITORINGTOPICS_TYPE_OBJECT_SUPPORT_HPP +#define FAST_DDS_GENERATED__MONITORINGTOPICS_TYPE_OBJECT_SUPPORT_HPP + +#include + + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +/** + * @brief Register DdsTopicData related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_DdsTopicData_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); +/** + * @brief Register DdsTopic related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_DdsTopic_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); +/** + * @brief Register MonitoringTopics related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_MonitoringTopics_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); + + +#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +#endif // FAST_DDS_GENERATED__MONITORINGTOPICS_TYPE_OBJECT_SUPPORT_HPP diff --git a/ddspipe_core/include/ddspipe_core/types/monitoring/topics/v1/MonitoringTopics.h b/ddspipe_core/include/ddspipe_core/types/monitoring/topics/v1/MonitoringTopics.h deleted file mode 100644 index c182594b..00000000 --- a/ddspipe_core/include/ddspipe_core/types/monitoring/topics/v1/MonitoringTopics.h +++ /dev/null @@ -1,689 +0,0 @@ -// 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 MonitoringTopics.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_MONITORINGTOPICS_H_ -#define _FAST_DDS_GENERATED_MONITORINGTOPICS_H_ - - -#include - -#include -#include -#include -#include -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(MONITORINGTOPICS_SOURCE) -#define MONITORINGTOPICS_DllAPI __declspec( dllexport ) -#else -#define MONITORINGTOPICS_DllAPI __declspec( dllimport ) -#endif // MONITORINGTOPICS_SOURCE -#else -#define MONITORINGTOPICS_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define MONITORINGTOPICS_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - - - - -/*! - * @brief This class represents the structure DdsTopicData defined by the user in the IDL file. - * @ingroup MonitoringTopics - */ -class DdsTopicData -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport DdsTopicData(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~DdsTopicData(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object DdsTopicData that will be copied. - */ - eProsima_user_DllExport DdsTopicData( - const DdsTopicData& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object DdsTopicData that will be copied. - */ - eProsima_user_DllExport DdsTopicData( - DdsTopicData&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object DdsTopicData that will be copied. - */ - eProsima_user_DllExport DdsTopicData& operator =( - const DdsTopicData& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object DdsTopicData that will be copied. - */ - eProsima_user_DllExport DdsTopicData& operator =( - DdsTopicData&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x DdsTopicData object to compare. - */ - eProsima_user_DllExport bool operator ==( - const DdsTopicData& x) const; - - /*! - * @brief Comparison operator. - * @param x DdsTopicData object to compare. - */ - eProsima_user_DllExport bool operator !=( - const DdsTopicData& x) const; - - /*! - * @brief This function copies the value in member participant_id - * @param _participant_id New value to be copied in member participant_id - */ - eProsima_user_DllExport void participant_id( - const std::string& _participant_id); - - /*! - * @brief This function moves the value in member participant_id - * @param _participant_id New value to be moved in member participant_id - */ - eProsima_user_DllExport void participant_id( - std::string&& _participant_id); - - /*! - * @brief This function returns a constant reference to member participant_id - * @return Constant reference to member participant_id - */ - eProsima_user_DllExport const std::string& participant_id() const; - - /*! - * @brief This function returns a reference to member participant_id - * @return Reference to member participant_id - */ - eProsima_user_DllExport std::string& participant_id(); - - - /*! - * @brief This function sets a value in member msgs_lost - * @param _msgs_lost New value for member msgs_lost - */ - eProsima_user_DllExport void msgs_lost( - uint32_t _msgs_lost); - - /*! - * @brief This function returns the value of member msgs_lost - * @return Value of member msgs_lost - */ - eProsima_user_DllExport uint32_t msgs_lost() const; - - /*! - * @brief This function returns a reference to member msgs_lost - * @return Reference to member msgs_lost - */ - eProsima_user_DllExport uint32_t& msgs_lost(); - - - /*! - * @brief This function sets a value in member msgs_received - * @param _msgs_received New value for member msgs_received - */ - eProsima_user_DllExport void msgs_received( - uint32_t _msgs_received); - - /*! - * @brief This function returns the value of member msgs_received - * @return Value of member msgs_received - */ - eProsima_user_DllExport uint32_t msgs_received() const; - - /*! - * @brief This function returns a reference to member msgs_received - * @return Reference to member msgs_received - */ - eProsima_user_DllExport uint32_t& msgs_received(); - - - /*! - * @brief This function sets a value in member msg_rx_rate - * @param _msg_rx_rate New value for member msg_rx_rate - */ - eProsima_user_DllExport void msg_rx_rate( - double _msg_rx_rate); - - /*! - * @brief This function returns the value of member msg_rx_rate - * @return Value of member msg_rx_rate - */ - eProsima_user_DllExport double msg_rx_rate() const; - - /*! - * @brief This function returns a reference to member msg_rx_rate - * @return Reference to member msg_rx_rate - */ - eProsima_user_DllExport double& msg_rx_rate(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const DdsTopicData& data, - size_t current_alignment = 0); - - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - -private: - - std::string m_participant_id; - uint32_t m_msgs_lost; - uint32_t m_msgs_received; - double m_msg_rx_rate; - -}; - - - - - -/*! - * @brief This class represents the structure DdsTopic defined by the user in the IDL file. - * @ingroup MonitoringTopics - */ -class DdsTopic -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport DdsTopic(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~DdsTopic(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object DdsTopic that will be copied. - */ - eProsima_user_DllExport DdsTopic( - const DdsTopic& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object DdsTopic that will be copied. - */ - eProsima_user_DllExport DdsTopic( - DdsTopic&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object DdsTopic that will be copied. - */ - eProsima_user_DllExport DdsTopic& operator =( - const DdsTopic& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object DdsTopic that will be copied. - */ - eProsima_user_DllExport DdsTopic& operator =( - DdsTopic&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x DdsTopic object to compare. - */ - eProsima_user_DllExport bool operator ==( - const DdsTopic& x) const; - - /*! - * @brief Comparison operator. - * @param x DdsTopic object to compare. - */ - eProsima_user_DllExport bool operator !=( - const DdsTopic& x) const; - - /*! - * @brief This function copies the value in member name - * @param _name New value to be copied in member name - */ - eProsima_user_DllExport void name( - const std::string& _name); - - /*! - * @brief This function moves the value in member name - * @param _name New value to be moved in member name - */ - eProsima_user_DllExport void name( - std::string&& _name); - - /*! - * @brief This function returns a constant reference to member name - * @return Constant reference to member name - */ - eProsima_user_DllExport const std::string& name() const; - - /*! - * @brief This function returns a reference to member name - * @return Reference to member name - */ - eProsima_user_DllExport std::string& name(); - - - /*! - * @brief This function copies the value in member type_name - * @param _type_name New value to be copied in member type_name - */ - eProsima_user_DllExport void type_name( - const std::string& _type_name); - - /*! - * @brief This function moves the value in member type_name - * @param _type_name New value to be moved in member type_name - */ - eProsima_user_DllExport void type_name( - std::string&& _type_name); - - /*! - * @brief This function returns a constant reference to member type_name - * @return Constant reference to member type_name - */ - eProsima_user_DllExport const std::string& type_name() const; - - /*! - * @brief This function returns a reference to member type_name - * @return Reference to member type_name - */ - eProsima_user_DllExport std::string& type_name(); - - - /*! - * @brief This function sets a value in member type_discovered - * @param _type_discovered New value for member type_discovered - */ - eProsima_user_DllExport void type_discovered( - bool _type_discovered); - - /*! - * @brief This function returns the value of member type_discovered - * @return Value of member type_discovered - */ - eProsima_user_DllExport bool type_discovered() const; - - /*! - * @brief This function returns a reference to member type_discovered - * @return Reference to member type_discovered - */ - eProsima_user_DllExport bool& type_discovered(); - - - /*! - * @brief This function sets a value in member type_mismatch - * @param _type_mismatch New value for member type_mismatch - */ - eProsima_user_DllExport void type_mismatch( - bool _type_mismatch); - - /*! - * @brief This function returns the value of member type_mismatch - * @return Value of member type_mismatch - */ - eProsima_user_DllExport bool type_mismatch() const; - - /*! - * @brief This function returns a reference to member type_mismatch - * @return Reference to member type_mismatch - */ - eProsima_user_DllExport bool& type_mismatch(); - - - /*! - * @brief This function sets a value in member qos_mismatch - * @param _qos_mismatch New value for member qos_mismatch - */ - eProsima_user_DllExport void qos_mismatch( - bool _qos_mismatch); - - /*! - * @brief This function returns the value of member qos_mismatch - * @return Value of member qos_mismatch - */ - eProsima_user_DllExport bool qos_mismatch() const; - - /*! - * @brief This function returns a reference to member qos_mismatch - * @return Reference to member qos_mismatch - */ - eProsima_user_DllExport bool& qos_mismatch(); - - - /*! - * @brief This function copies the value in member data - * @param _data New value to be copied in member data - */ - eProsima_user_DllExport void data( - const std::vector& _data); - - /*! - * @brief This function moves the value in member data - * @param _data New value to be moved in member data - */ - eProsima_user_DllExport void data( - std::vector&& _data); - - /*! - * @brief This function returns a constant reference to member data - * @return Constant reference to member data - */ - eProsima_user_DllExport const std::vector& data() const; - - /*! - * @brief This function returns a reference to member data - * @return Reference to member data - */ - eProsima_user_DllExport std::vector& data(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const DdsTopic& data, - size_t current_alignment = 0); - - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - -private: - - std::string m_name; - std::string m_type_name; - bool m_type_discovered; - bool m_type_mismatch; - bool m_qos_mismatch; - std::vector m_data; - -}; - - - - - -/*! - * @brief This class represents the structure MonitoringTopics defined by the user in the IDL file. - * @ingroup MonitoringTopics - */ -class MonitoringTopics -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport MonitoringTopics(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~MonitoringTopics(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object MonitoringTopics that will be copied. - */ - eProsima_user_DllExport MonitoringTopics( - const MonitoringTopics& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object MonitoringTopics that will be copied. - */ - eProsima_user_DllExport MonitoringTopics( - MonitoringTopics&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object MonitoringTopics that will be copied. - */ - eProsima_user_DllExport MonitoringTopics& operator =( - const MonitoringTopics& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object MonitoringTopics that will be copied. - */ - eProsima_user_DllExport MonitoringTopics& operator =( - MonitoringTopics&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x MonitoringTopics object to compare. - */ - eProsima_user_DllExport bool operator ==( - const MonitoringTopics& x) const; - - /*! - * @brief Comparison operator. - * @param x MonitoringTopics object to compare. - */ - eProsima_user_DllExport bool operator !=( - const MonitoringTopics& x) const; - - /*! - * @brief This function copies the value in member topics - * @param _topics New value to be copied in member topics - */ - eProsima_user_DllExport void topics( - const std::vector& _topics); - - /*! - * @brief This function moves the value in member topics - * @param _topics New value to be moved in member topics - */ - eProsima_user_DllExport void topics( - std::vector&& _topics); - - /*! - * @brief This function returns a constant reference to member topics - * @return Constant reference to member topics - */ - eProsima_user_DllExport const std::vector& topics() const; - - /*! - * @brief This function returns a reference to member topics - * @return Reference to member topics - */ - eProsima_user_DllExport std::vector& topics(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const MonitoringTopics& data, - size_t current_alignment = 0); - - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - -private: - - std::vector m_topics; - -}; - - -#endif // _FAST_DDS_GENERATED_MONITORINGTOPICS_H_ diff --git a/ddspipe_core/include/ddspipe_core/types/monitoring/topics/v1/MonitoringTopicsPubSubTypes.h b/ddspipe_core/include/ddspipe_core/types/monitoring/topics/v1/MonitoringTopicsPubSubTypes.h deleted file mode 100644 index a6c42429..00000000 --- a/ddspipe_core/include/ddspipe_core/types/monitoring/topics/v1/MonitoringTopicsPubSubTypes.h +++ /dev/null @@ -1,315 +0,0 @@ -// 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 MonitoringTopicsPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#ifndef _FAST_DDS_GENERATED_MONITORINGTOPICS_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_MONITORINGTOPICS_PUBSUBTYPES_H_ - -#include -#include -#include -#include -#include - -#include - - -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) -#error \ - Generated MonitoringTopics is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER - - - - -/*! - * @brief This class represents the TopicDataType of the type DdsTopicData defined by the user in the IDL file. - * @ingroup MonitoringTopics - */ -class DdsTopicDataPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef DdsTopicData type; - - eProsima_user_DllExport DdsTopicDataPubSubType(); - - eProsima_user_DllExport ~DdsTopicDataPubSubType() override; - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport void* createData() override; - - eProsima_user_DllExport void deleteData( - void* data) override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } - - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - static_cast(memory); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - - - - - -/*! - * @brief This class represents the TopicDataType of the type DdsTopic defined by the user in the IDL file. - * @ingroup MonitoringTopics - */ -class DdsTopicPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef DdsTopic type; - - eProsima_user_DllExport DdsTopicPubSubType(); - - eProsima_user_DllExport ~DdsTopicPubSubType() override; - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport void* createData() override; - - eProsima_user_DllExport void deleteData( - void* data) override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } - - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - static_cast(memory); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - - - - - -/*! - * @brief This class represents the TopicDataType of the type MonitoringTopics defined by the user in the IDL file. - * @ingroup MonitoringTopics - */ -class MonitoringTopicsPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef MonitoringTopics type; - - eProsima_user_DllExport MonitoringTopicsPubSubType(); - - eProsima_user_DllExport ~MonitoringTopicsPubSubType() override; - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport void* createData() override; - - eProsima_user_DllExport void deleteData( - void* data) override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } - - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - static_cast(memory); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - -#endif // _FAST_DDS_GENERATED_MONITORINGTOPICS_PUBSUBTYPES_H_ diff --git a/ddspipe_core/include/ddspipe_core/types/monitoring/topics/v1/MonitoringTopicsTypeObject.h b/ddspipe_core/include/ddspipe_core/types/monitoring/topics/v1/MonitoringTopicsTypeObject.h deleted file mode 100644 index 4d54975d..00000000 --- a/ddspipe_core/include/ddspipe_core/types/monitoring/topics/v1/MonitoringTopicsTypeObject.h +++ /dev/null @@ -1,89 +0,0 @@ -// 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 MonitoringTopicsTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_MONITORINGTOPICS_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_MONITORINGTOPICS_TYPE_OBJECT_H_ - - -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define eProsima_user_DllExport -#endif // if defined(_WIN32) - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(MonitoringTopics_SOURCE) -#define MonitoringTopics_DllAPI __declspec( dllexport ) -#else -#define MonitoringTopics_DllAPI __declspec( dllimport ) -#endif // MonitoringTopics_SOURCE -#else -#define MonitoringTopics_DllAPI -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define MonitoringTopics_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registerMonitoringTopicsTypes(); - - - -eProsima_user_DllExport const TypeIdentifier* GetDdsTopicDataIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetDdsTopicDataObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalDdsTopicDataObject(); -eProsima_user_DllExport const TypeObject* GetCompleteDdsTopicDataObject(); - - - - - -eProsima_user_DllExport const TypeIdentifier* GetDdsTopicIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetDdsTopicObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalDdsTopicObject(); -eProsima_user_DllExport const TypeObject* GetCompleteDdsTopicObject(); - - - - - -eProsima_user_DllExport const TypeIdentifier* GetMonitoringTopicsIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMonitoringTopicsObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalMonitoringTopicsObject(); -eProsima_user_DllExport const TypeObject* GetCompleteMonitoringTopicsObject(); - - -#endif // _FAST_DDS_GENERATED_MONITORINGTOPICS_TYPE_OBJECT_H_ \ No newline at end of file diff --git a/ddspipe_core/include/ddspipe_core/types/monitoring/topics/v2/MonitoringTopicsCdrAux.hpp b/ddspipe_core/include/ddspipe_core/types/monitoring/topics/v2/MonitoringTopicsCdrAux.hpp deleted file mode 100644 index aa0de5a1..00000000 --- a/ddspipe_core/include/ddspipe_core/types/monitoring/topics/v2/MonitoringTopicsCdrAux.hpp +++ /dev/null @@ -1,69 +0,0 @@ -// 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 MonitoringTopicsCdrAux.hpp - * This source file contains some definitions of CDR related functions. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_MONITORINGTOPICSCDRAUX_HPP_ -#define _FAST_DDS_GENERATED_MONITORINGTOPICSCDRAUX_HPP_ - -#include - -constexpr uint32_t DdsTopicData_max_cdr_typesize {280UL}; -constexpr uint32_t DdsTopicData_max_key_cdr_typesize {0UL}; - -constexpr uint32_t MonitoringTopics_max_cdr_typesize {2853616UL}; -constexpr uint32_t MonitoringTopics_max_key_cdr_typesize {0UL}; - -constexpr uint32_t DdsTopic_max_cdr_typesize {28536UL}; -constexpr uint32_t DdsTopic_max_key_cdr_typesize {0UL}; - - -namespace eprosima { -namespace fastcdr { - -class Cdr; -class CdrSizeCalculator; - - - -eProsima_user_DllExport void serialize_key( - eprosima::fastcdr::Cdr& scdr, - const DdsTopicData& data); - - - - - -eProsima_user_DllExport void serialize_key( - eprosima::fastcdr::Cdr& scdr, - const DdsTopic& data); - - - - - -eProsima_user_DllExport void serialize_key( - eprosima::fastcdr::Cdr& scdr, - const MonitoringTopics& data); - - -} // namespace fastcdr -} // namespace eprosima - -#endif // _FAST_DDS_GENERATED_MONITORINGTOPICSCDRAUX_HPP_ diff --git a/ddspipe_core/include/ddspipe_core/types/monitoring/topics/v2/MonitoringTopicsCdrAux.ipp b/ddspipe_core/include/ddspipe_core/types/monitoring/topics/v2/MonitoringTopicsCdrAux.ipp deleted file mode 100644 index 0ad02f8a..00000000 --- a/ddspipe_core/include/ddspipe_core/types/monitoring/topics/v2/MonitoringTopicsCdrAux.ipp +++ /dev/null @@ -1,331 +0,0 @@ -// 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 MonitoringTopicsCdrAux.ipp - * This source file contains some declarations of CDR related functions. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_MONITORINGTOPICSCDRAUX_IPP_ -#define _FAST_DDS_GENERATED_MONITORINGTOPICSCDRAUX_IPP_ - -#include "MonitoringTopicsCdrAux.hpp" - -#include -#include - - -#include -using namespace eprosima::fastcdr::exception; - -namespace eprosima { -namespace fastcdr { - - - -template<> -eProsima_user_DllExport size_t calculate_serialized_size( - eprosima::fastcdr::CdrSizeCalculator& calculator, - const DdsTopicData& data, - size_t& current_alignment) -{ - static_cast(data); - - eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); - size_t calculated_size {calculator.begin_calculate_type_serialized_size( - eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, - current_alignment)}; - - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.participant_id(), current_alignment); - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), - data.msgs_lost(), current_alignment); - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(2), - data.msgs_received(), current_alignment); - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(3), - data.msg_rx_rate(), current_alignment); - - - calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); - - return calculated_size; -} - -template<> -eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& scdr, - const DdsTopicData& data) -{ - eprosima::fastcdr::Cdr::state current_state(scdr); - scdr.begin_serialize_type(current_state, - eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR); - - scdr - << eprosima::fastcdr::MemberId(0) << data.participant_id() - << eprosima::fastcdr::MemberId(1) << data.msgs_lost() - << eprosima::fastcdr::MemberId(2) << data.msgs_received() - << eprosima::fastcdr::MemberId(3) << data.msg_rx_rate() - ; - scdr.end_serialize_type(current_state); -} - -template<> -eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr, - DdsTopicData& data) -{ - cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, - [&data](eprosima::fastcdr::Cdr& dcdr, const eprosima::fastcdr::MemberId& mid) -> bool - { - bool ret_value = true; - switch (mid.id) - { - case 0: - dcdr >> data.participant_id(); - break; - - case 1: - dcdr >> data.msgs_lost(); - break; - - case 2: - dcdr >> data.msgs_received(); - break; - - case 3: - dcdr >> data.msg_rx_rate(); - break; - - default: - ret_value = false; - break; - } - return ret_value; - }); -} - -void serialize_key( - eprosima::fastcdr::Cdr& scdr, - const DdsTopicData& data) -{ - static_cast(scdr); - static_cast(data); -} - -template<> -eProsima_user_DllExport size_t calculate_serialized_size( - eprosima::fastcdr::CdrSizeCalculator& calculator, - const DdsTopic& data, - size_t& current_alignment) -{ - static_cast(data); - - eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); - size_t calculated_size {calculator.begin_calculate_type_serialized_size( - eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, - current_alignment)}; - - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.name(), current_alignment); - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), - data.type_name(), current_alignment); - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(2), - data.type_discovered(), current_alignment); - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(3), - data.type_mismatch(), current_alignment); - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(4), - data.qos_mismatch(), current_alignment); - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(5), - data.data(), current_alignment); - - - calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); - - return calculated_size; -} - -template<> -eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& scdr, - const DdsTopic& data) -{ - eprosima::fastcdr::Cdr::state current_state(scdr); - scdr.begin_serialize_type(current_state, - eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR); - - scdr - << eprosima::fastcdr::MemberId(0) << data.name() - << eprosima::fastcdr::MemberId(1) << data.type_name() - << eprosima::fastcdr::MemberId(2) << data.type_discovered() - << eprosima::fastcdr::MemberId(3) << data.type_mismatch() - << eprosima::fastcdr::MemberId(4) << data.qos_mismatch() - << eprosima::fastcdr::MemberId(5) << data.data() - ; - scdr.end_serialize_type(current_state); -} - -template<> -eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr, - DdsTopic& data) -{ - cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, - [&data](eprosima::fastcdr::Cdr& dcdr, const eprosima::fastcdr::MemberId& mid) -> bool - { - bool ret_value = true; - switch (mid.id) - { - case 0: - dcdr >> data.name(); - break; - - case 1: - dcdr >> data.type_name(); - break; - - case 2: - dcdr >> data.type_discovered(); - break; - - case 3: - dcdr >> data.type_mismatch(); - break; - - case 4: - dcdr >> data.qos_mismatch(); - break; - - case 5: - dcdr >> data.data(); - break; - - default: - ret_value = false; - break; - } - return ret_value; - }); -} - -void serialize_key( - eprosima::fastcdr::Cdr& scdr, - const DdsTopic& data) -{ - static_cast(scdr); - static_cast(data); -} - -template<> -eProsima_user_DllExport size_t calculate_serialized_size( - eprosima::fastcdr::CdrSizeCalculator& calculator, - const MonitoringTopics& data, - size_t& current_alignment) -{ - static_cast(data); - - eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); - size_t calculated_size {calculator.begin_calculate_type_serialized_size( - eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, - current_alignment)}; - - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.topics(), current_alignment); - - - calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); - - return calculated_size; -} - -template<> -eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& scdr, - const MonitoringTopics& data) -{ - eprosima::fastcdr::Cdr::state current_state(scdr); - scdr.begin_serialize_type(current_state, - eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR); - - scdr - << eprosima::fastcdr::MemberId(0) << data.topics() - ; - scdr.end_serialize_type(current_state); -} - -template<> -eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr, - MonitoringTopics& data) -{ - cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, - [&data](eprosima::fastcdr::Cdr& dcdr, const eprosima::fastcdr::MemberId& mid) -> bool - { - bool ret_value = true; - switch (mid.id) - { - case 0: - dcdr >> data.topics(); - break; - - default: - ret_value = false; - break; - } - return ret_value; - }); -} - -void serialize_key( - eprosima::fastcdr::Cdr& scdr, - const MonitoringTopics& data) -{ - static_cast(scdr); - static_cast(data); -} - -} // namespace fastcdr -} // namespace eprosima - -#endif // _FAST_DDS_GENERATED_MONITORINGTOPICSCDRAUX_IPP_ diff --git a/ddspipe_core/include/ddspipe_core/types/monitoring/topics/v2/MonitoringTopicsTypeObject.h b/ddspipe_core/include/ddspipe_core/types/monitoring/topics/v2/MonitoringTopicsTypeObject.h deleted file mode 100644 index 4d54975d..00000000 --- a/ddspipe_core/include/ddspipe_core/types/monitoring/topics/v2/MonitoringTopicsTypeObject.h +++ /dev/null @@ -1,89 +0,0 @@ -// 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 MonitoringTopicsTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_MONITORINGTOPICS_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_MONITORINGTOPICS_TYPE_OBJECT_H_ - - -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define eProsima_user_DllExport -#endif // if defined(_WIN32) - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(MonitoringTopics_SOURCE) -#define MonitoringTopics_DllAPI __declspec( dllexport ) -#else -#define MonitoringTopics_DllAPI __declspec( dllimport ) -#endif // MonitoringTopics_SOURCE -#else -#define MonitoringTopics_DllAPI -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define MonitoringTopics_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registerMonitoringTopicsTypes(); - - - -eProsima_user_DllExport const TypeIdentifier* GetDdsTopicDataIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetDdsTopicDataObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalDdsTopicDataObject(); -eProsima_user_DllExport const TypeObject* GetCompleteDdsTopicDataObject(); - - - - - -eProsima_user_DllExport const TypeIdentifier* GetDdsTopicIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetDdsTopicObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalDdsTopicObject(); -eProsima_user_DllExport const TypeObject* GetCompleteDdsTopicObject(); - - - - - -eProsima_user_DllExport const TypeIdentifier* GetMonitoringTopicsIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMonitoringTopicsObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalMonitoringTopicsObject(); -eProsima_user_DllExport const TypeObject* GetCompleteMonitoringTopicsObject(); - - -#endif // _FAST_DDS_GENERATED_MONITORINGTOPICS_TYPE_OBJECT_H_ \ No newline at end of file diff --git a/ddspipe_core/include/ddspipe_core/types/monitoring/topics/v2/MonitoringTopicsv1.h b/ddspipe_core/include/ddspipe_core/types/monitoring/topics/v2/MonitoringTopicsv1.h deleted file mode 100644 index e55f37db..00000000 --- a/ddspipe_core/include/ddspipe_core/types/monitoring/topics/v2/MonitoringTopicsv1.h +++ /dev/null @@ -1,697 +0,0 @@ -// 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 MonitoringTopics.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#include - -#if FASTCDR_VERSION_MAJOR == 1 - -#ifndef _FAST_DDS_GENERATED_MONITORINGTOPICS_H_ -#define _FAST_DDS_GENERATED_MONITORINGTOPICS_H_ - - -#include - -#include -#include -#include -#include -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(MONITORINGTOPICS_SOURCE) -#define MONITORINGTOPICS_DllAPI __declspec( dllexport ) -#else -#define MONITORINGTOPICS_DllAPI __declspec( dllimport ) -#endif // MONITORINGTOPICS_SOURCE -#else -#define MONITORINGTOPICS_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define MONITORINGTOPICS_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - - - - -/*! - * @brief This class represents the structure DdsTopicData defined by the user in the IDL file. - * @ingroup MonitoringTopics - */ -class DdsTopicData -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport DdsTopicData(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~DdsTopicData(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object DdsTopicData that will be copied. - */ - eProsima_user_DllExport DdsTopicData( - const DdsTopicData& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object DdsTopicData that will be copied. - */ - eProsima_user_DllExport DdsTopicData( - DdsTopicData&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object DdsTopicData that will be copied. - */ - eProsima_user_DllExport DdsTopicData& operator =( - const DdsTopicData& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object DdsTopicData that will be copied. - */ - eProsima_user_DllExport DdsTopicData& operator =( - DdsTopicData&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x DdsTopicData object to compare. - */ - eProsima_user_DllExport bool operator ==( - const DdsTopicData& x) const; - - /*! - * @brief Comparison operator. - * @param x DdsTopicData object to compare. - */ - eProsima_user_DllExport bool operator !=( - const DdsTopicData& x) const; - - /*! - * @brief This function copies the value in member participant_id - * @param _participant_id New value to be copied in member participant_id - */ - eProsima_user_DllExport void participant_id( - const std::string& _participant_id); - - /*! - * @brief This function moves the value in member participant_id - * @param _participant_id New value to be moved in member participant_id - */ - eProsima_user_DllExport void participant_id( - std::string&& _participant_id); - - /*! - * @brief This function returns a constant reference to member participant_id - * @return Constant reference to member participant_id - */ - eProsima_user_DllExport const std::string& participant_id() const; - - /*! - * @brief This function returns a reference to member participant_id - * @return Reference to member participant_id - */ - eProsima_user_DllExport std::string& participant_id(); - - - /*! - * @brief This function sets a value in member msgs_lost - * @param _msgs_lost New value for member msgs_lost - */ - eProsima_user_DllExport void msgs_lost( - uint32_t _msgs_lost); - - /*! - * @brief This function returns the value of member msgs_lost - * @return Value of member msgs_lost - */ - eProsima_user_DllExport uint32_t msgs_lost() const; - - /*! - * @brief This function returns a reference to member msgs_lost - * @return Reference to member msgs_lost - */ - eProsima_user_DllExport uint32_t& msgs_lost(); - - - /*! - * @brief This function sets a value in member msgs_received - * @param _msgs_received New value for member msgs_received - */ - eProsima_user_DllExport void msgs_received( - uint32_t _msgs_received); - - /*! - * @brief This function returns the value of member msgs_received - * @return Value of member msgs_received - */ - eProsima_user_DllExport uint32_t msgs_received() const; - - /*! - * @brief This function returns a reference to member msgs_received - * @return Reference to member msgs_received - */ - eProsima_user_DllExport uint32_t& msgs_received(); - - - /*! - * @brief This function sets a value in member msg_rx_rate - * @param _msg_rx_rate New value for member msg_rx_rate - */ - eProsima_user_DllExport void msg_rx_rate( - double _msg_rx_rate); - - /*! - * @brief This function returns the value of member msg_rx_rate - * @return Value of member msg_rx_rate - */ - eProsima_user_DllExport double msg_rx_rate() const; - - /*! - * @brief This function returns a reference to member msg_rx_rate - * @return Reference to member msg_rx_rate - */ - eProsima_user_DllExport double& msg_rx_rate(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const DdsTopicData& data, - size_t current_alignment = 0); - - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - -private: - - std::string m_participant_id; - uint32_t m_msgs_lost; - uint32_t m_msgs_received; - double m_msg_rx_rate; - -}; - - - - - -/*! - * @brief This class represents the structure DdsTopic defined by the user in the IDL file. - * @ingroup MonitoringTopics - */ -class DdsTopic -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport DdsTopic(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~DdsTopic(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object DdsTopic that will be copied. - */ - eProsima_user_DllExport DdsTopic( - const DdsTopic& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object DdsTopic that will be copied. - */ - eProsima_user_DllExport DdsTopic( - DdsTopic&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object DdsTopic that will be copied. - */ - eProsima_user_DllExport DdsTopic& operator =( - const DdsTopic& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object DdsTopic that will be copied. - */ - eProsima_user_DllExport DdsTopic& operator =( - DdsTopic&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x DdsTopic object to compare. - */ - eProsima_user_DllExport bool operator ==( - const DdsTopic& x) const; - - /*! - * @brief Comparison operator. - * @param x DdsTopic object to compare. - */ - eProsima_user_DllExport bool operator !=( - const DdsTopic& x) const; - - /*! - * @brief This function copies the value in member name - * @param _name New value to be copied in member name - */ - eProsima_user_DllExport void name( - const std::string& _name); - - /*! - * @brief This function moves the value in member name - * @param _name New value to be moved in member name - */ - eProsima_user_DllExport void name( - std::string&& _name); - - /*! - * @brief This function returns a constant reference to member name - * @return Constant reference to member name - */ - eProsima_user_DllExport const std::string& name() const; - - /*! - * @brief This function returns a reference to member name - * @return Reference to member name - */ - eProsima_user_DllExport std::string& name(); - - - /*! - * @brief This function copies the value in member type_name - * @param _type_name New value to be copied in member type_name - */ - eProsima_user_DllExport void type_name( - const std::string& _type_name); - - /*! - * @brief This function moves the value in member type_name - * @param _type_name New value to be moved in member type_name - */ - eProsima_user_DllExport void type_name( - std::string&& _type_name); - - /*! - * @brief This function returns a constant reference to member type_name - * @return Constant reference to member type_name - */ - eProsima_user_DllExport const std::string& type_name() const; - - /*! - * @brief This function returns a reference to member type_name - * @return Reference to member type_name - */ - eProsima_user_DllExport std::string& type_name(); - - - /*! - * @brief This function sets a value in member type_discovered - * @param _type_discovered New value for member type_discovered - */ - eProsima_user_DllExport void type_discovered( - bool _type_discovered); - - /*! - * @brief This function returns the value of member type_discovered - * @return Value of member type_discovered - */ - eProsima_user_DllExport bool type_discovered() const; - - /*! - * @brief This function returns a reference to member type_discovered - * @return Reference to member type_discovered - */ - eProsima_user_DllExport bool& type_discovered(); - - - /*! - * @brief This function sets a value in member type_mismatch - * @param _type_mismatch New value for member type_mismatch - */ - eProsima_user_DllExport void type_mismatch( - bool _type_mismatch); - - /*! - * @brief This function returns the value of member type_mismatch - * @return Value of member type_mismatch - */ - eProsima_user_DllExport bool type_mismatch() const; - - /*! - * @brief This function returns a reference to member type_mismatch - * @return Reference to member type_mismatch - */ - eProsima_user_DllExport bool& type_mismatch(); - - - /*! - * @brief This function sets a value in member qos_mismatch - * @param _qos_mismatch New value for member qos_mismatch - */ - eProsima_user_DllExport void qos_mismatch( - bool _qos_mismatch); - - /*! - * @brief This function returns the value of member qos_mismatch - * @return Value of member qos_mismatch - */ - eProsima_user_DllExport bool qos_mismatch() const; - - /*! - * @brief This function returns a reference to member qos_mismatch - * @return Reference to member qos_mismatch - */ - eProsima_user_DllExport bool& qos_mismatch(); - - - /*! - * @brief This function copies the value in member data - * @param _data New value to be copied in member data - */ - eProsima_user_DllExport void data( - const std::vector& _data); - - /*! - * @brief This function moves the value in member data - * @param _data New value to be moved in member data - */ - eProsima_user_DllExport void data( - std::vector&& _data); - - /*! - * @brief This function returns a constant reference to member data - * @return Constant reference to member data - */ - eProsima_user_DllExport const std::vector& data() const; - - /*! - * @brief This function returns a reference to member data - * @return Reference to member data - */ - eProsima_user_DllExport std::vector& data(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const DdsTopic& data, - size_t current_alignment = 0); - - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - -private: - - std::string m_name; - std::string m_type_name; - bool m_type_discovered; - bool m_type_mismatch; - bool m_qos_mismatch; - std::vector m_data; - -}; - - - - - -/*! - * @brief This class represents the structure MonitoringTopics defined by the user in the IDL file. - * @ingroup MonitoringTopics - */ -class MonitoringTopics -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport MonitoringTopics(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~MonitoringTopics(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object MonitoringTopics that will be copied. - */ - eProsima_user_DllExport MonitoringTopics( - const MonitoringTopics& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object MonitoringTopics that will be copied. - */ - eProsima_user_DllExport MonitoringTopics( - MonitoringTopics&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object MonitoringTopics that will be copied. - */ - eProsima_user_DllExport MonitoringTopics& operator =( - const MonitoringTopics& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object MonitoringTopics that will be copied. - */ - eProsima_user_DllExport MonitoringTopics& operator =( - MonitoringTopics&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x MonitoringTopics object to compare. - */ - eProsima_user_DllExport bool operator ==( - const MonitoringTopics& x) const; - - /*! - * @brief Comparison operator. - * @param x MonitoringTopics object to compare. - */ - eProsima_user_DllExport bool operator !=( - const MonitoringTopics& x) const; - - /*! - * @brief This function copies the value in member topics - * @param _topics New value to be copied in member topics - */ - eProsima_user_DllExport void topics( - const std::vector& _topics); - - /*! - * @brief This function moves the value in member topics - * @param _topics New value to be moved in member topics - */ - eProsima_user_DllExport void topics( - std::vector&& _topics); - - /*! - * @brief This function returns a constant reference to member topics - * @return Constant reference to member topics - */ - eProsima_user_DllExport const std::vector& topics() const; - - /*! - * @brief This function returns a reference to member topics - * @return Reference to member topics - */ - eProsima_user_DllExport std::vector& topics(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const MonitoringTopics& data, - size_t current_alignment = 0); - - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - -private: - - std::vector m_topics; - -}; - - -#endif // _FAST_DDS_GENERATED_MONITORINGTOPICS_H_ - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddspipe_core/include/ddspipe_core/types/topic/dds/DdsTopic.hpp b/ddspipe_core/include/ddspipe_core/types/topic/dds/DdsTopic.hpp index a65b2caa..d90e2c1b 100644 --- a/ddspipe_core/include/ddspipe_core/types/topic/dds/DdsTopic.hpp +++ b/ddspipe_core/include/ddspipe_core/types/topic/dds/DdsTopic.hpp @@ -17,6 +17,8 @@ #include #include +#include + #include #include @@ -85,6 +87,9 @@ struct DdsTopic : public DistributedTopic //! Topic Type name std::string type_name{}; + + //! Type Identifiers: first one is complete and second one minimal + fastdds::dds::xtypes::TypeIdentifierPair type_identifiers; }; } /* namespace types */ diff --git a/ddspipe_core/package.xml b/ddspipe_core/package.xml index 3395a62f..f624d4f6 100644 --- a/ddspipe_core/package.xml +++ b/ddspipe_core/package.xml @@ -16,7 +16,7 @@ cmake - fastrtps + fastdds cpp_utils cmake_utils diff --git a/ddspipe_core/project_settings.cmake b/ddspipe_core/project_settings.cmake index 6d1817ca..0ca58963 100644 --- a/ddspipe_core/project_settings.cmake +++ b/ddspipe_core/project_settings.cmake @@ -26,11 +26,11 @@ set(MODULE_SUMMARY set(MODULE_FIND_PACKAGES fastcdr - fastrtps + fastdds cpp_utils ) -set(fastrtps_MINIMUM_VERSION "2.10") +set(fastdds_MINIMUM_VERSION "3.0.0") set(MODULE_DEPENDENCIES $<$:iphlpapi$Shlwapi> diff --git a/ddspipe_core/src/cpp/communication/dds/DdsBridge.cpp b/ddspipe_core/src/cpp/communication/dds/DdsBridge.cpp index 7625314d..d1247c95 100644 --- a/ddspipe_core/src/cpp/communication/dds/DdsBridge.cpp +++ b/ddspipe_core/src/cpp/communication/dds/DdsBridge.cpp @@ -67,7 +67,7 @@ void DdsBridge::enable() noexcept if (!enabled_) { - logInfo(DDSPIPE_DDSBRIDGE, "Enabling DdsBridge for topic " << topic_ << "."); + EPROSIMA_LOG_INFO(DDSPIPE_DDSBRIDGE, "Enabling DdsBridge for topic " << topic_ << "."); // ATTENTION: reference needed or it would copy Track for (auto& track_it : tracks_) @@ -85,7 +85,7 @@ void DdsBridge::disable() noexcept if (enabled_) { - logInfo(DDSPIPE_DDSBRIDGE, "Disabling DdsBridge for topic " << topic_ << "."); + EPROSIMA_LOG_INFO(DDSPIPE_DDSBRIDGE, "Disabling DdsBridge for topic " << topic_ << "."); // ATTENTION: reference needed or it would copy Track for (auto& track_it : tracks_) diff --git a/ddspipe_core/src/cpp/communication/dds/Track.cpp b/ddspipe_core/src/cpp/communication/dds/Track.cpp index 4d65c0a2..1f964a03 100644 --- a/ddspipe_core/src/cpp/communication/dds/Track.cpp +++ b/ddspipe_core/src/cpp/communication/dds/Track.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -86,7 +87,7 @@ void Track::enable() noexcept if (!enabled_) { - logInfo(DDSPIPE_TRACK, + EPROSIMA_LOG_INFO(DDSPIPE_TRACK, "Enabling Track " << reader_participant_id_ << " for topic " << topic_->serialize() << "."); enabled_ = true; @@ -116,7 +117,7 @@ void Track::disable() noexcept if (enabled_) { - logInfo(DDSPIPE_TRACK, + EPROSIMA_LOG_INFO(DDSPIPE_TRACK, "Disabling Track " << reader_participant_id_ << " for topic " << topic_->serialize() << "."); @@ -218,7 +219,7 @@ void Track::transmit_() noexcept // Get data received (send empty data to be created(allocated) in reader) std::unique_ptr data; - utils::ReturnCode ret = reader_->take(data); + auto ret = reader_->take(data); if (ret == utils::ReturnCode::RETCODE_NO_DATA) { @@ -238,11 +239,12 @@ void Track::transmit_() noexcept continue; } } - else if (!ret) + else if (ret != utils::ReturnCode::RETCODE_OK) { // Error reading data - logWarning(DDSPIPE_TRACK, "Error taking data in Track " << topic_->serialize() << ". Error code " << ret - << ". Skipping data and continue."); + EPROSIMA_LOG_WARNING(DDSPIPE_TRACK, + "Error taking data in Track " << topic_->serialize() << ". Error code " << ret + << ". Skipping data and continue."); continue; } @@ -259,9 +261,9 @@ void Track::transmit_() noexcept ret = writer_it.second->write(*data); - if (!ret) + if (ret != utils::ReturnCode::RETCODE_OK) { - logWarning( + EPROSIMA_LOG_WARNING( DDSPIPE_TRACK, "Error writting data in Track " << topic_->serialize() << " for writer " << writer_it.second.get() diff --git a/ddspipe_core/src/cpp/communication/rpc/RpcBridge.cpp b/ddspipe_core/src/cpp/communication/rpc/RpcBridge.cpp index 06a5720a..93927b76 100644 --- a/ddspipe_core/src/cpp/communication/rpc/RpcBridge.cpp +++ b/ddspipe_core/src/cpp/communication/rpc/RpcBridge.cpp @@ -59,7 +59,7 @@ RpcBridge::~RpcBridge() void RpcBridge::init_nts_() { - logInfo(DDSPIPE_RPCBRIDGE, "Creating endpoints in RpcBridge for service " << rpc_topic_ << "."); + EPROSIMA_LOG_INFO(DDSPIPE_RPCBRIDGE, "Creating endpoints in RpcBridge for service " << rpc_topic_ << "."); // TODO: remove and use every participant std::set ids = participants_->get_rtps_participants_ids(); @@ -113,7 +113,7 @@ void RpcBridge::enable() noexcept if (!enabled_ && servers_available_()) { - logInfo(DDSPIPE_RPCBRIDGE, "Enabling RpcBridge for service " << rpc_topic_ << "."); + EPROSIMA_LOG_INFO(DDSPIPE_RPCBRIDGE, "Enabling RpcBridge for service " << rpc_topic_ << "."); if (!init_) { @@ -123,7 +123,7 @@ void RpcBridge::enable() noexcept } catch (const utils::InitializationException& e) { - logError(DDSPIPE_RPCBRIDGE, + EPROSIMA_LOG_ERROR(DDSPIPE_RPCBRIDGE, "Error while creating endpoints in RpcBridge for service " << rpc_topic_ << ". Error code:" << e.what() << "."); return; @@ -163,7 +163,7 @@ void RpcBridge::disable() noexcept if (enabled_) { - logInfo(DDSPIPE_RPCBRIDGE, "Disabling RpcBridge for service " << rpc_topic_ << "."); + EPROSIMA_LOG_INFO(DDSPIPE_RPCBRIDGE, "Disabling RpcBridge for service " << rpc_topic_ << "."); enabled_ = false; @@ -271,7 +271,7 @@ void RpcBridge::transmit_( while (true) { { - std::lock_guard lock(reader->get_rtps_mutex()); + std::lock_guard lock(reader->get_rtps_mutex()); if (!enabled_ || !(reader->get_unread_count() > 0)) { @@ -300,11 +300,11 @@ void RpcBridge::transmit_( RpcPayloadData& rpc_data = dynamic_cast(*data); - // Will never return \c RETCODE_NO_DATA, otherwise would have finished before - if (!ret) + // Will never return \c NO_DATA, otherwise would have finished before + if (ret != utils::ReturnCode::RETCODE_OK) { // Error reading data - logWarning(DDSPIPE_RPCBRIDGE, + EPROSIMA_LOG_WARNING(DDSPIPE_RPCBRIDGE, "Error taking data at service Reader in topic " << reader->topic() << ". Error code " << ret << ". Skipping data and continue."); @@ -323,7 +323,7 @@ void RpcBridge::transmit_( if (reply_related_sample_identity == SampleIdentity::unknown()) { - logWarning(DDSPIPE_RPCBRIDGE, + EPROSIMA_LOG_WARNING(DDSPIPE_RPCBRIDGE, "RpcBridge for service " << rpc_topic_ << " received ill-formed request from remote endpoint " << rpc_data.source_guid << ". Ignoring..."); @@ -351,15 +351,15 @@ void RpcBridge::transmit_( ret = request_writers_[service_registry.first]->write(*data); - if (!ret) + if (ret != utils::ReturnCode::RETCODE_OK) { - logWarning(DDSPIPE_RPCBRIDGE, "Error writting request in RpcBridge for service " + EPROSIMA_LOG_WARNING(DDSPIPE_RPCBRIDGE, "Error writting request in RpcBridge for service " << rpc_topic_ << ". Error code " << ret << ". Skipping data for this writer and continue."); continue; } - eprosima::fastrtps::rtps::SequenceNumber_t sequence_number = + eprosima::fastdds::rtps::SequenceNumber_t sequence_number = rpc_data.sent_sequence_number; // Add entry to registry associated to the transmission of this request through this proxy client. service_registry.second->add( @@ -408,9 +408,9 @@ void RpcBridge::transmit_( ret = reply_writers_[registry_entry.first]->write(*data); - if (!ret) + if (ret != utils::ReturnCode::RETCODE_OK) { - logWarning(DDSPIPE_RPCBRIDGE, "Error writting reply in RpcBridge for service " + EPROSIMA_LOG_WARNING(DDSPIPE_RPCBRIDGE, "Error writting reply in RpcBridge for service " << rpc_topic_ << ". Error code " << ret << "."); } else diff --git a/ddspipe_core/src/cpp/communication/rpc/ServiceRegistry.cpp b/ddspipe_core/src/cpp/communication/rpc/ServiceRegistry.cpp index 1212d7ad..81f3a05f 100644 --- a/ddspipe_core/src/cpp/communication/rpc/ServiceRegistry.cpp +++ b/ddspipe_core/src/cpp/communication/rpc/ServiceRegistry.cpp @@ -68,7 +68,7 @@ void ServiceRegistry::add( if (registry_.count(idx)) { // Should never occur as each sequence number associated to a write operation is unique - logWarning(DDSPIPE_SERVICEREGISTRY, + EPROSIMA_LOG_WARNING(DDSPIPE_SERVICEREGISTRY, "ServiceRegistry for service " << topic_ << " in participant " << participant_id_ << " attempting to add entry with already present SequenceNumber."); return; diff --git a/ddspipe_core/src/cpp/configuration/RoutesConfiguration.cpp b/ddspipe_core/src/cpp/configuration/RoutesConfiguration.cpp index c9ee187c..59dae06e 100644 --- a/ddspipe_core/src/cpp/configuration/RoutesConfiguration.cpp +++ b/ddspipe_core/src/cpp/configuration/RoutesConfiguration.cpp @@ -87,7 +87,7 @@ bool RoutesConfiguration::is_valid( if (!src_in_dst && is_repeater) { // Warn the user repeater routes must be set manually - logWarning( + EPROSIMA_LOG_WARNING( DDSPIPE_ROUTES, "Source not found in destinations for repeater participant " << src_id << ". If willing to send data through this participant, add its name to the destinations (dst) list."); diff --git a/ddspipe_core/src/cpp/core/DdsPipe.cpp b/ddspipe_core/src/cpp/core/DdsPipe.cpp index 9de8d3b8..5a4eb898 100644 --- a/ddspipe_core/src/cpp/core/DdsPipe.cpp +++ b/ddspipe_core/src/cpp/core/DdsPipe.cpp @@ -14,11 +14,12 @@ #include -#include #include -#include #include +#include +#include #include +#include #include #include @@ -138,7 +139,7 @@ utils::ReturnCode DdsPipe::enable() noexcept { enabled_ = true; - logInfo(DDSPIPE, "Enabling DDS Pipe."); + EPROSIMA_LOG_INFO(DDSPIPE, "Enabling DDS Pipe."); activate_all_topics_nts_(); @@ -156,7 +157,7 @@ utils::ReturnCode DdsPipe::enable() noexcept } else { - logInfo(DDSPIPE, "Trying to enable an already enabled DDS Pipe."); + EPROSIMA_LOG_INFO(DDSPIPE, "Trying to enable an already enabled DDS Pipe."); return utils::ReturnCode::RETCODE_PRECONDITION_NOT_MET; } } @@ -169,7 +170,7 @@ utils::ReturnCode DdsPipe::disable() noexcept { enabled_ = false; - logInfo(DDSPIPE, "Disabling DDS Pipe."); + EPROSIMA_LOG_INFO(DDSPIPE, "Disabling DDS Pipe."); deactivate_all_topics_nts_(); @@ -177,7 +178,7 @@ utils::ReturnCode DdsPipe::disable() noexcept } else { - logInfo(DDSPIPE, "Trying to disable a disabled DDS Pipe."); + EPROSIMA_LOG_INFO(DDSPIPE, "Trying to disable a disabled DDS Pipe."); return utils::ReturnCode::RETCODE_PRECONDITION_NOT_MET; } } @@ -188,7 +189,7 @@ void DdsPipe::init_allowed_topics_() configuration_.allowlist, configuration_.blocklist); - logInfo(DDSROUTER, "DDS Router configured with allowed topics: " << *allowed_topics_); + EPROSIMA_LOG_INFO(DDSROUTER, "DDS Router configured with allowed topics: " << *allowed_topics_); } utils::ReturnCode DdsPipe::reload_allowed_topics_( @@ -413,7 +414,7 @@ void DdsPipe::init_bridges_nts_( void DdsPipe::discovered_topic_nts_( const utils::Heritable& topic) noexcept { - logInfo(DDSPIPE, "Discovered topic: " << topic << " by: " << topic->topic_discoverer() << "."); + EPROSIMA_LOG_INFO(DDSPIPE, "Discovered topic: " << topic << " by: " << topic->topic_discoverer() << "."); // Check if the bridge (and the topic) already exist. auto it_bridge = bridges_.find(topic); @@ -441,7 +442,7 @@ void DdsPipe::discovered_service_nts_( const ParticipantId& server_participant_id, const GuidPrefix& server_guid_prefix) noexcept { - logInfo(DDSPIPE, "Discovered service: " << topic << "."); + EPROSIMA_LOG_INFO(DDSPIPE, "Discovered service: " << topic << "."); auto it_bridge = rpc_bridges_.find(topic); @@ -472,7 +473,7 @@ void DdsPipe::removed_service_nts_( const ParticipantId& server_participant_id, const GuidPrefix& server_guid_prefix) noexcept { - logInfo(DDSPIPE, "Removed service: " << topic << "."); + EPROSIMA_LOG_INFO(DDSPIPE, "Removed service: " << topic << "."); auto it_bridge = rpc_bridges_.find(topic); @@ -486,7 +487,7 @@ void DdsPipe::create_new_bridge_nts_( const utils::Heritable& topic, bool enabled /*= false*/) noexcept { - logInfo(DDSPIPE, "Creating Bridge for topic: " << topic << "."); + EPROSIMA_LOG_INFO(DDSPIPE, "Creating Bridge for topic: " << topic << "."); try { @@ -511,7 +512,7 @@ void DdsPipe::create_new_bridge_nts_( } catch (const utils::InitializationException& e) { - logError(DDSPIPE, + EPROSIMA_LOG_ERROR(DDSPIPE, "Error creating Bridge for topic " << topic << ". Error code:" << e.what() << "."); } @@ -520,7 +521,7 @@ void DdsPipe::create_new_bridge_nts_( void DdsPipe::create_new_service_nts_( const RpcTopic& topic) noexcept { - logInfo(DDSPIPE, "Creating Service: " << topic << "."); + EPROSIMA_LOG_INFO(DDSPIPE, "Creating Service: " << topic << "."); // Endpoints not created until enabled for the first time, so no exception can be thrown rpc_bridges_[topic] = std::make_unique(topic, participants_database_, payload_pool_, thread_pool_); @@ -529,7 +530,7 @@ void DdsPipe::create_new_service_nts_( void DdsPipe::activate_topic_nts_( const utils::Heritable& topic) noexcept { - logInfo(DDSPIPE, "Activating topic: " << topic << "."); + EPROSIMA_LOG_INFO(DDSPIPE, "Activating topic: " << topic << "."); // Modify current_topics_ and set this topic as active current_topics_[topic] = true; @@ -552,7 +553,7 @@ void DdsPipe::activate_topic_nts_( void DdsPipe::deactivate_topic_nts_( const utils::Heritable& topic) noexcept { - logInfo(DDSPIPE, "Deactivating topic: " << topic << "."); + EPROSIMA_LOG_INFO(DDSPIPE, "Deactivating topic: " << topic << "."); // Modify current_topics_ and set this topic as not active current_topics_[topic] = false; diff --git a/ddspipe_core/src/cpp/dynamic/DiscoveryDatabase.cpp b/ddspipe_core/src/cpp/dynamic/DiscoveryDatabase.cpp index 456874e5..e2a463a9 100644 --- a/ddspipe_core/src/cpp/dynamic/DiscoveryDatabase.cpp +++ b/ddspipe_core/src/cpp/dynamic/DiscoveryDatabase.cpp @@ -123,7 +123,7 @@ bool DiscoveryDatabase::add_endpoint_( // If exists but inactive, modify entry it->second = new_endpoint; - logInfo(DDSPIPE_DISCOVERY_DATABASE, + EPROSIMA_LOG_INFO(DDSPIPE_DISCOVERY_DATABASE, "Modifying an already discovered (inactive) Endpoint " << new_endpoint << "."); return true; @@ -131,7 +131,8 @@ bool DiscoveryDatabase::add_endpoint_( } else { - logInfo(DDSPIPE_DISCOVERY_DATABASE, "Inserting a new discovered Endpoint " << new_endpoint << "."); + EPROSIMA_LOG_INFO(DDSPIPE_DISCOVERY_DATABASE, + "Inserting a new discovered Endpoint " << new_endpoint << "."); // Add it to the dictionary entities_.insert(std::pair(new_endpoint.guid, new_endpoint)); @@ -163,7 +164,7 @@ bool DiscoveryDatabase::update_endpoint_( } else { - logInfo(DDSPIPE_DISCOVERY_DATABASE, + EPROSIMA_LOG_INFO(DDSPIPE_DISCOVERY_DATABASE, "Modifying an already discovered Endpoint " << endpoint_to_update << "."); // Modify entry @@ -187,7 +188,7 @@ utils::ReturnCode DiscoveryDatabase::erase_endpoint_( { std::unique_lock lock(mutex_); - logInfo(DDSPIPE_DISCOVERY_DATABASE, "Erasing Endpoint " << endpoint_to_erase << "."); + EPROSIMA_LOG_INFO(DDSPIPE_DISCOVERY_DATABASE, "Erasing Endpoint " << endpoint_to_erase << "."); auto erased = entities_.erase(endpoint_to_erase.guid); @@ -308,7 +309,7 @@ void DiscoveryDatabase::queue_processing_thread_routine_() noexcept lock, [&] { - return !entities_to_process_.BothEmpty() || exit_.load(); + return !entities_to_process_.both_empty() || exit_.load(); }); if (exit_.load()) @@ -326,17 +327,17 @@ void DiscoveryDatabase::push_item_to_queue_( { { std::lock_guard lock(entities_to_process_cv_mutex_); - entities_to_process_.Push(item); + entities_to_process_.push(item); } entities_to_process_cv_.notify_one(); } void DiscoveryDatabase::process_queue_() noexcept { - entities_to_process_.Swap(); - while (!entities_to_process_.Empty()) + entities_to_process_.swap(); + while (!entities_to_process_.empty()) { - std::tuple queue_item = entities_to_process_.Front(); + std::tuple queue_item = entities_to_process_.front(); DatabaseOperation db_operation = std::get<0>(queue_item); Endpoint entity = std::get<1>(queue_item); try @@ -359,7 +360,7 @@ void DiscoveryDatabase::process_queue_() noexcept logDevError(DDSPIPE_DISCOVERY_DATABASE, "Error processing database operations queue:" << e.what() << "."); } - entities_to_process_.Pop(); + entities_to_process_.pop(); } } diff --git a/ddspipe_core/src/cpp/dynamic/ParticipantsDatabase.cpp b/ddspipe_core/src/cpp/dynamic/ParticipantsDatabase.cpp index 633c5944..4ec947b2 100644 --- a/ddspipe_core/src/cpp/dynamic/ParticipantsDatabase.cpp +++ b/ddspipe_core/src/cpp/dynamic/ParticipantsDatabase.cpp @@ -117,7 +117,7 @@ void ParticipantsDatabase::add_participant( } else { - logInfo(DDSPIPE_PARTICIPANT_DATABASE, "Inserting a new Participant " << id); + EPROSIMA_LOG_INFO(DDSPIPE_PARTICIPANT_DATABASE, "Inserting a new Participant " << id); } participants_[id] = participant; diff --git a/ddspipe_core/src/cpp/efficiency/payload/CopyPayloadPool.cpp b/ddspipe_core/src/cpp/efficiency/payload/CopyPayloadPool.cpp index a0a55e10..f67b29e0 100644 --- a/ddspipe_core/src/cpp/efficiency/payload/CopyPayloadPool.cpp +++ b/ddspipe_core/src/cpp/efficiency/payload/CopyPayloadPool.cpp @@ -24,26 +24,22 @@ namespace eprosima { namespace ddspipe { namespace core { +using namespace eprosima::fastdds::rtps; using namespace eprosima::ddspipe::core::types; bool CopyPayloadPool::get_payload( uint32_t size, - Payload& payload) + SerializedPayload_t& payload) { reserve_(size, payload); - payload.max_size = size; return true; } bool CopyPayloadPool::get_payload( - const Payload& src_payload, - IPayloadPool*& data_owner, - Payload& target_payload) + const SerializedPayload_t& src_payload, + SerializedPayload_t& target_payload) { - // As this class copies always the data, it does not matter the owner of this data - static_cast(data_owner); - if (!get_payload(src_payload.max_size, target_payload)) { return false; diff --git a/ddspipe_core/src/cpp/efficiency/payload/FastPayloadPool.cpp b/ddspipe_core/src/cpp/efficiency/payload/FastPayloadPool.cpp index 8a46072d..56af6efb 100644 --- a/ddspipe_core/src/cpp/efficiency/payload/FastPayloadPool.cpp +++ b/ddspipe_core/src/cpp/efficiency/payload/FastPayloadPool.cpp @@ -27,23 +27,23 @@ namespace eprosima { namespace ddspipe { namespace core { +using namespace eprosima::fastdds::rtps; using namespace eprosima::ddspipe::core::types; bool FastPayloadPool::get_payload( uint32_t size, - Payload& payload) + SerializedPayload_t& payload) { // Reserve new payload return reserve_(size, payload); } bool FastPayloadPool::get_payload( - const Payload& src_payload, - IPayloadPool*& data_owner, - Payload& target_payload) + const SerializedPayload_t& src_payload, + SerializedPayload_t& target_payload) { // If we are not the owner, create a new payload. Else, reference the existing one - if (data_owner != this) + if (src_payload.payload_owner != this) { logDebug(DDSPIPE_PAYLOADPOOL_FAST, "Copying payload with ptr: " << static_cast(src_payload.data) << "."); @@ -74,6 +74,7 @@ bool FastPayloadPool::get_payload( target_payload.data = src_payload.data; target_payload.length = src_payload.length; target_payload.max_size = src_payload.max_size; + target_payload.payload_owner = src_payload.payload_owner; } return true; } @@ -100,6 +101,7 @@ bool FastPayloadPool::release_payload( payload.length = 0; payload.max_size = 0; payload.data = nullptr; + payload.payload_owner = nullptr; payload.pos = 0; return true; @@ -107,7 +109,7 @@ bool FastPayloadPool::release_payload( bool FastPayloadPool::reserve_( uint32_t size, - types::Payload& payload) + SerializedPayload_t& payload) { if (size == 0) { @@ -123,8 +125,9 @@ bool FastPayloadPool::reserve_( MetaInfoType* reference_place = reinterpret_cast(memory_allocated); (*reference_place) = 1; - payload.data = reinterpret_cast(reference_place + 1); + payload.data = reinterpret_cast(reference_place + 1); payload.max_size = size; + payload.payload_owner = this; add_reserved_payload_(); @@ -134,7 +137,7 @@ bool FastPayloadPool::reserve_( } bool FastPayloadPool::release_( - types::Payload& payload) + SerializedPayload_t& payload) { logDebug(DDSPIPE_PAYLOADPOOL_FAST, "Releasing payload ptr: " << static_cast(payload.data) << "."); @@ -147,6 +150,7 @@ bool FastPayloadPool::release_( payload.length = 0; payload.max_size = 0; payload.data = nullptr; + payload.payload_owner = nullptr; payload.pos = 0; add_release_payload_(); diff --git a/ddspipe_core/src/cpp/efficiency/payload/MapPayloadPool.cpp b/ddspipe_core/src/cpp/efficiency/payload/MapPayloadPool.cpp index e6d13980..43c7ecb5 100644 --- a/ddspipe_core/src/cpp/efficiency/payload/MapPayloadPool.cpp +++ b/ddspipe_core/src/cpp/efficiency/payload/MapPayloadPool.cpp @@ -43,31 +43,27 @@ MapPayloadPool::~MapPayloadPool() bool MapPayloadPool::get_payload( uint32_t size, - Payload& payload) + eprosima::fastdds::rtps::SerializedPayload_t& payload) { // Reserve new payload if (!reserve_(size, payload)) { return false; } - payload.max_size = size; // Store this payload in map - { - std::lock_guard lock(reserved_payloads_mutex_); - reserved_payloads_[payload.data] = 1; - } + std::lock_guard lock(reserved_payloads_mutex_); + reserved_payloads_[payload.data] = 1; return true; } bool MapPayloadPool::get_payload( - const Payload& src_payload, - IPayloadPool*& data_owner, - Payload& target_payload) + const eprosima::fastdds::rtps::SerializedPayload_t& src_payload, + eprosima::fastdds::rtps::SerializedPayload_t& target_payload) { // If we are not the owner, create a new payload. Else, reference the existing one - if (data_owner != this) + if (src_payload.payload_owner != this) { // Store space for payload if (!get_payload(src_payload.max_size, target_payload)) @@ -87,7 +83,8 @@ bool MapPayloadPool::get_payload( auto payload_it = reserved_payloads_.find(src_payload.data); if (payload_it == reserved_payloads_.end()) { - logError(DDSPIPE_PAYLOADPOOL, "Payload ownership is this pool, but it is not reserved from here."); + EPROSIMA_LOG_ERROR(DDSPIPE_PAYLOADPOOL, + "Payload ownership is this pool, but it is not reserved from here."); throw utils::InconsistencyException("Payload ownership is this pool, but it is not reserved from here."); } @@ -98,12 +95,13 @@ bool MapPayloadPool::get_payload( target_payload.data = src_payload.data; target_payload.length = src_payload.length; target_payload.max_size = src_payload.max_size; + target_payload.payload_owner = this; } return true; } bool MapPayloadPool::release_payload( - Payload& payload) + eprosima::fastdds::rtps::SerializedPayload_t& payload) { std::lock_guard lock(reserved_payloads_mutex_); @@ -111,7 +109,7 @@ bool MapPayloadPool::release_payload( auto payload_it = reserved_payloads_.find(payload.data); if (payload_it == reserved_payloads_.end()) { - logError(DDSPIPE_PAYLOADPOOL, "Trying to release a payload from this pool that is not present."); + EPROSIMA_LOG_ERROR(DDSPIPE_PAYLOADPOOL, "Trying to release a payload from this pool that is not present."); throw utils::InconsistencyException("Trying to release a payload from this pool that is not present."); } @@ -134,6 +132,7 @@ bool MapPayloadPool::release_payload( payload.length = 0; payload.pos = 0; payload.max_size = 0; + payload.payload_owner = nullptr; payload.data = nullptr; return true; diff --git a/ddspipe_core/src/cpp/efficiency/payload/PayloadPool.cpp b/ddspipe_core/src/cpp/efficiency/payload/PayloadPool.cpp index 7eb71f73..4b767431 100644 --- a/ddspipe_core/src/cpp/efficiency/payload/PayloadPool.cpp +++ b/ddspipe_core/src/cpp/efficiency/payload/PayloadPool.cpp @@ -47,70 +47,11 @@ PayloadPool::~PayloadPool() } else { - logInfo(DDSPIPE_PAYLOADPOOL, + EPROSIMA_LOG_INFO(DDSPIPE_PAYLOADPOOL, "Removing PayloadPool correctly after reserve: " << reserve_count_ << " payloads."); } } -///// -// FAST DDS PART - -bool PayloadPool::get_payload( - uint32_t size, - eprosima::fastrtps::rtps::CacheChange_t& cache_change) -{ - if (get_payload(size, cache_change.serializedPayload)) - { - cache_change.payload_owner(this); - return true; - } - else - { - logDevError(DDSPIPE_PAYLOADPOOL, "Error occurred while creating payload.") - return false; - } -} - -bool PayloadPool::get_payload( - fastrtps::rtps::SerializedPayload_t& data, - IPayloadPool*& data_owner, - eprosima::fastrtps::rtps::CacheChange_t& cache_change) -{ - if (get_payload(data, data_owner, cache_change.serializedPayload)) - { - cache_change.payload_owner(this); - return true; - } - else - { - logDevError(DDSPIPE_PAYLOADPOOL, "Error occurred while referencing payload.") - return false; - } -} - -bool PayloadPool::release_payload( - fastrtps::rtps::CacheChange_t& cache_change) -{ - if (cache_change.payload_owner() == this) - { - if (release_payload(cache_change.serializedPayload)) - { - cache_change.payload_owner(nullptr); - return true; - } - else - { - logDevError(DDSPIPE_PAYLOADPOOL, "Error occurred while releasing payload.") - return false; - } - } - else - { - logError(DDSPIPE_PAYLOADPOOL, "Trying to remove a cache change in an incorrect pool.") - throw utils::InconsistencyException("Trying to remove a cache change in an incorrect pool."); - } -} - bool PayloadPool::is_clean() const noexcept { return reserve_count_ == release_count_; @@ -129,7 +70,7 @@ void PayloadPool::add_release_payload_() ++release_count_; if (release_count_ > reserve_count_) { - logError(DDSPIPE_PAYLOADPOOL, + EPROSIMA_LOG_ERROR(DDSPIPE_PAYLOADPOOL, "Inconsistent PayloadPool, releasing more payloads than reserved."); throw utils::InconsistencyException("Inconsistent PayloadPool, releasing more payloads than reserved."); } @@ -137,7 +78,7 @@ void PayloadPool::add_release_payload_() bool PayloadPool::reserve_( uint32_t size, - Payload& payload) + types::Payload& payload) { if (size == 0) { @@ -148,6 +89,9 @@ bool PayloadPool::reserve_( payload.reserve(size); + payload.max_size = size; + payload.payload_owner = this; + logDebug(DDSPIPE_PAYLOADPOOL, "Reserved payload ptr: " << payload.data << "."); add_reserved_payload_(); @@ -156,10 +100,11 @@ bool PayloadPool::reserve_( } bool PayloadPool::release_( - Payload& payload) + types::Payload& payload) { logDebug(DDSPIPE_PAYLOADPOOL, "Releasing payload ptr: " << payload.data << "."); + payload.payload_owner = nullptr; payload.empty(); if (payload.data != nullptr) @@ -167,6 +112,12 @@ bool PayloadPool::release_( return false; } + // Remove payload internal values + payload.length = 0; + payload.max_size = 0; + payload.data = nullptr; + payload.pos = 0; + add_release_payload_(); return true; diff --git a/ddspipe_core/src/cpp/efficiency/payload/PayloadPoolMediator.cpp b/ddspipe_core/src/cpp/efficiency/payload/PayloadPoolMediator.cpp index bc2cbef8..80ad90c4 100644 --- a/ddspipe_core/src/cpp/efficiency/payload/PayloadPoolMediator.cpp +++ b/ddspipe_core/src/cpp/efficiency/payload/PayloadPoolMediator.cpp @@ -33,7 +33,7 @@ PayloadPoolMediator::PayloadPoolMediator( { } -bool PayloadPoolMediator::write( +utils::ReturnCode PayloadPoolMediator::write( fastdds::dds::DataWriter* writer, types::RtpsPayloadData* data) { @@ -45,10 +45,10 @@ bool PayloadPoolMediator::write( return writer->write(data); } -bool PayloadPoolMediator::write( +utils::ReturnCode PayloadPoolMediator::write( fastdds::dds::DataWriter* writer, types::RtpsPayloadData* data, - fastrtps::rtps::WriteParams& params) + fastdds::rtps::WriteParams& params) { // Lock the mutex_ to ensure that the payload hasn't changed when we retrieve it in get_payload. std::lock_guard lock(mutex_); @@ -61,7 +61,7 @@ bool PayloadPoolMediator::write( utils::ReturnCode PayloadPoolMediator::write( fastdds::dds::DataWriter* writer, types::RtpsPayloadData* data, - const fastrtps::rtps::InstanceHandle_t& handle) + const fastdds::rtps::InstanceHandle_t& handle) { // Lock the mutex_ to ensure that the payload hasn't changed when we retrieve it in get_payload. std::lock_guard lock(mutex_); @@ -73,25 +73,22 @@ utils::ReturnCode PayloadPoolMediator::write( bool PayloadPoolMediator::get_payload( uint32_t size, - fastrtps::rtps::CacheChange_t& cache_change) + eprosima::fastdds::rtps::SerializedPayload_t& payload) { - fastrtps::rtps::IPayloadPool* payload_owner{payload_pool_.get()}; - - return get_payload(*payload_, payload_owner, cache_change); + return get_payload(*payload_, payload); } bool PayloadPoolMediator::get_payload( - fastrtps::rtps::SerializedPayload_t& data, - fastrtps::rtps::IPayloadPool*& data_owner, - fastrtps::rtps::CacheChange_t& cache_change) + const eprosima::fastdds::rtps::SerializedPayload_t& src_payload, + eprosima::fastdds::rtps::SerializedPayload_t& target_payload) { - return payload_pool_->get_payload(data, data_owner, cache_change); + return payload_pool_->get_payload(src_payload, target_payload); } bool PayloadPoolMediator::release_payload( - fastrtps::rtps::CacheChange_t& cache_change) + eprosima::fastdds::rtps::SerializedPayload_t& payload) { - return payload_pool_->release_payload(cache_change); + return payload_pool_->release_payload(payload); } } /* namespace core */ diff --git a/ddspipe_core/src/cpp/logging/DdsLogConsumer.cpp b/ddspipe_core/src/cpp/logging/DdsLogConsumer.cpp index c39c3689..8ebebed5 100644 --- a/ddspipe_core/src/cpp/logging/DdsLogConsumer.cpp +++ b/ddspipe_core/src/cpp/logging/DdsLogConsumer.cpp @@ -42,13 +42,6 @@ DdsLogConsumer::DdsLogConsumer( fastdds::dds::DomainParticipantQos pqos; pqos.name("DdsLogConsumerParticipant_" + std::to_string(configuration->publish.domain)); - if (configuration->publish.publish_type) - { - // Send the type information - pqos.wire_protocol().builtin.typelookup_config.use_client = false; - pqos.wire_protocol().builtin.typelookup_config.use_server = true; - } - participant_ = fastdds::dds::DomainParticipantFactory::get_instance()->create_participant( configuration->publish.domain, pqos); @@ -62,13 +55,6 @@ DdsLogConsumer::DdsLogConsumer( // Register the type fastdds::dds::TypeSupport type(new LogEntryPubSubType()); - if (configuration->publish.publish_type) - { - // Publish the type - registerLogEntryTypes(); - type->auto_fill_type_information(true); - } - type.register_type(participant_); // Create the publisher diff --git a/ddspipe_core/src/cpp/monitoring/Monitor.cpp b/ddspipe_core/src/cpp/monitoring/Monitor.cpp index b8e8bfda..ed9ad660 100644 --- a/ddspipe_core/src/cpp/monitoring/Monitor.cpp +++ b/ddspipe_core/src/cpp/monitoring/Monitor.cpp @@ -16,23 +16,15 @@ #include -#include #include #include +#include #include #include - -#if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) - #include - #include - #include - #include -#else - #include - #include - #include - #include -#endif // if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) +#include +#include +#include +#include namespace eprosima { namespace ddspipe { @@ -60,7 +52,7 @@ Monitor::~Monitor() void Monitor::monitor_status() { - logInfo(DDSPIPE_MONITOR, "MONITOR | Registering Status Monitor Producer."); + EPROSIMA_LOG_INFO(DDSPIPE_MONITOR, "MONITOR | Registering Status Monitor Producer."); // Register the Status Monitor Producer auto status_producer = ddspipe::core::StatusMonitorProducer::get_instance(); @@ -83,7 +75,7 @@ void Monitor::monitor_status() void Monitor::monitor_topics() { - logInfo(DDSPIPE_MONITOR, "MONITOR | Registering Topics Monitor Producer."); + EPROSIMA_LOG_INFO(DDSPIPE_MONITOR, "MONITOR | Registering Topics Monitor Producer."); // Register the Topics Monitor Producer auto topics_producer = ddspipe::core::TopicsMonitorProducer::get_instance(); @@ -107,7 +99,7 @@ void Monitor::monitor_topics() void Monitor::register_producer_( IMonitorProducer* producer) { - logInfo(DDSPIPE_MONITOR, "MONITOR | Registering producer " << producer << "."); + EPROSIMA_LOG_INFO(DDSPIPE_MONITOR, "MONITOR | Registering producer " << producer << "."); producers_.push_back(producer); diff --git a/ddspipe_core/src/cpp/monitoring/consumers/DdsMonitorParticipantRegistry.cpp b/ddspipe_core/src/cpp/monitoring/consumers/DdsMonitorParticipantRegistry.cpp index 6886e69b..ddbb08d9 100644 --- a/ddspipe_core/src/cpp/monitoring/consumers/DdsMonitorParticipantRegistry.cpp +++ b/ddspipe_core/src/cpp/monitoring/consumers/DdsMonitorParticipantRegistry.cpp @@ -36,7 +36,7 @@ DdsMonitorParticipantRegistry::~DdsMonitorParticipantRegistry() continue; } - logInfo(DDSPIPE_MONITOR, + EPROSIMA_LOG_INFO(DDSPIPE_MONITOR, "MONITOR | Deleting Participant " << participant.second << " on domain " << participant.first << "."); participant.second->delete_contained_entities(); @@ -58,7 +58,8 @@ fastdds::dds::DomainParticipant* DdsMonitorParticipantRegistry::get_participant( // The participant already exists. Use it. participant = participants_[domain]; - logInfo(DDSPIPE_MONITOR, "MONITOR | Reusing Participant " << participant << " on domain " << domain << ".") + EPROSIMA_LOG_INFO(DDSPIPE_MONITOR, + "MONITOR | Reusing Participant " << participant << " on domain " << domain << "."); } else { @@ -68,7 +69,8 @@ fastdds::dds::DomainParticipant* DdsMonitorParticipantRegistry::get_participant( participant = fastdds::dds::DomainParticipantFactory::get_instance()->create_participant(domain, pqos); - logInfo(DDSPIPE_MONITOR, "MONITOR | Created Participant " << participant << " on domain " << domain << "."); + EPROSIMA_LOG_INFO(DDSPIPE_MONITOR, + "MONITOR | Created Participant " << participant << " on domain " << domain << "."); if (participant == nullptr) { diff --git a/ddspipe_core/src/cpp/monitoring/producers/StatusMonitorProducer.cpp b/ddspipe_core/src/cpp/monitoring/producers/StatusMonitorProducer.cpp index b6ae6c14..fd868d26 100644 --- a/ddspipe_core/src/cpp/monitoring/producers/StatusMonitorProducer.cpp +++ b/ddspipe_core/src/cpp/monitoring/producers/StatusMonitorProducer.cpp @@ -32,7 +32,7 @@ void StatusMonitorProducer::init_instance( if (instance_ != nullptr) { - logWarning(DDSPIPE_MONITOR, "MONITOR | StatusMonitorProducer instance is already initialized."); + EPROSIMA_LOG_WARNING(DDSPIPE_MONITOR, "MONITOR | StatusMonitorProducer instance is already initialized."); return; } @@ -55,7 +55,7 @@ void StatusMonitorProducer::enable() { std::lock_guard lock(mutex_); - logInfo(DDSPIPE_MONITOR, "MONITOR | Enabling StatusMonitorProducer."); + EPROSIMA_LOG_INFO(DDSPIPE_MONITOR, "MONITOR | Enabling StatusMonitorProducer."); enabled_ = true; } @@ -64,7 +64,7 @@ void StatusMonitorProducer::disable() { std::lock_guard lock(mutex_); - logInfo(DDSPIPE_MONITOR, "MONITOR | Disabling StatusMonitorProducer."); + EPROSIMA_LOG_INFO(DDSPIPE_MONITOR, "MONITOR | Disabling StatusMonitorProducer."); enabled_ = false; } @@ -74,7 +74,7 @@ void StatusMonitorProducer::register_consumer( { if (!enabled_) { - logWarning(DDSPIPE_MONITOR, + EPROSIMA_LOG_WARNING(DDSPIPE_MONITOR, "MONITOR | Not registering consumer " << consumer->get_name() << " on StatusMonitorProducer" "since the StatusMonitorProducer is disabled."); @@ -83,7 +83,8 @@ void StatusMonitorProducer::register_consumer( std::lock_guard lock(mutex_); - logInfo(DDSPIPE_MONITOR, "MONITOR | Registering consumer " << consumer->get_name() << " on StatusMonitorProducer."); + EPROSIMA_LOG_INFO(DDSPIPE_MONITOR, + "MONITOR | Registering consumer " << consumer->get_name() << " on StatusMonitorProducer."); consumers_.push_back(std::move(consumer)); } @@ -92,7 +93,7 @@ void StatusMonitorProducer::clear_consumers() { std::lock_guard lock(mutex_); - logInfo(DDSPIPE_MONITOR, "MONITOR | Removing consumers from StatusMonitorProducer."); + EPROSIMA_LOG_INFO(DDSPIPE_MONITOR, "MONITOR | Removing consumers from StatusMonitorProducer."); consumers_.clear(); } @@ -147,7 +148,7 @@ void StatusMonitorProducer::clear_data() { std::lock_guard lock(mutex_); - logInfo(DDSPIPE_MONITOR, "MONITOR | Clearing StatusMonitorProducer data."); + EPROSIMA_LOG_INFO(DDSPIPE_MONITOR, "MONITOR | Clearing StatusMonitorProducer data."); error_status_.type_mismatch(false); error_status_.qos_mismatch(false); @@ -171,7 +172,7 @@ void StatusMonitorProducer::add_error_to_status( // 2. Simultaneous calls to add_error_to_status. std::lock_guard lock(mutex_); - logInfo(DDSPIPE_MONITOR, "MONITOR | Adding error " << error << " to status."); + EPROSIMA_LOG_INFO(DDSPIPE_MONITOR, "MONITOR | Adding error " << error << " to status."); if (error == "TYPE_MISMATCH") { @@ -187,7 +188,7 @@ void StatusMonitorProducer::add_error_to_status( void StatusMonitorProducer::produce_nts_() { - logInfo(DDSPIPE_MONITOR, "MONITOR | Producing MonitoringStatus."); + EPROSIMA_LOG_INFO(DDSPIPE_MONITOR, "MONITOR | Producing MonitoringStatus."); data_.error_status(error_status_); data_.has_errors(has_errors_); @@ -195,7 +196,7 @@ void StatusMonitorProducer::produce_nts_() void StatusMonitorProducer::consume_nts_() { - logInfo(DDSPIPE_MONITOR, "MONITOR | Consuming MonitoringStatus.") + EPROSIMA_LOG_INFO(DDSPIPE_MONITOR, "MONITOR | Consuming MonitoringStatus."); for (auto& consumer : consumers_) { diff --git a/ddspipe_core/src/cpp/monitoring/producers/TopicsMonitorProducer.cpp b/ddspipe_core/src/cpp/monitoring/producers/TopicsMonitorProducer.cpp index b9455de1..b03972ef 100644 --- a/ddspipe_core/src/cpp/monitoring/producers/TopicsMonitorProducer.cpp +++ b/ddspipe_core/src/cpp/monitoring/producers/TopicsMonitorProducer.cpp @@ -30,7 +30,7 @@ void TopicsMonitorProducer::init_instance( if (instance_ != nullptr) { - logWarning(DDSPIPE_MONITOR, "MONITOR | TopicsMonitorProducer instance is already initialized."); + EPROSIMA_LOG_WARNING(DDSPIPE_MONITOR, "MONITOR | TopicsMonitorProducer instance is already initialized."); return; } @@ -53,7 +53,7 @@ void TopicsMonitorProducer::enable() { std::lock_guard lock(mutex_); - logInfo(DDSPIPE_MONITOR, "MONITOR | Enabling TopicsMonitorProducer."); + EPROSIMA_LOG_INFO(DDSPIPE_MONITOR, "MONITOR | Enabling TopicsMonitorProducer."); enabled_ = true; } @@ -62,7 +62,7 @@ void TopicsMonitorProducer::disable() { std::lock_guard lock(mutex_); - logInfo(DDSPIPE_MONITOR, "MONITOR | Disabling TopicsMonitorProducer."); + EPROSIMA_LOG_INFO(DDSPIPE_MONITOR, "MONITOR | Disabling TopicsMonitorProducer."); enabled_ = false; } @@ -72,7 +72,7 @@ void TopicsMonitorProducer::register_consumer( { if (!enabled_) { - logWarning(DDSPIPE_MONITOR, + EPROSIMA_LOG_WARNING(DDSPIPE_MONITOR, "MONITOR | Not registering consumer " << consumer->get_name() << " on TopicsMonitorProducer" "since the TopicsMonitorProducer is disabled."); @@ -81,7 +81,8 @@ void TopicsMonitorProducer::register_consumer( std::lock_guard lock(mutex_); - logInfo(DDSPIPE_MONITOR, "MONITOR | Registering consumer " << consumer->get_name() << " on TopicsMonitorProducer."); + EPROSIMA_LOG_INFO(DDSPIPE_MONITOR, + "MONITOR | Registering consumer " << consumer->get_name() << " on TopicsMonitorProducer."); consumers_.push_back(std::move(consumer)); } @@ -90,7 +91,7 @@ void TopicsMonitorProducer::clear_consumers() { std::lock_guard lock(mutex_); - logInfo(DDSPIPE_MONITOR, "MONITOR | Removing all consumers from TopicsMonitorProducer."); + EPROSIMA_LOG_INFO(DDSPIPE_MONITOR, "MONITOR | Removing all consumers from TopicsMonitorProducer."); consumers_.clear(); } @@ -142,7 +143,7 @@ void TopicsMonitorProducer::clear_data() // Take the lock to prevent clearing the data while it's being saved std::lock_guard lock(mutex_); - logInfo(DDSPIPE_MONITOR, "MONITOR | Clearing the data."); + EPROSIMA_LOG_INFO(DDSPIPE_MONITOR, "MONITOR | Clearing the data."); topic_data_.clear(); participant_data_.clear(); @@ -167,7 +168,7 @@ void TopicsMonitorProducer::msgs_received( // 2. Simultaneous calls to msg_received. std::lock_guard lock(mutex_); - logInfo(DDSPIPE_MONITOR, "MONITOR | Received " << number_of_messages << " messages from Participant " << + EPROSIMA_LOG_INFO(DDSPIPE_MONITOR, "MONITOR | Received " << number_of_messages << " messages from Participant " << participant_id << " on Topic " << topic << "."); // Register the topic @@ -198,7 +199,7 @@ void TopicsMonitorProducer::msgs_lost( // 2. Simultaneous calls to msg_lost. std::lock_guard lock(mutex_); - logInfo(DDSPIPE_MONITOR, "MONITOR | Lost " << number_of_messages << " messages from Participant " << + EPROSIMA_LOG_INFO(DDSPIPE_MONITOR, "MONITOR | Lost " << number_of_messages << " messages from Participant " << participant_id << " on Topic " << topic << "."); // Register the topic @@ -227,7 +228,7 @@ void TopicsMonitorProducer::type_discovered( // 2. Simultaneous calls to msg_lost. std::lock_guard lock(mutex_); - logInfo(DDSPIPE_MONITOR, "MONITOR | Discovered type " << type_name << "."); + EPROSIMA_LOG_INFO(DDSPIPE_MONITOR, "MONITOR | Discovered type " << type_name << "."); types_discovered_[type_name] = true; } @@ -246,7 +247,7 @@ void TopicsMonitorProducer::type_mismatch( // 2. Simultaneous calls to msg_lost. std::lock_guard lock(mutex_); - logInfo(DDSPIPE_MONITOR, "MONITOR | Type mismatch on Topic " << topic << "."); + EPROSIMA_LOG_INFO(DDSPIPE_MONITOR, "MONITOR | Type mismatch on Topic " << topic << "."); // Register the topic topic_data_[topic].name(topic.m_topic_name); @@ -270,7 +271,7 @@ void TopicsMonitorProducer::qos_mismatch( // 2. Simultaneous calls to msg_lost. std::lock_guard lock(mutex_); - logInfo(DDSPIPE_MONITOR, "MONITOR | QoS mismatch on Topic " << topic << "."); + EPROSIMA_LOG_INFO(DDSPIPE_MONITOR, "MONITOR | QoS mismatch on Topic " << topic << "."); // Register the topic topic_data_[topic].name(topic.m_topic_name); @@ -282,7 +283,7 @@ void TopicsMonitorProducer::qos_mismatch( void TopicsMonitorProducer::produce_nts_() { - logInfo(DDSPIPE_MONITOR, "MONITOR | Producing MonitoringTopics."); + EPROSIMA_LOG_INFO(DDSPIPE_MONITOR, "MONITOR | Producing MonitoringTopics."); std::vector topics_data; @@ -317,7 +318,7 @@ void TopicsMonitorProducer::produce_nts_() void TopicsMonitorProducer::consume_nts_() { - logInfo(DDSPIPE_MONITOR, "MONITOR | Consuming MonitoringTopics."); + EPROSIMA_LOG_INFO(DDSPIPE_MONITOR, "MONITOR | Consuming MonitoringTopics."); for (auto& consumer : consumers_) { @@ -329,7 +330,7 @@ void TopicsMonitorProducer::consume_nts_() void TopicsMonitorProducer::reset_data_() { - logInfo(DDSPIPE_MONITOR, "MONITOR | Resetting the messages received and lost for the next period."); + EPROSIMA_LOG_INFO(DDSPIPE_MONITOR, "MONITOR | Resetting the messages received and lost for the next period."); // Reset the data for (auto& topic : participant_data_) diff --git a/ddspipe_core/src/cpp/testing/random_values.cpp b/ddspipe_core/src/cpp/testing/random_values.cpp index 4fb8d4b5..5e083c3e 100644 --- a/ddspipe_core/src/cpp/testing/random_values.cpp +++ b/ddspipe_core/src/cpp/testing/random_values.cpp @@ -25,7 +25,7 @@ Guid random_guid( unsigned int seed /* = 1 */) { Guid guid; - guid.entityId.value[3] = static_cast(seed); + guid.entityId.value[3] = static_cast(seed); guid.guidPrefix.value[0] = 0x01; guid.guidPrefix.value[1] = 0x0f; return guid; diff --git a/ddspipe_core/src/cpp/types/dds/Guid.cpp b/ddspipe_core/src/cpp/types/dds/Guid.cpp index 022b6db2..da1a4aa5 100644 --- a/ddspipe_core/src/cpp/types/dds/Guid.cpp +++ b/ddspipe_core/src/cpp/types/dds/Guid.cpp @@ -29,21 +29,21 @@ Guid::Guid( } Guid::Guid( - const fastrtps::rtps::GUID_t& x) + const fastdds::rtps::GUID_t& x) { guidPrefix = x.guidPrefix; entityId = x.entityId; } Guid::Guid( - fastrtps::rtps::GUID_t&& x) + fastdds::rtps::GUID_t&& x) { guidPrefix = std::move(x.guidPrefix); entityId = std::move(x.entityId); } Guid& Guid::operator = ( - const fastrtps::rtps::GUID_t& other) noexcept + const fastdds::rtps::GUID_t& other) noexcept { this->guidPrefix = other.guidPrefix; this->entityId = other.entityId; @@ -53,7 +53,7 @@ Guid& Guid::operator = ( bool Guid::is_valid() const noexcept { return guid_prefix().is_valid() && - entityId != eprosima::fastrtps::rtps::EntityId_t::unknown(); + entityId != eprosima::fastdds::rtps::EntityId_t::unknown(); } GuidPrefix Guid::guid_prefix() const noexcept @@ -69,7 +69,7 @@ Guid Guid::new_unique_guid() Guid new_guid; unsigned int numer = ++current_unique_value; unsigned int denom = 256; - for (unsigned int i = 0; i < fastrtps::rtps::EntityId_t::size; i++) + for (unsigned int i = 0; i < fastdds::rtps::EntityId_t::size; i++) { new_guid.entityId.value[i] = numer % denom; numer = static_cast(std::floor(numer / denom)); diff --git a/ddspipe_core/src/cpp/types/dds/GuidPrefix.cpp b/ddspipe_core/src/cpp/types/dds/GuidPrefix.cpp index 3e329652..1a7ffb95 100644 --- a/ddspipe_core/src/cpp/types/dds/GuidPrefix.cpp +++ b/ddspipe_core/src/cpp/types/dds/GuidPrefix.cpp @@ -41,7 +41,7 @@ GuidPrefix::GuidPrefix ( } GuidPrefix::GuidPrefix ( - bool ros /*= false*/, + bool ros, uint32_t id /*= 0*/) noexcept { if (ros) @@ -57,7 +57,7 @@ GuidPrefix::GuidPrefix ( // Modify depending on the seed // TODO : make available to modify for the whole guid prefix, so it is not truncated to 255 - value[2] = static_cast(id); + value[2] = static_cast(id); } GuidPrefix::GuidPrefix ( @@ -67,7 +67,7 @@ GuidPrefix::GuidPrefix ( } GuidPrefix& GuidPrefix::operator = ( - const fastrtps::rtps::GuidPrefix_t& other) noexcept + const fastdds::rtps::GuidPrefix_t& other) noexcept { for (unsigned int i = 0; i < this->size; ++i) { @@ -78,7 +78,7 @@ GuidPrefix& GuidPrefix::operator = ( bool GuidPrefix::is_valid() const noexcept { - return *this != eprosima::fastrtps::rtps::GuidPrefix_t::unknown(); + return *this != eprosima::fastdds::rtps::GuidPrefix_t::unknown(); } } /* namespace types */ diff --git a/ddspipe_core/src/cpp/types/dds/Payload.cpp b/ddspipe_core/src/cpp/types/dds/Payload.cpp index 8633ea16..aa208859 100644 --- a/ddspipe_core/src/cpp/types/dds/Payload.cpp +++ b/ddspipe_core/src/cpp/types/dds/Payload.cpp @@ -23,7 +23,7 @@ namespace types { std::ostream& operator <<( std::ostream& os, - const eprosima::fastrtps::rtps::octet& octet) + const eprosima::fastdds::rtps::octet& octet) { os << std::hex << std::setfill('0') << std::setw(2) << static_cast(octet) << std::dec; return os; diff --git a/ddspipe_core/src/cpp/types/dynamic_types/schema_idl.cpp b/ddspipe_core/src/cpp/types/dynamic_types/schema_idl.cpp deleted file mode 100644 index 3cae945e..00000000 --- a/ddspipe_core/src/cpp/types/dynamic_types/schema_idl.cpp +++ /dev/null @@ -1,454 +0,0 @@ -// Copyright 2023 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 schema_idl.cpp - */ - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -namespace eprosima { -namespace ddspipe { -namespace core { -namespace types { -namespace idl { - -constexpr const char* TYPE_OPENING = - "\n{\n"; - -constexpr const char* TYPE_CLOSURE = - "};\n"; - -constexpr const char* TAB_SEPARATOR = - " "; - -struct TreeNodeType -{ - TreeNodeType( - std::string member_name, - std::string type_kind_name, - fastrtps::types::DynamicType_ptr dynamic_type) - : member_name(member_name) - , type_kind_name(type_kind_name) - , dynamic_type(dynamic_type) - { - } - - std::string member_name; - std::string type_kind_name; - fastrtps::types::DynamicType_ptr dynamic_type; -}; - -// Forward declaration -std::string type_kind_to_str( - const fastrtps::types::DynamicType_ptr& type); - -fastrtps::types::DynamicType_ptr container_internal_type( - const fastrtps::types::DynamicType_ptr& dyn_type) -{ - return dyn_type->get_descriptor()->get_element_type(); -} - -std::vector container_size( - const fastrtps::types::DynamicType_ptr& dyn_type, - bool unidimensional = true) -{ - if (unidimensional) - { - return {dyn_type->get_descriptor()->get_total_bounds()}; - } - else - { - std::vector result; - for (unsigned int i = 0; i < dyn_type->get_descriptor()->get_bounds_size(); i++) - { - result.push_back(dyn_type->get_descriptor()->get_bounds(i)); - } - return result; - } -} - -std::vector> get_members_sorted( - const fastrtps::types::DynamicType_ptr& dyn_type) -{ - std::vector> result; - - std::map members; - dyn_type->get_all_members(members); - - for (const auto& member : members) - { - result.emplace_back( - std::make_pair( - member.second->get_name(), - member.second->get_descriptor()->get_type())); - } - return result; -} - -std::string array_kind_to_str( - const fastrtps::types::DynamicType_ptr& dyn_type) -{ - auto internal_type = container_internal_type(dyn_type); - auto this_array_size = container_size(dyn_type); - - std::stringstream ss; - ss << type_kind_to_str(internal_type); - - for (const auto& bound : this_array_size) - { - ss << "[" << bound << "]"; - } - - return ss.str(); -} - -std::string sequence_kind_to_str( - const fastrtps::types::DynamicType_ptr& dyn_type) -{ - auto internal_type = container_internal_type(dyn_type); - auto this_sequence_size = container_size(dyn_type); - - std::stringstream ss; - ss << "sequence<" << type_kind_to_str(internal_type); - - for (const auto& bound : this_sequence_size) - { - if (bound != fastrtps::types::BOUND_UNLIMITED) - { - ss << ", " << bound; - } - } - ss << ">"; - - return ss.str(); -} - -std::string map_kind_to_str( - const fastrtps::types::DynamicType_ptr& dyn_type) -{ - std::stringstream ss; - - auto key_type = dyn_type->get_descriptor()->get_key_element_type(); - auto value_type = dyn_type->get_descriptor()->get_element_type(); - ss << "map<" << type_kind_to_str(key_type) << ", " << type_kind_to_str(value_type) << ">"; - - return ss.str(); -} - -std::string type_kind_to_str( - const fastrtps::types::DynamicType_ptr& dyn_type) -{ - switch (dyn_type->get_kind()) - { - case fastrtps::types::TK_BOOLEAN: - return "boolean"; - - case fastrtps::types::TK_BYTE: - return "octet"; - - case fastrtps::types::TK_INT16: - return "short"; - - case fastrtps::types::TK_INT32: - return "long"; - - case fastrtps::types::TK_INT64: - return "long long"; - - case fastrtps::types::TK_UINT16: - return "unsigned short"; - - case fastrtps::types::TK_UINT32: - return "unsigned long"; - - case fastrtps::types::TK_UINT64: - return "unsigned long long"; - - case fastrtps::types::TK_FLOAT32: - return "float"; - - case fastrtps::types::TK_FLOAT64: - return "double"; - - case fastrtps::types::TK_FLOAT128: - return "long double"; - - case fastrtps::types::TK_CHAR8: - return "char"; - - case fastrtps::types::TK_CHAR16: - return "wchar"; - - case fastrtps::types::TK_STRING8: - return "string"; - - case fastrtps::types::TK_STRING16: - return "wstring"; - - case fastrtps::types::TK_ARRAY: - return array_kind_to_str(dyn_type); - - case fastrtps::types::TK_SEQUENCE: - return sequence_kind_to_str(dyn_type); - - case fastrtps::types::TK_MAP: - return map_kind_to_str(dyn_type); - - case fastrtps::types::TK_STRUCTURE: - case fastrtps::types::TK_ENUM: - case fastrtps::types::TK_UNION: - return dyn_type->get_name(); - - case fastrtps::types::TK_BITSET: - case fastrtps::types::TK_BITMASK: - case fastrtps::types::TK_NONE: - throw utils::UnsupportedException( - STR_ENTRY << "Type " << dyn_type->get_name() << " is not supported."); - - default: - throw utils::InconsistencyException( - STR_ENTRY << "Type " << dyn_type->get_name() << " has not correct kind."); - - } -} - -utils::TreeNode generate_dyn_type_tree( - const fastrtps::types::DynamicType_ptr& type, - const std::string& member_name = "PARENT") -{ - // Get kind - fastrtps::types::TypeKind kind = type->get_kind(); - - switch (kind) - { - case fastrtps::types::TK_STRUCTURE: - { - // If is struct, the call is recursive. - // Create new tree node - utils::TreeNode parent(member_name, type->get_name(), type); - - // Get all members of this struct - std::vector> members_by_name = get_members_sorted(type); - - for (const auto& member : members_by_name) - { - // Add each member with its name as a new node in a branch (recursion) - parent.add_branch( - generate_dyn_type_tree(member.second, member.first)); - } - return parent; - } - - case fastrtps::types::TK_ARRAY: - case fastrtps::types::TK_SEQUENCE: - { - // If container (array or struct) has exactly one branch - // Calculate child branch - auto internal_type = container_internal_type(type); - - // Create this node - utils::TreeNode container(member_name, type_kind_to_str(type), type); - // Add branch - container.add_branch(generate_dyn_type_tree(internal_type, "CONTAINER_MEMBER")); - - return container; - } - - default: - return utils::TreeNode(member_name, type_kind_to_str(type), type); - } -} - -std::ostream& node_to_str( - std::ostream& os, - const utils::TreeNode& node) -{ - os << TAB_SEPARATOR; - - if (node.info.dynamic_type->get_kind() == fastrtps::types::TK_ARRAY) - { - auto dim_pos = node.info.type_kind_name.find("["); - auto kind_name_str = node.info.type_kind_name.substr(0, dim_pos); - auto dim_str = node.info.type_kind_name.substr(dim_pos, std::string::npos); - - os << kind_name_str << " " << node.info.member_name << dim_str; - } - else - { - os << node.info.type_kind_name << " " << node.info.member_name; - } - - return os; -} - -std::ostream& struct_to_str( - std::ostream& os, - const utils::TreeNode& node) -{ - // Add types name - os << "struct " << node.info.type_kind_name << TYPE_OPENING; - - // Add struct attributes - for (auto const& child : node.branches()) - { - node_to_str(os, child.info); - os << ";\n"; - } - - // Close definition - os << TYPE_CLOSURE; - - return os; -} - -std::ostream& enum_to_str( - std::ostream& os, - const utils::TreeNode& node) -{ - os << "enum " << node.info.type_kind_name << TYPE_OPENING << TAB_SEPARATOR; - - std::map members; - node.info.dynamic_type->get_all_members(members); - bool first_iter = true; - for (const auto& member : members) - { - if (!first_iter) - { - os << ",\n" << TAB_SEPARATOR; - } - first_iter = false; - - os << member.second->get_name(); - } - - // Close definition - os << "\n" << TYPE_CLOSURE; - - return os; -} - -std::ostream& union_to_str( - std::ostream& os, - const utils::TreeNode& node) -{ - os << "union " << node.info.type_kind_name << " switch (" << type_kind_to_str( - node.info.dynamic_type->get_descriptor()->get_discriminator_type()) << ")" << TYPE_OPENING; - - std::map members; - node.info.dynamic_type->get_all_members(members); // WARNING: Default case not included in this collection, and currently not available - for (const auto& member : members) - { - auto labels = member.second->get_union_labels(); // WARNING: There might be casting issues as discriminant type is currently not taken into consideration - bool first_iter = true; - for (const auto& label : labels) - { - if (first_iter) - { - os << TAB_SEPARATOR; - } - else - { - os << " "; - } - first_iter = false; - - os << "case " << std::to_string(label) << ":"; - } - - os << "\n" << TAB_SEPARATOR << TAB_SEPARATOR << type_kind_to_str(member.second->get_descriptor()->get_type()) << - " " << member.second->get_name() << ";\n"; - - - } - - // Close definition - os << TYPE_CLOSURE; - - return os; -} - -std::string generate_dyn_type_schema_from_tree( - const utils::TreeNode& parent_node) -{ - std::set types_written; - - std::stringstream ss; - - // For every Node, check if it is of a "writable" type (i.e. struct, enum or union). - // If it is, check if it is not yet written - // If it is not, write it down - for (const auto& node : parent_node.all_nodes()) - { - auto kind = node.info.dynamic_type->get_kind(); - if (types_written.find(node.info.type_kind_name) == types_written.end()) - { - switch (kind) - { - case fastrtps::types::TK_STRUCTURE: - struct_to_str(ss, node); - break; - - case fastrtps::types::TK_ENUM: - enum_to_str(ss, node); - break; - - case fastrtps::types::TK_UNION: - union_to_str(ss, node); - break; - - default: - continue; - } - ss << "\n"; // Introduce blank line between type definitions - types_written.insert(node.info.type_kind_name); - } - } - - // Write struct parent node at last, after all its dependencies - // NOTE: not a requirement for Foxglove IDL Parser, dependencies can be placed after parent - struct_to_str(ss, parent_node); - - return ss.str(); -} - -std::string generate_idl_schema( - const fastrtps::types::DynamicType_ptr& dynamic_type) -{ - // Generate type tree - utils::TreeNode parent_type = generate_dyn_type_tree(dynamic_type); - - // From tree, generate string - return generate_dyn_type_schema_from_tree(parent_type); -} - -} /* namespace idl */ -} /* namespace types */ -} /* namespace core */ -} /* namespace ddspipe */ -} /* namespace eprosima */ diff --git a/ddspipe_core/src/cpp/types/dynamic_types/schema_msg.cpp b/ddspipe_core/src/cpp/types/dynamic_types/schema_msg.cpp index 8675e7b8..0df39b79 100644 --- a/ddspipe_core/src/cpp/types/dynamic_types/schema_msg.cpp +++ b/ddspipe_core/src/cpp/types/dynamic_types/schema_msg.cpp @@ -16,13 +16,17 @@ * @file schema_msg.cpp */ -#include +#include #include +#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -60,64 +64,88 @@ struct TreeNodeType // Forward declaration std::string type_kind_to_str( - const fastrtps::types::DynamicType_ptr& type); + const fastdds::dds::DynamicType::_ref_type& type); -fastrtps::types::DynamicType_ptr container_internal_type( - const fastrtps::types::DynamicType_ptr& dyn_type) +fastdds::dds::DynamicType::_ref_type container_internal_type( + const fastdds::dds::DynamicType::_ref_type& dyn_type) { - return dyn_type->get_descriptor()->get_element_type(); + fastdds::dds::TypeDescriptor::_ref_type type_descriptor {fastdds::dds::traits:: + make_shared()}; + if (fastdds::dds::RETCODE_OK != dyn_type->get_descriptor(type_descriptor)) + { + throw utils::InconsistencyException( + "Failed to get Type Descriptor for type: " + dyn_type->get_name().to_string()); + } + + return type_descriptor->element_type(); } -std::vector array_size( - const fastrtps::types::DynamicType_ptr& dyn_type, - bool unidimensional = true) +fastdds::dds::BoundSeq array_size( + const fastdds::dds::DynamicType::_ref_type& dyn_type) { - if (unidimensional) + fastdds::dds::TypeDescriptor::_ref_type type_descriptor {fastdds::dds::traits:: + make_shared()}; + if (fastdds::dds::RETCODE_OK != dyn_type->get_descriptor(type_descriptor)) { - return {dyn_type->get_descriptor()->get_total_bounds()}; - } - else - { - std::vector result; - for (unsigned int i = 0; i < dyn_type->get_descriptor()->get_bounds_size(); i++) - { - result.push_back(dyn_type->get_descriptor()->get_bounds(i)); - } - return result; + throw utils::InconsistencyException( + "Failed to get Type Descriptor for type: " + dyn_type->get_name().to_string()); } + + return type_descriptor->bound(); } -std::vector> get_members_sorted( - const fastrtps::types::DynamicType_ptr& dyn_type) +std::vector> get_members_sorted( + const fastdds::dds::DynamicType::_ref_type& dyn_type) { - std::vector> result; + std::vector> result; - std::map members; - dyn_type->get_all_members(members); + std::map members; + if (fastdds::dds::RETCODE_OK != dyn_type->get_all_members(members)) + { + throw utils::InconsistencyException( + "Failed to get Type Members for type: " + dyn_type->get_name().to_string()); + } for (const auto& member : members) { + fastdds::dds::ObjectName dyn_name = member.second->get_name(); + + fastdds::dds::MemberDescriptor::_ref_type member_descriptor {fastdds::dds::traits + ::make_shared()}; + if (fastdds::dds::RETCODE_OK != member.second->get_descriptor(member_descriptor)) + { + throw utils::InconsistencyException( + "Failed to get Type Descriptor of Member with name: " + dyn_name.to_string()); + } + result.emplace_back( - std::make_pair( - utils::demangle_if_ros_type(member.second->get_name()), - member.second->get_descriptor()->get_type())); + std::make_pair( + utils::demangle_if_ros_type(dyn_name.to_string()), + std::move(member_descriptor->type()))); } return result; } std::string container_kind_to_str( - const fastrtps::types::DynamicType_ptr& dyn_type, + const fastdds::dds::DynamicType::_ref_type& dyn_type, bool allow_bounded = false) { auto internal_type = container_internal_type(dyn_type); auto this_array_size = array_size(dyn_type); + // TODO: Change exception -> RETCODE + if (this_array_size.size() != 1) + { + throw utils::UnsupportedException( + STR_ENTRY << "Failed to convert container type: Multidimensional arrays are not supported in ROS2."); + } + std::stringstream ss; ss << type_kind_to_str(internal_type); for (const auto& bound : this_array_size) { - if (bound != fastrtps::types::BOUND_UNLIMITED) + if (bound != static_cast(fastdds::dds::LENGTH_UNLIMITED)) { if (allow_bounded) { @@ -138,92 +166,99 @@ std::string container_kind_to_str( } std::string type_kind_to_str( - const fastrtps::types::DynamicType_ptr& dyn_type) + const fastdds::dds::DynamicType::_ref_type& dyn_type) { switch (dyn_type->get_kind()) { - case fastrtps::types::TK_BOOLEAN: + case fastdds::dds::xtypes::TK_BOOLEAN: return "bool"; - case fastrtps::types::TK_BYTE: - return "uint8"; + case fastdds::dds::xtypes::TK_BYTE: + return "byte"; + + case fastdds::dds::xtypes::TK_INT8: + return "int8"; - case fastrtps::types::TK_INT16: + case fastdds::dds::xtypes::TK_INT16: return "int16"; - case fastrtps::types::TK_INT32: + case fastdds::dds::xtypes::TK_INT32: return "int32"; - case fastrtps::types::TK_INT64: + case fastdds::dds::xtypes::TK_INT64: return "int64"; - case fastrtps::types::TK_UINT16: + case fastdds::dds::xtypes::TK_UINT8: + return "uint8"; + + case fastdds::dds::xtypes::TK_UINT16: return "uint16"; - case fastrtps::types::TK_UINT32: + case fastdds::dds::xtypes::TK_UINT32: return "uint32"; - case fastrtps::types::TK_UINT64: + case fastdds::dds::xtypes::TK_UINT64: return "uint64"; - case fastrtps::types::TK_FLOAT32: + case fastdds::dds::xtypes::TK_FLOAT32: return "float32"; - case fastrtps::types::TK_FLOAT64: + case fastdds::dds::xtypes::TK_FLOAT64: return "float64"; - case fastrtps::types::TK_CHAR8: - return "int8"; + case fastdds::dds::xtypes::TK_CHAR8: + return "char"; - case fastrtps::types::TK_STRING8: + case fastdds::dds::xtypes::TK_STRING8: return "string"; - case fastrtps::types::TK_ARRAY: + case fastdds::dds::xtypes::TK_ARRAY: return container_kind_to_str(dyn_type); - case fastrtps::types::TK_SEQUENCE: + case fastdds::dds::xtypes::TK_SEQUENCE: return container_kind_to_str(dyn_type, true); - case fastrtps::types::TK_STRUCTURE: - return utils::demangle_if_ros_type(dyn_type->get_name()); - - case fastrtps::types::TK_FLOAT128: - case fastrtps::types::TK_CHAR16: - case fastrtps::types::TK_STRING16: - case fastrtps::types::TK_ENUM: - case fastrtps::types::TK_BITSET: - case fastrtps::types::TK_MAP: - case fastrtps::types::TK_UNION: - case fastrtps::types::TK_NONE: + case fastdds::dds::xtypes::TK_STRUCTURE: + return utils::demangle_if_ros_type((dyn_type->get_name()).to_string()); + + case fastdds::dds::xtypes::TK_FLOAT128: + case fastdds::dds::xtypes::TK_CHAR16: + case fastdds::dds::xtypes::TK_STRING16: + case fastdds::dds::xtypes::TK_ENUM: + case fastdds::dds::xtypes::TK_BITSET: + case fastdds::dds::xtypes::TK_MAP: + case fastdds::dds::xtypes::TK_UNION: + case fastdds::dds::xtypes::TK_NONE: throw utils::UnsupportedException( STR_ENTRY << "Type " << utils::demangle_if_ros_type( - dyn_type->get_name()) << " is not supported in ROS2 msg."); + (dyn_type->get_name()).to_string()) << " is not supported in ROS2 msg."); default: throw utils::InconsistencyException( STR_ENTRY << "Type " << utils::demangle_if_ros_type( - dyn_type->get_name()) << " has not correct kind."); + (dyn_type->get_name()).to_string()) << " has not correct kind."); } } utils::TreeNode generate_dyn_type_tree( - const fastrtps::types::DynamicType_ptr& type, + const fastdds::dds::DynamicType::_ref_type& type, const std::string& member_name = "PARENT") { // Get kind - fastrtps::types::TypeKind kind = type->get_kind(); + fastdds::dds::xtypes::TypeKind kind = type->get_kind(); switch (kind) { - case fastrtps::types::TK_STRUCTURE: + case fastdds::dds::xtypes::TK_STRUCTURE: { // If is struct, the call is recursive. // Create new tree node - utils::TreeNode parent(member_name, utils::demangle_if_ros_type(type->get_name()), true); + utils::TreeNode parent(member_name, utils::demangle_if_ros_type( + (type->get_name()).to_string()), true); // Get all members of this struct std::vector> members_by_name = get_members_sorted(type); + fastdds::dds::DynamicType::_ref_type>> members_by_name = get_members_sorted(type); for (const auto& member : members_by_name) { @@ -234,8 +269,8 @@ utils::TreeNode generate_dyn_type_tree( return parent; } - case fastrtps::types::TK_ARRAY: - case fastrtps::types::TK_SEQUENCE: + case fastdds::dds::xtypes::TK_ARRAY: + case fastdds::dds::xtypes::TK_SEQUENCE: { // If container (array or struct) has exactly one branch // Calculate child branch @@ -312,7 +347,7 @@ std::string generate_dyn_type_schema_from_tree( } std::string generate_ros2_schema( - const fastrtps::types::DynamicType_ptr& dynamic_type) + const fastdds::dds::DynamicType::_ref_type& dynamic_type) { // Generate type tree utils::TreeNode parent_type = generate_dyn_type_tree(dynamic_type); diff --git a/ddspipe_core/src/cpp/types/dynamic_types/types.cpp b/ddspipe_core/src/cpp/types/dynamic_types/types.cpp index 048514e0..93c87cb0 100644 --- a/ddspipe_core/src/cpp/types/dynamic_types/types.cpp +++ b/ddspipe_core/src/cpp/types/dynamic_types/types.cpp @@ -16,9 +16,8 @@ * @file types.cpp */ -#include - #include +#include namespace eprosima { namespace ddspipe { diff --git a/ddspipe_core/src/cpp/types/logging/LogEntryPubSubTypes.cxx b/ddspipe_core/src/cpp/types/logging/LogEntryPubSubTypes.cxx new file mode 100644 index 00000000..591feabb --- /dev/null +++ b/ddspipe_core/src/cpp/types/logging/LogEntryPubSubTypes.cxx @@ -0,0 +1,217 @@ +// 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 LogEntryPubSubTypes.cpp + * This header file contains the implementation of the serialization functions. + * + * This file was generated by the tool fastddsgen. + */ + +#include + +#include +#include + +#include +#include + +using SerializedPayload_t = eprosima::fastdds::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t; +using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; + +LogEntryPubSubType::LogEntryPubSubType() +{ + set_name("LogEntry"); + uint32_t type_size = LogEntry_max_cdr_typesize; + type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + uint32_t key_length = LogEntry_max_key_cdr_typesize > 16 ? LogEntry_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); +} + +LogEntryPubSubType::~LogEntryPubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool LogEntryPubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const LogEntry* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); + payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + ser.set_encoding_flag( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + ser << *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool LogEntryPubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + LogEntry* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + deser >> *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + return true; +} + +uint32_t LogEntryPubSubType::calculate_serialized_size( + const void* const data, + DataRepresentationId_t data_representation) +{ + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +} + +void* LogEntryPubSubType::create_data() +{ + return reinterpret_cast(new LogEntry()); +} + +void LogEntryPubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool LogEntryPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + LogEntry data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool LogEntryPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const LogEntry* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + LogEntry_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); + ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); + eprosima::fastcdr::serialize_key(ser, *p_type); + if (force_md5 || LogEntry_max_key_cdr_typesize > 16) + { + md5_.init(); + md5_.update(key_buffer_, static_cast(ser.get_serialized_data_length())); + md5_.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle.value[i] = md5_.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle.value[i] = key_buffer_[i]; + } + } + return true; +} + +void LogEntryPubSubType::register_type_object_representation() +{ + register_LogEntry_type_identifier(type_identifiers_); +} + + +// Include auxiliary functions like for serializing/deserializing. +#include diff --git a/ddspipe_core/src/cpp/types/logging/LogEntryTypeObjectSupport.cxx b/ddspipe_core/src/cpp/types/logging/LogEntryTypeObjectSupport.cxx new file mode 100644 index 00000000..4aabf72a --- /dev/null +++ b/ddspipe_core/src/cpp/types/logging/LogEntryTypeObjectSupport.cxx @@ -0,0 +1,312 @@ +// 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 LogEntryTypeObjectSupport.cxx + * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +using namespace eprosima::fastdds::dds::xtypes; + +void register_Kind_type_identifier( + TypeIdentifierPair& type_ids_Kind) +{ + ReturnCode_t return_code_Kind {eprosima::fastdds::dds::RETCODE_OK}; + return_code_Kind = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "Kind", type_ids_Kind); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_Kind) + { + EnumTypeFlag enum_flags_Kind = 0; + BitBound bit_bound_Kind = 32; + CommonEnumeratedHeader common_Kind = TypeObjectUtils::build_common_enumerated_header(bit_bound_Kind); + QualifiedTypeName type_name_Kind = "Kind"; + eprosima::fastcdr::optional type_ann_builtin_Kind; + eprosima::fastcdr::optional ann_custom_Kind; + CompleteTypeDetail detail_Kind = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_Kind, ann_custom_Kind, type_name_Kind.to_string()); + CompleteEnumeratedHeader header_Kind = TypeObjectUtils::build_complete_enumerated_header(common_Kind, detail_Kind); + CompleteEnumeratedLiteralSeq literal_seq_Kind; + { + EnumeratedLiteralFlag flags_Info = TypeObjectUtils::build_enumerated_literal_flag(false); + CommonEnumeratedLiteral common_Info = TypeObjectUtils::build_common_enumerated_literal(0, flags_Info); + eprosima::fastcdr::optional member_ann_builtin_Info; + ann_custom_Kind.reset(); + MemberName name_Info = "Info"; + CompleteMemberDetail detail_Info = TypeObjectUtils::build_complete_member_detail(name_Info, member_ann_builtin_Info, ann_custom_Kind); + CompleteEnumeratedLiteral literal_Info = TypeObjectUtils::build_complete_enumerated_literal(common_Info, detail_Info); + TypeObjectUtils::add_complete_enumerated_literal(literal_seq_Kind, literal_Info); + } + { + EnumeratedLiteralFlag flags_Warning = TypeObjectUtils::build_enumerated_literal_flag(false); + CommonEnumeratedLiteral common_Warning = TypeObjectUtils::build_common_enumerated_literal(1, flags_Warning); + eprosima::fastcdr::optional member_ann_builtin_Warning; + ann_custom_Kind.reset(); + MemberName name_Warning = "Warning"; + CompleteMemberDetail detail_Warning = TypeObjectUtils::build_complete_member_detail(name_Warning, member_ann_builtin_Warning, ann_custom_Kind); + CompleteEnumeratedLiteral literal_Warning = TypeObjectUtils::build_complete_enumerated_literal(common_Warning, detail_Warning); + TypeObjectUtils::add_complete_enumerated_literal(literal_seq_Kind, literal_Warning); + } + { + EnumeratedLiteralFlag flags_Error = TypeObjectUtils::build_enumerated_literal_flag(false); + CommonEnumeratedLiteral common_Error = TypeObjectUtils::build_common_enumerated_literal(2, flags_Error); + eprosima::fastcdr::optional member_ann_builtin_Error; + ann_custom_Kind.reset(); + MemberName name_Error = "Error"; + CompleteMemberDetail detail_Error = TypeObjectUtils::build_complete_member_detail(name_Error, member_ann_builtin_Error, ann_custom_Kind); + CompleteEnumeratedLiteral literal_Error = TypeObjectUtils::build_complete_enumerated_literal(common_Error, detail_Error); + TypeObjectUtils::add_complete_enumerated_literal(literal_seq_Kind, literal_Error); + } + CompleteEnumeratedType enumerated_type_Kind = TypeObjectUtils::build_complete_enumerated_type(enum_flags_Kind, header_Kind, + literal_seq_Kind); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_enumerated_type_object(enumerated_type_Kind, type_name_Kind.to_string(), type_ids_Kind)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "Kind already registered in TypeObjectRegistry for a different type."); + } + } +}// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_LogEntry_type_identifier( + TypeIdentifierPair& type_ids_LogEntry) +{ + + ReturnCode_t return_code_LogEntry {eprosima::fastdds::dds::RETCODE_OK}; + return_code_LogEntry = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "LogEntry", type_ids_LogEntry); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_LogEntry) + { + StructTypeFlag struct_flags_LogEntry = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_LogEntry = "LogEntry"; + eprosima::fastcdr::optional type_ann_builtin_LogEntry; + eprosima::fastcdr::optional ann_custom_LogEntry; + CompleteTypeDetail detail_LogEntry = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_LogEntry, ann_custom_LogEntry, type_name_LogEntry.to_string()); + CompleteStructHeader header_LogEntry; + header_LogEntry = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_LogEntry); + CompleteStructMemberSeq member_seq_LogEntry; + { + TypeIdentifierPair type_ids_event; + ReturnCode_t return_code_event {eprosima::fastdds::dds::RETCODE_OK}; + return_code_event = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_int32_t", type_ids_event); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_event) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "event Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_event = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, true, false); + MemberId member_id_event = 0x00000000; + bool common_event_ec {false}; + CommonStructMember common_event {TypeObjectUtils::build_common_struct_member(member_id_event, member_flags_event, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_event, common_event_ec))}; + if (!common_event_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure event member TypeIdentifier inconsistent."); + return; + } + MemberName name_event = "event"; + eprosima::fastcdr::optional member_ann_builtin_event; + ann_custom_LogEntry.reset(); + AppliedAnnotationSeq tmp_ann_custom_event; + eprosima::fastcdr::optional unit_event; + eprosima::fastcdr::optional min_event; + eprosima::fastcdr::optional max_event; + eprosima::fastcdr::optional hash_id_event; + if (unit_event.has_value() || min_event.has_value() || max_event.has_value() || hash_id_event.has_value()) + { + member_ann_builtin_event = TypeObjectUtils::build_applied_builtin_member_annotations(unit_event, min_event, max_event, hash_id_event); + } + if (!tmp_ann_custom_event.empty()) + { + ann_custom_LogEntry = tmp_ann_custom_event; + } + CompleteMemberDetail detail_event = TypeObjectUtils::build_complete_member_detail(name_event, member_ann_builtin_event, ann_custom_LogEntry); + CompleteStructMember member_event = TypeObjectUtils::build_complete_struct_member(common_event, detail_event); + TypeObjectUtils::add_complete_struct_member(member_seq_LogEntry, member_event); + } + { + TypeIdentifierPair type_ids_kind; + ReturnCode_t return_code_kind {eprosima::fastdds::dds::RETCODE_OK}; + return_code_kind = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "Kind", type_ids_kind); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_kind) + { + ::register_Kind_type_identifier(type_ids_kind); + } + StructMemberFlag member_flags_kind = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_kind = 0x00000001; + bool common_kind_ec {false}; + CommonStructMember common_kind {TypeObjectUtils::build_common_struct_member(member_id_kind, member_flags_kind, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_kind, common_kind_ec))}; + if (!common_kind_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure kind member TypeIdentifier inconsistent."); + return; + } + MemberName name_kind = "kind"; + eprosima::fastcdr::optional member_ann_builtin_kind; + ann_custom_LogEntry.reset(); + CompleteMemberDetail detail_kind = TypeObjectUtils::build_complete_member_detail(name_kind, member_ann_builtin_kind, ann_custom_LogEntry); + CompleteStructMember member_kind = TypeObjectUtils::build_complete_struct_member(common_kind, detail_kind); + TypeObjectUtils::add_complete_struct_member(member_seq_LogEntry, member_kind); + } + { + TypeIdentifierPair type_ids_category; + ReturnCode_t return_code_category {eprosima::fastdds::dds::RETCODE_OK}; + return_code_category = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_string_unbounded", type_ids_category); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_category) + { + { + SBound bound = 0; + StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, + "anonymous_string_unbounded", type_ids_category)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_category = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_category = 0x00000002; + bool common_category_ec {false}; + CommonStructMember common_category {TypeObjectUtils::build_common_struct_member(member_id_category, member_flags_category, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_category, common_category_ec))}; + if (!common_category_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure category member TypeIdentifier inconsistent."); + return; + } + MemberName name_category = "category"; + eprosima::fastcdr::optional member_ann_builtin_category; + ann_custom_LogEntry.reset(); + CompleteMemberDetail detail_category = TypeObjectUtils::build_complete_member_detail(name_category, member_ann_builtin_category, ann_custom_LogEntry); + CompleteStructMember member_category = TypeObjectUtils::build_complete_struct_member(common_category, detail_category); + TypeObjectUtils::add_complete_struct_member(member_seq_LogEntry, member_category); + } + { + TypeIdentifierPair type_ids_message; + ReturnCode_t return_code_message {eprosima::fastdds::dds::RETCODE_OK}; + return_code_message = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_string_unbounded", type_ids_message); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_message) + { + { + SBound bound = 0; + StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, + "anonymous_string_unbounded", type_ids_message)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_message = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_message = 0x00000003; + bool common_message_ec {false}; + CommonStructMember common_message {TypeObjectUtils::build_common_struct_member(member_id_message, member_flags_message, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_message, common_message_ec))}; + if (!common_message_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure message member TypeIdentifier inconsistent."); + return; + } + MemberName name_message = "message"; + eprosima::fastcdr::optional member_ann_builtin_message; + ann_custom_LogEntry.reset(); + CompleteMemberDetail detail_message = TypeObjectUtils::build_complete_member_detail(name_message, member_ann_builtin_message, ann_custom_LogEntry); + CompleteStructMember member_message = TypeObjectUtils::build_complete_struct_member(common_message, detail_message); + TypeObjectUtils::add_complete_struct_member(member_seq_LogEntry, member_message); + } + { + TypeIdentifierPair type_ids_timestamp; + ReturnCode_t return_code_timestamp {eprosima::fastdds::dds::RETCODE_OK}; + return_code_timestamp = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_string_unbounded", type_ids_timestamp); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_timestamp) + { + { + SBound bound = 0; + StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, + "anonymous_string_unbounded", type_ids_timestamp)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_timestamp = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_timestamp = 0x00000004; + bool common_timestamp_ec {false}; + CommonStructMember common_timestamp {TypeObjectUtils::build_common_struct_member(member_id_timestamp, member_flags_timestamp, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_timestamp, common_timestamp_ec))}; + if (!common_timestamp_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure timestamp member TypeIdentifier inconsistent."); + return; + } + MemberName name_timestamp = "timestamp"; + eprosima::fastcdr::optional member_ann_builtin_timestamp; + ann_custom_LogEntry.reset(); + CompleteMemberDetail detail_timestamp = TypeObjectUtils::build_complete_member_detail(name_timestamp, member_ann_builtin_timestamp, ann_custom_LogEntry); + CompleteStructMember member_timestamp = TypeObjectUtils::build_complete_struct_member(common_timestamp, detail_timestamp); + TypeObjectUtils::add_complete_struct_member(member_seq_LogEntry, member_timestamp); + } + CompleteStructType struct_type_LogEntry = TypeObjectUtils::build_complete_struct_type(struct_flags_LogEntry, header_LogEntry, member_seq_LogEntry); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_LogEntry, type_name_LogEntry.to_string(), type_ids_LogEntry)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "LogEntry already registered in TypeObjectRegistry for a different type."); + } + } +} + diff --git a/ddspipe_core/src/cpp/types/logging/v1/LogEntry.cxx b/ddspipe_core/src/cpp/types/logging/v1/LogEntry.cxx deleted file mode 100644 index 564551ce..00000000 --- a/ddspipe_core/src/cpp/types/logging/v1/LogEntry.cxx +++ /dev/null @@ -1,476 +0,0 @@ -// 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 LogEntry.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include - -#include - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - -namespace helper { -namespace internal { - -enum class Size -{ - UInt8, - UInt16, - UInt32, - UInt64, -}; - -constexpr Size get_size( - int s) -{ - return (s <= 8 ) ? Size::UInt8: - (s <= 16) ? Size::UInt16: - (s <= 32) ? Size::UInt32: Size::UInt64; -} - -template -struct FindTypeH; - -template<> -struct FindTypeH -{ - using type = std::uint8_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint16_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint32_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint64_t; -}; -} // namespace internal - -template -struct FindType -{ - using type = typename internal::FindTypeH::type; -}; -} // namespace helper - -#define LogEntry_max_cdr_typesize 792ULL; - - - - -LogEntry::LogEntry() -{ - // long m_event - m_event = 0; - // Kind m_kind - m_kind = ::Info; - // /type_d() m_category - - // /type_d() m_message - - // /type_d() m_timestamp - - - // Just to register all known types - registerLogEntryTypes(); -} - -LogEntry::~LogEntry() -{ -} - -LogEntry::LogEntry( - const LogEntry& x) -{ - m_event = x.m_event; - - - m_kind = x.m_kind; - - - m_category = x.m_category; - - - m_message = x.m_message; - - - m_timestamp = x.m_timestamp; - -} - -LogEntry::LogEntry( - LogEntry&& x) noexcept -{ - m_event = x.m_event; - - - m_kind = x.m_kind; - - - m_category = std::move(x.m_category); - - - m_message = std::move(x.m_message); - - - m_timestamp = std::move(x.m_timestamp); - -} - -LogEntry& LogEntry::operator =( - const LogEntry& x) -{ - m_event = x.m_event; - - - m_kind = x.m_kind; - - - m_category = x.m_category; - - - m_message = x.m_message; - - - m_timestamp = x.m_timestamp; - - return *this; -} - -LogEntry& LogEntry::operator =( - LogEntry&& x) noexcept -{ - m_event = x.m_event; - - - m_kind = x.m_kind; - - - m_category = std::move(x.m_category); - - - m_message = std::move(x.m_message); - - - m_timestamp = std::move(x.m_timestamp); - - return *this; -} - -bool LogEntry::operator ==( - const LogEntry& x) const -{ - return (m_event == x.m_event && - m_kind == x.m_kind && - m_category == x.m_category && - m_message == x.m_message && - m_timestamp == x.m_timestamp); -} - -bool LogEntry::operator !=( - const LogEntry& x) const -{ - return !(*this == x); -} - -size_t LogEntry::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return LogEntry_max_cdr_typesize; -} - -size_t LogEntry::getCdrSerializedSize( - const LogEntry& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.category().size() + 1; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.message().size() + 1; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.timestamp().size() + 1; - - - return current_alignment - initial_alignment; -} - -void LogEntry::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_event; - - scdr << (uint32_t)m_kind; - - scdr << m_category.c_str(); - - scdr << m_message.c_str(); - - scdr << m_timestamp.c_str(); - -} - -void LogEntry::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_event; - - - - { - uint32_t enum_value = 0; - dcdr >> enum_value; - m_kind = (Kind)enum_value; - } - - - - dcdr >> m_category; - - - - dcdr >> m_message; - - - - dcdr >> m_timestamp; - - -} - -bool LogEntry::isKeyDefined() -{ - return true; -} - -void LogEntry::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; - - scdr << m_event; - - - - - -} - -/*! - * @brief This function sets a value in member event - * @param _event New value for member event - */ -void LogEntry::event( - int32_t _event) -{ - m_event = _event; -} - -/*! - * @brief This function returns the value of member event - * @return Value of member event - */ -int32_t LogEntry::event() const -{ - return m_event; -} - -/*! - * @brief This function returns a reference to member event - * @return Reference to member event - */ -int32_t& LogEntry::event() -{ - return m_event; -} - -/*! - * @brief This function sets a value in member kind - * @param _kind New value for member kind - */ -void LogEntry::kind( - Kind _kind) -{ - m_kind = _kind; -} - -/*! - * @brief This function returns the value of member kind - * @return Value of member kind - */ -Kind LogEntry::kind() const -{ - return m_kind; -} - -/*! - * @brief This function returns a reference to member kind - * @return Reference to member kind - */ -Kind& LogEntry::kind() -{ - return m_kind; -} - -/*! - * @brief This function copies the value in member category - * @param _category New value to be copied in member category - */ -void LogEntry::category( - const std::string& _category) -{ - m_category = _category; -} - -/*! - * @brief This function moves the value in member category - * @param _category New value to be moved in member category - */ -void LogEntry::category( - std::string&& _category) -{ - m_category = std::move(_category); -} - -/*! - * @brief This function returns a constant reference to member category - * @return Constant reference to member category - */ -const std::string& LogEntry::category() const -{ - return m_category; -} - -/*! - * @brief This function returns a reference to member category - * @return Reference to member category - */ -std::string& LogEntry::category() -{ - return m_category; -} - -/*! - * @brief This function copies the value in member message - * @param _message New value to be copied in member message - */ -void LogEntry::message( - const std::string& _message) -{ - m_message = _message; -} - -/*! - * @brief This function moves the value in member message - * @param _message New value to be moved in member message - */ -void LogEntry::message( - std::string&& _message) -{ - m_message = std::move(_message); -} - -/*! - * @brief This function returns a constant reference to member message - * @return Constant reference to member message - */ -const std::string& LogEntry::message() const -{ - return m_message; -} - -/*! - * @brief This function returns a reference to member message - * @return Reference to member message - */ -std::string& LogEntry::message() -{ - return m_message; -} - -/*! - * @brief This function copies the value in member timestamp - * @param _timestamp New value to be copied in member timestamp - */ -void LogEntry::timestamp( - const std::string& _timestamp) -{ - m_timestamp = _timestamp; -} - -/*! - * @brief This function moves the value in member timestamp - * @param _timestamp New value to be moved in member timestamp - */ -void LogEntry::timestamp( - std::string&& _timestamp) -{ - m_timestamp = std::move(_timestamp); -} - -/*! - * @brief This function returns a constant reference to member timestamp - * @return Constant reference to member timestamp - */ -const std::string& LogEntry::timestamp() const -{ - return m_timestamp; -} - -/*! - * @brief This function returns a reference to member timestamp - * @return Reference to member timestamp - */ -std::string& LogEntry::timestamp() -{ - return m_timestamp; -} diff --git a/ddspipe_core/src/cpp/types/logging/v1/LogEntryPubSubTypes.cxx b/ddspipe_core/src/cpp/types/logging/v1/LogEntryPubSubTypes.cxx deleted file mode 100644 index 9b6231dd..00000000 --- a/ddspipe_core/src/cpp/types/logging/v1/LogEntryPubSubTypes.cxx +++ /dev/null @@ -1,230 +0,0 @@ -// 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 LogEntryPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#include - -#include -#include - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; -using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - - - - - - - - - - - - -LogEntryPubSubType::LogEntryPubSubType() -{ - setName("LogEntry"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(LogEntry::getMaxCdrSerializedSize()); -#else - LogEntry_max_cdr_typesize; -#endif // if FASTCDR_VERSION_MAJOR == 1 - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = LogEntry_max_key_cdr_typesize > 16 ? LogEntry_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -LogEntryPubSubType::~LogEntryPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool LogEntryPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - LogEntry* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool LogEntryPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - LogEntry* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function LogEntryPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* LogEntryPubSubType::createData() -{ - return reinterpret_cast(new LogEntry()); -} - -void LogEntryPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool LogEntryPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - LogEntry* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - LogEntry_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || LogEntry_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} diff --git a/ddspipe_core/src/cpp/types/logging/v1/LogEntryTypeObject.cxx b/ddspipe_core/src/cpp/types/logging/v1/LogEntryTypeObject.cxx deleted file mode 100644 index 3335f42d..00000000 --- a/ddspipe_core/src/cpp/types/logging/v1/LogEntryTypeObject.cxx +++ /dev/null @@ -1,622 +0,0 @@ -// 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 LogEntryTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // ifdef _WIN32 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerLogEntryTypes() -{ - static std::once_flag once_flag; - std::call_once(once_flag, []() - { - TypeObjectFactory* factory = TypeObjectFactory::get_instance(); - factory->add_type_object("Kind", GetKindIdentifier(true), - GetKindObject(true)); - factory->add_type_object("Kind", GetKindIdentifier(false), - GetKindObject(false)); - - - factory->add_type_object("LogEntry", GetLogEntryIdentifier(true), - GetLogEntryObject(true)); - factory->add_type_object("LogEntry", GetLogEntryIdentifier(false), - GetLogEntryObject(false)); - - }); -} - -const TypeIdentifier* GetKindIdentifier( - bool complete) -{ - const TypeIdentifier* c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("Kind", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetKindObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("Kind", complete); -} - -const TypeObject* GetKindObject( - bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("Kind", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteKindObject(); - } - // else - return GetMinimalKindObject(); -} - -const TypeObject* GetMinimalKindObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("Kind", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject* type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_ENUM); - - // No flags apply - //type_object->minimal().enumerated_type().enum_flags().IS_FINAL(false); - //type_object->minimal().enumerated_type().enum_flags().IS_APPENDABLE(false); - //type_object->minimal().enumerated_type().enum_flags().IS_MUTABLE(false); - //type_object->minimal().enumerated_type().enum_flags().IS_NESTED(false); - //type_object->minimal().enumerated_type().enum_flags().IS_AUTOID_HASH(false); - - type_object->minimal().enumerated_type().header().common().bit_bound(32); // TODO fixed by IDL, isn't? - - uint32_t value = 0; - MinimalEnumeratedLiteral mel_Info; - mel_Info.common().flags().TRY_CONSTRUCT1(false); // Doesn't apply - mel_Info.common().flags().TRY_CONSTRUCT2(false); // Doesn't apply - mel_Info.common().flags().IS_EXTERNAL(false); // Doesn't apply - mel_Info.common().flags().IS_OPTIONAL(false); // Doesn't apply - mel_Info.common().flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - mel_Info.common().flags().IS_KEY(false); // Doesn't apply - mel_Info.common().flags().IS_DEFAULT(false); - mel_Info.common().value(value++); - MD5 Info_hash("Info"); - for (int i = 0; i < 4; ++i) - { - mel_Info.detail().name_hash()[i] = Info_hash.digest[i]; - } - type_object->minimal().enumerated_type().literal_seq().emplace_back(mel_Info); - - MinimalEnumeratedLiteral mel_Warning; - mel_Warning.common().flags().TRY_CONSTRUCT1(false); // Doesn't apply - mel_Warning.common().flags().TRY_CONSTRUCT2(false); // Doesn't apply - mel_Warning.common().flags().IS_EXTERNAL(false); // Doesn't apply - mel_Warning.common().flags().IS_OPTIONAL(false); // Doesn't apply - mel_Warning.common().flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - mel_Warning.common().flags().IS_KEY(false); // Doesn't apply - mel_Warning.common().flags().IS_DEFAULT(false); - mel_Warning.common().value(value++); - MD5 Warning_hash("Warning"); - for (int i = 0; i < 4; ++i) - { - mel_Warning.detail().name_hash()[i] = Warning_hash.digest[i]; - } - type_object->minimal().enumerated_type().literal_seq().emplace_back(mel_Warning); - - MinimalEnumeratedLiteral mel_Error; - mel_Error.common().flags().TRY_CONSTRUCT1(false); // Doesn't apply - mel_Error.common().flags().TRY_CONSTRUCT2(false); // Doesn't apply - mel_Error.common().flags().IS_EXTERNAL(false); // Doesn't apply - mel_Error.common().flags().IS_OPTIONAL(false); // Doesn't apply - mel_Error.common().flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - mel_Error.common().flags().IS_KEY(false); // Doesn't apply - mel_Error.common().flags().IS_DEFAULT(false); - mel_Error.common().value(value++); - MD5 Error_hash("Error"); - for (int i = 0; i < 4; ++i) - { - mel_Error.detail().name_hash()[i] = Error_hash.digest[i]; - } - type_object->minimal().enumerated_type().literal_seq().emplace_back(mel_Error); - - - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().enumerated_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for (int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("Kind", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("Kind", false); -} - -const TypeObject* GetCompleteKindObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("Kind", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject* type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_ENUM); - - // No flags apply - //type_object->complete().enumerated_type().enum_flags().IS_FINAL(false); - //type_object->complete().enumerated_type().enum_flags().IS_APPENDABLE(false); - //type_object->complete().enumerated_type().enum_flags().IS_MUTABLE(false); - //type_object->complete().enumerated_type().enum_flags().IS_NESTED(false); - //type_object->complete().enumerated_type().enum_flags().IS_AUTOID_HASH(false); - - type_object->complete().enumerated_type().header().common().bit_bound(32); // TODO fixed by IDL, isn't? - type_object->complete().enumerated_type().header().detail().type_name("Kind"); - - uint32_t value = 0; - CompleteEnumeratedLiteral cel_Info; - cel_Info.common().flags().TRY_CONSTRUCT1(false); // Doesn't apply - cel_Info.common().flags().TRY_CONSTRUCT2(false); // Doesn't apply - cel_Info.common().flags().IS_EXTERNAL(false); // Doesn't apply - cel_Info.common().flags().IS_OPTIONAL(false); // Doesn't apply - cel_Info.common().flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - cel_Info.common().flags().IS_KEY(false); // Doesn't apply - cel_Info.common().flags().IS_DEFAULT(false); - cel_Info.common().value(value++); - cel_Info.detail().name("Info"); - - type_object->complete().enumerated_type().literal_seq().emplace_back(cel_Info); - - CompleteEnumeratedLiteral cel_Warning; - cel_Warning.common().flags().TRY_CONSTRUCT1(false); // Doesn't apply - cel_Warning.common().flags().TRY_CONSTRUCT2(false); // Doesn't apply - cel_Warning.common().flags().IS_EXTERNAL(false); // Doesn't apply - cel_Warning.common().flags().IS_OPTIONAL(false); // Doesn't apply - cel_Warning.common().flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - cel_Warning.common().flags().IS_KEY(false); // Doesn't apply - cel_Warning.common().flags().IS_DEFAULT(false); - cel_Warning.common().value(value++); - cel_Warning.detail().name("Warning"); - - type_object->complete().enumerated_type().literal_seq().emplace_back(cel_Warning); - - CompleteEnumeratedLiteral cel_Error; - cel_Error.common().flags().TRY_CONSTRUCT1(false); // Doesn't apply - cel_Error.common().flags().TRY_CONSTRUCT2(false); // Doesn't apply - cel_Error.common().flags().IS_EXTERNAL(false); // Doesn't apply - cel_Error.common().flags().IS_OPTIONAL(false); // Doesn't apply - cel_Error.common().flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - cel_Error.common().flags().IS_KEY(false); // Doesn't apply - cel_Error.common().flags().IS_DEFAULT(false); - cel_Error.common().value(value++); - cel_Error.detail().name("Error"); - - type_object->complete().enumerated_type().literal_seq().emplace_back(cel_Error); - - - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().enumerated_type(), - current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for (int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("Kind", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("Kind", true); -} - -const TypeIdentifier* GetLogEntryIdentifier( - bool complete) -{ - const TypeIdentifier* c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("LogEntry", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetLogEntryObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("LogEntry", complete); -} - -const TypeObject* GetLogEntryObject( - bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("LogEntry", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteLogEntryObject(); - } - //else - return GetMinimalLogEntryObject(); -} - -const TypeObject* GetMinimalLogEntryObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("LogEntry", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject* type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_event; - mst_event.common().member_id(memberId++); - mst_event.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_event.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_event.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_event.common().member_flags().IS_OPTIONAL(false); - mst_event.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_event.common().member_flags().IS_KEY(true); - mst_event.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_event.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - - - MD5 event_hash("event"); - for (int i = 0; i < 4; ++i) - { - mst_event.detail().name_hash()[i] = event_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_event); - - MinimalStructMember mst_kind; - mst_kind.common().member_id(memberId++); - mst_kind.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_kind.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_kind.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_kind.common().member_flags().IS_OPTIONAL(false); - mst_kind.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_kind.common().member_flags().IS_KEY(false); - mst_kind.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_kind.common().member_type_id(*GetKindIdentifier(false)); - - MD5 kind_hash("kind"); - for (int i = 0; i < 4; ++i) - { - mst_kind.detail().name_hash()[i] = kind_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_kind); - - MinimalStructMember mst_category; - mst_category.common().member_id(memberId++); - mst_category.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_category.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_category.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_category.common().member_flags().IS_OPTIONAL(false); - mst_category.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_category.common().member_flags().IS_KEY(false); - mst_category.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_category.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - MD5 category_hash("category"); - for (int i = 0; i < 4; ++i) - { - mst_category.detail().name_hash()[i] = category_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_category); - - MinimalStructMember mst_message; - mst_message.common().member_id(memberId++); - mst_message.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_message.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_message.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_message.common().member_flags().IS_OPTIONAL(false); - mst_message.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_message.common().member_flags().IS_KEY(false); - mst_message.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_message.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - MD5 message_hash("message"); - for (int i = 0; i < 4; ++i) - { - mst_message.detail().name_hash()[i] = message_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_message); - - MinimalStructMember mst_timestamp; - mst_timestamp.common().member_id(memberId++); - mst_timestamp.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_timestamp.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_timestamp.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_timestamp.common().member_flags().IS_OPTIONAL(false); - mst_timestamp.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_timestamp.common().member_flags().IS_KEY(false); - mst_timestamp.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_timestamp.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - MD5 timestamp_hash("timestamp"); - for (int i = 0; i < 4; ++i) - { - mst_timestamp.detail().name_hash()[i] = timestamp_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_timestamp); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for (int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("LogEntry", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("LogEntry", false); -} - -const TypeObject* GetCompleteLogEntryObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("LogEntry", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject* type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_event; - cst_event.common().member_id(memberId++); - cst_event.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_event.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_event.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_event.common().member_flags().IS_OPTIONAL(false); - cst_event.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_event.common().member_flags().IS_KEY(true); - cst_event.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_event.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - - - cst_event.detail().name("event"); - - { - AppliedAnnotation ann; - //ann.annotation_typeid(GetkeyIdentifier(true)); - ann.annotation_typeid(*TypeObjectFactory::get_instance()->get_type_identifier_trying_complete("key")); - { - AppliedAnnotationParameter annParam; - MD5 message_hash("value"); - for (int i = 0; i < 4; ++i) - { - annParam.paramname_hash()[i] = message_hash.digest[i]; - } - AnnotationParameterValue paramValue; - paramValue._d(TK_BOOLEAN); - paramValue.from_string("true"); - annParam.value(paramValue); - ann.param_seq().push_back(annParam); - } - - cst_event.detail().ann_custom().push_back(ann); - } - - - type_object->complete().struct_type().member_seq().emplace_back(cst_event); - - CompleteStructMember cst_kind; - cst_kind.common().member_id(memberId++); - cst_kind.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_kind.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_kind.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_kind.common().member_flags().IS_OPTIONAL(false); - cst_kind.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_kind.common().member_flags().IS_KEY(false); - cst_kind.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_kind.common().member_type_id(*GetKindIdentifier(true)); - - cst_kind.detail().name("kind"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_kind); - - CompleteStructMember cst_category; - cst_category.common().member_id(memberId++); - cst_category.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_category.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_category.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_category.common().member_flags().IS_OPTIONAL(false); - cst_category.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_category.common().member_flags().IS_KEY(false); - cst_category.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_category.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - cst_category.detail().name("category"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_category); - - CompleteStructMember cst_message; - cst_message.common().member_id(memberId++); - cst_message.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_message.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_message.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_message.common().member_flags().IS_OPTIONAL(false); - cst_message.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_message.common().member_flags().IS_KEY(false); - cst_message.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_message.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - cst_message.detail().name("message"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_message); - - CompleteStructMember cst_timestamp; - cst_timestamp.common().member_id(memberId++); - cst_timestamp.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_timestamp.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_timestamp.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_timestamp.common().member_flags().IS_OPTIONAL(false); - cst_timestamp.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_timestamp.common().member_flags().IS_KEY(false); - cst_timestamp.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_timestamp.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - cst_timestamp.detail().name("timestamp"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_timestamp); - - - // Header - type_object->complete().struct_type().header().detail().type_name("LogEntry"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for (int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("LogEntry", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("LogEntry", true); -} diff --git a/ddspipe_core/src/cpp/types/logging/v2/LogEntry.cxx b/ddspipe_core/src/cpp/types/logging/v2/LogEntry.cxx deleted file mode 100644 index 68891d6a..00000000 --- a/ddspipe_core/src/cpp/types/logging/v2/LogEntry.cxx +++ /dev/null @@ -1,289 +0,0 @@ -// 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 LogEntry.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include - -#if FASTCDR_VERSION_MAJOR > 1 - -#include - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - - - - -LogEntry::LogEntry() -{ - // Just to register all known types - registerLogEntryTypes(); -} - -LogEntry::~LogEntry() -{ -} - -LogEntry::LogEntry( - const LogEntry& x) -{ - m_event = x.m_event; - m_kind = x.m_kind; - m_category = x.m_category; - m_message = x.m_message; - m_timestamp = x.m_timestamp; -} - -LogEntry::LogEntry( - LogEntry&& x) noexcept -{ - m_event = x.m_event; - m_kind = x.m_kind; - m_category = std::move(x.m_category); - m_message = std::move(x.m_message); - m_timestamp = std::move(x.m_timestamp); -} - -LogEntry& LogEntry::operator =( - const LogEntry& x) -{ - - m_event = x.m_event; - m_kind = x.m_kind; - m_category = x.m_category; - m_message = x.m_message; - m_timestamp = x.m_timestamp; - return *this; -} - -LogEntry& LogEntry::operator =( - LogEntry&& x) noexcept -{ - - m_event = x.m_event; - m_kind = x.m_kind; - m_category = std::move(x.m_category); - m_message = std::move(x.m_message); - m_timestamp = std::move(x.m_timestamp); - return *this; -} - -bool LogEntry::operator ==( - const LogEntry& x) const -{ - return (m_event == x.m_event && - m_kind == x.m_kind && - m_category == x.m_category && - m_message == x.m_message && - m_timestamp == x.m_timestamp); -} - -bool LogEntry::operator !=( - const LogEntry& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function sets a value in member event - * @param _event New value for member event - */ -void LogEntry::event( - int32_t _event) -{ - m_event = _event; -} - -/*! - * @brief This function returns the value of member event - * @return Value of member event - */ -int32_t LogEntry::event() const -{ - return m_event; -} - -/*! - * @brief This function returns a reference to member event - * @return Reference to member event - */ -int32_t& LogEntry::event() -{ - return m_event; -} - -/*! - * @brief This function sets a value in member kind - * @param _kind New value for member kind - */ -void LogEntry::kind( - Kind _kind) -{ - m_kind = _kind; -} - -/*! - * @brief This function returns the value of member kind - * @return Value of member kind - */ -Kind LogEntry::kind() const -{ - return m_kind; -} - -/*! - * @brief This function returns a reference to member kind - * @return Reference to member kind - */ -Kind& LogEntry::kind() -{ - return m_kind; -} - -/*! - * @brief This function copies the value in member category - * @param _category New value to be copied in member category - */ -void LogEntry::category( - const std::string& _category) -{ - m_category = _category; -} - -/*! - * @brief This function moves the value in member category - * @param _category New value to be moved in member category - */ -void LogEntry::category( - std::string&& _category) -{ - m_category = std::move(_category); -} - -/*! - * @brief This function returns a constant reference to member category - * @return Constant reference to member category - */ -const std::string& LogEntry::category() const -{ - return m_category; -} - -/*! - * @brief This function returns a reference to member category - * @return Reference to member category - */ -std::string& LogEntry::category() -{ - return m_category; -} - -/*! - * @brief This function copies the value in member message - * @param _message New value to be copied in member message - */ -void LogEntry::message( - const std::string& _message) -{ - m_message = _message; -} - -/*! - * @brief This function moves the value in member message - * @param _message New value to be moved in member message - */ -void LogEntry::message( - std::string&& _message) -{ - m_message = std::move(_message); -} - -/*! - * @brief This function returns a constant reference to member message - * @return Constant reference to member message - */ -const std::string& LogEntry::message() const -{ - return m_message; -} - -/*! - * @brief This function returns a reference to member message - * @return Reference to member message - */ -std::string& LogEntry::message() -{ - return m_message; -} - -/*! - * @brief This function copies the value in member timestamp - * @param _timestamp New value to be copied in member timestamp - */ -void LogEntry::timestamp( - const std::string& _timestamp) -{ - m_timestamp = _timestamp; -} - -/*! - * @brief This function moves the value in member timestamp - * @param _timestamp New value to be moved in member timestamp - */ -void LogEntry::timestamp( - std::string&& _timestamp) -{ - m_timestamp = std::move(_timestamp); -} - -/*! - * @brief This function returns a constant reference to member timestamp - * @return Constant reference to member timestamp - */ -const std::string& LogEntry::timestamp() const -{ - return m_timestamp; -} - -/*! - * @brief This function returns a reference to member timestamp - * @return Reference to member timestamp - */ -std::string& LogEntry::timestamp() -{ - return m_timestamp; -} - -// Include auxiliary functions like for serializing/deserializing. -#include - -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddspipe_core/src/cpp/types/logging/v2/LogEntryPubSubTypes.cxx b/ddspipe_core/src/cpp/types/logging/v2/LogEntryPubSubTypes.cxx deleted file mode 100644 index 47fa1f4c..00000000 --- a/ddspipe_core/src/cpp/types/logging/v2/LogEntryPubSubTypes.cxx +++ /dev/null @@ -1,230 +0,0 @@ -// 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 LogEntryPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#include - -#include -#include - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; -using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - - - - - - - - - - - - -LogEntryPubSubType::LogEntryPubSubType() -{ - setName("LogEntry"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(LogEntry::getMaxCdrSerializedSize()); -#else - LogEntry_max_cdr_typesize; -#endif // if FASTCDR_VERSION_MAJOR == 1 - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = LogEntry_max_key_cdr_typesize > 16 ? LogEntry_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -LogEntryPubSubType::~LogEntryPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool LogEntryPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - LogEntry* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool LogEntryPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - LogEntry* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function LogEntryPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* LogEntryPubSubType::createData() -{ - return reinterpret_cast(new LogEntry()); -} - -void LogEntryPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool LogEntryPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - LogEntry* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - LogEntry_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || LogEntry_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} diff --git a/ddspipe_core/src/cpp/types/logging/v2/LogEntryTypeObject.cxx b/ddspipe_core/src/cpp/types/logging/v2/LogEntryTypeObject.cxx deleted file mode 100644 index 229dac58..00000000 --- a/ddspipe_core/src/cpp/types/logging/v2/LogEntryTypeObject.cxx +++ /dev/null @@ -1,622 +0,0 @@ -// 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 LogEntryTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // ifdef _WIN32 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerLogEntryTypes() -{ - static std::once_flag once_flag; - std::call_once(once_flag, []() - { - TypeObjectFactory* factory = TypeObjectFactory::get_instance(); - factory->add_type_object("Kind", GetKindIdentifier(true), - GetKindObject(true)); - factory->add_type_object("Kind", GetKindIdentifier(false), - GetKindObject(false)); - - - factory->add_type_object("LogEntry", GetLogEntryIdentifier(true), - GetLogEntryObject(true)); - factory->add_type_object("LogEntry", GetLogEntryIdentifier(false), - GetLogEntryObject(false)); - - }); -} - -const TypeIdentifier* GetKindIdentifier( - bool complete) -{ - const TypeIdentifier* c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("Kind", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetKindObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("Kind", complete); -} - -const TypeObject* GetKindObject( - bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("Kind", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteKindObject(); - } - // else - return GetMinimalKindObject(); -} - -const TypeObject* GetMinimalKindObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("Kind", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject* type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_ENUM); - - // No flags apply - //type_object->minimal().enumerated_type().enum_flags().IS_FINAL(false); - //type_object->minimal().enumerated_type().enum_flags().IS_APPENDABLE(false); - //type_object->minimal().enumerated_type().enum_flags().IS_MUTABLE(false); - //type_object->minimal().enumerated_type().enum_flags().IS_NESTED(false); - //type_object->minimal().enumerated_type().enum_flags().IS_AUTOID_HASH(false); - - type_object->minimal().enumerated_type().header().common().bit_bound(32); // TODO fixed by IDL, isn't? - - uint32_t value = 0; - MinimalEnumeratedLiteral mel_Info; - mel_Info.common().flags().TRY_CONSTRUCT1(false); // Doesn't apply - mel_Info.common().flags().TRY_CONSTRUCT2(false); // Doesn't apply - mel_Info.common().flags().IS_EXTERNAL(false); // Doesn't apply - mel_Info.common().flags().IS_OPTIONAL(false); // Doesn't apply - mel_Info.common().flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - mel_Info.common().flags().IS_KEY(false); // Doesn't apply - mel_Info.common().flags().IS_DEFAULT(false); - mel_Info.common().value(value++); - MD5 Info_hash("Info"); - for (int i = 0; i < 4; ++i) - { - mel_Info.detail().name_hash()[i] = Info_hash.digest[i]; - } - type_object->minimal().enumerated_type().literal_seq().emplace_back(mel_Info); - - MinimalEnumeratedLiteral mel_Warning; - mel_Warning.common().flags().TRY_CONSTRUCT1(false); // Doesn't apply - mel_Warning.common().flags().TRY_CONSTRUCT2(false); // Doesn't apply - mel_Warning.common().flags().IS_EXTERNAL(false); // Doesn't apply - mel_Warning.common().flags().IS_OPTIONAL(false); // Doesn't apply - mel_Warning.common().flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - mel_Warning.common().flags().IS_KEY(false); // Doesn't apply - mel_Warning.common().flags().IS_DEFAULT(false); - mel_Warning.common().value(value++); - MD5 Warning_hash("Warning"); - for (int i = 0; i < 4; ++i) - { - mel_Warning.detail().name_hash()[i] = Warning_hash.digest[i]; - } - type_object->minimal().enumerated_type().literal_seq().emplace_back(mel_Warning); - - MinimalEnumeratedLiteral mel_Error; - mel_Error.common().flags().TRY_CONSTRUCT1(false); // Doesn't apply - mel_Error.common().flags().TRY_CONSTRUCT2(false); // Doesn't apply - mel_Error.common().flags().IS_EXTERNAL(false); // Doesn't apply - mel_Error.common().flags().IS_OPTIONAL(false); // Doesn't apply - mel_Error.common().flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - mel_Error.common().flags().IS_KEY(false); // Doesn't apply - mel_Error.common().flags().IS_DEFAULT(false); - mel_Error.common().value(value++); - MD5 Error_hash("Error"); - for (int i = 0; i < 4; ++i) - { - mel_Error.detail().name_hash()[i] = Error_hash.digest[i]; - } - type_object->minimal().enumerated_type().literal_seq().emplace_back(mel_Error); - - - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().enumerated_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for (int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("Kind", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("Kind", false); -} - -const TypeObject* GetCompleteKindObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("Kind", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject* type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_ENUM); - - // No flags apply - //type_object->complete().enumerated_type().enum_flags().IS_FINAL(false); - //type_object->complete().enumerated_type().enum_flags().IS_APPENDABLE(false); - //type_object->complete().enumerated_type().enum_flags().IS_MUTABLE(false); - //type_object->complete().enumerated_type().enum_flags().IS_NESTED(false); - //type_object->complete().enumerated_type().enum_flags().IS_AUTOID_HASH(false); - - type_object->complete().enumerated_type().header().common().bit_bound(32); // TODO fixed by IDL, isn't? - type_object->complete().enumerated_type().header().detail().type_name("Kind"); - - uint32_t value = 0; - CompleteEnumeratedLiteral cel_Info; - cel_Info.common().flags().TRY_CONSTRUCT1(false); // Doesn't apply - cel_Info.common().flags().TRY_CONSTRUCT2(false); // Doesn't apply - cel_Info.common().flags().IS_EXTERNAL(false); // Doesn't apply - cel_Info.common().flags().IS_OPTIONAL(false); // Doesn't apply - cel_Info.common().flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - cel_Info.common().flags().IS_KEY(false); // Doesn't apply - cel_Info.common().flags().IS_DEFAULT(false); - cel_Info.common().value(value++); - cel_Info.detail().name("Info"); - - type_object->complete().enumerated_type().literal_seq().emplace_back(cel_Info); - - CompleteEnumeratedLiteral cel_Warning; - cel_Warning.common().flags().TRY_CONSTRUCT1(false); // Doesn't apply - cel_Warning.common().flags().TRY_CONSTRUCT2(false); // Doesn't apply - cel_Warning.common().flags().IS_EXTERNAL(false); // Doesn't apply - cel_Warning.common().flags().IS_OPTIONAL(false); // Doesn't apply - cel_Warning.common().flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - cel_Warning.common().flags().IS_KEY(false); // Doesn't apply - cel_Warning.common().flags().IS_DEFAULT(false); - cel_Warning.common().value(value++); - cel_Warning.detail().name("Warning"); - - type_object->complete().enumerated_type().literal_seq().emplace_back(cel_Warning); - - CompleteEnumeratedLiteral cel_Error; - cel_Error.common().flags().TRY_CONSTRUCT1(false); // Doesn't apply - cel_Error.common().flags().TRY_CONSTRUCT2(false); // Doesn't apply - cel_Error.common().flags().IS_EXTERNAL(false); // Doesn't apply - cel_Error.common().flags().IS_OPTIONAL(false); // Doesn't apply - cel_Error.common().flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - cel_Error.common().flags().IS_KEY(false); // Doesn't apply - cel_Error.common().flags().IS_DEFAULT(false); - cel_Error.common().value(value++); - cel_Error.detail().name("Error"); - - type_object->complete().enumerated_type().literal_seq().emplace_back(cel_Error); - - - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().enumerated_type(), - current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for (int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("Kind", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("Kind", true); -} - -const TypeIdentifier* GetLogEntryIdentifier( - bool complete) -{ - const TypeIdentifier* c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("LogEntry", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetLogEntryObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("LogEntry", complete); -} - -const TypeObject* GetLogEntryObject( - bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("LogEntry", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteLogEntryObject(); - } - //else - return GetMinimalLogEntryObject(); -} - -const TypeObject* GetMinimalLogEntryObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("LogEntry", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject* type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_event; - mst_event.common().member_id(memberId++); - mst_event.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_event.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_event.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_event.common().member_flags().IS_OPTIONAL(false); - mst_event.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_event.common().member_flags().IS_KEY(true); - mst_event.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_event.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - - - MD5 event_hash("event"); - for (int i = 0; i < 4; ++i) - { - mst_event.detail().name_hash()[i] = event_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_event); - - MinimalStructMember mst_kind; - mst_kind.common().member_id(memberId++); - mst_kind.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_kind.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_kind.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_kind.common().member_flags().IS_OPTIONAL(false); - mst_kind.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_kind.common().member_flags().IS_KEY(false); - mst_kind.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_kind.common().member_type_id(*GetKindIdentifier(false)); - - MD5 kind_hash("kind"); - for (int i = 0; i < 4; ++i) - { - mst_kind.detail().name_hash()[i] = kind_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_kind); - - MinimalStructMember mst_category; - mst_category.common().member_id(memberId++); - mst_category.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_category.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_category.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_category.common().member_flags().IS_OPTIONAL(false); - mst_category.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_category.common().member_flags().IS_KEY(false); - mst_category.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_category.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - MD5 category_hash("category"); - for (int i = 0; i < 4; ++i) - { - mst_category.detail().name_hash()[i] = category_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_category); - - MinimalStructMember mst_message; - mst_message.common().member_id(memberId++); - mst_message.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_message.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_message.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_message.common().member_flags().IS_OPTIONAL(false); - mst_message.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_message.common().member_flags().IS_KEY(false); - mst_message.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_message.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - MD5 message_hash("message"); - for (int i = 0; i < 4; ++i) - { - mst_message.detail().name_hash()[i] = message_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_message); - - MinimalStructMember mst_timestamp; - mst_timestamp.common().member_id(memberId++); - mst_timestamp.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_timestamp.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_timestamp.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_timestamp.common().member_flags().IS_OPTIONAL(false); - mst_timestamp.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_timestamp.common().member_flags().IS_KEY(false); - mst_timestamp.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_timestamp.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - MD5 timestamp_hash("timestamp"); - for (int i = 0; i < 4; ++i) - { - mst_timestamp.detail().name_hash()[i] = timestamp_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_timestamp); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for (int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("LogEntry", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("LogEntry", false); -} - -const TypeObject* GetCompleteLogEntryObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("LogEntry", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject* type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_event; - cst_event.common().member_id(memberId++); - cst_event.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_event.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_event.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_event.common().member_flags().IS_OPTIONAL(false); - cst_event.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_event.common().member_flags().IS_KEY(true); - cst_event.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_event.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - - - cst_event.detail().name("event"); - - { - AppliedAnnotation ann; - //ann.annotation_typeid(GetkeyIdentifier(true)); - ann.annotation_typeid(*TypeObjectFactory::get_instance()->get_type_identifier_trying_complete("key")); - { - AppliedAnnotationParameter annParam; - MD5 message_hash("value"); - for (int i = 0; i < 4; ++i) - { - annParam.paramname_hash()[i] = message_hash.digest[i]; - } - AnnotationParameterValue paramValue; - paramValue._d(TK_BOOLEAN); - paramValue.from_string("true"); - annParam.value(paramValue); - ann.param_seq().push_back(annParam); - } - - cst_event.detail().ann_custom().push_back(ann); - } - - - type_object->complete().struct_type().member_seq().emplace_back(cst_event); - - CompleteStructMember cst_kind; - cst_kind.common().member_id(memberId++); - cst_kind.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_kind.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_kind.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_kind.common().member_flags().IS_OPTIONAL(false); - cst_kind.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_kind.common().member_flags().IS_KEY(false); - cst_kind.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_kind.common().member_type_id(*GetKindIdentifier(true)); - - cst_kind.detail().name("kind"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_kind); - - CompleteStructMember cst_category; - cst_category.common().member_id(memberId++); - cst_category.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_category.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_category.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_category.common().member_flags().IS_OPTIONAL(false); - cst_category.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_category.common().member_flags().IS_KEY(false); - cst_category.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_category.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - cst_category.detail().name("category"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_category); - - CompleteStructMember cst_message; - cst_message.common().member_id(memberId++); - cst_message.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_message.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_message.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_message.common().member_flags().IS_OPTIONAL(false); - cst_message.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_message.common().member_flags().IS_KEY(false); - cst_message.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_message.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - cst_message.detail().name("message"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_message); - - CompleteStructMember cst_timestamp; - cst_timestamp.common().member_id(memberId++); - cst_timestamp.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_timestamp.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_timestamp.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_timestamp.common().member_flags().IS_OPTIONAL(false); - cst_timestamp.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_timestamp.common().member_flags().IS_KEY(false); - cst_timestamp.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_timestamp.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - cst_timestamp.detail().name("timestamp"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_timestamp); - - - // Header - type_object->complete().struct_type().header().detail().type_name("LogEntry"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for (int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("LogEntry", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("LogEntry", true); -} diff --git a/ddspipe_core/src/cpp/types/logging/v2/LogEntryv1.cxx b/ddspipe_core/src/cpp/types/logging/v2/LogEntryv1.cxx deleted file mode 100644 index 079deb03..00000000 --- a/ddspipe_core/src/cpp/types/logging/v2/LogEntryv1.cxx +++ /dev/null @@ -1,480 +0,0 @@ -// 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 LogEntry.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include - -#if FASTCDR_VERSION_MAJOR == 1 - -#include - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - -namespace helper { -namespace internal { - -enum class Size -{ - UInt8, - UInt16, - UInt32, - UInt64, -}; - -constexpr Size get_size( - int s) -{ - return (s <= 8 ) ? Size::UInt8: - (s <= 16) ? Size::UInt16: - (s <= 32) ? Size::UInt32: Size::UInt64; -} - -template -struct FindTypeH; - -template<> -struct FindTypeH -{ - using type = std::uint8_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint16_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint32_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint64_t; -}; -} // namespace internal - -template -struct FindType -{ - using type = typename internal::FindTypeH::type; -}; -} // namespace helper - -#define LogEntry_max_cdr_typesize 792ULL; - - - - -LogEntry::LogEntry() -{ - // long m_event - m_event = 0; - // Kind m_kind - m_kind = ::Info; - // /type_d() m_category - - // /type_d() m_message - - // /type_d() m_timestamp - - - // Just to register all known types - registerLogEntryTypes(); -} - -LogEntry::~LogEntry() -{ -} - -LogEntry::LogEntry( - const LogEntry& x) -{ - m_event = x.m_event; - - - m_kind = x.m_kind; - - - m_category = x.m_category; - - - m_message = x.m_message; - - - m_timestamp = x.m_timestamp; - -} - -LogEntry::LogEntry( - LogEntry&& x) noexcept -{ - m_event = x.m_event; - - - m_kind = x.m_kind; - - - m_category = std::move(x.m_category); - - - m_message = std::move(x.m_message); - - - m_timestamp = std::move(x.m_timestamp); - -} - -LogEntry& LogEntry::operator =( - const LogEntry& x) -{ - m_event = x.m_event; - - - m_kind = x.m_kind; - - - m_category = x.m_category; - - - m_message = x.m_message; - - - m_timestamp = x.m_timestamp; - - return *this; -} - -LogEntry& LogEntry::operator =( - LogEntry&& x) noexcept -{ - m_event = x.m_event; - - - m_kind = x.m_kind; - - - m_category = std::move(x.m_category); - - - m_message = std::move(x.m_message); - - - m_timestamp = std::move(x.m_timestamp); - - return *this; -} - -bool LogEntry::operator ==( - const LogEntry& x) const -{ - return (m_event == x.m_event && - m_kind == x.m_kind && - m_category == x.m_category && - m_message == x.m_message && - m_timestamp == x.m_timestamp); -} - -bool LogEntry::operator !=( - const LogEntry& x) const -{ - return !(*this == x); -} - -size_t LogEntry::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return LogEntry_max_cdr_typesize; -} - -size_t LogEntry::getCdrSerializedSize( - const LogEntry& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.category().size() + 1; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.message().size() + 1; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.timestamp().size() + 1; - - - return current_alignment - initial_alignment; -} - -void LogEntry::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_event; - - scdr << (uint32_t)m_kind; - - scdr << m_category.c_str(); - - scdr << m_message.c_str(); - - scdr << m_timestamp.c_str(); - -} - -void LogEntry::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_event; - - - - { - uint32_t enum_value = 0; - dcdr >> enum_value; - m_kind = (Kind)enum_value; - } - - - - dcdr >> m_category; - - - - dcdr >> m_message; - - - - dcdr >> m_timestamp; - - -} - -bool LogEntry::isKeyDefined() -{ - return true; -} - -void LogEntry::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; - - scdr << m_event; - - - - - -} - -/*! - * @brief This function sets a value in member event - * @param _event New value for member event - */ -void LogEntry::event( - int32_t _event) -{ - m_event = _event; -} - -/*! - * @brief This function returns the value of member event - * @return Value of member event - */ -int32_t LogEntry::event() const -{ - return m_event; -} - -/*! - * @brief This function returns a reference to member event - * @return Reference to member event - */ -int32_t& LogEntry::event() -{ - return m_event; -} - -/*! - * @brief This function sets a value in member kind - * @param _kind New value for member kind - */ -void LogEntry::kind( - Kind _kind) -{ - m_kind = _kind; -} - -/*! - * @brief This function returns the value of member kind - * @return Value of member kind - */ -Kind LogEntry::kind() const -{ - return m_kind; -} - -/*! - * @brief This function returns a reference to member kind - * @return Reference to member kind - */ -Kind& LogEntry::kind() -{ - return m_kind; -} - -/*! - * @brief This function copies the value in member category - * @param _category New value to be copied in member category - */ -void LogEntry::category( - const std::string& _category) -{ - m_category = _category; -} - -/*! - * @brief This function moves the value in member category - * @param _category New value to be moved in member category - */ -void LogEntry::category( - std::string&& _category) -{ - m_category = std::move(_category); -} - -/*! - * @brief This function returns a constant reference to member category - * @return Constant reference to member category - */ -const std::string& LogEntry::category() const -{ - return m_category; -} - -/*! - * @brief This function returns a reference to member category - * @return Reference to member category - */ -std::string& LogEntry::category() -{ - return m_category; -} - -/*! - * @brief This function copies the value in member message - * @param _message New value to be copied in member message - */ -void LogEntry::message( - const std::string& _message) -{ - m_message = _message; -} - -/*! - * @brief This function moves the value in member message - * @param _message New value to be moved in member message - */ -void LogEntry::message( - std::string&& _message) -{ - m_message = std::move(_message); -} - -/*! - * @brief This function returns a constant reference to member message - * @return Constant reference to member message - */ -const std::string& LogEntry::message() const -{ - return m_message; -} - -/*! - * @brief This function returns a reference to member message - * @return Reference to member message - */ -std::string& LogEntry::message() -{ - return m_message; -} - -/*! - * @brief This function copies the value in member timestamp - * @param _timestamp New value to be copied in member timestamp - */ -void LogEntry::timestamp( - const std::string& _timestamp) -{ - m_timestamp = _timestamp; -} - -/*! - * @brief This function moves the value in member timestamp - * @param _timestamp New value to be moved in member timestamp - */ -void LogEntry::timestamp( - std::string&& _timestamp) -{ - m_timestamp = std::move(_timestamp); -} - -/*! - * @brief This function returns a constant reference to member timestamp - * @return Constant reference to member timestamp - */ -const std::string& LogEntry::timestamp() const -{ - return m_timestamp; -} - -/*! - * @brief This function returns a reference to member timestamp - * @return Reference to member timestamp - */ -std::string& LogEntry::timestamp() -{ - return m_timestamp; -} - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddspipe_core/src/cpp/types/monitoring/status/MonitoringStatusPubSubTypes.cxx b/ddspipe_core/src/cpp/types/monitoring/status/MonitoringStatusPubSubTypes.cxx new file mode 100644 index 00000000..d2f46c24 --- /dev/null +++ b/ddspipe_core/src/cpp/types/monitoring/status/MonitoringStatusPubSubTypes.cxx @@ -0,0 +1,398 @@ +// 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 MonitoringStatusPubSubTypes.cpp + * This header file contains the implementation of the serialization functions. + * + * This file was generated by the tool fastddsgen. + */ + +#include + +#include +#include + +#include +#include + +using SerializedPayload_t = eprosima::fastdds::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t; +using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; + +MonitoringErrorStatusPubSubType::MonitoringErrorStatusPubSubType() +{ + set_name("MonitoringErrorStatus"); + uint32_t type_size = MonitoringErrorStatus_max_cdr_typesize; + type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MonitoringErrorStatus_max_key_cdr_typesize > 16 ? MonitoringErrorStatus_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); +} + +MonitoringErrorStatusPubSubType::~MonitoringErrorStatusPubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool MonitoringErrorStatusPubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const MonitoringErrorStatus* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); + payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + ser.set_encoding_flag( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + ser << *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool MonitoringErrorStatusPubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + MonitoringErrorStatus* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + deser >> *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + return true; +} + +uint32_t MonitoringErrorStatusPubSubType::calculate_serialized_size( + const void* const data, + DataRepresentationId_t data_representation) +{ + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +} + +void* MonitoringErrorStatusPubSubType::create_data() +{ + return reinterpret_cast(new MonitoringErrorStatus()); +} + +void MonitoringErrorStatusPubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool MonitoringErrorStatusPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MonitoringErrorStatus data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MonitoringErrorStatusPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const MonitoringErrorStatus* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MonitoringErrorStatus_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); + ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); + eprosima::fastcdr::serialize_key(ser, *p_type); + if (force_md5 || MonitoringErrorStatus_max_key_cdr_typesize > 16) + { + md5_.init(); + md5_.update(key_buffer_, static_cast(ser.get_serialized_data_length())); + md5_.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle.value[i] = md5_.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle.value[i] = key_buffer_[i]; + } + } + return true; +} + +void MonitoringErrorStatusPubSubType::register_type_object_representation() +{ + register_MonitoringErrorStatus_type_identifier(type_identifiers_); +} + +MonitoringStatusPubSubType::MonitoringStatusPubSubType() +{ + set_name("MonitoringStatus"); + uint32_t type_size = MonitoringStatus_max_cdr_typesize; + type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MonitoringStatus_max_key_cdr_typesize > 16 ? MonitoringStatus_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); +} + +MonitoringStatusPubSubType::~MonitoringStatusPubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool MonitoringStatusPubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const MonitoringStatus* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); + payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + ser.set_encoding_flag( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + ser << *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool MonitoringStatusPubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + MonitoringStatus* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + deser >> *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + return true; +} + +uint32_t MonitoringStatusPubSubType::calculate_serialized_size( + const void* const data, + DataRepresentationId_t data_representation) +{ + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +} + +void* MonitoringStatusPubSubType::create_data() +{ + return reinterpret_cast(new MonitoringStatus()); +} + +void MonitoringStatusPubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool MonitoringStatusPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MonitoringStatus data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MonitoringStatusPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const MonitoringStatus* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MonitoringStatus_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); + ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); + eprosima::fastcdr::serialize_key(ser, *p_type); + if (force_md5 || MonitoringStatus_max_key_cdr_typesize > 16) + { + md5_.init(); + md5_.update(key_buffer_, static_cast(ser.get_serialized_data_length())); + md5_.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle.value[i] = md5_.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle.value[i] = key_buffer_[i]; + } + } + return true; +} + +void MonitoringStatusPubSubType::register_type_object_representation() +{ + register_MonitoringStatus_type_identifier(type_identifiers_); +} + + +// Include auxiliary functions like for serializing/deserializing. +#include diff --git a/ddspipe_core/src/cpp/types/monitoring/status/MonitoringStatusTypeObjectSupport.cxx b/ddspipe_core/src/cpp/types/monitoring/status/MonitoringStatusTypeObjectSupport.cxx new file mode 100644 index 00000000..de488fdc --- /dev/null +++ b/ddspipe_core/src/cpp/types/monitoring/status/MonitoringStatusTypeObjectSupport.cxx @@ -0,0 +1,217 @@ +// 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 MonitoringStatusTypeObjectSupport.cxx + * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +using namespace eprosima::fastdds::dds::xtypes; + +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_MonitoringErrorStatus_type_identifier( + TypeIdentifierPair& type_ids_MonitoringErrorStatus) +{ + + ReturnCode_t return_code_MonitoringErrorStatus {eprosima::fastdds::dds::RETCODE_OK}; + return_code_MonitoringErrorStatus = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "MonitoringErrorStatus", type_ids_MonitoringErrorStatus); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_MonitoringErrorStatus) + { + StructTypeFlag struct_flags_MonitoringErrorStatus = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_MonitoringErrorStatus = "MonitoringErrorStatus"; + eprosima::fastcdr::optional type_ann_builtin_MonitoringErrorStatus; + eprosima::fastcdr::optional ann_custom_MonitoringErrorStatus; + CompleteTypeDetail detail_MonitoringErrorStatus = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_MonitoringErrorStatus, ann_custom_MonitoringErrorStatus, type_name_MonitoringErrorStatus.to_string()); + CompleteStructHeader header_MonitoringErrorStatus; + header_MonitoringErrorStatus = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_MonitoringErrorStatus); + CompleteStructMemberSeq member_seq_MonitoringErrorStatus; + { + TypeIdentifierPair type_ids_type_mismatch; + ReturnCode_t return_code_type_mismatch {eprosima::fastdds::dds::RETCODE_OK}; + return_code_type_mismatch = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_bool", type_ids_type_mismatch); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_type_mismatch) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "type_mismatch Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_type_mismatch = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_type_mismatch = 0x00000000; + bool common_type_mismatch_ec {false}; + CommonStructMember common_type_mismatch {TypeObjectUtils::build_common_struct_member(member_id_type_mismatch, member_flags_type_mismatch, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_type_mismatch, common_type_mismatch_ec))}; + if (!common_type_mismatch_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure type_mismatch member TypeIdentifier inconsistent."); + return; + } + MemberName name_type_mismatch = "type_mismatch"; + eprosima::fastcdr::optional member_ann_builtin_type_mismatch; + ann_custom_MonitoringErrorStatus.reset(); + CompleteMemberDetail detail_type_mismatch = TypeObjectUtils::build_complete_member_detail(name_type_mismatch, member_ann_builtin_type_mismatch, ann_custom_MonitoringErrorStatus); + CompleteStructMember member_type_mismatch = TypeObjectUtils::build_complete_struct_member(common_type_mismatch, detail_type_mismatch); + TypeObjectUtils::add_complete_struct_member(member_seq_MonitoringErrorStatus, member_type_mismatch); + } + { + TypeIdentifierPair type_ids_qos_mismatch; + ReturnCode_t return_code_qos_mismatch {eprosima::fastdds::dds::RETCODE_OK}; + return_code_qos_mismatch = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_bool", type_ids_qos_mismatch); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_qos_mismatch) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "qos_mismatch Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_qos_mismatch = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_qos_mismatch = 0x00000001; + bool common_qos_mismatch_ec {false}; + CommonStructMember common_qos_mismatch {TypeObjectUtils::build_common_struct_member(member_id_qos_mismatch, member_flags_qos_mismatch, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_qos_mismatch, common_qos_mismatch_ec))}; + if (!common_qos_mismatch_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure qos_mismatch member TypeIdentifier inconsistent."); + return; + } + MemberName name_qos_mismatch = "qos_mismatch"; + eprosima::fastcdr::optional member_ann_builtin_qos_mismatch; + ann_custom_MonitoringErrorStatus.reset(); + CompleteMemberDetail detail_qos_mismatch = TypeObjectUtils::build_complete_member_detail(name_qos_mismatch, member_ann_builtin_qos_mismatch, ann_custom_MonitoringErrorStatus); + CompleteStructMember member_qos_mismatch = TypeObjectUtils::build_complete_struct_member(common_qos_mismatch, detail_qos_mismatch); + TypeObjectUtils::add_complete_struct_member(member_seq_MonitoringErrorStatus, member_qos_mismatch); + } + CompleteStructType struct_type_MonitoringErrorStatus = TypeObjectUtils::build_complete_struct_type(struct_flags_MonitoringErrorStatus, header_MonitoringErrorStatus, member_seq_MonitoringErrorStatus); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_MonitoringErrorStatus, type_name_MonitoringErrorStatus.to_string(), type_ids_MonitoringErrorStatus)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "MonitoringErrorStatus already registered in TypeObjectRegistry for a different type."); + } + } +} +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_MonitoringStatus_type_identifier( + TypeIdentifierPair& type_ids_MonitoringStatus) +{ + + ReturnCode_t return_code_MonitoringStatus {eprosima::fastdds::dds::RETCODE_OK}; + return_code_MonitoringStatus = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "MonitoringStatus", type_ids_MonitoringStatus); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_MonitoringStatus) + { + StructTypeFlag struct_flags_MonitoringStatus = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_MonitoringStatus = "MonitoringStatus"; + eprosima::fastcdr::optional type_ann_builtin_MonitoringStatus; + eprosima::fastcdr::optional ann_custom_MonitoringStatus; + CompleteTypeDetail detail_MonitoringStatus = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_MonitoringStatus, ann_custom_MonitoringStatus, type_name_MonitoringStatus.to_string()); + CompleteStructHeader header_MonitoringStatus; + header_MonitoringStatus = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_MonitoringStatus); + CompleteStructMemberSeq member_seq_MonitoringStatus; + { + TypeIdentifierPair type_ids_error_status; + ReturnCode_t return_code_error_status {eprosima::fastdds::dds::RETCODE_OK}; + return_code_error_status = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "MonitoringErrorStatus", type_ids_error_status); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_error_status) + { + ::register_MonitoringErrorStatus_type_identifier(type_ids_error_status); + } + StructMemberFlag member_flags_error_status = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_error_status = 0x00000000; + bool common_error_status_ec {false}; + CommonStructMember common_error_status {TypeObjectUtils::build_common_struct_member(member_id_error_status, member_flags_error_status, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_error_status, common_error_status_ec))}; + if (!common_error_status_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure error_status member TypeIdentifier inconsistent."); + return; + } + MemberName name_error_status = "error_status"; + eprosima::fastcdr::optional member_ann_builtin_error_status; + ann_custom_MonitoringStatus.reset(); + CompleteMemberDetail detail_error_status = TypeObjectUtils::build_complete_member_detail(name_error_status, member_ann_builtin_error_status, ann_custom_MonitoringStatus); + CompleteStructMember member_error_status = TypeObjectUtils::build_complete_struct_member(common_error_status, detail_error_status); + TypeObjectUtils::add_complete_struct_member(member_seq_MonitoringStatus, member_error_status); + } + { + TypeIdentifierPair type_ids_has_errors; + ReturnCode_t return_code_has_errors {eprosima::fastdds::dds::RETCODE_OK}; + return_code_has_errors = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_bool", type_ids_has_errors); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_has_errors) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "has_errors Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_has_errors = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_has_errors = 0x00000001; + bool common_has_errors_ec {false}; + CommonStructMember common_has_errors {TypeObjectUtils::build_common_struct_member(member_id_has_errors, member_flags_has_errors, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_has_errors, common_has_errors_ec))}; + if (!common_has_errors_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure has_errors member TypeIdentifier inconsistent."); + return; + } + MemberName name_has_errors = "has_errors"; + eprosima::fastcdr::optional member_ann_builtin_has_errors; + ann_custom_MonitoringStatus.reset(); + CompleteMemberDetail detail_has_errors = TypeObjectUtils::build_complete_member_detail(name_has_errors, member_ann_builtin_has_errors, ann_custom_MonitoringStatus); + CompleteStructMember member_has_errors = TypeObjectUtils::build_complete_struct_member(common_has_errors, detail_has_errors); + TypeObjectUtils::add_complete_struct_member(member_seq_MonitoringStatus, member_has_errors); + } + CompleteStructType struct_type_MonitoringStatus = TypeObjectUtils::build_complete_struct_type(struct_flags_MonitoringStatus, header_MonitoringStatus, member_seq_MonitoringStatus); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_MonitoringStatus, type_name_MonitoringStatus.to_string(), type_ids_MonitoringStatus)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "MonitoringStatus already registered in TypeObjectRegistry for a different type."); + } + } +} + diff --git a/ddspipe_core/src/cpp/types/monitoring/status/v1/MonitoringStatus.cxx b/ddspipe_core/src/cpp/types/monitoring/status/v1/MonitoringStatus.cxx deleted file mode 100644 index e6811fe5..00000000 --- a/ddspipe_core/src/cpp/types/monitoring/status/v1/MonitoringStatus.cxx +++ /dev/null @@ -1,465 +0,0 @@ -// 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 MonitoringStatus.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - -namespace helper { -namespace internal { - -enum class Size -{ - UInt8, - UInt16, - UInt32, - UInt64, -}; - -constexpr Size get_size( - int s) -{ - return (s <= 8 ) ? Size::UInt8: - (s <= 16) ? Size::UInt16: - (s <= 32) ? Size::UInt32: Size::UInt64; -} - -template -struct FindTypeH; - -template<> -struct FindTypeH -{ - using type = std::uint8_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint16_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint32_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint64_t; -}; -} // namespace internal - -template -struct FindType -{ - using type = typename internal::FindTypeH::type; -}; -} // namespace helper - -#define MonitoringErrorStatus_max_cdr_typesize 6ULL; -#define MonitoringStatus_max_cdr_typesize 11ULL; - - - - -MonitoringErrorStatus::MonitoringErrorStatus() -{ - // boolean m_type_mismatch - m_type_mismatch = false; - // boolean m_qos_mismatch - m_qos_mismatch = false; - -} - -MonitoringErrorStatus::~MonitoringErrorStatus() -{ -} - -MonitoringErrorStatus::MonitoringErrorStatus( - const MonitoringErrorStatus& x) -{ - m_type_mismatch = x.m_type_mismatch; - - - m_qos_mismatch = x.m_qos_mismatch; - -} - -MonitoringErrorStatus::MonitoringErrorStatus( - MonitoringErrorStatus&& x) noexcept -{ - m_type_mismatch = x.m_type_mismatch; - - - m_qos_mismatch = x.m_qos_mismatch; - -} - -MonitoringErrorStatus& MonitoringErrorStatus::operator =( - const MonitoringErrorStatus& x) -{ - m_type_mismatch = x.m_type_mismatch; - - - m_qos_mismatch = x.m_qos_mismatch; - - return *this; -} - -MonitoringErrorStatus& MonitoringErrorStatus::operator =( - MonitoringErrorStatus&& x) noexcept -{ - m_type_mismatch = x.m_type_mismatch; - - - m_qos_mismatch = x.m_qos_mismatch; - - return *this; -} - -bool MonitoringErrorStatus::operator ==( - const MonitoringErrorStatus& x) const -{ - return (m_type_mismatch == x.m_type_mismatch && - m_qos_mismatch == x.m_qos_mismatch); -} - -bool MonitoringErrorStatus::operator !=( - const MonitoringErrorStatus& x) const -{ - return !(*this == x); -} - -size_t MonitoringErrorStatus::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return MonitoringErrorStatus_max_cdr_typesize; -} - -size_t MonitoringErrorStatus::getCdrSerializedSize( - const MonitoringErrorStatus& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); - - - current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); - - - return current_alignment - initial_alignment; -} - -void MonitoringErrorStatus::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_type_mismatch; - - scdr << m_qos_mismatch; - -} - -void MonitoringErrorStatus::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_type_mismatch; - - - - dcdr >> m_qos_mismatch; - - -} - -bool MonitoringErrorStatus::isKeyDefined() -{ - return false; -} - -void MonitoringErrorStatus::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function sets a value in member type_mismatch - * @param _type_mismatch New value for member type_mismatch - */ -void MonitoringErrorStatus::type_mismatch( - bool _type_mismatch) -{ - m_type_mismatch = _type_mismatch; -} - -/*! - * @brief This function returns the value of member type_mismatch - * @return Value of member type_mismatch - */ -bool MonitoringErrorStatus::type_mismatch() const -{ - return m_type_mismatch; -} - -/*! - * @brief This function returns a reference to member type_mismatch - * @return Reference to member type_mismatch - */ -bool& MonitoringErrorStatus::type_mismatch() -{ - return m_type_mismatch; -} - -/*! - * @brief This function sets a value in member qos_mismatch - * @param _qos_mismatch New value for member qos_mismatch - */ -void MonitoringErrorStatus::qos_mismatch( - bool _qos_mismatch) -{ - m_qos_mismatch = _qos_mismatch; -} - -/*! - * @brief This function returns the value of member qos_mismatch - * @return Value of member qos_mismatch - */ -bool MonitoringErrorStatus::qos_mismatch() const -{ - return m_qos_mismatch; -} - -/*! - * @brief This function returns a reference to member qos_mismatch - * @return Reference to member qos_mismatch - */ -bool& MonitoringErrorStatus::qos_mismatch() -{ - return m_qos_mismatch; -} - -MonitoringStatus::MonitoringStatus() -{ - // MonitoringErrorStatus m_error_status - - // boolean m_has_errors - m_has_errors = false; - -} - -MonitoringStatus::~MonitoringStatus() -{ -} - -MonitoringStatus::MonitoringStatus( - const MonitoringStatus& x) -{ - m_error_status = x.m_error_status; - - - m_has_errors = x.m_has_errors; - -} - -MonitoringStatus::MonitoringStatus( - MonitoringStatus&& x) noexcept -{ - m_error_status = std::move(x.m_error_status); - - - m_has_errors = x.m_has_errors; - -} - -MonitoringStatus& MonitoringStatus::operator =( - const MonitoringStatus& x) -{ - m_error_status = x.m_error_status; - - - m_has_errors = x.m_has_errors; - - return *this; -} - -MonitoringStatus& MonitoringStatus::operator =( - MonitoringStatus&& x) noexcept -{ - m_error_status = std::move(x.m_error_status); - - - m_has_errors = x.m_has_errors; - - return *this; -} - -bool MonitoringStatus::operator ==( - const MonitoringStatus& x) const -{ - return (m_error_status == x.m_error_status && - m_has_errors == x.m_has_errors); -} - -bool MonitoringStatus::operator !=( - const MonitoringStatus& x) const -{ - return !(*this == x); -} - -size_t MonitoringStatus::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return MonitoringStatus_max_cdr_typesize; -} - -size_t MonitoringStatus::getCdrSerializedSize( - const MonitoringStatus& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += MonitoringErrorStatus::getCdrSerializedSize(data.error_status(), current_alignment); - - - current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); - - - return current_alignment - initial_alignment; -} - -void MonitoringStatus::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_error_status; - - scdr << m_has_errors; - -} - -void MonitoringStatus::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_error_status; - - - - dcdr >> m_has_errors; - - -} - -bool MonitoringStatus::isKeyDefined() -{ - return false; -} - -void MonitoringStatus::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function copies the value in member error_status - * @param _error_status New value to be copied in member error_status - */ -void MonitoringStatus::error_status( - const MonitoringErrorStatus& _error_status) -{ - m_error_status = _error_status; -} - -/*! - * @brief This function moves the value in member error_status - * @param _error_status New value to be moved in member error_status - */ -void MonitoringStatus::error_status( - MonitoringErrorStatus&& _error_status) -{ - m_error_status = std::move(_error_status); -} - -/*! - * @brief This function returns a constant reference to member error_status - * @return Constant reference to member error_status - */ -const MonitoringErrorStatus& MonitoringStatus::error_status() const -{ - return m_error_status; -} - -/*! - * @brief This function returns a reference to member error_status - * @return Reference to member error_status - */ -MonitoringErrorStatus& MonitoringStatus::error_status() -{ - return m_error_status; -} - -/*! - * @brief This function sets a value in member has_errors - * @param _has_errors New value for member has_errors - */ -void MonitoringStatus::has_errors( - bool _has_errors) -{ - m_has_errors = _has_errors; -} - -/*! - * @brief This function returns the value of member has_errors - * @return Value of member has_errors - */ -bool MonitoringStatus::has_errors() const -{ - return m_has_errors; -} - -/*! - * @brief This function returns a reference to member has_errors - * @return Reference to member has_errors - */ -bool& MonitoringStatus::has_errors() -{ - return m_has_errors; -} diff --git a/ddspipe_core/src/cpp/types/monitoring/status/v1/MonitoringStatusPubSubTypes.cxx b/ddspipe_core/src/cpp/types/monitoring/status/v1/MonitoringStatusPubSubTypes.cxx deleted file mode 100644 index e17cde95..00000000 --- a/ddspipe_core/src/cpp/types/monitoring/status/v1/MonitoringStatusPubSubTypes.cxx +++ /dev/null @@ -1,411 +0,0 @@ -// 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 MonitoringStatusPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#include - -#include -#include - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; -using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - - - -MonitoringErrorStatusPubSubType::MonitoringErrorStatusPubSubType() -{ - setName("MonitoringErrorStatus"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MonitoringErrorStatus::getMaxCdrSerializedSize()); -#else - MonitoringErrorStatus_max_cdr_typesize; -#endif // if FASTCDR_VERSION_MAJOR == 1 - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MonitoringErrorStatus_max_key_cdr_typesize > - 16 ? MonitoringErrorStatus_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -MonitoringErrorStatusPubSubType::~MonitoringErrorStatusPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool MonitoringErrorStatusPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - MonitoringErrorStatus* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool MonitoringErrorStatusPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - MonitoringErrorStatus* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function MonitoringErrorStatusPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MonitoringErrorStatusPubSubType::createData() -{ - return reinterpret_cast(new MonitoringErrorStatus()); -} - -void MonitoringErrorStatusPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool MonitoringErrorStatusPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - MonitoringErrorStatus* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MonitoringErrorStatus_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MonitoringErrorStatus_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - -MonitoringStatusPubSubType::MonitoringStatusPubSubType() -{ - setName("MonitoringStatus"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MonitoringStatus::getMaxCdrSerializedSize()); -#else - MonitoringStatus_max_cdr_typesize; -#endif // if FASTCDR_VERSION_MAJOR == 1 - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MonitoringStatus_max_key_cdr_typesize > 16 ? MonitoringStatus_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -MonitoringStatusPubSubType::~MonitoringStatusPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool MonitoringStatusPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - MonitoringStatus* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool MonitoringStatusPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - MonitoringStatus* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function MonitoringStatusPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MonitoringStatusPubSubType::createData() -{ - return reinterpret_cast(new MonitoringStatus()); -} - -void MonitoringStatusPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool MonitoringStatusPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - MonitoringStatus* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MonitoringStatus_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MonitoringStatus_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} diff --git a/ddspipe_core/src/cpp/types/monitoring/status/v1/MonitoringStatusTypeObject.cxx b/ddspipe_core/src/cpp/types/monitoring/status/v1/MonitoringStatusTypeObject.cxx deleted file mode 100644 index ff7465d1..00000000 --- a/ddspipe_core/src/cpp/types/monitoring/status/v1/MonitoringStatusTypeObject.cxx +++ /dev/null @@ -1,487 +0,0 @@ -// 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 MonitoringStatusTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // ifdef _WIN32 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerMonitoringStatusTypes() -{ - static std::once_flag once_flag; - std::call_once(once_flag, []() - { - TypeObjectFactory* factory = TypeObjectFactory::get_instance(); - factory->add_type_object("MonitoringErrorStatus", GetMonitoringErrorStatusIdentifier(true), - GetMonitoringErrorStatusObject(true)); - factory->add_type_object("MonitoringErrorStatus", GetMonitoringErrorStatusIdentifier(false), - GetMonitoringErrorStatusObject(false)); - - - factory->add_type_object("MonitoringStatus", GetMonitoringStatusIdentifier(true), - GetMonitoringStatusObject(true)); - factory->add_type_object("MonitoringStatus", GetMonitoringStatusIdentifier(false), - GetMonitoringStatusObject(false)); - - }); -} - -const TypeIdentifier* GetMonitoringErrorStatusIdentifier( - bool complete) -{ - const TypeIdentifier* c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("MonitoringErrorStatus", - complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetMonitoringErrorStatusObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("MonitoringErrorStatus", complete); -} - -const TypeObject* GetMonitoringErrorStatusObject( - bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MonitoringErrorStatus", - complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteMonitoringErrorStatusObject(); - } - //else - return GetMinimalMonitoringErrorStatusObject(); -} - -const TypeObject* GetMinimalMonitoringErrorStatusObject() -{ - const TypeObject* c_type_object = - TypeObjectFactory::get_instance()->get_type_object("MonitoringErrorStatus", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject* type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_type_mismatch; - mst_type_mismatch.common().member_id(memberId++); - mst_type_mismatch.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_type_mismatch.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_type_mismatch.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_type_mismatch.common().member_flags().IS_OPTIONAL(false); - mst_type_mismatch.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_type_mismatch.common().member_flags().IS_KEY(false); - mst_type_mismatch.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_type_mismatch.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - - MD5 type_mismatch_hash("type_mismatch"); - for (int i = 0; i < 4; ++i) - { - mst_type_mismatch.detail().name_hash()[i] = type_mismatch_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_type_mismatch); - - MinimalStructMember mst_qos_mismatch; - mst_qos_mismatch.common().member_id(memberId++); - mst_qos_mismatch.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_qos_mismatch.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_qos_mismatch.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_qos_mismatch.common().member_flags().IS_OPTIONAL(false); - mst_qos_mismatch.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_qos_mismatch.common().member_flags().IS_KEY(false); - mst_qos_mismatch.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_qos_mismatch.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - - MD5 qos_mismatch_hash("qos_mismatch"); - for (int i = 0; i < 4; ++i) - { - mst_qos_mismatch.detail().name_hash()[i] = qos_mismatch_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_qos_mismatch); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for (int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("MonitoringErrorStatus", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("MonitoringErrorStatus", false); -} - -const TypeObject* GetCompleteMonitoringErrorStatusObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MonitoringErrorStatus", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject* type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_type_mismatch; - cst_type_mismatch.common().member_id(memberId++); - cst_type_mismatch.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_type_mismatch.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_type_mismatch.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_type_mismatch.common().member_flags().IS_OPTIONAL(false); - cst_type_mismatch.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_type_mismatch.common().member_flags().IS_KEY(false); - cst_type_mismatch.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_type_mismatch.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - - cst_type_mismatch.detail().name("type_mismatch"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_type_mismatch); - - CompleteStructMember cst_qos_mismatch; - cst_qos_mismatch.common().member_id(memberId++); - cst_qos_mismatch.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_qos_mismatch.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_qos_mismatch.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_qos_mismatch.common().member_flags().IS_OPTIONAL(false); - cst_qos_mismatch.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_qos_mismatch.common().member_flags().IS_KEY(false); - cst_qos_mismatch.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_qos_mismatch.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - - cst_qos_mismatch.detail().name("qos_mismatch"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_qos_mismatch); - - - // Header - type_object->complete().struct_type().header().detail().type_name("MonitoringErrorStatus"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for (int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("MonitoringErrorStatus", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("MonitoringErrorStatus", true); -} - -const TypeIdentifier* GetMonitoringStatusIdentifier( - bool complete) -{ - const TypeIdentifier* c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("MonitoringStatus", - complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetMonitoringStatusObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("MonitoringStatus", complete); -} - -const TypeObject* GetMonitoringStatusObject( - bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MonitoringStatus", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteMonitoringStatusObject(); - } - //else - return GetMinimalMonitoringStatusObject(); -} - -const TypeObject* GetMinimalMonitoringStatusObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MonitoringStatus", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject* type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_error_status; - mst_error_status.common().member_id(memberId++); - mst_error_status.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_error_status.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_error_status.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_error_status.common().member_flags().IS_OPTIONAL(false); - mst_error_status.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_error_status.common().member_flags().IS_KEY(false); - mst_error_status.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_error_status.common().member_type_id(*GetMonitoringErrorStatusIdentifier(false)); - - MD5 error_status_hash("error_status"); - for (int i = 0; i < 4; ++i) - { - mst_error_status.detail().name_hash()[i] = error_status_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_error_status); - - MinimalStructMember mst_has_errors; - mst_has_errors.common().member_id(memberId++); - mst_has_errors.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_has_errors.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_has_errors.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_has_errors.common().member_flags().IS_OPTIONAL(false); - mst_has_errors.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_has_errors.common().member_flags().IS_KEY(false); - mst_has_errors.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_has_errors.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - - MD5 has_errors_hash("has_errors"); - for (int i = 0; i < 4; ++i) - { - mst_has_errors.detail().name_hash()[i] = has_errors_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_has_errors); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for (int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("MonitoringStatus", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("MonitoringStatus", false); -} - -const TypeObject* GetCompleteMonitoringStatusObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MonitoringStatus", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject* type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_error_status; - cst_error_status.common().member_id(memberId++); - cst_error_status.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_error_status.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_error_status.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_error_status.common().member_flags().IS_OPTIONAL(false); - cst_error_status.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_error_status.common().member_flags().IS_KEY(false); - cst_error_status.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_error_status.common().member_type_id(*GetMonitoringErrorStatusIdentifier(true)); - - cst_error_status.detail().name("error_status"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_error_status); - - CompleteStructMember cst_has_errors; - cst_has_errors.common().member_id(memberId++); - cst_has_errors.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_has_errors.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_has_errors.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_has_errors.common().member_flags().IS_OPTIONAL(false); - cst_has_errors.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_has_errors.common().member_flags().IS_KEY(false); - cst_has_errors.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_has_errors.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - - cst_has_errors.detail().name("has_errors"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_has_errors); - - - // Header - type_object->complete().struct_type().header().detail().type_name("MonitoringStatus"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for (int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("MonitoringStatus", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("MonitoringStatus", true); -} diff --git a/ddspipe_core/src/cpp/types/monitoring/status/v2/MonitoringStatus.cxx b/ddspipe_core/src/cpp/types/monitoring/status/v2/MonitoringStatus.cxx deleted file mode 100644 index a2e9028c..00000000 --- a/ddspipe_core/src/cpp/types/monitoring/status/v2/MonitoringStatus.cxx +++ /dev/null @@ -1,275 +0,0 @@ -// 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 MonitoringStatus.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include - -#if FASTCDR_VERSION_MAJOR > 1 - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - - - - -MonitoringErrorStatus::MonitoringErrorStatus() -{ -} - -MonitoringErrorStatus::~MonitoringErrorStatus() -{ -} - -MonitoringErrorStatus::MonitoringErrorStatus( - const MonitoringErrorStatus& x) -{ - m_type_mismatch = x.m_type_mismatch; - m_qos_mismatch = x.m_qos_mismatch; -} - -MonitoringErrorStatus::MonitoringErrorStatus( - MonitoringErrorStatus&& x) noexcept -{ - m_type_mismatch = x.m_type_mismatch; - m_qos_mismatch = x.m_qos_mismatch; -} - -MonitoringErrorStatus& MonitoringErrorStatus::operator =( - const MonitoringErrorStatus& x) -{ - - m_type_mismatch = x.m_type_mismatch; - m_qos_mismatch = x.m_qos_mismatch; - return *this; -} - -MonitoringErrorStatus& MonitoringErrorStatus::operator =( - MonitoringErrorStatus&& x) noexcept -{ - - m_type_mismatch = x.m_type_mismatch; - m_qos_mismatch = x.m_qos_mismatch; - return *this; -} - -bool MonitoringErrorStatus::operator ==( - const MonitoringErrorStatus& x) const -{ - return (m_type_mismatch == x.m_type_mismatch && - m_qos_mismatch == x.m_qos_mismatch); -} - -bool MonitoringErrorStatus::operator !=( - const MonitoringErrorStatus& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function sets a value in member type_mismatch - * @param _type_mismatch New value for member type_mismatch - */ -void MonitoringErrorStatus::type_mismatch( - bool _type_mismatch) -{ - m_type_mismatch = _type_mismatch; -} - -/*! - * @brief This function returns the value of member type_mismatch - * @return Value of member type_mismatch - */ -bool MonitoringErrorStatus::type_mismatch() const -{ - return m_type_mismatch; -} - -/*! - * @brief This function returns a reference to member type_mismatch - * @return Reference to member type_mismatch - */ -bool& MonitoringErrorStatus::type_mismatch() -{ - return m_type_mismatch; -} - -/*! - * @brief This function sets a value in member qos_mismatch - * @param _qos_mismatch New value for member qos_mismatch - */ -void MonitoringErrorStatus::qos_mismatch( - bool _qos_mismatch) -{ - m_qos_mismatch = _qos_mismatch; -} - -/*! - * @brief This function returns the value of member qos_mismatch - * @return Value of member qos_mismatch - */ -bool MonitoringErrorStatus::qos_mismatch() const -{ - return m_qos_mismatch; -} - -/*! - * @brief This function returns a reference to member qos_mismatch - * @return Reference to member qos_mismatch - */ -bool& MonitoringErrorStatus::qos_mismatch() -{ - return m_qos_mismatch; -} - -MonitoringStatus::MonitoringStatus() -{ -} - -MonitoringStatus::~MonitoringStatus() -{ -} - -MonitoringStatus::MonitoringStatus( - const MonitoringStatus& x) -{ - m_error_status = x.m_error_status; - m_has_errors = x.m_has_errors; -} - -MonitoringStatus::MonitoringStatus( - MonitoringStatus&& x) noexcept -{ - m_error_status = std::move(x.m_error_status); - m_has_errors = x.m_has_errors; -} - -MonitoringStatus& MonitoringStatus::operator =( - const MonitoringStatus& x) -{ - - m_error_status = x.m_error_status; - m_has_errors = x.m_has_errors; - return *this; -} - -MonitoringStatus& MonitoringStatus::operator =( - MonitoringStatus&& x) noexcept -{ - - m_error_status = std::move(x.m_error_status); - m_has_errors = x.m_has_errors; - return *this; -} - -bool MonitoringStatus::operator ==( - const MonitoringStatus& x) const -{ - return (m_error_status == x.m_error_status && - m_has_errors == x.m_has_errors); -} - -bool MonitoringStatus::operator !=( - const MonitoringStatus& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function copies the value in member error_status - * @param _error_status New value to be copied in member error_status - */ -void MonitoringStatus::error_status( - const MonitoringErrorStatus& _error_status) -{ - m_error_status = _error_status; -} - -/*! - * @brief This function moves the value in member error_status - * @param _error_status New value to be moved in member error_status - */ -void MonitoringStatus::error_status( - MonitoringErrorStatus&& _error_status) -{ - m_error_status = std::move(_error_status); -} - -/*! - * @brief This function returns a constant reference to member error_status - * @return Constant reference to member error_status - */ -const MonitoringErrorStatus& MonitoringStatus::error_status() const -{ - return m_error_status; -} - -/*! - * @brief This function returns a reference to member error_status - * @return Reference to member error_status - */ -MonitoringErrorStatus& MonitoringStatus::error_status() -{ - return m_error_status; -} - -/*! - * @brief This function sets a value in member has_errors - * @param _has_errors New value for member has_errors - */ -void MonitoringStatus::has_errors( - bool _has_errors) -{ - m_has_errors = _has_errors; -} - -/*! - * @brief This function returns the value of member has_errors - * @return Value of member has_errors - */ -bool MonitoringStatus::has_errors() const -{ - return m_has_errors; -} - -/*! - * @brief This function returns a reference to member has_errors - * @return Reference to member has_errors - */ -bool& MonitoringStatus::has_errors() -{ - return m_has_errors; -} - -// Include auxiliary functions like for serializing/deserializing. -#include - -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddspipe_core/src/cpp/types/monitoring/status/v2/MonitoringStatusPubSubTypes.cxx b/ddspipe_core/src/cpp/types/monitoring/status/v2/MonitoringStatusPubSubTypes.cxx deleted file mode 100644 index b287587d..00000000 --- a/ddspipe_core/src/cpp/types/monitoring/status/v2/MonitoringStatusPubSubTypes.cxx +++ /dev/null @@ -1,411 +0,0 @@ -// 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 MonitoringStatusPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#include - -#include -#include - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; -using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - - - -MonitoringErrorStatusPubSubType::MonitoringErrorStatusPubSubType() -{ - setName("MonitoringErrorStatus"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MonitoringErrorStatus::getMaxCdrSerializedSize()); -#else - MonitoringErrorStatus_max_cdr_typesize; -#endif // if FASTCDR_VERSION_MAJOR == 1 - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MonitoringErrorStatus_max_key_cdr_typesize > - 16 ? MonitoringErrorStatus_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -MonitoringErrorStatusPubSubType::~MonitoringErrorStatusPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool MonitoringErrorStatusPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - MonitoringErrorStatus* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool MonitoringErrorStatusPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - MonitoringErrorStatus* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function MonitoringErrorStatusPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MonitoringErrorStatusPubSubType::createData() -{ - return reinterpret_cast(new MonitoringErrorStatus()); -} - -void MonitoringErrorStatusPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool MonitoringErrorStatusPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - MonitoringErrorStatus* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MonitoringErrorStatus_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MonitoringErrorStatus_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - -MonitoringStatusPubSubType::MonitoringStatusPubSubType() -{ - setName("MonitoringStatus"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MonitoringStatus::getMaxCdrSerializedSize()); -#else - MonitoringStatus_max_cdr_typesize; -#endif // if FASTCDR_VERSION_MAJOR == 1 - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MonitoringStatus_max_key_cdr_typesize > 16 ? MonitoringStatus_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -MonitoringStatusPubSubType::~MonitoringStatusPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool MonitoringStatusPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - MonitoringStatus* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool MonitoringStatusPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - MonitoringStatus* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function MonitoringStatusPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MonitoringStatusPubSubType::createData() -{ - return reinterpret_cast(new MonitoringStatus()); -} - -void MonitoringStatusPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool MonitoringStatusPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - MonitoringStatus* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MonitoringStatus_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MonitoringStatus_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} diff --git a/ddspipe_core/src/cpp/types/monitoring/status/v2/MonitoringStatusTypeObject.cxx b/ddspipe_core/src/cpp/types/monitoring/status/v2/MonitoringStatusTypeObject.cxx deleted file mode 100644 index 25259815..00000000 --- a/ddspipe_core/src/cpp/types/monitoring/status/v2/MonitoringStatusTypeObject.cxx +++ /dev/null @@ -1,487 +0,0 @@ -// 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 MonitoringStatusTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // ifdef _WIN32 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerMonitoringStatusTypes() -{ - static std::once_flag once_flag; - std::call_once(once_flag, []() - { - TypeObjectFactory* factory = TypeObjectFactory::get_instance(); - factory->add_type_object("MonitoringErrorStatus", GetMonitoringErrorStatusIdentifier(true), - GetMonitoringErrorStatusObject(true)); - factory->add_type_object("MonitoringErrorStatus", GetMonitoringErrorStatusIdentifier(false), - GetMonitoringErrorStatusObject(false)); - - - factory->add_type_object("MonitoringStatus", GetMonitoringStatusIdentifier(true), - GetMonitoringStatusObject(true)); - factory->add_type_object("MonitoringStatus", GetMonitoringStatusIdentifier(false), - GetMonitoringStatusObject(false)); - - }); -} - -const TypeIdentifier* GetMonitoringErrorStatusIdentifier( - bool complete) -{ - const TypeIdentifier* c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("MonitoringErrorStatus", - complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetMonitoringErrorStatusObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("MonitoringErrorStatus", complete); -} - -const TypeObject* GetMonitoringErrorStatusObject( - bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MonitoringErrorStatus", - complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteMonitoringErrorStatusObject(); - } - //else - return GetMinimalMonitoringErrorStatusObject(); -} - -const TypeObject* GetMinimalMonitoringErrorStatusObject() -{ - const TypeObject* c_type_object = - TypeObjectFactory::get_instance()->get_type_object("MonitoringErrorStatus", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject* type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_type_mismatch; - mst_type_mismatch.common().member_id(memberId++); - mst_type_mismatch.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_type_mismatch.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_type_mismatch.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_type_mismatch.common().member_flags().IS_OPTIONAL(false); - mst_type_mismatch.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_type_mismatch.common().member_flags().IS_KEY(false); - mst_type_mismatch.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_type_mismatch.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - - MD5 type_mismatch_hash("type_mismatch"); - for (int i = 0; i < 4; ++i) - { - mst_type_mismatch.detail().name_hash()[i] = type_mismatch_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_type_mismatch); - - MinimalStructMember mst_qos_mismatch; - mst_qos_mismatch.common().member_id(memberId++); - mst_qos_mismatch.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_qos_mismatch.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_qos_mismatch.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_qos_mismatch.common().member_flags().IS_OPTIONAL(false); - mst_qos_mismatch.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_qos_mismatch.common().member_flags().IS_KEY(false); - mst_qos_mismatch.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_qos_mismatch.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - - MD5 qos_mismatch_hash("qos_mismatch"); - for (int i = 0; i < 4; ++i) - { - mst_qos_mismatch.detail().name_hash()[i] = qos_mismatch_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_qos_mismatch); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for (int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("MonitoringErrorStatus", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("MonitoringErrorStatus", false); -} - -const TypeObject* GetCompleteMonitoringErrorStatusObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MonitoringErrorStatus", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject* type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_type_mismatch; - cst_type_mismatch.common().member_id(memberId++); - cst_type_mismatch.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_type_mismatch.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_type_mismatch.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_type_mismatch.common().member_flags().IS_OPTIONAL(false); - cst_type_mismatch.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_type_mismatch.common().member_flags().IS_KEY(false); - cst_type_mismatch.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_type_mismatch.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - - cst_type_mismatch.detail().name("type_mismatch"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_type_mismatch); - - CompleteStructMember cst_qos_mismatch; - cst_qos_mismatch.common().member_id(memberId++); - cst_qos_mismatch.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_qos_mismatch.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_qos_mismatch.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_qos_mismatch.common().member_flags().IS_OPTIONAL(false); - cst_qos_mismatch.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_qos_mismatch.common().member_flags().IS_KEY(false); - cst_qos_mismatch.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_qos_mismatch.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - - cst_qos_mismatch.detail().name("qos_mismatch"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_qos_mismatch); - - - // Header - type_object->complete().struct_type().header().detail().type_name("MonitoringErrorStatus"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for (int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("MonitoringErrorStatus", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("MonitoringErrorStatus", true); -} - -const TypeIdentifier* GetMonitoringStatusIdentifier( - bool complete) -{ - const TypeIdentifier* c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("MonitoringStatus", - complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetMonitoringStatusObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("MonitoringStatus", complete); -} - -const TypeObject* GetMonitoringStatusObject( - bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MonitoringStatus", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteMonitoringStatusObject(); - } - //else - return GetMinimalMonitoringStatusObject(); -} - -const TypeObject* GetMinimalMonitoringStatusObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MonitoringStatus", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject* type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_error_status; - mst_error_status.common().member_id(memberId++); - mst_error_status.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_error_status.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_error_status.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_error_status.common().member_flags().IS_OPTIONAL(false); - mst_error_status.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_error_status.common().member_flags().IS_KEY(false); - mst_error_status.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_error_status.common().member_type_id(*GetMonitoringErrorStatusIdentifier(false)); - - MD5 error_status_hash("error_status"); - for (int i = 0; i < 4; ++i) - { - mst_error_status.detail().name_hash()[i] = error_status_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_error_status); - - MinimalStructMember mst_has_errors; - mst_has_errors.common().member_id(memberId++); - mst_has_errors.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_has_errors.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_has_errors.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_has_errors.common().member_flags().IS_OPTIONAL(false); - mst_has_errors.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_has_errors.common().member_flags().IS_KEY(false); - mst_has_errors.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_has_errors.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - - MD5 has_errors_hash("has_errors"); - for (int i = 0; i < 4; ++i) - { - mst_has_errors.detail().name_hash()[i] = has_errors_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_has_errors); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for (int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("MonitoringStatus", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("MonitoringStatus", false); -} - -const TypeObject* GetCompleteMonitoringStatusObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MonitoringStatus", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject* type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_error_status; - cst_error_status.common().member_id(memberId++); - cst_error_status.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_error_status.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_error_status.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_error_status.common().member_flags().IS_OPTIONAL(false); - cst_error_status.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_error_status.common().member_flags().IS_KEY(false); - cst_error_status.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_error_status.common().member_type_id(*GetMonitoringErrorStatusIdentifier(true)); - - cst_error_status.detail().name("error_status"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_error_status); - - CompleteStructMember cst_has_errors; - cst_has_errors.common().member_id(memberId++); - cst_has_errors.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_has_errors.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_has_errors.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_has_errors.common().member_flags().IS_OPTIONAL(false); - cst_has_errors.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_has_errors.common().member_flags().IS_KEY(false); - cst_has_errors.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_has_errors.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - - cst_has_errors.detail().name("has_errors"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_has_errors); - - - // Header - type_object->complete().struct_type().header().detail().type_name("MonitoringStatus"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for (int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("MonitoringStatus", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("MonitoringStatus", true); -} diff --git a/ddspipe_core/src/cpp/types/monitoring/status/v2/MonitoringStatusv1.cxx b/ddspipe_core/src/cpp/types/monitoring/status/v2/MonitoringStatusv1.cxx deleted file mode 100644 index 49f2422f..00000000 --- a/ddspipe_core/src/cpp/types/monitoring/status/v2/MonitoringStatusv1.cxx +++ /dev/null @@ -1,469 +0,0 @@ -// 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 MonitoringStatus.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include - -#if FASTCDR_VERSION_MAJOR == 1 - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - -namespace helper { -namespace internal { - -enum class Size -{ - UInt8, - UInt16, - UInt32, - UInt64, -}; - -constexpr Size get_size( - int s) -{ - return (s <= 8 ) ? Size::UInt8: - (s <= 16) ? Size::UInt16: - (s <= 32) ? Size::UInt32: Size::UInt64; -} - -template -struct FindTypeH; - -template<> -struct FindTypeH -{ - using type = std::uint8_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint16_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint32_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint64_t; -}; -} // namespace internal - -template -struct FindType -{ - using type = typename internal::FindTypeH::type; -}; -} // namespace helper - -#define MonitoringErrorStatus_max_cdr_typesize 6ULL; -#define MonitoringStatus_max_cdr_typesize 11ULL; - - - - -MonitoringErrorStatus::MonitoringErrorStatus() -{ - // boolean m_type_mismatch - m_type_mismatch = false; - // boolean m_qos_mismatch - m_qos_mismatch = false; - -} - -MonitoringErrorStatus::~MonitoringErrorStatus() -{ -} - -MonitoringErrorStatus::MonitoringErrorStatus( - const MonitoringErrorStatus& x) -{ - m_type_mismatch = x.m_type_mismatch; - - - m_qos_mismatch = x.m_qos_mismatch; - -} - -MonitoringErrorStatus::MonitoringErrorStatus( - MonitoringErrorStatus&& x) noexcept -{ - m_type_mismatch = x.m_type_mismatch; - - - m_qos_mismatch = x.m_qos_mismatch; - -} - -MonitoringErrorStatus& MonitoringErrorStatus::operator =( - const MonitoringErrorStatus& x) -{ - m_type_mismatch = x.m_type_mismatch; - - - m_qos_mismatch = x.m_qos_mismatch; - - return *this; -} - -MonitoringErrorStatus& MonitoringErrorStatus::operator =( - MonitoringErrorStatus&& x) noexcept -{ - m_type_mismatch = x.m_type_mismatch; - - - m_qos_mismatch = x.m_qos_mismatch; - - return *this; -} - -bool MonitoringErrorStatus::operator ==( - const MonitoringErrorStatus& x) const -{ - return (m_type_mismatch == x.m_type_mismatch && - m_qos_mismatch == x.m_qos_mismatch); -} - -bool MonitoringErrorStatus::operator !=( - const MonitoringErrorStatus& x) const -{ - return !(*this == x); -} - -size_t MonitoringErrorStatus::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return MonitoringErrorStatus_max_cdr_typesize; -} - -size_t MonitoringErrorStatus::getCdrSerializedSize( - const MonitoringErrorStatus& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); - - - current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); - - - return current_alignment - initial_alignment; -} - -void MonitoringErrorStatus::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_type_mismatch; - - scdr << m_qos_mismatch; - -} - -void MonitoringErrorStatus::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_type_mismatch; - - - - dcdr >> m_qos_mismatch; - - -} - -bool MonitoringErrorStatus::isKeyDefined() -{ - return false; -} - -void MonitoringErrorStatus::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function sets a value in member type_mismatch - * @param _type_mismatch New value for member type_mismatch - */ -void MonitoringErrorStatus::type_mismatch( - bool _type_mismatch) -{ - m_type_mismatch = _type_mismatch; -} - -/*! - * @brief This function returns the value of member type_mismatch - * @return Value of member type_mismatch - */ -bool MonitoringErrorStatus::type_mismatch() const -{ - return m_type_mismatch; -} - -/*! - * @brief This function returns a reference to member type_mismatch - * @return Reference to member type_mismatch - */ -bool& MonitoringErrorStatus::type_mismatch() -{ - return m_type_mismatch; -} - -/*! - * @brief This function sets a value in member qos_mismatch - * @param _qos_mismatch New value for member qos_mismatch - */ -void MonitoringErrorStatus::qos_mismatch( - bool _qos_mismatch) -{ - m_qos_mismatch = _qos_mismatch; -} - -/*! - * @brief This function returns the value of member qos_mismatch - * @return Value of member qos_mismatch - */ -bool MonitoringErrorStatus::qos_mismatch() const -{ - return m_qos_mismatch; -} - -/*! - * @brief This function returns a reference to member qos_mismatch - * @return Reference to member qos_mismatch - */ -bool& MonitoringErrorStatus::qos_mismatch() -{ - return m_qos_mismatch; -} - -MonitoringStatus::MonitoringStatus() -{ - // MonitoringErrorStatus m_error_status - - // boolean m_has_errors - m_has_errors = false; - -} - -MonitoringStatus::~MonitoringStatus() -{ -} - -MonitoringStatus::MonitoringStatus( - const MonitoringStatus& x) -{ - m_error_status = x.m_error_status; - - - m_has_errors = x.m_has_errors; - -} - -MonitoringStatus::MonitoringStatus( - MonitoringStatus&& x) noexcept -{ - m_error_status = std::move(x.m_error_status); - - - m_has_errors = x.m_has_errors; - -} - -MonitoringStatus& MonitoringStatus::operator =( - const MonitoringStatus& x) -{ - m_error_status = x.m_error_status; - - - m_has_errors = x.m_has_errors; - - return *this; -} - -MonitoringStatus& MonitoringStatus::operator =( - MonitoringStatus&& x) noexcept -{ - m_error_status = std::move(x.m_error_status); - - - m_has_errors = x.m_has_errors; - - return *this; -} - -bool MonitoringStatus::operator ==( - const MonitoringStatus& x) const -{ - return (m_error_status == x.m_error_status && - m_has_errors == x.m_has_errors); -} - -bool MonitoringStatus::operator !=( - const MonitoringStatus& x) const -{ - return !(*this == x); -} - -size_t MonitoringStatus::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return MonitoringStatus_max_cdr_typesize; -} - -size_t MonitoringStatus::getCdrSerializedSize( - const MonitoringStatus& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += MonitoringErrorStatus::getCdrSerializedSize(data.error_status(), current_alignment); - - - current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); - - - return current_alignment - initial_alignment; -} - -void MonitoringStatus::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_error_status; - - scdr << m_has_errors; - -} - -void MonitoringStatus::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_error_status; - - - - dcdr >> m_has_errors; - - -} - -bool MonitoringStatus::isKeyDefined() -{ - return false; -} - -void MonitoringStatus::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function copies the value in member error_status - * @param _error_status New value to be copied in member error_status - */ -void MonitoringStatus::error_status( - const MonitoringErrorStatus& _error_status) -{ - m_error_status = _error_status; -} - -/*! - * @brief This function moves the value in member error_status - * @param _error_status New value to be moved in member error_status - */ -void MonitoringStatus::error_status( - MonitoringErrorStatus&& _error_status) -{ - m_error_status = std::move(_error_status); -} - -/*! - * @brief This function returns a constant reference to member error_status - * @return Constant reference to member error_status - */ -const MonitoringErrorStatus& MonitoringStatus::error_status() const -{ - return m_error_status; -} - -/*! - * @brief This function returns a reference to member error_status - * @return Reference to member error_status - */ -MonitoringErrorStatus& MonitoringStatus::error_status() -{ - return m_error_status; -} - -/*! - * @brief This function sets a value in member has_errors - * @param _has_errors New value for member has_errors - */ -void MonitoringStatus::has_errors( - bool _has_errors) -{ - m_has_errors = _has_errors; -} - -/*! - * @brief This function returns the value of member has_errors - * @return Value of member has_errors - */ -bool MonitoringStatus::has_errors() const -{ - return m_has_errors; -} - -/*! - * @brief This function returns a reference to member has_errors - * @return Reference to member has_errors - */ -bool& MonitoringStatus::has_errors() -{ - return m_has_errors; -} - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddspipe_core/src/cpp/types/monitoring/topics/MonitoringTopicsPubSubTypes.cxx b/ddspipe_core/src/cpp/types/monitoring/topics/MonitoringTopicsPubSubTypes.cxx new file mode 100644 index 00000000..e2d82a5d --- /dev/null +++ b/ddspipe_core/src/cpp/types/monitoring/topics/MonitoringTopicsPubSubTypes.cxx @@ -0,0 +1,579 @@ +// 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 MonitoringTopicsPubSubTypes.cpp + * This header file contains the implementation of the serialization functions. + * + * This file was generated by the tool fastddsgen. + */ + +#include + +#include +#include + +#include +#include + +using SerializedPayload_t = eprosima::fastdds::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t; +using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; + +DdsTopicDataPubSubType::DdsTopicDataPubSubType() +{ + set_name("DdsTopicData"); + uint32_t type_size = DdsTopicData_max_cdr_typesize; + type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = DdsTopicData_max_key_cdr_typesize > 16 ? DdsTopicData_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); +} + +DdsTopicDataPubSubType::~DdsTopicDataPubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool DdsTopicDataPubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const DdsTopicData* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); + payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + ser.set_encoding_flag( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + ser << *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool DdsTopicDataPubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + DdsTopicData* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + deser >> *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + return true; +} + +uint32_t DdsTopicDataPubSubType::calculate_serialized_size( + const void* const data, + DataRepresentationId_t data_representation) +{ + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +} + +void* DdsTopicDataPubSubType::create_data() +{ + return reinterpret_cast(new DdsTopicData()); +} + +void DdsTopicDataPubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool DdsTopicDataPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + DdsTopicData data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool DdsTopicDataPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const DdsTopicData* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + DdsTopicData_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); + ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); + eprosima::fastcdr::serialize_key(ser, *p_type); + if (force_md5 || DdsTopicData_max_key_cdr_typesize > 16) + { + md5_.init(); + md5_.update(key_buffer_, static_cast(ser.get_serialized_data_length())); + md5_.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle.value[i] = md5_.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle.value[i] = key_buffer_[i]; + } + } + return true; +} + +void DdsTopicDataPubSubType::register_type_object_representation() +{ + register_DdsTopicData_type_identifier(type_identifiers_); +} + +DdsTopicPubSubType::DdsTopicPubSubType() +{ + set_name("DdsTopic"); + uint32_t type_size = DdsTopic_max_cdr_typesize; + type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = DdsTopic_max_key_cdr_typesize > 16 ? DdsTopic_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); +} + +DdsTopicPubSubType::~DdsTopicPubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool DdsTopicPubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const DdsTopic* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); + payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + ser.set_encoding_flag( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + ser << *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool DdsTopicPubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + DdsTopic* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + deser >> *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + return true; +} + +uint32_t DdsTopicPubSubType::calculate_serialized_size( + const void* const data, + DataRepresentationId_t data_representation) +{ + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +} + +void* DdsTopicPubSubType::create_data() +{ + return reinterpret_cast(new DdsTopic()); +} + +void DdsTopicPubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool DdsTopicPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + DdsTopic data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool DdsTopicPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const DdsTopic* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + DdsTopic_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); + ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); + eprosima::fastcdr::serialize_key(ser, *p_type); + if (force_md5 || DdsTopic_max_key_cdr_typesize > 16) + { + md5_.init(); + md5_.update(key_buffer_, static_cast(ser.get_serialized_data_length())); + md5_.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle.value[i] = md5_.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle.value[i] = key_buffer_[i]; + } + } + return true; +} + +void DdsTopicPubSubType::register_type_object_representation() +{ + register_DdsTopic_type_identifier(type_identifiers_); +} + +MonitoringTopicsPubSubType::MonitoringTopicsPubSubType() +{ + set_name("MonitoringTopics"); + uint32_t type_size = MonitoringTopics_max_cdr_typesize; + type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = MonitoringTopics_max_key_cdr_typesize > 16 ? MonitoringTopics_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); +} + +MonitoringTopicsPubSubType::~MonitoringTopicsPubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool MonitoringTopicsPubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const MonitoringTopics* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); + payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + ser.set_encoding_flag( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + ser << *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool MonitoringTopicsPubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + MonitoringTopics* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + deser >> *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + return true; +} + +uint32_t MonitoringTopicsPubSubType::calculate_serialized_size( + const void* const data, + DataRepresentationId_t data_representation) +{ + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +} + +void* MonitoringTopicsPubSubType::create_data() +{ + return reinterpret_cast(new MonitoringTopics()); +} + +void MonitoringTopicsPubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool MonitoringTopicsPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + MonitoringTopics data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool MonitoringTopicsPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const MonitoringTopics* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + MonitoringTopics_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); + ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); + eprosima::fastcdr::serialize_key(ser, *p_type); + if (force_md5 || MonitoringTopics_max_key_cdr_typesize > 16) + { + md5_.init(); + md5_.update(key_buffer_, static_cast(ser.get_serialized_data_length())); + md5_.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle.value[i] = md5_.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle.value[i] = key_buffer_[i]; + } + } + return true; +} + +void MonitoringTopicsPubSubType::register_type_object_representation() +{ + register_MonitoringTopics_type_identifier(type_identifiers_); +} + + +// Include auxiliary functions like for serializing/deserializing. +#include diff --git a/ddspipe_core/src/cpp/types/monitoring/topics/MonitoringTopicsTypeObjectSupport.cxx b/ddspipe_core/src/cpp/types/monitoring/topics/MonitoringTopicsTypeObjectSupport.cxx new file mode 100644 index 00000000..9c4af3c2 --- /dev/null +++ b/ddspipe_core/src/cpp/types/monitoring/topics/MonitoringTopicsTypeObjectSupport.cxx @@ -0,0 +1,542 @@ +// 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 MonitoringTopicsTypeObjectSupport.cxx + * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +using namespace eprosima::fastdds::dds::xtypes; + +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_DdsTopicData_type_identifier( + TypeIdentifierPair& type_ids_DdsTopicData) +{ + + ReturnCode_t return_code_DdsTopicData {eprosima::fastdds::dds::RETCODE_OK}; + return_code_DdsTopicData = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "DdsTopicData", type_ids_DdsTopicData); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_DdsTopicData) + { + StructTypeFlag struct_flags_DdsTopicData = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_DdsTopicData = "DdsTopicData"; + eprosima::fastcdr::optional type_ann_builtin_DdsTopicData; + eprosima::fastcdr::optional ann_custom_DdsTopicData; + CompleteTypeDetail detail_DdsTopicData = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_DdsTopicData, ann_custom_DdsTopicData, type_name_DdsTopicData.to_string()); + CompleteStructHeader header_DdsTopicData; + header_DdsTopicData = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_DdsTopicData); + CompleteStructMemberSeq member_seq_DdsTopicData; + { + TypeIdentifierPair type_ids_participant_id; + ReturnCode_t return_code_participant_id {eprosima::fastdds::dds::RETCODE_OK}; + return_code_participant_id = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_string_unbounded", type_ids_participant_id); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_participant_id) + { + { + SBound bound = 0; + StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, + "anonymous_string_unbounded", type_ids_participant_id)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_participant_id = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_participant_id = 0x00000000; + bool common_participant_id_ec {false}; + CommonStructMember common_participant_id {TypeObjectUtils::build_common_struct_member(member_id_participant_id, member_flags_participant_id, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_participant_id, common_participant_id_ec))}; + if (!common_participant_id_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure participant_id member TypeIdentifier inconsistent."); + return; + } + MemberName name_participant_id = "participant_id"; + eprosima::fastcdr::optional member_ann_builtin_participant_id; + ann_custom_DdsTopicData.reset(); + CompleteMemberDetail detail_participant_id = TypeObjectUtils::build_complete_member_detail(name_participant_id, member_ann_builtin_participant_id, ann_custom_DdsTopicData); + CompleteStructMember member_participant_id = TypeObjectUtils::build_complete_struct_member(common_participant_id, detail_participant_id); + TypeObjectUtils::add_complete_struct_member(member_seq_DdsTopicData, member_participant_id); + } + { + TypeIdentifierPair type_ids_msgs_lost; + ReturnCode_t return_code_msgs_lost {eprosima::fastdds::dds::RETCODE_OK}; + return_code_msgs_lost = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_uint32_t", type_ids_msgs_lost); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_msgs_lost) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "msgs_lost Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_msgs_lost = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_msgs_lost = 0x00000001; + bool common_msgs_lost_ec {false}; + CommonStructMember common_msgs_lost {TypeObjectUtils::build_common_struct_member(member_id_msgs_lost, member_flags_msgs_lost, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_msgs_lost, common_msgs_lost_ec))}; + if (!common_msgs_lost_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure msgs_lost member TypeIdentifier inconsistent."); + return; + } + MemberName name_msgs_lost = "msgs_lost"; + eprosima::fastcdr::optional member_ann_builtin_msgs_lost; + ann_custom_DdsTopicData.reset(); + CompleteMemberDetail detail_msgs_lost = TypeObjectUtils::build_complete_member_detail(name_msgs_lost, member_ann_builtin_msgs_lost, ann_custom_DdsTopicData); + CompleteStructMember member_msgs_lost = TypeObjectUtils::build_complete_struct_member(common_msgs_lost, detail_msgs_lost); + TypeObjectUtils::add_complete_struct_member(member_seq_DdsTopicData, member_msgs_lost); + } + { + TypeIdentifierPair type_ids_msgs_received; + ReturnCode_t return_code_msgs_received {eprosima::fastdds::dds::RETCODE_OK}; + return_code_msgs_received = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_uint32_t", type_ids_msgs_received); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_msgs_received) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "msgs_received Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_msgs_received = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_msgs_received = 0x00000002; + bool common_msgs_received_ec {false}; + CommonStructMember common_msgs_received {TypeObjectUtils::build_common_struct_member(member_id_msgs_received, member_flags_msgs_received, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_msgs_received, common_msgs_received_ec))}; + if (!common_msgs_received_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure msgs_received member TypeIdentifier inconsistent."); + return; + } + MemberName name_msgs_received = "msgs_received"; + eprosima::fastcdr::optional member_ann_builtin_msgs_received; + ann_custom_DdsTopicData.reset(); + CompleteMemberDetail detail_msgs_received = TypeObjectUtils::build_complete_member_detail(name_msgs_received, member_ann_builtin_msgs_received, ann_custom_DdsTopicData); + CompleteStructMember member_msgs_received = TypeObjectUtils::build_complete_struct_member(common_msgs_received, detail_msgs_received); + TypeObjectUtils::add_complete_struct_member(member_seq_DdsTopicData, member_msgs_received); + } + { + TypeIdentifierPair type_ids_msg_rx_rate; + ReturnCode_t return_code_msg_rx_rate {eprosima::fastdds::dds::RETCODE_OK}; + return_code_msg_rx_rate = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_double", type_ids_msg_rx_rate); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_msg_rx_rate) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "msg_rx_rate Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_msg_rx_rate = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_msg_rx_rate = 0x00000003; + bool common_msg_rx_rate_ec {false}; + CommonStructMember common_msg_rx_rate {TypeObjectUtils::build_common_struct_member(member_id_msg_rx_rate, member_flags_msg_rx_rate, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_msg_rx_rate, common_msg_rx_rate_ec))}; + if (!common_msg_rx_rate_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure msg_rx_rate member TypeIdentifier inconsistent."); + return; + } + MemberName name_msg_rx_rate = "msg_rx_rate"; + eprosima::fastcdr::optional member_ann_builtin_msg_rx_rate; + ann_custom_DdsTopicData.reset(); + CompleteMemberDetail detail_msg_rx_rate = TypeObjectUtils::build_complete_member_detail(name_msg_rx_rate, member_ann_builtin_msg_rx_rate, ann_custom_DdsTopicData); + CompleteStructMember member_msg_rx_rate = TypeObjectUtils::build_complete_struct_member(common_msg_rx_rate, detail_msg_rx_rate); + TypeObjectUtils::add_complete_struct_member(member_seq_DdsTopicData, member_msg_rx_rate); + } + CompleteStructType struct_type_DdsTopicData = TypeObjectUtils::build_complete_struct_type(struct_flags_DdsTopicData, header_DdsTopicData, member_seq_DdsTopicData); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_DdsTopicData, type_name_DdsTopicData.to_string(), type_ids_DdsTopicData)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "DdsTopicData already registered in TypeObjectRegistry for a different type."); + } + } +} +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_DdsTopic_type_identifier( + TypeIdentifierPair& type_ids_DdsTopic) +{ + + ReturnCode_t return_code_DdsTopic {eprosima::fastdds::dds::RETCODE_OK}; + return_code_DdsTopic = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "DdsTopic", type_ids_DdsTopic); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_DdsTopic) + { + StructTypeFlag struct_flags_DdsTopic = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_DdsTopic = "DdsTopic"; + eprosima::fastcdr::optional type_ann_builtin_DdsTopic; + eprosima::fastcdr::optional ann_custom_DdsTopic; + CompleteTypeDetail detail_DdsTopic = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_DdsTopic, ann_custom_DdsTopic, type_name_DdsTopic.to_string()); + CompleteStructHeader header_DdsTopic; + header_DdsTopic = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_DdsTopic); + CompleteStructMemberSeq member_seq_DdsTopic; + { + TypeIdentifierPair type_ids_name; + ReturnCode_t return_code_name {eprosima::fastdds::dds::RETCODE_OK}; + return_code_name = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_string_unbounded", type_ids_name); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_name) + { + { + SBound bound = 0; + StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, + "anonymous_string_unbounded", type_ids_name)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_name = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_name = 0x00000000; + bool common_name_ec {false}; + CommonStructMember common_name {TypeObjectUtils::build_common_struct_member(member_id_name, member_flags_name, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_name, common_name_ec))}; + if (!common_name_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure name member TypeIdentifier inconsistent."); + return; + } + MemberName name_name = "name"; + eprosima::fastcdr::optional member_ann_builtin_name; + ann_custom_DdsTopic.reset(); + CompleteMemberDetail detail_name = TypeObjectUtils::build_complete_member_detail(name_name, member_ann_builtin_name, ann_custom_DdsTopic); + CompleteStructMember member_name = TypeObjectUtils::build_complete_struct_member(common_name, detail_name); + TypeObjectUtils::add_complete_struct_member(member_seq_DdsTopic, member_name); + } + { + TypeIdentifierPair type_ids_type_name; + ReturnCode_t return_code_type_name {eprosima::fastdds::dds::RETCODE_OK}; + return_code_type_name = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_string_unbounded", type_ids_type_name); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_type_name) + { + { + SBound bound = 0; + StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, + "anonymous_string_unbounded", type_ids_type_name)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_type_name = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_type_name = 0x00000001; + bool common_type_name_ec {false}; + CommonStructMember common_type_name {TypeObjectUtils::build_common_struct_member(member_id_type_name, member_flags_type_name, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_type_name, common_type_name_ec))}; + if (!common_type_name_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure type_name member TypeIdentifier inconsistent."); + return; + } + MemberName name_type_name = "type_name"; + eprosima::fastcdr::optional member_ann_builtin_type_name; + ann_custom_DdsTopic.reset(); + CompleteMemberDetail detail_type_name = TypeObjectUtils::build_complete_member_detail(name_type_name, member_ann_builtin_type_name, ann_custom_DdsTopic); + CompleteStructMember member_type_name = TypeObjectUtils::build_complete_struct_member(common_type_name, detail_type_name); + TypeObjectUtils::add_complete_struct_member(member_seq_DdsTopic, member_type_name); + } + { + TypeIdentifierPair type_ids_type_discovered; + ReturnCode_t return_code_type_discovered {eprosima::fastdds::dds::RETCODE_OK}; + return_code_type_discovered = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_bool", type_ids_type_discovered); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_type_discovered) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "type_discovered Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_type_discovered = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_type_discovered = 0x00000002; + bool common_type_discovered_ec {false}; + CommonStructMember common_type_discovered {TypeObjectUtils::build_common_struct_member(member_id_type_discovered, member_flags_type_discovered, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_type_discovered, common_type_discovered_ec))}; + if (!common_type_discovered_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure type_discovered member TypeIdentifier inconsistent."); + return; + } + MemberName name_type_discovered = "type_discovered"; + eprosima::fastcdr::optional member_ann_builtin_type_discovered; + ann_custom_DdsTopic.reset(); + CompleteMemberDetail detail_type_discovered = TypeObjectUtils::build_complete_member_detail(name_type_discovered, member_ann_builtin_type_discovered, ann_custom_DdsTopic); + CompleteStructMember member_type_discovered = TypeObjectUtils::build_complete_struct_member(common_type_discovered, detail_type_discovered); + TypeObjectUtils::add_complete_struct_member(member_seq_DdsTopic, member_type_discovered); + } + { + TypeIdentifierPair type_ids_type_mismatch; + ReturnCode_t return_code_type_mismatch {eprosima::fastdds::dds::RETCODE_OK}; + return_code_type_mismatch = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_bool", type_ids_type_mismatch); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_type_mismatch) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "type_mismatch Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_type_mismatch = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_type_mismatch = 0x00000003; + bool common_type_mismatch_ec {false}; + CommonStructMember common_type_mismatch {TypeObjectUtils::build_common_struct_member(member_id_type_mismatch, member_flags_type_mismatch, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_type_mismatch, common_type_mismatch_ec))}; + if (!common_type_mismatch_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure type_mismatch member TypeIdentifier inconsistent."); + return; + } + MemberName name_type_mismatch = "type_mismatch"; + eprosima::fastcdr::optional member_ann_builtin_type_mismatch; + ann_custom_DdsTopic.reset(); + CompleteMemberDetail detail_type_mismatch = TypeObjectUtils::build_complete_member_detail(name_type_mismatch, member_ann_builtin_type_mismatch, ann_custom_DdsTopic); + CompleteStructMember member_type_mismatch = TypeObjectUtils::build_complete_struct_member(common_type_mismatch, detail_type_mismatch); + TypeObjectUtils::add_complete_struct_member(member_seq_DdsTopic, member_type_mismatch); + } + { + TypeIdentifierPair type_ids_qos_mismatch; + ReturnCode_t return_code_qos_mismatch {eprosima::fastdds::dds::RETCODE_OK}; + return_code_qos_mismatch = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_bool", type_ids_qos_mismatch); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_qos_mismatch) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "qos_mismatch Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_qos_mismatch = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_qos_mismatch = 0x00000004; + bool common_qos_mismatch_ec {false}; + CommonStructMember common_qos_mismatch {TypeObjectUtils::build_common_struct_member(member_id_qos_mismatch, member_flags_qos_mismatch, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_qos_mismatch, common_qos_mismatch_ec))}; + if (!common_qos_mismatch_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure qos_mismatch member TypeIdentifier inconsistent."); + return; + } + MemberName name_qos_mismatch = "qos_mismatch"; + eprosima::fastcdr::optional member_ann_builtin_qos_mismatch; + ann_custom_DdsTopic.reset(); + CompleteMemberDetail detail_qos_mismatch = TypeObjectUtils::build_complete_member_detail(name_qos_mismatch, member_ann_builtin_qos_mismatch, ann_custom_DdsTopic); + CompleteStructMember member_qos_mismatch = TypeObjectUtils::build_complete_struct_member(common_qos_mismatch, detail_qos_mismatch); + TypeObjectUtils::add_complete_struct_member(member_seq_DdsTopic, member_qos_mismatch); + } + { + TypeIdentifierPair type_ids_data; + ReturnCode_t return_code_data {eprosima::fastdds::dds::RETCODE_OK}; + return_code_data = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_sequence_DdsTopicData_unbounded", type_ids_data); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_data) + { + return_code_data = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "DdsTopicData", type_ids_data); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_data) + { + ::register_DdsTopicData_type_identifier(type_ids_data); + } + bool element_identifier_anonymous_sequence_DdsTopicData_unbounded_ec {false}; + TypeIdentifier* element_identifier_anonymous_sequence_DdsTopicData_unbounded {new TypeIdentifier(TypeObjectUtils::retrieve_complete_type_identifier(type_ids_data, element_identifier_anonymous_sequence_DdsTopicData_unbounded_ec))}; + if (!element_identifier_anonymous_sequence_DdsTopicData_unbounded_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Sequence element TypeIdentifier inconsistent."); + return; + } + EquivalenceKind equiv_kind_anonymous_sequence_DdsTopicData_unbounded = EK_COMPLETE; + if (TK_NONE == type_ids_data.type_identifier2()._d()) + { + equiv_kind_anonymous_sequence_DdsTopicData_unbounded = EK_BOTH; + } + CollectionElementFlag element_flags_anonymous_sequence_DdsTopicData_unbounded = 0; + PlainCollectionHeader header_anonymous_sequence_DdsTopicData_unbounded = TypeObjectUtils::build_plain_collection_header(equiv_kind_anonymous_sequence_DdsTopicData_unbounded, element_flags_anonymous_sequence_DdsTopicData_unbounded); + { + SBound bound = 0; + PlainSequenceSElemDefn seq_sdefn = TypeObjectUtils::build_plain_sequence_s_elem_defn(header_anonymous_sequence_DdsTopicData_unbounded, bound, + eprosima::fastcdr::external(element_identifier_anonymous_sequence_DdsTopicData_unbounded)); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_sequence_type_identifier(seq_sdefn, "anonymous_sequence_DdsTopicData_unbounded", type_ids_data)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_sequence_DdsTopicData_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_data = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_data = 0x00000005; + bool common_data_ec {false}; + CommonStructMember common_data {TypeObjectUtils::build_common_struct_member(member_id_data, member_flags_data, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_data, common_data_ec))}; + if (!common_data_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure data member TypeIdentifier inconsistent."); + return; + } + MemberName name_data = "data"; + eprosima::fastcdr::optional member_ann_builtin_data; + ann_custom_DdsTopic.reset(); + CompleteMemberDetail detail_data = TypeObjectUtils::build_complete_member_detail(name_data, member_ann_builtin_data, ann_custom_DdsTopic); + CompleteStructMember member_data = TypeObjectUtils::build_complete_struct_member(common_data, detail_data); + TypeObjectUtils::add_complete_struct_member(member_seq_DdsTopic, member_data); + } + CompleteStructType struct_type_DdsTopic = TypeObjectUtils::build_complete_struct_type(struct_flags_DdsTopic, header_DdsTopic, member_seq_DdsTopic); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_DdsTopic, type_name_DdsTopic.to_string(), type_ids_DdsTopic)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "DdsTopic already registered in TypeObjectRegistry for a different type."); + } + } +} +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_MonitoringTopics_type_identifier( + TypeIdentifierPair& type_ids_MonitoringTopics) +{ + + ReturnCode_t return_code_MonitoringTopics {eprosima::fastdds::dds::RETCODE_OK}; + return_code_MonitoringTopics = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "MonitoringTopics", type_ids_MonitoringTopics); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_MonitoringTopics) + { + StructTypeFlag struct_flags_MonitoringTopics = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_MonitoringTopics = "MonitoringTopics"; + eprosima::fastcdr::optional type_ann_builtin_MonitoringTopics; + eprosima::fastcdr::optional ann_custom_MonitoringTopics; + CompleteTypeDetail detail_MonitoringTopics = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_MonitoringTopics, ann_custom_MonitoringTopics, type_name_MonitoringTopics.to_string()); + CompleteStructHeader header_MonitoringTopics; + header_MonitoringTopics = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_MonitoringTopics); + CompleteStructMemberSeq member_seq_MonitoringTopics; + { + TypeIdentifierPair type_ids_topics; + ReturnCode_t return_code_topics {eprosima::fastdds::dds::RETCODE_OK}; + return_code_topics = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_sequence_DdsTopic_unbounded", type_ids_topics); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_topics) + { + return_code_topics = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "DdsTopic", type_ids_topics); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_topics) + { + ::register_DdsTopic_type_identifier(type_ids_topics); + } + bool element_identifier_anonymous_sequence_DdsTopic_unbounded_ec {false}; + TypeIdentifier* element_identifier_anonymous_sequence_DdsTopic_unbounded {new TypeIdentifier(TypeObjectUtils::retrieve_complete_type_identifier(type_ids_topics, element_identifier_anonymous_sequence_DdsTopic_unbounded_ec))}; + if (!element_identifier_anonymous_sequence_DdsTopic_unbounded_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Sequence element TypeIdentifier inconsistent."); + return; + } + EquivalenceKind equiv_kind_anonymous_sequence_DdsTopic_unbounded = EK_COMPLETE; + if (TK_NONE == type_ids_topics.type_identifier2()._d()) + { + equiv_kind_anonymous_sequence_DdsTopic_unbounded = EK_BOTH; + } + CollectionElementFlag element_flags_anonymous_sequence_DdsTopic_unbounded = 0; + PlainCollectionHeader header_anonymous_sequence_DdsTopic_unbounded = TypeObjectUtils::build_plain_collection_header(equiv_kind_anonymous_sequence_DdsTopic_unbounded, element_flags_anonymous_sequence_DdsTopic_unbounded); + { + SBound bound = 0; + PlainSequenceSElemDefn seq_sdefn = TypeObjectUtils::build_plain_sequence_s_elem_defn(header_anonymous_sequence_DdsTopic_unbounded, bound, + eprosima::fastcdr::external(element_identifier_anonymous_sequence_DdsTopic_unbounded)); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_sequence_type_identifier(seq_sdefn, "anonymous_sequence_DdsTopic_unbounded", type_ids_topics)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_sequence_DdsTopic_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_topics = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_topics = 0x00000000; + bool common_topics_ec {false}; + CommonStructMember common_topics {TypeObjectUtils::build_common_struct_member(member_id_topics, member_flags_topics, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_topics, common_topics_ec))}; + if (!common_topics_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure topics member TypeIdentifier inconsistent."); + return; + } + MemberName name_topics = "topics"; + eprosima::fastcdr::optional member_ann_builtin_topics; + ann_custom_MonitoringTopics.reset(); + CompleteMemberDetail detail_topics = TypeObjectUtils::build_complete_member_detail(name_topics, member_ann_builtin_topics, ann_custom_MonitoringTopics); + CompleteStructMember member_topics = TypeObjectUtils::build_complete_struct_member(common_topics, detail_topics); + TypeObjectUtils::add_complete_struct_member(member_seq_MonitoringTopics, member_topics); + } + CompleteStructType struct_type_MonitoringTopics = TypeObjectUtils::build_complete_struct_type(struct_flags_MonitoringTopics, header_MonitoringTopics, member_seq_MonitoringTopics); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_MonitoringTopics, type_name_MonitoringTopics.to_string(), type_ids_MonitoringTopics)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "MonitoringTopics already registered in TypeObjectRegistry for a different type."); + } + } +} + diff --git a/ddspipe_core/src/cpp/types/monitoring/topics/v1/MonitoringTopics.cxx b/ddspipe_core/src/cpp/types/monitoring/topics/v1/MonitoringTopics.cxx deleted file mode 100644 index df3e5698..00000000 --- a/ddspipe_core/src/cpp/types/monitoring/topics/v1/MonitoringTopics.cxx +++ /dev/null @@ -1,969 +0,0 @@ -// 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 MonitoringTopics.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include - -#include - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - -namespace helper { -namespace internal { - -enum class Size -{ - UInt8, - UInt16, - UInt32, - UInt64, -}; - -constexpr Size get_size( - int s) -{ - return (s <= 8 ) ? Size::UInt8: - (s <= 16) ? Size::UInt16: - (s <= 32) ? Size::UInt32: Size::UInt64; -} - -template -struct FindTypeH; - -template<> -struct FindTypeH -{ - using type = std::uint8_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint16_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint32_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint64_t; -}; -} // namespace internal - -template -struct FindType -{ - using type = typename internal::FindTypeH::type; -}; -} // namespace helper - -#define DdsTopicData_max_cdr_typesize 280ULL; -#define MonitoringTopics_max_cdr_typesize 2853616ULL; -#define DdsTopic_max_cdr_typesize 28536ULL; - - - - -DdsTopicData::DdsTopicData() -{ - // /type_d() m_participant_id - - // unsigned long m_msgs_lost - m_msgs_lost = 0; - // unsigned long m_msgs_received - m_msgs_received = 0; - // double m_msg_rx_rate - m_msg_rx_rate = 0.0; - - // Just to register all known types - registerMonitoringTopicsTypes(); -} - -DdsTopicData::~DdsTopicData() -{ -} - -DdsTopicData::DdsTopicData( - const DdsTopicData& x) -{ - m_participant_id = x.m_participant_id; - - - m_msgs_lost = x.m_msgs_lost; - - - m_msgs_received = x.m_msgs_received; - - - m_msg_rx_rate = x.m_msg_rx_rate; - -} - -DdsTopicData::DdsTopicData( - DdsTopicData&& x) noexcept -{ - m_participant_id = std::move(x.m_participant_id); - - - m_msgs_lost = x.m_msgs_lost; - - - m_msgs_received = x.m_msgs_received; - - - m_msg_rx_rate = x.m_msg_rx_rate; - -} - -DdsTopicData& DdsTopicData::operator =( - const DdsTopicData& x) -{ - m_participant_id = x.m_participant_id; - - - m_msgs_lost = x.m_msgs_lost; - - - m_msgs_received = x.m_msgs_received; - - - m_msg_rx_rate = x.m_msg_rx_rate; - - return *this; -} - -DdsTopicData& DdsTopicData::operator =( - DdsTopicData&& x) noexcept -{ - m_participant_id = std::move(x.m_participant_id); - - - m_msgs_lost = x.m_msgs_lost; - - - m_msgs_received = x.m_msgs_received; - - - m_msg_rx_rate = x.m_msg_rx_rate; - - return *this; -} - -bool DdsTopicData::operator ==( - const DdsTopicData& x) const -{ - return (m_participant_id == x.m_participant_id && - m_msgs_lost == x.m_msgs_lost && - m_msgs_received == x.m_msgs_received && - m_msg_rx_rate == x.m_msg_rx_rate); -} - -bool DdsTopicData::operator !=( - const DdsTopicData& x) const -{ - return !(*this == x); -} - -size_t DdsTopicData::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return DdsTopicData_max_cdr_typesize; -} - -size_t DdsTopicData::getCdrSerializedSize( - const DdsTopicData& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.participant_id().size() + 1; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - current_alignment += 8 + eprosima::fastcdr::Cdr::alignment(current_alignment, 8); - - - return current_alignment - initial_alignment; -} - -void DdsTopicData::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_participant_id.c_str(); - - scdr << m_msgs_lost; - - scdr << m_msgs_received; - - scdr << m_msg_rx_rate; - -} - -void DdsTopicData::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_participant_id; - - - - dcdr >> m_msgs_lost; - - - - dcdr >> m_msgs_received; - - - - dcdr >> m_msg_rx_rate; - - -} - -bool DdsTopicData::isKeyDefined() -{ - return false; -} - -void DdsTopicData::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function copies the value in member participant_id - * @param _participant_id New value to be copied in member participant_id - */ -void DdsTopicData::participant_id( - const std::string& _participant_id) -{ - m_participant_id = _participant_id; -} - -/*! - * @brief This function moves the value in member participant_id - * @param _participant_id New value to be moved in member participant_id - */ -void DdsTopicData::participant_id( - std::string&& _participant_id) -{ - m_participant_id = std::move(_participant_id); -} - -/*! - * @brief This function returns a constant reference to member participant_id - * @return Constant reference to member participant_id - */ -const std::string& DdsTopicData::participant_id() const -{ - return m_participant_id; -} - -/*! - * @brief This function returns a reference to member participant_id - * @return Reference to member participant_id - */ -std::string& DdsTopicData::participant_id() -{ - return m_participant_id; -} - -/*! - * @brief This function sets a value in member msgs_lost - * @param _msgs_lost New value for member msgs_lost - */ -void DdsTopicData::msgs_lost( - uint32_t _msgs_lost) -{ - m_msgs_lost = _msgs_lost; -} - -/*! - * @brief This function returns the value of member msgs_lost - * @return Value of member msgs_lost - */ -uint32_t DdsTopicData::msgs_lost() const -{ - return m_msgs_lost; -} - -/*! - * @brief This function returns a reference to member msgs_lost - * @return Reference to member msgs_lost - */ -uint32_t& DdsTopicData::msgs_lost() -{ - return m_msgs_lost; -} - -/*! - * @brief This function sets a value in member msgs_received - * @param _msgs_received New value for member msgs_received - */ -void DdsTopicData::msgs_received( - uint32_t _msgs_received) -{ - m_msgs_received = _msgs_received; -} - -/*! - * @brief This function returns the value of member msgs_received - * @return Value of member msgs_received - */ -uint32_t DdsTopicData::msgs_received() const -{ - return m_msgs_received; -} - -/*! - * @brief This function returns a reference to member msgs_received - * @return Reference to member msgs_received - */ -uint32_t& DdsTopicData::msgs_received() -{ - return m_msgs_received; -} - -/*! - * @brief This function sets a value in member msg_rx_rate - * @param _msg_rx_rate New value for member msg_rx_rate - */ -void DdsTopicData::msg_rx_rate( - double _msg_rx_rate) -{ - m_msg_rx_rate = _msg_rx_rate; -} - -/*! - * @brief This function returns the value of member msg_rx_rate - * @return Value of member msg_rx_rate - */ -double DdsTopicData::msg_rx_rate() const -{ - return m_msg_rx_rate; -} - -/*! - * @brief This function returns a reference to member msg_rx_rate - * @return Reference to member msg_rx_rate - */ -double& DdsTopicData::msg_rx_rate() -{ - return m_msg_rx_rate; -} - -DdsTopic::DdsTopic() -{ - // /type_d() m_name - - // /type_d() m_type_name - - // boolean m_type_discovered - m_type_discovered = false; - // boolean m_type_mismatch - m_type_mismatch = false; - // boolean m_qos_mismatch - m_qos_mismatch = false; - // sequence m_data - - - // Just to register all known types - registerMonitoringTopicsTypes(); -} - -DdsTopic::~DdsTopic() -{ -} - -DdsTopic::DdsTopic( - const DdsTopic& x) -{ - m_name = x.m_name; - - - m_type_name = x.m_type_name; - - - m_type_discovered = x.m_type_discovered; - - - m_type_mismatch = x.m_type_mismatch; - - - m_qos_mismatch = x.m_qos_mismatch; - - - m_data = x.m_data; - -} - -DdsTopic::DdsTopic( - DdsTopic&& x) noexcept -{ - m_name = std::move(x.m_name); - - - m_type_name = std::move(x.m_type_name); - - - m_type_discovered = x.m_type_discovered; - - - m_type_mismatch = x.m_type_mismatch; - - - m_qos_mismatch = x.m_qos_mismatch; - - - m_data = std::move(x.m_data); - -} - -DdsTopic& DdsTopic::operator =( - const DdsTopic& x) -{ - m_name = x.m_name; - - - m_type_name = x.m_type_name; - - - m_type_discovered = x.m_type_discovered; - - - m_type_mismatch = x.m_type_mismatch; - - - m_qos_mismatch = x.m_qos_mismatch; - - - m_data = x.m_data; - - return *this; -} - -DdsTopic& DdsTopic::operator =( - DdsTopic&& x) noexcept -{ - m_name = std::move(x.m_name); - - - m_type_name = std::move(x.m_type_name); - - - m_type_discovered = x.m_type_discovered; - - - m_type_mismatch = x.m_type_mismatch; - - - m_qos_mismatch = x.m_qos_mismatch; - - - m_data = std::move(x.m_data); - - return *this; -} - -bool DdsTopic::operator ==( - const DdsTopic& x) const -{ - return (m_name == x.m_name && - m_type_name == x.m_type_name && - m_type_discovered == x.m_type_discovered && - m_type_mismatch == x.m_type_mismatch && - m_qos_mismatch == x.m_qos_mismatch && - m_data == x.m_data); -} - -bool DdsTopic::operator !=( - const DdsTopic& x) const -{ - return !(*this == x); -} - -size_t DdsTopic::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return DdsTopic_max_cdr_typesize; -} - -size_t DdsTopic::getCdrSerializedSize( - const DdsTopic& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.name().size() + 1; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.type_name().size() + 1; - - - current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); - - - current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); - - - current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - for (size_t a = 0; a < data.data().size(); ++a) - { - current_alignment += DdsTopicData::getCdrSerializedSize(data.data().at(a), current_alignment); - } - - - - return current_alignment - initial_alignment; -} - -void DdsTopic::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_name.c_str(); - - scdr << m_type_name.c_str(); - - scdr << m_type_discovered; - - scdr << m_type_mismatch; - - scdr << m_qos_mismatch; - - scdr << m_data; - - -} - -void DdsTopic::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_name; - - - - dcdr >> m_type_name; - - - - dcdr >> m_type_discovered; - - - - dcdr >> m_type_mismatch; - - - - dcdr >> m_qos_mismatch; - - - - dcdr >> m_data; - - -} - -bool DdsTopic::isKeyDefined() -{ - return false; -} - -void DdsTopic::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function copies the value in member name - * @param _name New value to be copied in member name - */ -void DdsTopic::name( - const std::string& _name) -{ - m_name = _name; -} - -/*! - * @brief This function moves the value in member name - * @param _name New value to be moved in member name - */ -void DdsTopic::name( - std::string&& _name) -{ - m_name = std::move(_name); -} - -/*! - * @brief This function returns a constant reference to member name - * @return Constant reference to member name - */ -const std::string& DdsTopic::name() const -{ - return m_name; -} - -/*! - * @brief This function returns a reference to member name - * @return Reference to member name - */ -std::string& DdsTopic::name() -{ - return m_name; -} - -/*! - * @brief This function copies the value in member type_name - * @param _type_name New value to be copied in member type_name - */ -void DdsTopic::type_name( - const std::string& _type_name) -{ - m_type_name = _type_name; -} - -/*! - * @brief This function moves the value in member type_name - * @param _type_name New value to be moved in member type_name - */ -void DdsTopic::type_name( - std::string&& _type_name) -{ - m_type_name = std::move(_type_name); -} - -/*! - * @brief This function returns a constant reference to member type_name - * @return Constant reference to member type_name - */ -const std::string& DdsTopic::type_name() const -{ - return m_type_name; -} - -/*! - * @brief This function returns a reference to member type_name - * @return Reference to member type_name - */ -std::string& DdsTopic::type_name() -{ - return m_type_name; -} - -/*! - * @brief This function sets a value in member type_discovered - * @param _type_discovered New value for member type_discovered - */ -void DdsTopic::type_discovered( - bool _type_discovered) -{ - m_type_discovered = _type_discovered; -} - -/*! - * @brief This function returns the value of member type_discovered - * @return Value of member type_discovered - */ -bool DdsTopic::type_discovered() const -{ - return m_type_discovered; -} - -/*! - * @brief This function returns a reference to member type_discovered - * @return Reference to member type_discovered - */ -bool& DdsTopic::type_discovered() -{ - return m_type_discovered; -} - -/*! - * @brief This function sets a value in member type_mismatch - * @param _type_mismatch New value for member type_mismatch - */ -void DdsTopic::type_mismatch( - bool _type_mismatch) -{ - m_type_mismatch = _type_mismatch; -} - -/*! - * @brief This function returns the value of member type_mismatch - * @return Value of member type_mismatch - */ -bool DdsTopic::type_mismatch() const -{ - return m_type_mismatch; -} - -/*! - * @brief This function returns a reference to member type_mismatch - * @return Reference to member type_mismatch - */ -bool& DdsTopic::type_mismatch() -{ - return m_type_mismatch; -} - -/*! - * @brief This function sets a value in member qos_mismatch - * @param _qos_mismatch New value for member qos_mismatch - */ -void DdsTopic::qos_mismatch( - bool _qos_mismatch) -{ - m_qos_mismatch = _qos_mismatch; -} - -/*! - * @brief This function returns the value of member qos_mismatch - * @return Value of member qos_mismatch - */ -bool DdsTopic::qos_mismatch() const -{ - return m_qos_mismatch; -} - -/*! - * @brief This function returns a reference to member qos_mismatch - * @return Reference to member qos_mismatch - */ -bool& DdsTopic::qos_mismatch() -{ - return m_qos_mismatch; -} - -/*! - * @brief This function copies the value in member data - * @param _data New value to be copied in member data - */ -void DdsTopic::data( - const std::vector& _data) -{ - m_data = _data; -} - -/*! - * @brief This function moves the value in member data - * @param _data New value to be moved in member data - */ -void DdsTopic::data( - std::vector&& _data) -{ - m_data = std::move(_data); -} - -/*! - * @brief This function returns a constant reference to member data - * @return Constant reference to member data - */ -const std::vector& DdsTopic::data() const -{ - return m_data; -} - -/*! - * @brief This function returns a reference to member data - * @return Reference to member data - */ -std::vector& DdsTopic::data() -{ - return m_data; -} - -MonitoringTopics::MonitoringTopics() -{ - // sequence m_topics - - - // Just to register all known types - registerMonitoringTopicsTypes(); -} - -MonitoringTopics::~MonitoringTopics() -{ -} - -MonitoringTopics::MonitoringTopics( - const MonitoringTopics& x) -{ - m_topics = x.m_topics; - -} - -MonitoringTopics::MonitoringTopics( - MonitoringTopics&& x) noexcept -{ - m_topics = std::move(x.m_topics); - -} - -MonitoringTopics& MonitoringTopics::operator =( - const MonitoringTopics& x) -{ - m_topics = x.m_topics; - - return *this; -} - -MonitoringTopics& MonitoringTopics::operator =( - MonitoringTopics&& x) noexcept -{ - m_topics = std::move(x.m_topics); - - return *this; -} - -bool MonitoringTopics::operator ==( - const MonitoringTopics& x) const -{ - return (m_topics == x.m_topics); -} - -bool MonitoringTopics::operator !=( - const MonitoringTopics& x) const -{ - return !(*this == x); -} - -size_t MonitoringTopics::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return MonitoringTopics_max_cdr_typesize; -} - -size_t MonitoringTopics::getCdrSerializedSize( - const MonitoringTopics& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - for (size_t a = 0; a < data.topics().size(); ++a) - { - current_alignment += DdsTopic::getCdrSerializedSize(data.topics().at(a), current_alignment); - } - - - - return current_alignment - initial_alignment; -} - -void MonitoringTopics::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_topics; - - -} - -void MonitoringTopics::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_topics; - - -} - -bool MonitoringTopics::isKeyDefined() -{ - return false; -} - -void MonitoringTopics::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function copies the value in member topics - * @param _topics New value to be copied in member topics - */ -void MonitoringTopics::topics( - const std::vector& _topics) -{ - m_topics = _topics; -} - -/*! - * @brief This function moves the value in member topics - * @param _topics New value to be moved in member topics - */ -void MonitoringTopics::topics( - std::vector&& _topics) -{ - m_topics = std::move(_topics); -} - -/*! - * @brief This function returns a constant reference to member topics - * @return Constant reference to member topics - */ -const std::vector& MonitoringTopics::topics() const -{ - return m_topics; -} - -/*! - * @brief This function returns a reference to member topics - * @return Reference to member topics - */ -std::vector& MonitoringTopics::topics() -{ - return m_topics; -} diff --git a/ddspipe_core/src/cpp/types/monitoring/topics/v1/MonitoringTopicsPubSubTypes.cxx b/ddspipe_core/src/cpp/types/monitoring/topics/v1/MonitoringTopicsPubSubTypes.cxx deleted file mode 100644 index 46e85f1d..00000000 --- a/ddspipe_core/src/cpp/types/monitoring/topics/v1/MonitoringTopicsPubSubTypes.cxx +++ /dev/null @@ -1,599 +0,0 @@ -// 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 MonitoringTopicsPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#include - -#include -#include - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; -using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - - - -DdsTopicDataPubSubType::DdsTopicDataPubSubType() -{ - setName("DdsTopicData"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(DdsTopicData::getMaxCdrSerializedSize()); -#else - DdsTopicData_max_cdr_typesize; -#endif // if FASTCDR_VERSION_MAJOR == 1 - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = DdsTopicData_max_key_cdr_typesize > 16 ? DdsTopicData_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -DdsTopicDataPubSubType::~DdsTopicDataPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool DdsTopicDataPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - DdsTopicData* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool DdsTopicDataPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - DdsTopicData* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function DdsTopicDataPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* DdsTopicDataPubSubType::createData() -{ - return reinterpret_cast(new DdsTopicData()); -} - -void DdsTopicDataPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool DdsTopicDataPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - DdsTopicData* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - DdsTopicData_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || DdsTopicData_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - -DdsTopicPubSubType::DdsTopicPubSubType() -{ - setName("DdsTopic"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(DdsTopic::getMaxCdrSerializedSize()); -#else - DdsTopic_max_cdr_typesize; -#endif // if FASTCDR_VERSION_MAJOR == 1 - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = DdsTopic_max_key_cdr_typesize > 16 ? DdsTopic_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -DdsTopicPubSubType::~DdsTopicPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool DdsTopicPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - DdsTopic* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool DdsTopicPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - DdsTopic* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function DdsTopicPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* DdsTopicPubSubType::createData() -{ - return reinterpret_cast(new DdsTopic()); -} - -void DdsTopicPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool DdsTopicPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - DdsTopic* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - DdsTopic_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || DdsTopic_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - -MonitoringTopicsPubSubType::MonitoringTopicsPubSubType() -{ - setName("MonitoringTopics"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MonitoringTopics::getMaxCdrSerializedSize()); -#else - MonitoringTopics_max_cdr_typesize; -#endif // if FASTCDR_VERSION_MAJOR == 1 - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MonitoringTopics_max_key_cdr_typesize > 16 ? MonitoringTopics_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -MonitoringTopicsPubSubType::~MonitoringTopicsPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool MonitoringTopicsPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - MonitoringTopics* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool MonitoringTopicsPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - MonitoringTopics* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function MonitoringTopicsPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MonitoringTopicsPubSubType::createData() -{ - return reinterpret_cast(new MonitoringTopics()); -} - -void MonitoringTopicsPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool MonitoringTopicsPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - MonitoringTopics* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MonitoringTopics_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MonitoringTopics_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} diff --git a/ddspipe_core/src/cpp/types/monitoring/topics/v1/MonitoringTopicsTypeObject.cxx b/ddspipe_core/src/cpp/types/monitoring/topics/v1/MonitoringTopicsTypeObject.cxx deleted file mode 100644 index 0323341f..00000000 --- a/ddspipe_core/src/cpp/types/monitoring/topics/v1/MonitoringTopicsTypeObject.cxx +++ /dev/null @@ -1,878 +0,0 @@ -// 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 MonitoringTopicsTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // ifdef _WIN32 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerMonitoringTopicsTypes() -{ - static std::once_flag once_flag; - std::call_once(once_flag, []() - { - TypeObjectFactory* factory = TypeObjectFactory::get_instance(); - factory->add_type_object("DdsTopicData", GetDdsTopicDataIdentifier(true), - GetDdsTopicDataObject(true)); - factory->add_type_object("DdsTopicData", GetDdsTopicDataIdentifier(false), - GetDdsTopicDataObject(false)); - - - factory->add_type_object("DdsTopic", GetDdsTopicIdentifier(true), - GetDdsTopicObject(true)); - factory->add_type_object("DdsTopic", GetDdsTopicIdentifier(false), - GetDdsTopicObject(false)); - - - factory->add_type_object("MonitoringTopics", GetMonitoringTopicsIdentifier(true), - GetMonitoringTopicsObject(true)); - factory->add_type_object("MonitoringTopics", GetMonitoringTopicsIdentifier(false), - GetMonitoringTopicsObject(false)); - - }); -} - -const TypeIdentifier* GetDdsTopicDataIdentifier( - bool complete) -{ - const TypeIdentifier* c_identifier = - TypeObjectFactory::get_instance()->get_type_identifier("DdsTopicData", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetDdsTopicDataObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("DdsTopicData", complete); -} - -const TypeObject* GetDdsTopicDataObject( - bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("DdsTopicData", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteDdsTopicDataObject(); - } - //else - return GetMinimalDdsTopicDataObject(); -} - -const TypeObject* GetMinimalDdsTopicDataObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("DdsTopicData", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject* type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_participant_id; - mst_participant_id.common().member_id(memberId++); - mst_participant_id.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_participant_id.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_participant_id.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_participant_id.common().member_flags().IS_OPTIONAL(false); - mst_participant_id.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_participant_id.common().member_flags().IS_KEY(false); - mst_participant_id.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_participant_id.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - MD5 participant_id_hash("participant_id"); - for (int i = 0; i < 4; ++i) - { - mst_participant_id.detail().name_hash()[i] = participant_id_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_participant_id); - - MinimalStructMember mst_msgs_lost; - mst_msgs_lost.common().member_id(memberId++); - mst_msgs_lost.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_msgs_lost.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_msgs_lost.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_msgs_lost.common().member_flags().IS_OPTIONAL(false); - mst_msgs_lost.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_msgs_lost.common().member_flags().IS_KEY(false); - mst_msgs_lost.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_msgs_lost.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); - - - MD5 msgs_lost_hash("msgs_lost"); - for (int i = 0; i < 4; ++i) - { - mst_msgs_lost.detail().name_hash()[i] = msgs_lost_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_msgs_lost); - - MinimalStructMember mst_msgs_received; - mst_msgs_received.common().member_id(memberId++); - mst_msgs_received.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_msgs_received.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_msgs_received.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_msgs_received.common().member_flags().IS_OPTIONAL(false); - mst_msgs_received.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_msgs_received.common().member_flags().IS_KEY(false); - mst_msgs_received.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_msgs_received.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", - false)); - - - MD5 msgs_received_hash("msgs_received"); - for (int i = 0; i < 4; ++i) - { - mst_msgs_received.detail().name_hash()[i] = msgs_received_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_msgs_received); - - MinimalStructMember mst_msg_rx_rate; - mst_msg_rx_rate.common().member_id(memberId++); - mst_msg_rx_rate.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_msg_rx_rate.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_msg_rx_rate.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_msg_rx_rate.common().member_flags().IS_OPTIONAL(false); - mst_msg_rx_rate.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_msg_rx_rate.common().member_flags().IS_KEY(false); - mst_msg_rx_rate.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_msg_rx_rate.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("double", - false)); - - - MD5 msg_rx_rate_hash("msg_rx_rate"); - for (int i = 0; i < 4; ++i) - { - mst_msg_rx_rate.detail().name_hash()[i] = msg_rx_rate_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_msg_rx_rate); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for (int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("DdsTopicData", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("DdsTopicData", false); -} - -const TypeObject* GetCompleteDdsTopicDataObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("DdsTopicData", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject* type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_participant_id; - cst_participant_id.common().member_id(memberId++); - cst_participant_id.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_participant_id.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_participant_id.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_participant_id.common().member_flags().IS_OPTIONAL(false); - cst_participant_id.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_participant_id.common().member_flags().IS_KEY(false); - cst_participant_id.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_participant_id.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - cst_participant_id.detail().name("participant_id"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_participant_id); - - CompleteStructMember cst_msgs_lost; - cst_msgs_lost.common().member_id(memberId++); - cst_msgs_lost.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_msgs_lost.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_msgs_lost.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_msgs_lost.common().member_flags().IS_OPTIONAL(false); - cst_msgs_lost.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_msgs_lost.common().member_flags().IS_KEY(false); - cst_msgs_lost.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_msgs_lost.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); - - - cst_msgs_lost.detail().name("msgs_lost"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_msgs_lost); - - CompleteStructMember cst_msgs_received; - cst_msgs_received.common().member_id(memberId++); - cst_msgs_received.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_msgs_received.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_msgs_received.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_msgs_received.common().member_flags().IS_OPTIONAL(false); - cst_msgs_received.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_msgs_received.common().member_flags().IS_KEY(false); - cst_msgs_received.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_msgs_received.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", - false)); - - - cst_msgs_received.detail().name("msgs_received"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_msgs_received); - - CompleteStructMember cst_msg_rx_rate; - cst_msg_rx_rate.common().member_id(memberId++); - cst_msg_rx_rate.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_msg_rx_rate.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_msg_rx_rate.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_msg_rx_rate.common().member_flags().IS_OPTIONAL(false); - cst_msg_rx_rate.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_msg_rx_rate.common().member_flags().IS_KEY(false); - cst_msg_rx_rate.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_msg_rx_rate.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("double", - false)); - - - cst_msg_rx_rate.detail().name("msg_rx_rate"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_msg_rx_rate); - - - // Header - type_object->complete().struct_type().header().detail().type_name("DdsTopicData"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for (int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("DdsTopicData", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("DdsTopicData", true); -} - -const TypeIdentifier* GetDdsTopicIdentifier( - bool complete) -{ - const TypeIdentifier* c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("DdsTopic", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetDdsTopicObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("DdsTopic", complete); -} - -const TypeObject* GetDdsTopicObject( - bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("DdsTopic", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteDdsTopicObject(); - } - //else - return GetMinimalDdsTopicObject(); -} - -const TypeObject* GetMinimalDdsTopicObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("DdsTopic", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject* type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_name; - mst_name.common().member_id(memberId++); - mst_name.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_name.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_name.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_name.common().member_flags().IS_OPTIONAL(false); - mst_name.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_name.common().member_flags().IS_KEY(false); - mst_name.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_name.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - MD5 name_hash("name"); - for (int i = 0; i < 4; ++i) - { - mst_name.detail().name_hash()[i] = name_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_name); - - MinimalStructMember mst_type_name; - mst_type_name.common().member_id(memberId++); - mst_type_name.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_type_name.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_type_name.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_type_name.common().member_flags().IS_OPTIONAL(false); - mst_type_name.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_type_name.common().member_flags().IS_KEY(false); - mst_type_name.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_type_name.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - MD5 type_name_hash("type_name"); - for (int i = 0; i < 4; ++i) - { - mst_type_name.detail().name_hash()[i] = type_name_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_type_name); - - MinimalStructMember mst_type_discovered; - mst_type_discovered.common().member_id(memberId++); - mst_type_discovered.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_type_discovered.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_type_discovered.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_type_discovered.common().member_flags().IS_OPTIONAL(false); - mst_type_discovered.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_type_discovered.common().member_flags().IS_KEY(false); - mst_type_discovered.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_type_discovered.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - - MD5 type_discovered_hash("type_discovered"); - for (int i = 0; i < 4; ++i) - { - mst_type_discovered.detail().name_hash()[i] = type_discovered_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_type_discovered); - - MinimalStructMember mst_type_mismatch; - mst_type_mismatch.common().member_id(memberId++); - mst_type_mismatch.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_type_mismatch.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_type_mismatch.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_type_mismatch.common().member_flags().IS_OPTIONAL(false); - mst_type_mismatch.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_type_mismatch.common().member_flags().IS_KEY(false); - mst_type_mismatch.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_type_mismatch.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - - MD5 type_mismatch_hash("type_mismatch"); - for (int i = 0; i < 4; ++i) - { - mst_type_mismatch.detail().name_hash()[i] = type_mismatch_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_type_mismatch); - - MinimalStructMember mst_qos_mismatch; - mst_qos_mismatch.common().member_id(memberId++); - mst_qos_mismatch.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_qos_mismatch.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_qos_mismatch.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_qos_mismatch.common().member_flags().IS_OPTIONAL(false); - mst_qos_mismatch.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_qos_mismatch.common().member_flags().IS_KEY(false); - mst_qos_mismatch.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_qos_mismatch.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - - MD5 qos_mismatch_hash("qos_mismatch"); - for (int i = 0; i < 4; ++i) - { - mst_qos_mismatch.detail().name_hash()[i] = qos_mismatch_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_qos_mismatch); - - MinimalStructMember mst_data; - mst_data.common().member_id(memberId++); - mst_data.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_data.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_data.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_data.common().member_flags().IS_OPTIONAL(false); - mst_data.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_data.common().member_flags().IS_KEY(false); - mst_data.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_data.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("DdsTopicData", 100, - false)); - - MD5 data_hash("data"); - for (int i = 0; i < 4; ++i) - { - mst_data.detail().name_hash()[i] = data_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_data); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for (int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("DdsTopic", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("DdsTopic", false); -} - -const TypeObject* GetCompleteDdsTopicObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("DdsTopic", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject* type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_name; - cst_name.common().member_id(memberId++); - cst_name.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_name.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_name.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_name.common().member_flags().IS_OPTIONAL(false); - cst_name.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_name.common().member_flags().IS_KEY(false); - cst_name.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_name.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - cst_name.detail().name("name"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_name); - - CompleteStructMember cst_type_name; - cst_type_name.common().member_id(memberId++); - cst_type_name.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_type_name.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_type_name.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_type_name.common().member_flags().IS_OPTIONAL(false); - cst_type_name.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_type_name.common().member_flags().IS_KEY(false); - cst_type_name.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_type_name.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - cst_type_name.detail().name("type_name"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_type_name); - - CompleteStructMember cst_type_discovered; - cst_type_discovered.common().member_id(memberId++); - cst_type_discovered.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_type_discovered.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_type_discovered.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_type_discovered.common().member_flags().IS_OPTIONAL(false); - cst_type_discovered.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_type_discovered.common().member_flags().IS_KEY(false); - cst_type_discovered.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_type_discovered.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - - cst_type_discovered.detail().name("type_discovered"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_type_discovered); - - CompleteStructMember cst_type_mismatch; - cst_type_mismatch.common().member_id(memberId++); - cst_type_mismatch.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_type_mismatch.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_type_mismatch.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_type_mismatch.common().member_flags().IS_OPTIONAL(false); - cst_type_mismatch.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_type_mismatch.common().member_flags().IS_KEY(false); - cst_type_mismatch.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_type_mismatch.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - - cst_type_mismatch.detail().name("type_mismatch"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_type_mismatch); - - CompleteStructMember cst_qos_mismatch; - cst_qos_mismatch.common().member_id(memberId++); - cst_qos_mismatch.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_qos_mismatch.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_qos_mismatch.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_qos_mismatch.common().member_flags().IS_OPTIONAL(false); - cst_qos_mismatch.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_qos_mismatch.common().member_flags().IS_KEY(false); - cst_qos_mismatch.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_qos_mismatch.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - - cst_qos_mismatch.detail().name("qos_mismatch"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_qos_mismatch); - - CompleteStructMember cst_data; - cst_data.common().member_id(memberId++); - cst_data.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_data.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_data.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_data.common().member_flags().IS_OPTIONAL(false); - cst_data.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_data.common().member_flags().IS_KEY(false); - cst_data.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_data.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("DdsTopicData", 100, - true)); - - cst_data.detail().name("data"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_data); - - - // Header - type_object->complete().struct_type().header().detail().type_name("DdsTopic"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for (int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("DdsTopic", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("DdsTopic", true); -} - -const TypeIdentifier* GetMonitoringTopicsIdentifier( - bool complete) -{ - const TypeIdentifier* c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("MonitoringTopics", - complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetMonitoringTopicsObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("MonitoringTopics", complete); -} - -const TypeObject* GetMonitoringTopicsObject( - bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MonitoringTopics", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteMonitoringTopicsObject(); - } - //else - return GetMinimalMonitoringTopicsObject(); -} - -const TypeObject* GetMinimalMonitoringTopicsObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MonitoringTopics", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject* type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_topics; - mst_topics.common().member_id(memberId++); - mst_topics.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_topics.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_topics.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_topics.common().member_flags().IS_OPTIONAL(false); - mst_topics.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_topics.common().member_flags().IS_KEY(false); - mst_topics.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_topics.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("DdsTopic", 100, - false)); - - MD5 topics_hash("topics"); - for (int i = 0; i < 4; ++i) - { - mst_topics.detail().name_hash()[i] = topics_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_topics); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for (int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("MonitoringTopics", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("MonitoringTopics", false); -} - -const TypeObject* GetCompleteMonitoringTopicsObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MonitoringTopics", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject* type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_topics; - cst_topics.common().member_id(memberId++); - cst_topics.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_topics.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_topics.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_topics.common().member_flags().IS_OPTIONAL(false); - cst_topics.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_topics.common().member_flags().IS_KEY(false); - cst_topics.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_topics.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("DdsTopic", 100, - true)); - - cst_topics.detail().name("topics"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_topics); - - - // Header - type_object->complete().struct_type().header().detail().type_name("MonitoringTopics"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for (int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("MonitoringTopics", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("MonitoringTopics", true); -} diff --git a/ddspipe_core/src/cpp/types/monitoring/topics/v2/MonitoringTopics.cxx b/ddspipe_core/src/cpp/types/monitoring/topics/v2/MonitoringTopics.cxx deleted file mode 100644 index 1c6e67b3..00000000 --- a/ddspipe_core/src/cpp/types/monitoring/topics/v2/MonitoringTopics.cxx +++ /dev/null @@ -1,597 +0,0 @@ -// 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 MonitoringTopics.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include - -#if FASTCDR_VERSION_MAJOR > 1 - -#include - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - - - - -DdsTopicData::DdsTopicData() -{ - // Just to register all known types - registerMonitoringTopicsTypes(); -} - -DdsTopicData::~DdsTopicData() -{ -} - -DdsTopicData::DdsTopicData( - const DdsTopicData& x) -{ - m_participant_id = x.m_participant_id; - m_msgs_lost = x.m_msgs_lost; - m_msgs_received = x.m_msgs_received; - m_msg_rx_rate = x.m_msg_rx_rate; -} - -DdsTopicData::DdsTopicData( - DdsTopicData&& x) noexcept -{ - m_participant_id = std::move(x.m_participant_id); - m_msgs_lost = x.m_msgs_lost; - m_msgs_received = x.m_msgs_received; - m_msg_rx_rate = x.m_msg_rx_rate; -} - -DdsTopicData& DdsTopicData::operator =( - const DdsTopicData& x) -{ - - m_participant_id = x.m_participant_id; - m_msgs_lost = x.m_msgs_lost; - m_msgs_received = x.m_msgs_received; - m_msg_rx_rate = x.m_msg_rx_rate; - return *this; -} - -DdsTopicData& DdsTopicData::operator =( - DdsTopicData&& x) noexcept -{ - - m_participant_id = std::move(x.m_participant_id); - m_msgs_lost = x.m_msgs_lost; - m_msgs_received = x.m_msgs_received; - m_msg_rx_rate = x.m_msg_rx_rate; - return *this; -} - -bool DdsTopicData::operator ==( - const DdsTopicData& x) const -{ - return (m_participant_id == x.m_participant_id && - m_msgs_lost == x.m_msgs_lost && - m_msgs_received == x.m_msgs_received && - m_msg_rx_rate == x.m_msg_rx_rate); -} - -bool DdsTopicData::operator !=( - const DdsTopicData& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function copies the value in member participant_id - * @param _participant_id New value to be copied in member participant_id - */ -void DdsTopicData::participant_id( - const std::string& _participant_id) -{ - m_participant_id = _participant_id; -} - -/*! - * @brief This function moves the value in member participant_id - * @param _participant_id New value to be moved in member participant_id - */ -void DdsTopicData::participant_id( - std::string&& _participant_id) -{ - m_participant_id = std::move(_participant_id); -} - -/*! - * @brief This function returns a constant reference to member participant_id - * @return Constant reference to member participant_id - */ -const std::string& DdsTopicData::participant_id() const -{ - return m_participant_id; -} - -/*! - * @brief This function returns a reference to member participant_id - * @return Reference to member participant_id - */ -std::string& DdsTopicData::participant_id() -{ - return m_participant_id; -} - -/*! - * @brief This function sets a value in member msgs_lost - * @param _msgs_lost New value for member msgs_lost - */ -void DdsTopicData::msgs_lost( - uint32_t _msgs_lost) -{ - m_msgs_lost = _msgs_lost; -} - -/*! - * @brief This function returns the value of member msgs_lost - * @return Value of member msgs_lost - */ -uint32_t DdsTopicData::msgs_lost() const -{ - return m_msgs_lost; -} - -/*! - * @brief This function returns a reference to member msgs_lost - * @return Reference to member msgs_lost - */ -uint32_t& DdsTopicData::msgs_lost() -{ - return m_msgs_lost; -} - -/*! - * @brief This function sets a value in member msgs_received - * @param _msgs_received New value for member msgs_received - */ -void DdsTopicData::msgs_received( - uint32_t _msgs_received) -{ - m_msgs_received = _msgs_received; -} - -/*! - * @brief This function returns the value of member msgs_received - * @return Value of member msgs_received - */ -uint32_t DdsTopicData::msgs_received() const -{ - return m_msgs_received; -} - -/*! - * @brief This function returns a reference to member msgs_received - * @return Reference to member msgs_received - */ -uint32_t& DdsTopicData::msgs_received() -{ - return m_msgs_received; -} - -/*! - * @brief This function sets a value in member msg_rx_rate - * @param _msg_rx_rate New value for member msg_rx_rate - */ -void DdsTopicData::msg_rx_rate( - double _msg_rx_rate) -{ - m_msg_rx_rate = _msg_rx_rate; -} - -/*! - * @brief This function returns the value of member msg_rx_rate - * @return Value of member msg_rx_rate - */ -double DdsTopicData::msg_rx_rate() const -{ - return m_msg_rx_rate; -} - -/*! - * @brief This function returns a reference to member msg_rx_rate - * @return Reference to member msg_rx_rate - */ -double& DdsTopicData::msg_rx_rate() -{ - return m_msg_rx_rate; -} - -DdsTopic::DdsTopic() -{ - // Just to register all known types - registerMonitoringTopicsTypes(); -} - -DdsTopic::~DdsTopic() -{ -} - -DdsTopic::DdsTopic( - const DdsTopic& x) -{ - m_name = x.m_name; - m_type_name = x.m_type_name; - m_type_discovered = x.m_type_discovered; - m_type_mismatch = x.m_type_mismatch; - m_qos_mismatch = x.m_qos_mismatch; - m_data = x.m_data; -} - -DdsTopic::DdsTopic( - DdsTopic&& x) noexcept -{ - m_name = std::move(x.m_name); - m_type_name = std::move(x.m_type_name); - m_type_discovered = x.m_type_discovered; - m_type_mismatch = x.m_type_mismatch; - m_qos_mismatch = x.m_qos_mismatch; - m_data = std::move(x.m_data); -} - -DdsTopic& DdsTopic::operator =( - const DdsTopic& x) -{ - - m_name = x.m_name; - m_type_name = x.m_type_name; - m_type_discovered = x.m_type_discovered; - m_type_mismatch = x.m_type_mismatch; - m_qos_mismatch = x.m_qos_mismatch; - m_data = x.m_data; - return *this; -} - -DdsTopic& DdsTopic::operator =( - DdsTopic&& x) noexcept -{ - - m_name = std::move(x.m_name); - m_type_name = std::move(x.m_type_name); - m_type_discovered = x.m_type_discovered; - m_type_mismatch = x.m_type_mismatch; - m_qos_mismatch = x.m_qos_mismatch; - m_data = std::move(x.m_data); - return *this; -} - -bool DdsTopic::operator ==( - const DdsTopic& x) const -{ - return (m_name == x.m_name && - m_type_name == x.m_type_name && - m_type_discovered == x.m_type_discovered && - m_type_mismatch == x.m_type_mismatch && - m_qos_mismatch == x.m_qos_mismatch && - m_data == x.m_data); -} - -bool DdsTopic::operator !=( - const DdsTopic& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function copies the value in member name - * @param _name New value to be copied in member name - */ -void DdsTopic::name( - const std::string& _name) -{ - m_name = _name; -} - -/*! - * @brief This function moves the value in member name - * @param _name New value to be moved in member name - */ -void DdsTopic::name( - std::string&& _name) -{ - m_name = std::move(_name); -} - -/*! - * @brief This function returns a constant reference to member name - * @return Constant reference to member name - */ -const std::string& DdsTopic::name() const -{ - return m_name; -} - -/*! - * @brief This function returns a reference to member name - * @return Reference to member name - */ -std::string& DdsTopic::name() -{ - return m_name; -} - -/*! - * @brief This function copies the value in member type_name - * @param _type_name New value to be copied in member type_name - */ -void DdsTopic::type_name( - const std::string& _type_name) -{ - m_type_name = _type_name; -} - -/*! - * @brief This function moves the value in member type_name - * @param _type_name New value to be moved in member type_name - */ -void DdsTopic::type_name( - std::string&& _type_name) -{ - m_type_name = std::move(_type_name); -} - -/*! - * @brief This function returns a constant reference to member type_name - * @return Constant reference to member type_name - */ -const std::string& DdsTopic::type_name() const -{ - return m_type_name; -} - -/*! - * @brief This function returns a reference to member type_name - * @return Reference to member type_name - */ -std::string& DdsTopic::type_name() -{ - return m_type_name; -} - -/*! - * @brief This function sets a value in member type_discovered - * @param _type_discovered New value for member type_discovered - */ -void DdsTopic::type_discovered( - bool _type_discovered) -{ - m_type_discovered = _type_discovered; -} - -/*! - * @brief This function returns the value of member type_discovered - * @return Value of member type_discovered - */ -bool DdsTopic::type_discovered() const -{ - return m_type_discovered; -} - -/*! - * @brief This function returns a reference to member type_discovered - * @return Reference to member type_discovered - */ -bool& DdsTopic::type_discovered() -{ - return m_type_discovered; -} - -/*! - * @brief This function sets a value in member type_mismatch - * @param _type_mismatch New value for member type_mismatch - */ -void DdsTopic::type_mismatch( - bool _type_mismatch) -{ - m_type_mismatch = _type_mismatch; -} - -/*! - * @brief This function returns the value of member type_mismatch - * @return Value of member type_mismatch - */ -bool DdsTopic::type_mismatch() const -{ - return m_type_mismatch; -} - -/*! - * @brief This function returns a reference to member type_mismatch - * @return Reference to member type_mismatch - */ -bool& DdsTopic::type_mismatch() -{ - return m_type_mismatch; -} - -/*! - * @brief This function sets a value in member qos_mismatch - * @param _qos_mismatch New value for member qos_mismatch - */ -void DdsTopic::qos_mismatch( - bool _qos_mismatch) -{ - m_qos_mismatch = _qos_mismatch; -} - -/*! - * @brief This function returns the value of member qos_mismatch - * @return Value of member qos_mismatch - */ -bool DdsTopic::qos_mismatch() const -{ - return m_qos_mismatch; -} - -/*! - * @brief This function returns a reference to member qos_mismatch - * @return Reference to member qos_mismatch - */ -bool& DdsTopic::qos_mismatch() -{ - return m_qos_mismatch; -} - -/*! - * @brief This function copies the value in member data - * @param _data New value to be copied in member data - */ -void DdsTopic::data( - const std::vector& _data) -{ - m_data = _data; -} - -/*! - * @brief This function moves the value in member data - * @param _data New value to be moved in member data - */ -void DdsTopic::data( - std::vector&& _data) -{ - m_data = std::move(_data); -} - -/*! - * @brief This function returns a constant reference to member data - * @return Constant reference to member data - */ -const std::vector& DdsTopic::data() const -{ - return m_data; -} - -/*! - * @brief This function returns a reference to member data - * @return Reference to member data - */ -std::vector& DdsTopic::data() -{ - return m_data; -} - -MonitoringTopics::MonitoringTopics() -{ - // Just to register all known types - registerMonitoringTopicsTypes(); -} - -MonitoringTopics::~MonitoringTopics() -{ -} - -MonitoringTopics::MonitoringTopics( - const MonitoringTopics& x) -{ - m_topics = x.m_topics; -} - -MonitoringTopics::MonitoringTopics( - MonitoringTopics&& x) noexcept -{ - m_topics = std::move(x.m_topics); -} - -MonitoringTopics& MonitoringTopics::operator =( - const MonitoringTopics& x) -{ - - m_topics = x.m_topics; - return *this; -} - -MonitoringTopics& MonitoringTopics::operator =( - MonitoringTopics&& x) noexcept -{ - - m_topics = std::move(x.m_topics); - return *this; -} - -bool MonitoringTopics::operator ==( - const MonitoringTopics& x) const -{ - return (m_topics == x.m_topics); -} - -bool MonitoringTopics::operator !=( - const MonitoringTopics& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function copies the value in member topics - * @param _topics New value to be copied in member topics - */ -void MonitoringTopics::topics( - const std::vector& _topics) -{ - m_topics = _topics; -} - -/*! - * @brief This function moves the value in member topics - * @param _topics New value to be moved in member topics - */ -void MonitoringTopics::topics( - std::vector&& _topics) -{ - m_topics = std::move(_topics); -} - -/*! - * @brief This function returns a constant reference to member topics - * @return Constant reference to member topics - */ -const std::vector& MonitoringTopics::topics() const -{ - return m_topics; -} - -/*! - * @brief This function returns a reference to member topics - * @return Reference to member topics - */ -std::vector& MonitoringTopics::topics() -{ - return m_topics; -} - -// Include auxiliary functions like for serializing/deserializing. -#include - -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddspipe_core/src/cpp/types/monitoring/topics/v2/MonitoringTopicsPubSubTypes.cxx b/ddspipe_core/src/cpp/types/monitoring/topics/v2/MonitoringTopicsPubSubTypes.cxx deleted file mode 100644 index fbbf0abd..00000000 --- a/ddspipe_core/src/cpp/types/monitoring/topics/v2/MonitoringTopicsPubSubTypes.cxx +++ /dev/null @@ -1,599 +0,0 @@ -// 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 MonitoringTopicsPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#include - -#include -#include - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; -using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - - - -DdsTopicDataPubSubType::DdsTopicDataPubSubType() -{ - setName("DdsTopicData"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(DdsTopicData::getMaxCdrSerializedSize()); -#else - DdsTopicData_max_cdr_typesize; -#endif // if FASTCDR_VERSION_MAJOR == 1 - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = DdsTopicData_max_key_cdr_typesize > 16 ? DdsTopicData_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -DdsTopicDataPubSubType::~DdsTopicDataPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool DdsTopicDataPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - DdsTopicData* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool DdsTopicDataPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - DdsTopicData* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function DdsTopicDataPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* DdsTopicDataPubSubType::createData() -{ - return reinterpret_cast(new DdsTopicData()); -} - -void DdsTopicDataPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool DdsTopicDataPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - DdsTopicData* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - DdsTopicData_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || DdsTopicData_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - -DdsTopicPubSubType::DdsTopicPubSubType() -{ - setName("DdsTopic"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(DdsTopic::getMaxCdrSerializedSize()); -#else - DdsTopic_max_cdr_typesize; -#endif // if FASTCDR_VERSION_MAJOR == 1 - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = DdsTopic_max_key_cdr_typesize > 16 ? DdsTopic_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -DdsTopicPubSubType::~DdsTopicPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool DdsTopicPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - DdsTopic* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool DdsTopicPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - DdsTopic* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function DdsTopicPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* DdsTopicPubSubType::createData() -{ - return reinterpret_cast(new DdsTopic()); -} - -void DdsTopicPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool DdsTopicPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - DdsTopic* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - DdsTopic_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || DdsTopic_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - -MonitoringTopicsPubSubType::MonitoringTopicsPubSubType() -{ - setName("MonitoringTopics"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(MonitoringTopics::getMaxCdrSerializedSize()); -#else - MonitoringTopics_max_cdr_typesize; -#endif // if FASTCDR_VERSION_MAJOR == 1 - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = MonitoringTopics_max_key_cdr_typesize > 16 ? MonitoringTopics_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -MonitoringTopicsPubSubType::~MonitoringTopicsPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool MonitoringTopicsPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - MonitoringTopics* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool MonitoringTopicsPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - MonitoringTopics* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function MonitoringTopicsPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* MonitoringTopicsPubSubType::createData() -{ - return reinterpret_cast(new MonitoringTopics()); -} - -void MonitoringTopicsPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool MonitoringTopicsPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - MonitoringTopics* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - MonitoringTopics_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || MonitoringTopics_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} diff --git a/ddspipe_core/src/cpp/types/monitoring/topics/v2/MonitoringTopicsTypeObject.cxx b/ddspipe_core/src/cpp/types/monitoring/topics/v2/MonitoringTopicsTypeObject.cxx deleted file mode 100644 index 1fadc2cc..00000000 --- a/ddspipe_core/src/cpp/types/monitoring/topics/v2/MonitoringTopicsTypeObject.cxx +++ /dev/null @@ -1,878 +0,0 @@ -// 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 MonitoringTopicsTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // ifdef _WIN32 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerMonitoringTopicsTypes() -{ - static std::once_flag once_flag; - std::call_once(once_flag, []() - { - TypeObjectFactory* factory = TypeObjectFactory::get_instance(); - factory->add_type_object("DdsTopicData", GetDdsTopicDataIdentifier(true), - GetDdsTopicDataObject(true)); - factory->add_type_object("DdsTopicData", GetDdsTopicDataIdentifier(false), - GetDdsTopicDataObject(false)); - - - factory->add_type_object("DdsTopic", GetDdsTopicIdentifier(true), - GetDdsTopicObject(true)); - factory->add_type_object("DdsTopic", GetDdsTopicIdentifier(false), - GetDdsTopicObject(false)); - - - factory->add_type_object("MonitoringTopics", GetMonitoringTopicsIdentifier(true), - GetMonitoringTopicsObject(true)); - factory->add_type_object("MonitoringTopics", GetMonitoringTopicsIdentifier(false), - GetMonitoringTopicsObject(false)); - - }); -} - -const TypeIdentifier* GetDdsTopicDataIdentifier( - bool complete) -{ - const TypeIdentifier* c_identifier = - TypeObjectFactory::get_instance()->get_type_identifier("DdsTopicData", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetDdsTopicDataObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("DdsTopicData", complete); -} - -const TypeObject* GetDdsTopicDataObject( - bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("DdsTopicData", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteDdsTopicDataObject(); - } - //else - return GetMinimalDdsTopicDataObject(); -} - -const TypeObject* GetMinimalDdsTopicDataObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("DdsTopicData", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject* type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_participant_id; - mst_participant_id.common().member_id(memberId++); - mst_participant_id.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_participant_id.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_participant_id.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_participant_id.common().member_flags().IS_OPTIONAL(false); - mst_participant_id.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_participant_id.common().member_flags().IS_KEY(false); - mst_participant_id.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_participant_id.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - MD5 participant_id_hash("participant_id"); - for (int i = 0; i < 4; ++i) - { - mst_participant_id.detail().name_hash()[i] = participant_id_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_participant_id); - - MinimalStructMember mst_msgs_lost; - mst_msgs_lost.common().member_id(memberId++); - mst_msgs_lost.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_msgs_lost.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_msgs_lost.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_msgs_lost.common().member_flags().IS_OPTIONAL(false); - mst_msgs_lost.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_msgs_lost.common().member_flags().IS_KEY(false); - mst_msgs_lost.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_msgs_lost.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); - - - MD5 msgs_lost_hash("msgs_lost"); - for (int i = 0; i < 4; ++i) - { - mst_msgs_lost.detail().name_hash()[i] = msgs_lost_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_msgs_lost); - - MinimalStructMember mst_msgs_received; - mst_msgs_received.common().member_id(memberId++); - mst_msgs_received.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_msgs_received.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_msgs_received.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_msgs_received.common().member_flags().IS_OPTIONAL(false); - mst_msgs_received.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_msgs_received.common().member_flags().IS_KEY(false); - mst_msgs_received.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_msgs_received.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", - false)); - - - MD5 msgs_received_hash("msgs_received"); - for (int i = 0; i < 4; ++i) - { - mst_msgs_received.detail().name_hash()[i] = msgs_received_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_msgs_received); - - MinimalStructMember mst_msg_rx_rate; - mst_msg_rx_rate.common().member_id(memberId++); - mst_msg_rx_rate.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_msg_rx_rate.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_msg_rx_rate.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_msg_rx_rate.common().member_flags().IS_OPTIONAL(false); - mst_msg_rx_rate.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_msg_rx_rate.common().member_flags().IS_KEY(false); - mst_msg_rx_rate.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_msg_rx_rate.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("double", - false)); - - - MD5 msg_rx_rate_hash("msg_rx_rate"); - for (int i = 0; i < 4; ++i) - { - mst_msg_rx_rate.detail().name_hash()[i] = msg_rx_rate_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_msg_rx_rate); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for (int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("DdsTopicData", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("DdsTopicData", false); -} - -const TypeObject* GetCompleteDdsTopicDataObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("DdsTopicData", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject* type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_participant_id; - cst_participant_id.common().member_id(memberId++); - cst_participant_id.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_participant_id.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_participant_id.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_participant_id.common().member_flags().IS_OPTIONAL(false); - cst_participant_id.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_participant_id.common().member_flags().IS_KEY(false); - cst_participant_id.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_participant_id.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - cst_participant_id.detail().name("participant_id"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_participant_id); - - CompleteStructMember cst_msgs_lost; - cst_msgs_lost.common().member_id(memberId++); - cst_msgs_lost.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_msgs_lost.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_msgs_lost.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_msgs_lost.common().member_flags().IS_OPTIONAL(false); - cst_msgs_lost.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_msgs_lost.common().member_flags().IS_KEY(false); - cst_msgs_lost.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_msgs_lost.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); - - - cst_msgs_lost.detail().name("msgs_lost"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_msgs_lost); - - CompleteStructMember cst_msgs_received; - cst_msgs_received.common().member_id(memberId++); - cst_msgs_received.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_msgs_received.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_msgs_received.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_msgs_received.common().member_flags().IS_OPTIONAL(false); - cst_msgs_received.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_msgs_received.common().member_flags().IS_KEY(false); - cst_msgs_received.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_msgs_received.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", - false)); - - - cst_msgs_received.detail().name("msgs_received"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_msgs_received); - - CompleteStructMember cst_msg_rx_rate; - cst_msg_rx_rate.common().member_id(memberId++); - cst_msg_rx_rate.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_msg_rx_rate.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_msg_rx_rate.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_msg_rx_rate.common().member_flags().IS_OPTIONAL(false); - cst_msg_rx_rate.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_msg_rx_rate.common().member_flags().IS_KEY(false); - cst_msg_rx_rate.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_msg_rx_rate.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("double", - false)); - - - cst_msg_rx_rate.detail().name("msg_rx_rate"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_msg_rx_rate); - - - // Header - type_object->complete().struct_type().header().detail().type_name("DdsTopicData"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for (int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("DdsTopicData", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("DdsTopicData", true); -} - -const TypeIdentifier* GetDdsTopicIdentifier( - bool complete) -{ - const TypeIdentifier* c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("DdsTopic", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetDdsTopicObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("DdsTopic", complete); -} - -const TypeObject* GetDdsTopicObject( - bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("DdsTopic", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteDdsTopicObject(); - } - //else - return GetMinimalDdsTopicObject(); -} - -const TypeObject* GetMinimalDdsTopicObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("DdsTopic", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject* type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_name; - mst_name.common().member_id(memberId++); - mst_name.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_name.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_name.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_name.common().member_flags().IS_OPTIONAL(false); - mst_name.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_name.common().member_flags().IS_KEY(false); - mst_name.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_name.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - MD5 name_hash("name"); - for (int i = 0; i < 4; ++i) - { - mst_name.detail().name_hash()[i] = name_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_name); - - MinimalStructMember mst_type_name; - mst_type_name.common().member_id(memberId++); - mst_type_name.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_type_name.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_type_name.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_type_name.common().member_flags().IS_OPTIONAL(false); - mst_type_name.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_type_name.common().member_flags().IS_KEY(false); - mst_type_name.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_type_name.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - MD5 type_name_hash("type_name"); - for (int i = 0; i < 4; ++i) - { - mst_type_name.detail().name_hash()[i] = type_name_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_type_name); - - MinimalStructMember mst_type_discovered; - mst_type_discovered.common().member_id(memberId++); - mst_type_discovered.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_type_discovered.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_type_discovered.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_type_discovered.common().member_flags().IS_OPTIONAL(false); - mst_type_discovered.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_type_discovered.common().member_flags().IS_KEY(false); - mst_type_discovered.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_type_discovered.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - - MD5 type_discovered_hash("type_discovered"); - for (int i = 0; i < 4; ++i) - { - mst_type_discovered.detail().name_hash()[i] = type_discovered_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_type_discovered); - - MinimalStructMember mst_type_mismatch; - mst_type_mismatch.common().member_id(memberId++); - mst_type_mismatch.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_type_mismatch.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_type_mismatch.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_type_mismatch.common().member_flags().IS_OPTIONAL(false); - mst_type_mismatch.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_type_mismatch.common().member_flags().IS_KEY(false); - mst_type_mismatch.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_type_mismatch.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - - MD5 type_mismatch_hash("type_mismatch"); - for (int i = 0; i < 4; ++i) - { - mst_type_mismatch.detail().name_hash()[i] = type_mismatch_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_type_mismatch); - - MinimalStructMember mst_qos_mismatch; - mst_qos_mismatch.common().member_id(memberId++); - mst_qos_mismatch.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_qos_mismatch.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_qos_mismatch.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_qos_mismatch.common().member_flags().IS_OPTIONAL(false); - mst_qos_mismatch.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_qos_mismatch.common().member_flags().IS_KEY(false); - mst_qos_mismatch.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_qos_mismatch.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - - MD5 qos_mismatch_hash("qos_mismatch"); - for (int i = 0; i < 4; ++i) - { - mst_qos_mismatch.detail().name_hash()[i] = qos_mismatch_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_qos_mismatch); - - MinimalStructMember mst_data; - mst_data.common().member_id(memberId++); - mst_data.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_data.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_data.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_data.common().member_flags().IS_OPTIONAL(false); - mst_data.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_data.common().member_flags().IS_KEY(false); - mst_data.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_data.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("DdsTopicData", 100, - false)); - - MD5 data_hash("data"); - for (int i = 0; i < 4; ++i) - { - mst_data.detail().name_hash()[i] = data_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_data); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for (int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("DdsTopic", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("DdsTopic", false); -} - -const TypeObject* GetCompleteDdsTopicObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("DdsTopic", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject* type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_name; - cst_name.common().member_id(memberId++); - cst_name.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_name.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_name.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_name.common().member_flags().IS_OPTIONAL(false); - cst_name.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_name.common().member_flags().IS_KEY(false); - cst_name.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_name.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - cst_name.detail().name("name"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_name); - - CompleteStructMember cst_type_name; - cst_type_name.common().member_id(memberId++); - cst_type_name.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_type_name.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_type_name.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_type_name.common().member_flags().IS_OPTIONAL(false); - cst_type_name.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_type_name.common().member_flags().IS_KEY(false); - cst_type_name.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_type_name.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - cst_type_name.detail().name("type_name"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_type_name); - - CompleteStructMember cst_type_discovered; - cst_type_discovered.common().member_id(memberId++); - cst_type_discovered.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_type_discovered.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_type_discovered.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_type_discovered.common().member_flags().IS_OPTIONAL(false); - cst_type_discovered.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_type_discovered.common().member_flags().IS_KEY(false); - cst_type_discovered.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_type_discovered.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - - cst_type_discovered.detail().name("type_discovered"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_type_discovered); - - CompleteStructMember cst_type_mismatch; - cst_type_mismatch.common().member_id(memberId++); - cst_type_mismatch.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_type_mismatch.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_type_mismatch.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_type_mismatch.common().member_flags().IS_OPTIONAL(false); - cst_type_mismatch.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_type_mismatch.common().member_flags().IS_KEY(false); - cst_type_mismatch.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_type_mismatch.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - - cst_type_mismatch.detail().name("type_mismatch"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_type_mismatch); - - CompleteStructMember cst_qos_mismatch; - cst_qos_mismatch.common().member_id(memberId++); - cst_qos_mismatch.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_qos_mismatch.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_qos_mismatch.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_qos_mismatch.common().member_flags().IS_OPTIONAL(false); - cst_qos_mismatch.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_qos_mismatch.common().member_flags().IS_KEY(false); - cst_qos_mismatch.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_qos_mismatch.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - - cst_qos_mismatch.detail().name("qos_mismatch"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_qos_mismatch); - - CompleteStructMember cst_data; - cst_data.common().member_id(memberId++); - cst_data.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_data.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_data.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_data.common().member_flags().IS_OPTIONAL(false); - cst_data.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_data.common().member_flags().IS_KEY(false); - cst_data.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_data.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("DdsTopicData", 100, - true)); - - cst_data.detail().name("data"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_data); - - - // Header - type_object->complete().struct_type().header().detail().type_name("DdsTopic"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for (int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("DdsTopic", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("DdsTopic", true); -} - -const TypeIdentifier* GetMonitoringTopicsIdentifier( - bool complete) -{ - const TypeIdentifier* c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("MonitoringTopics", - complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetMonitoringTopicsObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("MonitoringTopics", complete); -} - -const TypeObject* GetMonitoringTopicsObject( - bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MonitoringTopics", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteMonitoringTopicsObject(); - } - //else - return GetMinimalMonitoringTopicsObject(); -} - -const TypeObject* GetMinimalMonitoringTopicsObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MonitoringTopics", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject* type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_topics; - mst_topics.common().member_id(memberId++); - mst_topics.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_topics.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_topics.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_topics.common().member_flags().IS_OPTIONAL(false); - mst_topics.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_topics.common().member_flags().IS_KEY(false); - mst_topics.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_topics.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("DdsTopic", 100, - false)); - - MD5 topics_hash("topics"); - for (int i = 0; i < 4; ++i) - { - mst_topics.detail().name_hash()[i] = topics_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_topics); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for (int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("MonitoringTopics", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("MonitoringTopics", false); -} - -const TypeObject* GetCompleteMonitoringTopicsObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MonitoringTopics", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject* type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_topics; - cst_topics.common().member_id(memberId++); - cst_topics.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_topics.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_topics.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_topics.common().member_flags().IS_OPTIONAL(false); - cst_topics.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_topics.common().member_flags().IS_KEY(false); - cst_topics.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_topics.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("DdsTopic", 100, - true)); - - cst_topics.detail().name("topics"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_topics); - - - // Header - type_object->complete().struct_type().header().detail().type_name("MonitoringTopics"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for (int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("MonitoringTopics", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("MonitoringTopics", true); -} diff --git a/ddspipe_core/src/cpp/types/monitoring/topics/v2/MonitoringTopicsv1.cxx b/ddspipe_core/src/cpp/types/monitoring/topics/v2/MonitoringTopicsv1.cxx deleted file mode 100644 index 8d36413a..00000000 --- a/ddspipe_core/src/cpp/types/monitoring/topics/v2/MonitoringTopicsv1.cxx +++ /dev/null @@ -1,973 +0,0 @@ -// 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 MonitoringTopics.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include - -#if FASTCDR_VERSION_MAJOR == 1 - -#include - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - -namespace helper { -namespace internal { - -enum class Size -{ - UInt8, - UInt16, - UInt32, - UInt64, -}; - -constexpr Size get_size( - int s) -{ - return (s <= 8 ) ? Size::UInt8: - (s <= 16) ? Size::UInt16: - (s <= 32) ? Size::UInt32: Size::UInt64; -} - -template -struct FindTypeH; - -template<> -struct FindTypeH -{ - using type = std::uint8_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint16_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint32_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint64_t; -}; -} // namespace internal - -template -struct FindType -{ - using type = typename internal::FindTypeH::type; -}; -} // namespace helper - -#define DdsTopicData_max_cdr_typesize 280ULL; -#define MonitoringTopics_max_cdr_typesize 2853616ULL; -#define DdsTopic_max_cdr_typesize 28536ULL; - - - - -DdsTopicData::DdsTopicData() -{ - // /type_d() m_participant_id - - // unsigned long m_msgs_lost - m_msgs_lost = 0; - // unsigned long m_msgs_received - m_msgs_received = 0; - // double m_msg_rx_rate - m_msg_rx_rate = 0.0; - - // Just to register all known types - registerMonitoringTopicsTypes(); -} - -DdsTopicData::~DdsTopicData() -{ -} - -DdsTopicData::DdsTopicData( - const DdsTopicData& x) -{ - m_participant_id = x.m_participant_id; - - - m_msgs_lost = x.m_msgs_lost; - - - m_msgs_received = x.m_msgs_received; - - - m_msg_rx_rate = x.m_msg_rx_rate; - -} - -DdsTopicData::DdsTopicData( - DdsTopicData&& x) noexcept -{ - m_participant_id = std::move(x.m_participant_id); - - - m_msgs_lost = x.m_msgs_lost; - - - m_msgs_received = x.m_msgs_received; - - - m_msg_rx_rate = x.m_msg_rx_rate; - -} - -DdsTopicData& DdsTopicData::operator =( - const DdsTopicData& x) -{ - m_participant_id = x.m_participant_id; - - - m_msgs_lost = x.m_msgs_lost; - - - m_msgs_received = x.m_msgs_received; - - - m_msg_rx_rate = x.m_msg_rx_rate; - - return *this; -} - -DdsTopicData& DdsTopicData::operator =( - DdsTopicData&& x) noexcept -{ - m_participant_id = std::move(x.m_participant_id); - - - m_msgs_lost = x.m_msgs_lost; - - - m_msgs_received = x.m_msgs_received; - - - m_msg_rx_rate = x.m_msg_rx_rate; - - return *this; -} - -bool DdsTopicData::operator ==( - const DdsTopicData& x) const -{ - return (m_participant_id == x.m_participant_id && - m_msgs_lost == x.m_msgs_lost && - m_msgs_received == x.m_msgs_received && - m_msg_rx_rate == x.m_msg_rx_rate); -} - -bool DdsTopicData::operator !=( - const DdsTopicData& x) const -{ - return !(*this == x); -} - -size_t DdsTopicData::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return DdsTopicData_max_cdr_typesize; -} - -size_t DdsTopicData::getCdrSerializedSize( - const DdsTopicData& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.participant_id().size() + 1; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - current_alignment += 8 + eprosima::fastcdr::Cdr::alignment(current_alignment, 8); - - - return current_alignment - initial_alignment; -} - -void DdsTopicData::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_participant_id.c_str(); - - scdr << m_msgs_lost; - - scdr << m_msgs_received; - - scdr << m_msg_rx_rate; - -} - -void DdsTopicData::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_participant_id; - - - - dcdr >> m_msgs_lost; - - - - dcdr >> m_msgs_received; - - - - dcdr >> m_msg_rx_rate; - - -} - -bool DdsTopicData::isKeyDefined() -{ - return false; -} - -void DdsTopicData::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function copies the value in member participant_id - * @param _participant_id New value to be copied in member participant_id - */ -void DdsTopicData::participant_id( - const std::string& _participant_id) -{ - m_participant_id = _participant_id; -} - -/*! - * @brief This function moves the value in member participant_id - * @param _participant_id New value to be moved in member participant_id - */ -void DdsTopicData::participant_id( - std::string&& _participant_id) -{ - m_participant_id = std::move(_participant_id); -} - -/*! - * @brief This function returns a constant reference to member participant_id - * @return Constant reference to member participant_id - */ -const std::string& DdsTopicData::participant_id() const -{ - return m_participant_id; -} - -/*! - * @brief This function returns a reference to member participant_id - * @return Reference to member participant_id - */ -std::string& DdsTopicData::participant_id() -{ - return m_participant_id; -} - -/*! - * @brief This function sets a value in member msgs_lost - * @param _msgs_lost New value for member msgs_lost - */ -void DdsTopicData::msgs_lost( - uint32_t _msgs_lost) -{ - m_msgs_lost = _msgs_lost; -} - -/*! - * @brief This function returns the value of member msgs_lost - * @return Value of member msgs_lost - */ -uint32_t DdsTopicData::msgs_lost() const -{ - return m_msgs_lost; -} - -/*! - * @brief This function returns a reference to member msgs_lost - * @return Reference to member msgs_lost - */ -uint32_t& DdsTopicData::msgs_lost() -{ - return m_msgs_lost; -} - -/*! - * @brief This function sets a value in member msgs_received - * @param _msgs_received New value for member msgs_received - */ -void DdsTopicData::msgs_received( - uint32_t _msgs_received) -{ - m_msgs_received = _msgs_received; -} - -/*! - * @brief This function returns the value of member msgs_received - * @return Value of member msgs_received - */ -uint32_t DdsTopicData::msgs_received() const -{ - return m_msgs_received; -} - -/*! - * @brief This function returns a reference to member msgs_received - * @return Reference to member msgs_received - */ -uint32_t& DdsTopicData::msgs_received() -{ - return m_msgs_received; -} - -/*! - * @brief This function sets a value in member msg_rx_rate - * @param _msg_rx_rate New value for member msg_rx_rate - */ -void DdsTopicData::msg_rx_rate( - double _msg_rx_rate) -{ - m_msg_rx_rate = _msg_rx_rate; -} - -/*! - * @brief This function returns the value of member msg_rx_rate - * @return Value of member msg_rx_rate - */ -double DdsTopicData::msg_rx_rate() const -{ - return m_msg_rx_rate; -} - -/*! - * @brief This function returns a reference to member msg_rx_rate - * @return Reference to member msg_rx_rate - */ -double& DdsTopicData::msg_rx_rate() -{ - return m_msg_rx_rate; -} - -DdsTopic::DdsTopic() -{ - // /type_d() m_name - - // /type_d() m_type_name - - // boolean m_type_discovered - m_type_discovered = false; - // boolean m_type_mismatch - m_type_mismatch = false; - // boolean m_qos_mismatch - m_qos_mismatch = false; - // sequence m_data - - - // Just to register all known types - registerMonitoringTopicsTypes(); -} - -DdsTopic::~DdsTopic() -{ -} - -DdsTopic::DdsTopic( - const DdsTopic& x) -{ - m_name = x.m_name; - - - m_type_name = x.m_type_name; - - - m_type_discovered = x.m_type_discovered; - - - m_type_mismatch = x.m_type_mismatch; - - - m_qos_mismatch = x.m_qos_mismatch; - - - m_data = x.m_data; - -} - -DdsTopic::DdsTopic( - DdsTopic&& x) noexcept -{ - m_name = std::move(x.m_name); - - - m_type_name = std::move(x.m_type_name); - - - m_type_discovered = x.m_type_discovered; - - - m_type_mismatch = x.m_type_mismatch; - - - m_qos_mismatch = x.m_qos_mismatch; - - - m_data = std::move(x.m_data); - -} - -DdsTopic& DdsTopic::operator =( - const DdsTopic& x) -{ - m_name = x.m_name; - - - m_type_name = x.m_type_name; - - - m_type_discovered = x.m_type_discovered; - - - m_type_mismatch = x.m_type_mismatch; - - - m_qos_mismatch = x.m_qos_mismatch; - - - m_data = x.m_data; - - return *this; -} - -DdsTopic& DdsTopic::operator =( - DdsTopic&& x) noexcept -{ - m_name = std::move(x.m_name); - - - m_type_name = std::move(x.m_type_name); - - - m_type_discovered = x.m_type_discovered; - - - m_type_mismatch = x.m_type_mismatch; - - - m_qos_mismatch = x.m_qos_mismatch; - - - m_data = std::move(x.m_data); - - return *this; -} - -bool DdsTopic::operator ==( - const DdsTopic& x) const -{ - return (m_name == x.m_name && - m_type_name == x.m_type_name && - m_type_discovered == x.m_type_discovered && - m_type_mismatch == x.m_type_mismatch && - m_qos_mismatch == x.m_qos_mismatch && - m_data == x.m_data); -} - -bool DdsTopic::operator !=( - const DdsTopic& x) const -{ - return !(*this == x); -} - -size_t DdsTopic::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return DdsTopic_max_cdr_typesize; -} - -size_t DdsTopic::getCdrSerializedSize( - const DdsTopic& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.name().size() + 1; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.type_name().size() + 1; - - - current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); - - - current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); - - - current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - for (size_t a = 0; a < data.data().size(); ++a) - { - current_alignment += DdsTopicData::getCdrSerializedSize(data.data().at(a), current_alignment); - } - - - - return current_alignment - initial_alignment; -} - -void DdsTopic::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_name.c_str(); - - scdr << m_type_name.c_str(); - - scdr << m_type_discovered; - - scdr << m_type_mismatch; - - scdr << m_qos_mismatch; - - scdr << m_data; - - -} - -void DdsTopic::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_name; - - - - dcdr >> m_type_name; - - - - dcdr >> m_type_discovered; - - - - dcdr >> m_type_mismatch; - - - - dcdr >> m_qos_mismatch; - - - - dcdr >> m_data; - - -} - -bool DdsTopic::isKeyDefined() -{ - return false; -} - -void DdsTopic::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function copies the value in member name - * @param _name New value to be copied in member name - */ -void DdsTopic::name( - const std::string& _name) -{ - m_name = _name; -} - -/*! - * @brief This function moves the value in member name - * @param _name New value to be moved in member name - */ -void DdsTopic::name( - std::string&& _name) -{ - m_name = std::move(_name); -} - -/*! - * @brief This function returns a constant reference to member name - * @return Constant reference to member name - */ -const std::string& DdsTopic::name() const -{ - return m_name; -} - -/*! - * @brief This function returns a reference to member name - * @return Reference to member name - */ -std::string& DdsTopic::name() -{ - return m_name; -} - -/*! - * @brief This function copies the value in member type_name - * @param _type_name New value to be copied in member type_name - */ -void DdsTopic::type_name( - const std::string& _type_name) -{ - m_type_name = _type_name; -} - -/*! - * @brief This function moves the value in member type_name - * @param _type_name New value to be moved in member type_name - */ -void DdsTopic::type_name( - std::string&& _type_name) -{ - m_type_name = std::move(_type_name); -} - -/*! - * @brief This function returns a constant reference to member type_name - * @return Constant reference to member type_name - */ -const std::string& DdsTopic::type_name() const -{ - return m_type_name; -} - -/*! - * @brief This function returns a reference to member type_name - * @return Reference to member type_name - */ -std::string& DdsTopic::type_name() -{ - return m_type_name; -} - -/*! - * @brief This function sets a value in member type_discovered - * @param _type_discovered New value for member type_discovered - */ -void DdsTopic::type_discovered( - bool _type_discovered) -{ - m_type_discovered = _type_discovered; -} - -/*! - * @brief This function returns the value of member type_discovered - * @return Value of member type_discovered - */ -bool DdsTopic::type_discovered() const -{ - return m_type_discovered; -} - -/*! - * @brief This function returns a reference to member type_discovered - * @return Reference to member type_discovered - */ -bool& DdsTopic::type_discovered() -{ - return m_type_discovered; -} - -/*! - * @brief This function sets a value in member type_mismatch - * @param _type_mismatch New value for member type_mismatch - */ -void DdsTopic::type_mismatch( - bool _type_mismatch) -{ - m_type_mismatch = _type_mismatch; -} - -/*! - * @brief This function returns the value of member type_mismatch - * @return Value of member type_mismatch - */ -bool DdsTopic::type_mismatch() const -{ - return m_type_mismatch; -} - -/*! - * @brief This function returns a reference to member type_mismatch - * @return Reference to member type_mismatch - */ -bool& DdsTopic::type_mismatch() -{ - return m_type_mismatch; -} - -/*! - * @brief This function sets a value in member qos_mismatch - * @param _qos_mismatch New value for member qos_mismatch - */ -void DdsTopic::qos_mismatch( - bool _qos_mismatch) -{ - m_qos_mismatch = _qos_mismatch; -} - -/*! - * @brief This function returns the value of member qos_mismatch - * @return Value of member qos_mismatch - */ -bool DdsTopic::qos_mismatch() const -{ - return m_qos_mismatch; -} - -/*! - * @brief This function returns a reference to member qos_mismatch - * @return Reference to member qos_mismatch - */ -bool& DdsTopic::qos_mismatch() -{ - return m_qos_mismatch; -} - -/*! - * @brief This function copies the value in member data - * @param _data New value to be copied in member data - */ -void DdsTopic::data( - const std::vector& _data) -{ - m_data = _data; -} - -/*! - * @brief This function moves the value in member data - * @param _data New value to be moved in member data - */ -void DdsTopic::data( - std::vector&& _data) -{ - m_data = std::move(_data); -} - -/*! - * @brief This function returns a constant reference to member data - * @return Constant reference to member data - */ -const std::vector& DdsTopic::data() const -{ - return m_data; -} - -/*! - * @brief This function returns a reference to member data - * @return Reference to member data - */ -std::vector& DdsTopic::data() -{ - return m_data; -} - -MonitoringTopics::MonitoringTopics() -{ - // sequence m_topics - - - // Just to register all known types - registerMonitoringTopicsTypes(); -} - -MonitoringTopics::~MonitoringTopics() -{ -} - -MonitoringTopics::MonitoringTopics( - const MonitoringTopics& x) -{ - m_topics = x.m_topics; - -} - -MonitoringTopics::MonitoringTopics( - MonitoringTopics&& x) noexcept -{ - m_topics = std::move(x.m_topics); - -} - -MonitoringTopics& MonitoringTopics::operator =( - const MonitoringTopics& x) -{ - m_topics = x.m_topics; - - return *this; -} - -MonitoringTopics& MonitoringTopics::operator =( - MonitoringTopics&& x) noexcept -{ - m_topics = std::move(x.m_topics); - - return *this; -} - -bool MonitoringTopics::operator ==( - const MonitoringTopics& x) const -{ - return (m_topics == x.m_topics); -} - -bool MonitoringTopics::operator !=( - const MonitoringTopics& x) const -{ - return !(*this == x); -} - -size_t MonitoringTopics::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return MonitoringTopics_max_cdr_typesize; -} - -size_t MonitoringTopics::getCdrSerializedSize( - const MonitoringTopics& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - for (size_t a = 0; a < data.topics().size(); ++a) - { - current_alignment += DdsTopic::getCdrSerializedSize(data.topics().at(a), current_alignment); - } - - - - return current_alignment - initial_alignment; -} - -void MonitoringTopics::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_topics; - - -} - -void MonitoringTopics::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_topics; - - -} - -bool MonitoringTopics::isKeyDefined() -{ - return false; -} - -void MonitoringTopics::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function copies the value in member topics - * @param _topics New value to be copied in member topics - */ -void MonitoringTopics::topics( - const std::vector& _topics) -{ - m_topics = _topics; -} - -/*! - * @brief This function moves the value in member topics - * @param _topics New value to be moved in member topics - */ -void MonitoringTopics::topics( - std::vector&& _topics) -{ - m_topics = std::move(_topics); -} - -/*! - * @brief This function returns a constant reference to member topics - * @return Constant reference to member topics - */ -const std::vector& MonitoringTopics::topics() const -{ - return m_topics; -} - -/*! - * @brief This function returns a reference to member topics - * @return Reference to member topics - */ -std::vector& MonitoringTopics::topics() -{ - return m_topics; -} - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddspipe_core/src/cpp/types/topic/dds/DdsTopic.cpp b/ddspipe_core/src/cpp/types/topic/dds/DdsTopic.cpp index b30b404f..11e5c4fd 100644 --- a/ddspipe_core/src/cpp/types/topic/dds/DdsTopic.cpp +++ b/ddspipe_core/src/cpp/types/topic/dds/DdsTopic.cpp @@ -121,6 +121,7 @@ DdsTopic& DdsTopic::operator = ( Topic::operator =(other); this->type_name = other.type_name; + this->type_identifiers = other.type_identifiers; return *this; } diff --git a/ddspipe_core/test/unittest/core/ddspipe/CMakeLists.txt b/ddspipe_core/test/unittest/core/ddspipe/CMakeLists.txt index fd153500..623e1614 100644 --- a/ddspipe_core/test/unittest/core/ddspipe/CMakeLists.txt +++ b/ddspipe_core/test/unittest/core/ddspipe/CMakeLists.txt @@ -25,13 +25,6 @@ file( "${PROJECT_SOURCE_DIR}/include/*.ipp" ) -# Exclude types' files depending on the Fast DDS version -if ("${fastrtps_VERSION}" VERSION_LESS 2.13) - list(FILTER LIBRARY_SOURCES EXCLUDE REGEX "v2/") -else() - list(FILTER LIBRARY_SOURCES EXCLUDE REGEX "v1/") -endif() - all_library_sources( "${TEST_SOURCES}" "${LIBRARY_SOURCES}" @@ -45,7 +38,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES fastcdr - fastrtps + fastdds cpp_utils ) diff --git a/ddspipe_core/test/unittest/dynamic/allowed_topic_list/CMakeLists.txt b/ddspipe_core/test/unittest/dynamic/allowed_topic_list/CMakeLists.txt index 4edef040..ae0b1041 100644 --- a/ddspipe_core/test/unittest/dynamic/allowed_topic_list/CMakeLists.txt +++ b/ddspipe_core/test/unittest/dynamic/allowed_topic_list/CMakeLists.txt @@ -41,7 +41,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES fastcdr - fastrtps + fastdds cpp_utils ) diff --git a/ddspipe_core/test/unittest/dynamic/participants_database/CMakeLists.txt b/ddspipe_core/test/unittest/dynamic/participants_database/CMakeLists.txt index bf91b850..49fb729c 100644 --- a/ddspipe_core/test/unittest/dynamic/participants_database/CMakeLists.txt +++ b/ddspipe_core/test/unittest/dynamic/participants_database/CMakeLists.txt @@ -39,7 +39,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES fastcdr - fastrtps + fastdds cpp_utils ) diff --git a/ddspipe_core/test/unittest/efficiency/CMakeLists.txt b/ddspipe_core/test/unittest/efficiency/CMakeLists.txt index ed0d0811..18fea881 100644 --- a/ddspipe_core/test/unittest/efficiency/CMakeLists.txt +++ b/ddspipe_core/test/unittest/efficiency/CMakeLists.txt @@ -27,17 +27,16 @@ set(TEST_SOURCES set(TEST_LIST reserve + reserve_negative release reserve_and_release_counter + reserve_and_release_counter_negative is_clean - get_payload_cache_change - get_payload_from_src_cache_change - release_payload_cache_change ) set(TEST_EXTRA_LIBRARIES fastcdr - fastrtps + fastdds cpp_utils ) @@ -73,7 +72,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES fastcdr - fastrtps + fastdds cpp_utils ) @@ -109,7 +108,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES fastcdr - fastrtps + fastdds cpp_utils ) diff --git a/ddspipe_core/test/unittest/efficiency/FastPayloadPoolTest.cpp b/ddspipe_core/test/unittest/efficiency/FastPayloadPoolTest.cpp index 7fd3d31a..85d507d7 100644 --- a/ddspipe_core/test/unittest/efficiency/FastPayloadPoolTest.cpp +++ b/ddspipe_core/test/unittest/efficiency/FastPayloadPoolTest.cpp @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include @@ -67,10 +67,8 @@ void get_release( FastPayloadPool& pool, Payload& src_payload) { - eprosima::fastrtps::rtps::IPayloadPool* payload_owner = - static_cast(&pool); Payload dst_payload; - ASSERT_TRUE(pool.get_payload(src_payload, payload_owner, dst_payload)); + ASSERT_TRUE(pool.get_payload(src_payload, dst_payload)); ASSERT_TRUE(pool.release_payload(dst_payload)); } @@ -140,7 +138,7 @@ TEST(FastPayloadPoolTest, get_payload) */ TEST(FastPayloadPoolTest, get_payload_from_src) { - eprosima::fastrtps::rtps::IPayloadPool* pool = new test::MockFastPayloadPool(); // Requires to be ptr to pass it to get_payload + eprosima::fastdds::rtps::IPayloadPool* pool = new test::MockFastPayloadPool(); // Requires to be ptr to pass it to get_payload test::MockFastPayloadPool* pool_ = static_cast(pool); Payload payload0; @@ -155,13 +153,13 @@ TEST(FastPayloadPoolTest, get_payload_from_src) ASSERT_EQ(pool_->pointers_stored(), 1u); // get payload1 from src payload0 - ASSERT_TRUE(pool_->get_payload(payload0, pool, payload1)); + ASSERT_TRUE(pool_->get_payload(payload0, payload1)); ASSERT_EQ(pool_->pointers_stored(), 1u); ASSERT_EQ(payload1.max_size, payload0.max_size); ASSERT_EQ(payload1.data, payload0.data); // get payload2 from src payload1 - ASSERT_TRUE(pool_->get_payload(payload1, pool, payload2)); + ASSERT_TRUE(pool_->get_payload(payload1, payload2)); ASSERT_EQ(pool_->pointers_stored(), 1u); ASSERT_EQ(payload2.max_size, payload0.max_size); ASSERT_EQ(payload2.data, payload0.data); @@ -171,7 +169,7 @@ TEST(FastPayloadPoolTest, get_payload_from_src) ASSERT_EQ(pool_->pointers_stored(), 1u); // get payload3 from src payload1 - ASSERT_TRUE(pool_->get_payload(payload1, pool, payload3)); + ASSERT_TRUE(pool_->get_payload(payload1, payload3)); ASSERT_EQ(pool_->pointers_stored(), 1u); ASSERT_EQ(payload3.max_size, payload1.max_size); ASSERT_EQ(payload3.data, payload1.data); @@ -181,7 +179,7 @@ TEST(FastPayloadPoolTest, get_payload_from_src) ASSERT_EQ(pool_->pointers_stored(), 2u); // get payload5 from src payload4 - ASSERT_TRUE(pool_->get_payload(payload4, pool, payload5)); + ASSERT_TRUE(pool_->get_payload(payload4, payload5)); ASSERT_EQ(pool_->pointers_stored(), 2u); ASSERT_EQ(payload5.max_size, payload4.max_size); ASSERT_EQ(payload5.data, payload4.data); @@ -213,9 +211,9 @@ TEST(FastPayloadPoolTest, get_payload_from_src_no_owner) { // Each pool has a IPayloadPool and a MockFastPayloadPool so it can be called to get_payload from source // and specific methods from mock - eprosima::fastrtps::rtps::IPayloadPool* pool = new test::MockFastPayloadPool(); // Requires to be ptr to pass it to get_payload + eprosima::fastdds::rtps::IPayloadPool* pool = new test::MockFastPayloadPool(); // Requires to be ptr to pass it to get_payload test::MockFastPayloadPool* pool_ = static_cast(pool); - eprosima::fastrtps::rtps::IPayloadPool* pool_aux = new test::MockFastPayloadPool(); // Requires to be ptr to pass it to get_payload + eprosima::fastdds::rtps::IPayloadPool* pool_aux = new test::MockFastPayloadPool(); // Requires to be ptr to pass it to get_payload test::MockFastPayloadPool* pool_aux_ = static_cast(pool_aux); Payload payload_src; @@ -227,7 +225,7 @@ TEST(FastPayloadPoolTest, get_payload_from_src_no_owner) ASSERT_EQ(pool_->pointers_stored(), 0u); // get payload from src payload aux - ASSERT_TRUE(pool_->get_payload(payload_src, pool_aux, payload_target)); + ASSERT_TRUE(pool_->get_payload(payload_src, payload_target)); ASSERT_EQ(pool_->pointers_stored(), 1u); // release payload aux from pool aux @@ -253,9 +251,8 @@ TEST(FastPayloadPoolTest, get_payload_from_src_negative) { // Source has size 0 and different owner { - eprosima::fastrtps::rtps::IPayloadPool* pool = new test::MockFastPayloadPool(); // Requires to be ptr to pass it to get_payload + eprosima::fastdds::rtps::IPayloadPool* pool = new test::MockFastPayloadPool(); // Requires to be ptr to pass it to get_payload test::MockFastPayloadPool* pool_ = static_cast(pool); - eprosima::fastrtps::rtps::IPayloadPool* pool_aux = nullptr; // nullptr Payload payload_src; Payload payload_target; @@ -263,7 +260,6 @@ TEST(FastPayloadPoolTest, get_payload_from_src_negative) ASSERT_FALSE( pool_->get_payload( payload_src, - pool_aux, payload_target)); delete pool; @@ -282,7 +278,7 @@ TEST(FastPayloadPoolTest, get_payload_from_src_negative) */ TEST(FastPayloadPoolTest, release_payload) { - eprosima::fastrtps::rtps::IPayloadPool* pool = new test::MockFastPayloadPool(); // Requires to be ptr to pass it to get_payload + eprosima::fastdds::rtps::IPayloadPool* pool = new test::MockFastPayloadPool(); // Requires to be ptr to pass it to get_payload test::MockFastPayloadPool* pool_ = static_cast(pool); std::vector payloads(TEST_NUMBER); @@ -292,7 +288,7 @@ TEST(FastPayloadPoolTest, release_payload) // get N-1 payloads from first for (unsigned int i = 1; i < TEST_NUMBER; i++) { - pool_->get_payload(payloads[0], pool, payloads[i]); + pool_->get_payload(payloads[0], payloads[i]); } // release N-2 payloads @@ -304,7 +300,7 @@ TEST(FastPayloadPoolTest, release_payload) // get N-2 more payloads from first for (unsigned int i = 2; i < TEST_NUMBER; i++) { - pool_->get_payload(payloads[0], pool, payloads[i]); + pool_->get_payload(payloads[0], payloads[i]); } // release N payloads @@ -394,10 +390,8 @@ TEST(FastPayloadPoolTest, concurrent_release) ASSERT_TRUE(pool.get_payload(DEFAULT_SIZE, payload)); - eprosima::fastrtps::rtps::IPayloadPool* payload_owner = - static_cast(&pool); Payload dst_payload; - ASSERT_TRUE(pool.get_payload(payload, payload_owner, dst_payload)); + ASSERT_TRUE(pool.get_payload(payload, dst_payload)); std::thread t1(test::release, std::ref(pool), std::ref(dst_payload)); diff --git a/ddspipe_core/test/unittest/efficiency/MapPayloadPoolTest.cpp b/ddspipe_core/test/unittest/efficiency/MapPayloadPoolTest.cpp index d8cc5409..ac025eec 100644 --- a/ddspipe_core/test/unittest/efficiency/MapPayloadPoolTest.cpp +++ b/ddspipe_core/test/unittest/efficiency/MapPayloadPoolTest.cpp @@ -15,7 +15,7 @@ #include #include -#include +#include #include #include @@ -101,6 +101,10 @@ TEST(MapPayloadPoolTest, get_payload) // END : Clean all remaining payloads pool.clean_all(payloads); + + // Check payload pool is empty + ASSERT_TRUE(pool.is_clean()); + ASSERT_EQ(pool.pointers_stored(), 0u); } // fail reserve memory @@ -109,6 +113,10 @@ TEST(MapPayloadPoolTest, get_payload) Payload payload; ASSERT_FALSE(pool.get_payload(0, payload)); + + // Check payload pool is empty + ASSERT_TRUE(pool.is_clean()); + ASSERT_EQ(pool.pointers_stored(), 0u); } } @@ -127,7 +135,7 @@ TEST(MapPayloadPoolTest, get_payload) */ TEST(MapPayloadPoolTest, get_payload_from_src) { - eprosima::fastrtps::rtps::IPayloadPool* pool = new test::MockMapPayloadPool(); // Requires to be ptr to pass it to get_payload + eprosima::fastdds::rtps::IPayloadPool* pool = new test::MockMapPayloadPool(); test::MockMapPayloadPool* pool_ = static_cast(pool); Payload payload0; @@ -143,14 +151,14 @@ TEST(MapPayloadPoolTest, get_payload_from_src) ASSERT_EQ(pool_->reference_count(payload0), 1u); // get payload1 from src payload0 - ASSERT_TRUE(pool_->get_payload(payload0, pool, payload1)); + ASSERT_TRUE(pool_->get_payload(payload0, payload1)); ASSERT_EQ(pool_->pointers_stored(), 1u); ASSERT_EQ(pool_->reference_count(payload1), 2u); ASSERT_EQ(payload1.max_size, payload0.max_size); ASSERT_EQ(payload1.data, payload0.data); // get payload2 from src payload1 - ASSERT_TRUE(pool_->get_payload(payload1, pool, payload2)); + ASSERT_TRUE(pool_->get_payload(payload1, payload2)); ASSERT_EQ(pool_->pointers_stored(), 1u); ASSERT_EQ(pool_->reference_count(payload2), 3u); ASSERT_EQ(payload2.max_size, payload0.max_size); @@ -162,7 +170,7 @@ TEST(MapPayloadPoolTest, get_payload_from_src) ASSERT_EQ(pool_->reference_count(payload2), 2u); // get payload3 from src payload1 - ASSERT_TRUE(pool_->get_payload(payload1, pool, payload3)); + ASSERT_TRUE(pool_->get_payload(payload1, payload3)); ASSERT_EQ(pool_->pointers_stored(), 1u); ASSERT_EQ(pool_->reference_count(payload3), 3u); ASSERT_EQ(payload3.max_size, payload1.max_size); @@ -175,7 +183,7 @@ TEST(MapPayloadPoolTest, get_payload_from_src) ASSERT_EQ(pool_->reference_count(payload4), 1u); // get payload5 from src payload4 - ASSERT_TRUE(pool_->get_payload(payload4, pool, payload5)); + ASSERT_TRUE(pool_->get_payload(payload4, payload5)); ASSERT_EQ(pool_->pointers_stored(), 2u); ASSERT_EQ(pool_->reference_count(payload1), 3u); ASSERT_EQ(pool_->reference_count(payload5), 2u); @@ -209,9 +217,9 @@ TEST(MapPayloadPoolTest, get_payload_from_src_no_owner) { // Each pool has a IPayloadPool and a MockMapPayloadPool so it can be called to get_payload from source // and specific methods from mock - eprosima::fastrtps::rtps::IPayloadPool* pool = new test::MockMapPayloadPool(); // Requires to be ptr to pass it to get_payload + eprosima::fastdds::rtps::IPayloadPool* pool = new test::MockMapPayloadPool(); // Requires to be ptr to pass it to get_payload test::MockMapPayloadPool* pool_ = static_cast(pool); - eprosima::fastrtps::rtps::IPayloadPool* pool_aux = new test::MockMapPayloadPool(); // Requires to be ptr to pass it to get_payload + eprosima::fastdds::rtps::IPayloadPool* pool_aux = new test::MockMapPayloadPool(); // Requires to be ptr to pass it to get_payload test::MockMapPayloadPool* pool_aux_ = static_cast(pool_aux); Payload payload_src; @@ -223,7 +231,7 @@ TEST(MapPayloadPoolTest, get_payload_from_src_no_owner) ASSERT_EQ(pool_->pointers_stored(), 0u); // get payload from src payload aux - ASSERT_TRUE(pool_->get_payload(payload_src, pool_aux, payload_target)); + ASSERT_TRUE(pool_->get_payload(payload_src, payload_target)); ASSERT_EQ(pool_->pointers_stored(), 1u); // release payload aux from pool aux @@ -243,40 +251,14 @@ TEST(MapPayloadPoolTest, get_payload_from_src_no_owner) * Check negative cases for get_payload from source * * CASES: - * The source says the owner is the same pool, but is not * Source has size 0 and different owner */ TEST(MapPayloadPoolTest, get_payload_from_src_negative) { - // The source says the owner is the same pool, but is not - { - // 1 log error expected - INSTANTIATE_LOG_TESTER(eprosima::utils::Log::Kind::Error, 1, 1); - - eprosima::fastrtps::rtps::IPayloadPool* pool = new test::MockMapPayloadPool(); // Requires to be ptr to pass it to get_payload - test::MockMapPayloadPool* pool_ = static_cast(pool); - test::MockMapPayloadPool pool_aux; - - Payload payload_src; - Payload payload_target; - - // Get payload for source - pool_aux.get_payload(DEFAULT_SIZE, payload_src); - - // In a different pool, try to source it as if it was from same pool - ASSERT_THROW(pool_->get_payload(payload_src, pool, payload_target), eprosima::utils::InconsistencyException); - - // END : release payload - pool_aux.release_payload(payload_src); - - delete pool; - } - // Source has size 0 and different owner { - eprosima::fastrtps::rtps::IPayloadPool* pool = new test::MockMapPayloadPool(); // Requires to be ptr to pass it to get_payload + eprosima::fastdds::rtps::IPayloadPool* pool = new test::MockMapPayloadPool(); // Requires to be ptr to pass it to get_payload test::MockMapPayloadPool* pool_ = static_cast(pool); - eprosima::fastrtps::rtps::IPayloadPool* pool_aux = nullptr; // nullptr Payload payload_src; Payload payload_target; @@ -284,9 +266,12 @@ TEST(MapPayloadPoolTest, get_payload_from_src_negative) ASSERT_FALSE( pool_->get_payload( payload_src, - pool_aux, payload_target)); + // Check payload pool is empty + ASSERT_TRUE(pool_->is_clean()); + ASSERT_EQ(pool_->pointers_stored(), 0u); + delete pool; } } @@ -303,7 +288,7 @@ TEST(MapPayloadPoolTest, get_payload_from_src_negative) */ TEST(MapPayloadPoolTest, release_payload) { - eprosima::fastrtps::rtps::IPayloadPool* pool = new test::MockMapPayloadPool(); // Requires to be ptr to pass it to get_payload + eprosima::fastdds::rtps::IPayloadPool* pool = new test::MockMapPayloadPool(); // Requires to be ptr to pass it to get_payload test::MockMapPayloadPool* pool_ = static_cast(pool); std::vector payloads(TEST_NUMBER); @@ -313,7 +298,7 @@ TEST(MapPayloadPoolTest, release_payload) // get N-1 payloads from first for (unsigned int i = 1; i < TEST_NUMBER; i++) { - pool_->get_payload(payloads[0], pool, payloads[i]); + pool_->get_payload(payloads[0], payloads[i]); ASSERT_EQ(pool_->reference_count(payloads[0]), i + 1) << i; } @@ -327,7 +312,7 @@ TEST(MapPayloadPoolTest, release_payload) // get N-2 more payloads from first for (unsigned int i = 2; i < TEST_NUMBER; i++) { - pool_->get_payload(payloads[0], pool, payloads[i]); + pool_->get_payload(payloads[0], payloads[i]); ASSERT_EQ(pool_->reference_count(payloads[0]), i + 1) << i; } diff --git a/ddspipe_core/test/unittest/efficiency/PayloadPoolTest.cpp b/ddspipe_core/test/unittest/efficiency/PayloadPoolTest.cpp index b673a49b..7add4958 100644 --- a/ddspipe_core/test/unittest/efficiency/PayloadPoolTest.cpp +++ b/ddspipe_core/test/unittest/efficiency/PayloadPoolTest.cpp @@ -16,8 +16,7 @@ #include #include -#include -#include +#include #include #include @@ -35,14 +34,14 @@ using ::testing::Invoke; using ::testing::Return; namespace eprosima { -namespace fastrtps { +namespace fastdds { namespace rtps { /* * WORKAROUND: * This definition is needed due to googletest-distribution (1.11.0) requires to every class used inside ASSERT macro * to have the operator << defined in SAME namespace than the class. - * In our case, Payload is defined as eprosima::fastrtps::rtps::SerializedPayload_t but redefined as + * In our case, Payload is defined as eprosima::fastdds::rtps::SerializedPayload_t but redefined as * eprosima::ddspipe::core::types::Payload and the operator << is defined in eprosima::ddspipe::core::types * Thus, gtest could not find this definition (arising a very messy and cryptic compilation error). * This definition corrects that problem. @@ -51,14 +50,14 @@ namespace rtps { * In googletest-distribution release-1.10.0 this does not happen. */ void PrintTo( - const SerializedPayload_t, + const SerializedPayload_t&, std::ostream* os) { - *os << "::eprosima::fastrtps::rtps::SerializedPayload_t"; + *os << "::eprosima::fastdds::rtps::SerializedPayload_t"; } } /* namespace rtps */ -} /* namespace fastrtps */ +} /* namespace fastdds */ } /* namespace eprosima */ namespace eprosima { @@ -77,8 +76,6 @@ class MockPayloadPool : public PayloadPool // Using parent methods and variables as public using PayloadPool::PayloadPool; - using PayloadPool::get_payload; - using PayloadPool::release_payload; using PayloadPool::reserve_; using PayloadPool::release_; using PayloadPool::reserve_count_; @@ -88,7 +85,7 @@ class MockPayloadPool : public PayloadPool MOCK_METHOD( bool, get_payload, - (uint32_t size, eprosima::ddspipe::core::types::Payload& target_payload), + (uint32_t size, eprosima::fastdds::rtps::SerializedPayload_t& target_payload), (override)); MOCK_METHOD( @@ -96,15 +93,14 @@ class MockPayloadPool : public PayloadPool get_payload, ( const Payload& src_payload, - eprosima::fastrtps::rtps::IPayloadPool*&data_owner, - eprosima::ddspipe::core::types::Payload& target_payload + eprosima::fastdds::rtps::SerializedPayload_t& target_payload ), (override)); MOCK_METHOD( bool, release_payload, - (eprosima::ddspipe::core::types::Payload& target_payload), + (eprosima::fastdds::rtps::SerializedPayload_t& target_payload), (override)); }; @@ -138,6 +134,8 @@ TEST(PayloadPoolTest, reserve) // This would (maybe) fail with SEG FAULT if the data has not been correctly set payload.data[0] = 16u; + + ASSERT_TRUE(pool.release_(payload)); } // large size @@ -156,6 +154,8 @@ TEST(PayloadPoolTest, reserve) // This would (maybe) fail with SEG FAULT if the data has not been correctly set payload.data[0] = 4u; payload.data[0x1000 - 1] = 5u; + + ASSERT_TRUE(pool.release_(payload)); } } @@ -320,154 +320,15 @@ TEST(PayloadPoolTest, is_clean) ASSERT_TRUE(pool.is_clean()); // reserve and not clean - eprosima::fastrtps::rtps::CacheChange_t cc; - pool.reserve_(sizeof(PayloadUnit), cc.serializedPayload); + Payload payload; + pool.reserve_(sizeof(PayloadUnit), payload); ASSERT_FALSE(pool.is_clean()); // release and clean - pool.release_(cc.serializedPayload); + pool.release_(payload); ASSERT_TRUE(pool.is_clean()); } -/** - * Test get_payload cache_change fails if the child class fails - * - * CASES: - * - get_payload for payload goes ok - * - get_payload for payload fails - */ -TEST(PayloadPoolTest, get_payload_cache_change) -{ - // get_payload for payload goes ok - { - test::MockPayloadPool pool; - eprosima::fastrtps::rtps::CacheChange_t cc; - - EXPECT_CALL(pool, get_payload(_, _)).Times(1).WillOnce(Return(true)); - - EXPECT_TRUE(pool.get_payload(sizeof(PayloadUnit), cc)); - - // Clean cache change correctly so process dont break - cc.payload_owner(nullptr); - } - - // get_payload for payload goes ok - { - test::MockPayloadPool pool; - eprosima::fastrtps::rtps::CacheChange_t cc; - - EXPECT_CALL(pool, get_payload(_, _)).Times(1).WillOnce(Return(false)); - - EXPECT_FALSE(pool.get_payload(sizeof(PayloadUnit), cc)); - } -} - -/** - * Test get_payload cache_change with source fails if the child class fails - * - * CASES: - * - get_payload for payload goes ok - * - get_payload for payload fails - */ -TEST(PayloadPoolTest, get_payload_from_src_cache_change) -{ - // get_payload for payload goes ok - { - test::MockPayloadPool pool; - eprosima::fastrtps::rtps::CacheChange_t target; - Payload source; - eprosima::fastrtps::rtps::IPayloadPool* aux_pool; - - EXPECT_CALL(pool, get_payload(_, _, _)).Times(1).WillOnce(Return(true)); - - EXPECT_TRUE(pool.get_payload(source, aux_pool, target)); - - // Clean cache change correctly so process dont break - target.payload_owner(nullptr); - } -} - -/** - * Test get_payload cache_change with source fails if the child class fails - * - * CASES: - * - get_payload for payload fails - */ -TEST(PayloadPoolTest, get_payload_from_src_cache_change_negative) -{ - // get_payload for payload fails - { - test::MockPayloadPool pool; - eprosima::fastrtps::rtps::CacheChange_t target; - Payload source; - eprosima::fastrtps::rtps::IPayloadPool* aux_pool; - - EXPECT_CALL(pool, get_payload(_, _, _)).Times(1).WillOnce(Return(false)); - - EXPECT_FALSE(pool.get_payload(source, aux_pool, target)); - } -} - -/** - * Test release_payload cache_change method using MockPayloadPool when inside get_payload method fails - * - * CASES: - * different ownership - * this ownership release ok - */ -TEST(PayloadPoolTest, release_payload_cache_change) -{ - // this ownership release ok - { - test::MockPayloadPool pool; - eprosima::fastrtps::rtps::CacheChange_t cc; - - // ownership must be this pool - cc.payload_owner(&pool); - - EXPECT_CALL(pool, release_payload(_)).Times(1).WillOnce(Return(true)); - - EXPECT_TRUE(pool.release_payload(cc)); - } -} - -/** - * Test release_payload cache_change method from a different owner - * - * CASES: - * this ownership release fail - */ -TEST(PayloadPoolTest, release_payload_cache_change_negative) -{ - // different ownership - { - // 1 log error expected - INSTANTIATE_LOG_TESTER(eprosima::utils::Log::Kind::Error, 1, 1); - - test::MockPayloadPool pool; - eprosima::fastrtps::rtps::CacheChange_t cc; - cc.payload_owner(nullptr); - - EXPECT_THROW(pool.release_payload(cc), eprosima::utils::InconsistencyException); - } - - // this ownership release fail - { - test::MockPayloadPool pool; - eprosima::fastrtps::rtps::CacheChange_t cc; - - // ownership must be this pool - cc.payload_owner(&pool); - - EXPECT_CALL(pool, release_payload(_)).Times(1).WillOnce(Return(false)); - - EXPECT_FALSE(pool.release_payload(cc)); - - // Clean cache change correctly so process dont break - cc.payload_owner(nullptr); - } -} - int main( int argc, char** argv) diff --git a/ddspipe_core/test/unittest/logging/constants.hpp b/ddspipe_core/test/unittest/logging/constants.hpp index 76b92afd..7479bbf8 100644 --- a/ddspipe_core/test/unittest/logging/constants.hpp +++ b/ddspipe_core/test/unittest/logging/constants.hpp @@ -22,7 +22,8 @@ #include #include -#include +#include + #include #include @@ -33,7 +34,7 @@ using namespace eprosima; using namespace eprosima::ddspipe::core::types; // Maximum time to wait for a sample to arrive. -const auto MAX_WAITING_TIME = fastrtps::Duration_t(1); +const auto MAX_WAITING_TIME = fastdds::dds::Duration_t(1); // The domain and topic the Monitor should publish its data in. constexpr DomainIdType DOMAIN = 84; diff --git a/ddspipe_core/test/unittest/logging/dds_consumer/CMakeLists.txt b/ddspipe_core/test/unittest/logging/dds_consumer/CMakeLists.txt index 657393a5..7430c5a0 100644 --- a/ddspipe_core/test/unittest/logging/dds_consumer/CMakeLists.txt +++ b/ddspipe_core/test/unittest/logging/dds_consumer/CMakeLists.txt @@ -25,13 +25,6 @@ file( "${PROJECT_SOURCE_DIR}/include/*.ipp" ) -# Exclude types' files depending on the Fast DDS version -if ("${fastrtps_VERSION}" VERSION_LESS 2.13) - list(FILTER LIBRARY_SOURCES EXCLUDE REGEX "v2/") -else() - list(FILTER LIBRARY_SOURCES EXCLUDE REGEX "v1/") -endif() - all_library_sources( "${TEST_SOURCES}" "${LIBRARY_SOURCES}" @@ -44,7 +37,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES fastcdr - fastrtps + fastdds cpp_utils ) diff --git a/ddspipe_core/test/unittest/logging/dds_consumer/DdsLogConsumerTest.cpp b/ddspipe_core/test/unittest/logging/dds_consumer/DdsLogConsumerTest.cpp index 126be167..86c794a4 100644 --- a/ddspipe_core/test/unittest/logging/dds_consumer/DdsLogConsumerTest.cpp +++ b/ddspipe_core/test/unittest/logging/dds_consumer/DdsLogConsumerTest.cpp @@ -34,15 +34,9 @@ #include #include -#if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) - #include - #include - #include -#else - #include - #include - #include -#endif // if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) +#include +#include +#include #include "../constants.hpp" @@ -103,9 +97,9 @@ class DdsLogConsumerTest : public testing::Test * Test that the DdsLogConsumer publishes logs when publish::enable is set to true. * * CASES: - * - check that the DdsLogConsumer publishes logInfos. - * - check that the DdsLogConsumer publishes logWarnings. - * - check that the DdsLogConsumer publishes logErrors. + * - check that the DdsLogConsumer publishes log info traces. + * - check that the DdsLogConsumer publishes log warning traces. + * - check that the DdsLogConsumer publishes log error traces. */ TEST_F(DdsLogConsumerTest, publish_logs) { @@ -138,14 +132,14 @@ TEST_F(DdsLogConsumerTest, publish_logs) // INFO { - logInfo(DDSPIPE_TEST, "LOG_CONSUMER_TEST | You only live once."); + EPROSIMA_LOG_INFO(DDSPIPE_TEST, "LOG_CONSUMER_TEST | You only live once."); utils::Log::Flush(); // Wait for the subscriber to receive the message ASSERT_TRUE(reader_->wait_for_unread_message(test::logging::MAX_WAITING_TIME)); // Verify that the content of the LogEntry published by the Log is correct - ASSERT_EQ(reader_->take_next_sample(&entry, &info), ReturnCode_t::RETCODE_OK); + ASSERT_EQ(reader_->take_next_sample(&entry, &info), RETCODE_OK); ASSERT_EQ(info.instance_state, ALIVE_INSTANCE_STATE); ASSERT_EQ(entry.event(), UNDEFINED); @@ -156,14 +150,14 @@ TEST_F(DdsLogConsumerTest, publish_logs) // WARNING { - logWarning(DDSPIPE_TEST, "LOG_CONSUMER_TEST | You only live once."); + EPROSIMA_LOG_WARNING(DDSPIPE_TEST, "LOG_CONSUMER_TEST | You only live once."); utils::Log::Flush(); // Wait for the subscriber to receive the message ASSERT_TRUE(reader_->wait_for_unread_message(test::logging::MAX_WAITING_TIME)); // Verify that the content of the LogEntry published by the Log is correct - ASSERT_EQ(reader_->take_next_sample(&entry, &info), ReturnCode_t::RETCODE_OK); + ASSERT_EQ(reader_->take_next_sample(&entry, &info), RETCODE_OK); ASSERT_EQ(info.instance_state, ALIVE_INSTANCE_STATE); ASSERT_EQ(entry.event(), UNDEFINED); @@ -174,14 +168,14 @@ TEST_F(DdsLogConsumerTest, publish_logs) // ERROR { - logError(DDSPIPE_TEST, "LOG_CONSUMER_TEST | You only live once."); + EPROSIMA_LOG_ERROR(DDSPIPE_TEST, "LOG_CONSUMER_TEST | You only live once."); utils::Log::Flush(); // Wait for the subscriber to receive the message ASSERT_TRUE(reader_->wait_for_unread_message(test::logging::MAX_WAITING_TIME)); // Verify that the content of the LogEntry published by the Log is correct - ASSERT_EQ(reader_->take_next_sample(&entry, &info), ReturnCode_t::RETCODE_OK); + ASSERT_EQ(reader_->take_next_sample(&entry, &info), RETCODE_OK); ASSERT_EQ(info.instance_state, ALIVE_INSTANCE_STATE); ASSERT_EQ(entry.event(), UNDEFINED); @@ -197,9 +191,9 @@ TEST_F(DdsLogConsumerTest, publish_logs) * Test that the DdsLogConsumer doesn't publish when publish::enable is set to false. * * CASES: - * - check that the DdsLogConsumer doesn't publish logInfos. - * - check that the DdsLogConsumer doesn't publish logWarnings. - * - check that the DdsLogConsumer doesn't publish logErrors. + * - check that the DdsLogConsumer doesn't publish log info traces. + * - check that the DdsLogConsumer doesn't publish log warning traces. + * - check that the DdsLogConsumer doesn't publish log error traces. */ TEST_F(DdsLogConsumerTest, dont_publish_logs) { @@ -232,38 +226,38 @@ TEST_F(DdsLogConsumerTest, dont_publish_logs) // INFO { - logInfo(DDSPIPE_TEST, "LOG_CONSUMER_TEST | You only live once."); + EPROSIMA_LOG_INFO(DDSPIPE_TEST, "LOG_CONSUMER_TEST | You only live once."); utils::Log::Flush(); // Wait for the subscriber to receive the message ASSERT_FALSE(reader_->wait_for_unread_message(test::logging::MAX_WAITING_TIME)); // Verify that the content of the LogEntry published by the Log is correct - ASSERT_EQ(reader_->take_next_sample(&entry, &info), ReturnCode_t::RETCODE_NO_DATA); + ASSERT_EQ(reader_->take_next_sample(&entry, &info), RETCODE_NO_DATA); } // WARNING { - logWarning(DDSPIPE_TEST, "LOG_CONSUMER_TEST | You only live once."); + EPROSIMA_LOG_WARNING(DDSPIPE_TEST, "LOG_CONSUMER_TEST | You only live once."); utils::Log::Flush(); // Wait for the subscriber to receive the message ASSERT_FALSE(reader_->wait_for_unread_message(test::logging::MAX_WAITING_TIME)); // Verify that the content of the LogEntry published by the Log is correct - ASSERT_EQ(reader_->take_next_sample(&entry, &info), ReturnCode_t::RETCODE_NO_DATA); + ASSERT_EQ(reader_->take_next_sample(&entry, &info), RETCODE_NO_DATA); } // ERROR { - logError(DDSPIPE_TEST, "LOG_CONSUMER_TEST | You only live once."); + EPROSIMA_LOG_ERROR(DDSPIPE_TEST, "LOG_CONSUMER_TEST | You only live once."); utils::Log::Flush(); // Wait for the subscriber to receive the message ASSERT_FALSE(reader_->wait_for_unread_message(test::logging::MAX_WAITING_TIME)); // Verify that the content of the LogEntry published by the Log is correct - ASSERT_EQ(reader_->take_next_sample(&entry, &info), ReturnCode_t::RETCODE_NO_DATA); + ASSERT_EQ(reader_->take_next_sample(&entry, &info), RETCODE_NO_DATA); } utils::Log::ClearConsumers(); diff --git a/ddspipe_core/test/unittest/logging/std_consumer/CMakeLists.txt b/ddspipe_core/test/unittest/logging/std_consumer/CMakeLists.txt index 696a238d..b5670c9b 100644 --- a/ddspipe_core/test/unittest/logging/std_consumer/CMakeLists.txt +++ b/ddspipe_core/test/unittest/logging/std_consumer/CMakeLists.txt @@ -25,13 +25,6 @@ file( "${PROJECT_SOURCE_DIR}/include/*.ipp" ) -# Exclude types' files depending on the Fast DDS version -if ("${fastrtps_VERSION}" VERSION_LESS 2.13) - list(FILTER LIBRARY_SOURCES EXCLUDE REGEX "v2/") -else() - list(FILTER LIBRARY_SOURCES EXCLUDE REGEX "v1/") -endif() - all_library_sources( "${TEST_SOURCES}" "${LIBRARY_SOURCES}" @@ -44,7 +37,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES fastcdr - fastrtps + fastdds cpp_utils ) diff --git a/ddspipe_core/test/unittest/logging/std_consumer/StdLogConsumerTest.cpp b/ddspipe_core/test/unittest/logging/std_consumer/StdLogConsumerTest.cpp index d3d9f2d3..2f37df93 100644 --- a/ddspipe_core/test/unittest/logging/std_consumer/StdLogConsumerTest.cpp +++ b/ddspipe_core/test/unittest/logging/std_consumer/StdLogConsumerTest.cpp @@ -30,9 +30,9 @@ using namespace eprosima::fastdds::dds; * Test that the StdLogConsumer prints logs when stdout is set to true. * * CASES: - * - check that the StdLogConsumer prints logInfos. - * - check that the StdLogConsumer prints logWarnings. - * - check that the StdLogConsumer prints logErrors. + * - check that the StdLogConsumer prints EPROSIMA_LOG_INFOs. + * - check that the StdLogConsumer prints EPROSIMA_LOG_WARNINGs. + * - check that the StdLogConsumer prints EPROSIMA_LOG_ERRORs. */ TEST(StdLogConsumerTest, print_logs) { @@ -59,7 +59,7 @@ TEST(StdLogConsumerTest, print_logs) { testing::internal::CaptureStdout(); - logInfo(DDSPIPE_TEST, "LOG_CONSUMER_TEST | You only live once."); + EPROSIMA_LOG_INFO(DDSPIPE_TEST, "LOG_CONSUMER_TEST | You only live once."); eprosima::utils::Log::Flush(); ASSERT_FALSE(testing::internal::GetCapturedStdout().empty()); @@ -69,7 +69,7 @@ TEST(StdLogConsumerTest, print_logs) { testing::internal::CaptureStderr(); - logWarning(DDSPIPE_TEST, "LOG_CONSUMER_TEST | You only live once."); + EPROSIMA_LOG_WARNING(DDSPIPE_TEST, "LOG_CONSUMER_TEST | You only live once."); eprosima::utils::Log::Flush(); ASSERT_FALSE(testing::internal::GetCapturedStderr().empty()); @@ -79,7 +79,7 @@ TEST(StdLogConsumerTest, print_logs) { testing::internal::CaptureStderr(); - logError(DDSPIPE_TEST, "LOG_CONSUMER_TEST | You only live once."); + EPROSIMA_LOG_ERROR(DDSPIPE_TEST, "LOG_CONSUMER_TEST | You only live once."); eprosima::utils::Log::Flush(); ASSERT_FALSE(testing::internal::GetCapturedStderr().empty()); @@ -90,9 +90,9 @@ TEST(StdLogConsumerTest, print_logs) * Test that the StdLogConsumer doesn't print logs when stdout is set to false. * * CASES: - * - check that the StdLogConsumer doesn't print logInfos. - * - check that the StdLogConsumer doesn't print logWarnings. - * - check that the StdLogConsumer doesn't print logErrors. + * - check that the StdLogConsumer doesn't print EPROSIMA_LOG_INFOs. + * - check that the StdLogConsumer doesn't print EPROSIMA_LOG_WARNINGs. + * - check that the StdLogConsumer doesn't print EPROSIMA_LOG_ERRORs. */ TEST(StdLogConsumerTest, dont_print_logs) { @@ -119,7 +119,7 @@ TEST(StdLogConsumerTest, dont_print_logs) { testing::internal::CaptureStdout(); - logInfo(DDSPIPE_TEST, "LOG_CONSUMER_TEST | You only live once."); + EPROSIMA_LOG_INFO(DDSPIPE_TEST, "LOG_CONSUMER_TEST | You only live once."); eprosima::utils::Log::Flush(); ASSERT_TRUE(testing::internal::GetCapturedStdout().empty()); @@ -129,7 +129,7 @@ TEST(StdLogConsumerTest, dont_print_logs) { testing::internal::CaptureStderr(); - logWarning(DDSPIPE_TEST, "LOG_CONSUMER_TEST | You only live once."); + EPROSIMA_LOG_WARNING(DDSPIPE_TEST, "LOG_CONSUMER_TEST | You only live once."); eprosima::utils::Log::Flush(); ASSERT_TRUE(testing::internal::GetCapturedStderr().empty()); @@ -139,7 +139,7 @@ TEST(StdLogConsumerTest, dont_print_logs) { testing::internal::CaptureStderr(); - logError(DDSPIPE_TEST, "LOG_CONSUMER_TEST | You only live once."); + EPROSIMA_LOG_ERROR(DDSPIPE_TEST, "LOG_CONSUMER_TEST | You only live once."); eprosima::utils::Log::Flush(); ASSERT_TRUE(testing::internal::GetCapturedStderr().empty()); diff --git a/ddspipe_core/test/unittest/monitoring/constants.hpp b/ddspipe_core/test/unittest/monitoring/constants.hpp index e759fb4f..0f9a6715 100644 --- a/ddspipe_core/test/unittest/monitoring/constants.hpp +++ b/ddspipe_core/test/unittest/monitoring/constants.hpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include @@ -37,7 +37,7 @@ constexpr std::uint32_t PERIOD_MS = 500; constexpr double PERIOD_SECS = (double) PERIOD_MS / 1000; // Maximum time to wait for a sample to arrive. -const auto MAX_WAITING_TIME = fastrtps::Duration_t(PERIOD_SECS * 3); +const auto MAX_WAITING_TIME = fastdds::dds::Duration_t(PERIOD_SECS * 3); // The domain and topic the Monitor should publish its data in. constexpr DomainIdType DOMAIN = 84; diff --git a/ddspipe_core/test/unittest/monitoring/status/dds/CMakeLists.txt b/ddspipe_core/test/unittest/monitoring/status/dds/CMakeLists.txt index cb87fdbf..9ea87ac1 100644 --- a/ddspipe_core/test/unittest/monitoring/status/dds/CMakeLists.txt +++ b/ddspipe_core/test/unittest/monitoring/status/dds/CMakeLists.txt @@ -25,13 +25,6 @@ file( "${PROJECT_SOURCE_DIR}/include/*.ipp" ) -# Exclude types' files depending on the Fast DDS version -if ("${fastrtps_VERSION}" VERSION_LESS 2.13) - list(FILTER LIBRARY_SOURCES EXCLUDE REGEX "v2/") -else() - list(FILTER LIBRARY_SOURCES EXCLUDE REGEX "v1/") -endif() - all_library_sources( "${TEST_SOURCES}" "${LIBRARY_SOURCES}" @@ -44,7 +37,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES fastcdr - fastrtps + fastdds cpp_utils ) diff --git a/ddspipe_core/test/unittest/monitoring/status/dds/DdsMonitorStatusTest.cpp b/ddspipe_core/test/unittest/monitoring/status/dds/DdsMonitorStatusTest.cpp index 1777be12..8add043b 100644 --- a/ddspipe_core/test/unittest/monitoring/status/dds/DdsMonitorStatusTest.cpp +++ b/ddspipe_core/test/unittest/monitoring/status/dds/DdsMonitorStatusTest.cpp @@ -29,13 +29,8 @@ #include #include -#if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) - #include - #include -#else - #include - #include -#endif // if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) +#include +#include #include "../../constants.hpp" @@ -131,7 +126,7 @@ TEST_F(DdsMonitorStatusTest, type_mismatch) // Wait for the monitor to publish the next message ASSERT_TRUE(reader_->wait_for_unread_message(test::monitor::MAX_WAITING_TIME)); - ASSERT_EQ(reader_->take_next_sample(&status, &info), ReturnCode_t::RETCODE_OK); + ASSERT_EQ(reader_->take_next_sample(&status, &info), RETCODE_OK); ASSERT_EQ(info.instance_state, ALIVE_INSTANCE_STATE); // Verify that the content of the MonitoringStatus published by the Monitor is correct @@ -157,7 +152,7 @@ TEST_F(DdsMonitorStatusTest, qos_mismatch) // Wait for the monitor to publish the next message ASSERT_TRUE(reader_->wait_for_unread_message(test::monitor::MAX_WAITING_TIME)); - ASSERT_EQ(reader_->take_next_sample(&status, &info), ReturnCode_t::RETCODE_OK); + ASSERT_EQ(reader_->take_next_sample(&status, &info), RETCODE_OK); ASSERT_EQ(info.instance_state, ALIVE_INSTANCE_STATE); // Verify that the content of the MonitoringStatus published by the Monitor is correct diff --git a/ddspipe_core/test/unittest/monitoring/status/logging/CMakeLists.txt b/ddspipe_core/test/unittest/monitoring/status/logging/CMakeLists.txt index cf96873f..0ed515e1 100644 --- a/ddspipe_core/test/unittest/monitoring/status/logging/CMakeLists.txt +++ b/ddspipe_core/test/unittest/monitoring/status/logging/CMakeLists.txt @@ -25,13 +25,6 @@ file( "${PROJECT_SOURCE_DIR}/include/*.ipp" ) -# Exclude types' files depending on the Fast DDS version -if ("${fastrtps_VERSION}" VERSION_LESS 2.13) - list(FILTER LIBRARY_SOURCES EXCLUDE REGEX "v2/") -else() - list(FILTER LIBRARY_SOURCES EXCLUDE REGEX "v1/") -endif() - all_library_sources( "${TEST_SOURCES}" "${LIBRARY_SOURCES}" @@ -44,7 +37,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES fastcdr - fastrtps + fastdds cpp_utils ) diff --git a/ddspipe_core/test/unittest/monitoring/topics/dds/CMakeLists.txt b/ddspipe_core/test/unittest/monitoring/topics/dds/CMakeLists.txt index 7393215e..92ad31f3 100644 --- a/ddspipe_core/test/unittest/monitoring/topics/dds/CMakeLists.txt +++ b/ddspipe_core/test/unittest/monitoring/topics/dds/CMakeLists.txt @@ -25,13 +25,6 @@ file( "${PROJECT_SOURCE_DIR}/include/*.ipp" ) -# Exclude types' files depending on the Fast DDS version -if ("${fastrtps_VERSION}" VERSION_LESS 2.13) - list(FILTER LIBRARY_SOURCES EXCLUDE REGEX "v2/") -else() - list(FILTER LIBRARY_SOURCES EXCLUDE REGEX "v1/") -endif() - all_library_sources( "${TEST_SOURCES}" "${LIBRARY_SOURCES}" @@ -47,7 +40,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES fastcdr - fastrtps + fastdds cpp_utils ) diff --git a/ddspipe_core/test/unittest/monitoring/topics/dds/DdsMonitorTopicsTest.cpp b/ddspipe_core/test/unittest/monitoring/topics/dds/DdsMonitorTopicsTest.cpp index 2b624fa0..24e16e8d 100644 --- a/ddspipe_core/test/unittest/monitoring/topics/dds/DdsMonitorTopicsTest.cpp +++ b/ddspipe_core/test/unittest/monitoring/topics/dds/DdsMonitorTopicsTest.cpp @@ -31,13 +31,8 @@ #include #include -#if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) - #include - #include -#else - #include - #include -#endif // if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) +#include +#include #include "../../constants.hpp" @@ -143,7 +138,7 @@ TEST_F(DdsMonitorTopicsTest, msgs_received) // Wait for the monitor to publish the next message ASSERT_TRUE(reader_->wait_for_unread_message(test::monitor::MAX_WAITING_TIME)); - ASSERT_EQ(reader_->take_next_sample(&topics, &info), ReturnCode_t::RETCODE_OK); + ASSERT_EQ(reader_->take_next_sample(&topics, &info), RETCODE_OK); ASSERT_EQ(info.instance_state, ALIVE_INSTANCE_STATE); ASSERT_EQ(topics.topics().size(), 1); @@ -175,7 +170,7 @@ TEST_F(DdsMonitorTopicsTest, msgs_lost) // Wait for the monitor to publish the next message ASSERT_TRUE(reader_->wait_for_unread_message(test::monitor::MAX_WAITING_TIME)); - ASSERT_EQ(reader_->take_next_sample(&topics, &info), ReturnCode_t::RETCODE_OK); + ASSERT_EQ(reader_->take_next_sample(&topics, &info), RETCODE_OK); ASSERT_EQ(info.instance_state, ALIVE_INSTANCE_STATE); // Verify that the content of the MonitoringTopics published by the Monitor is correct @@ -211,7 +206,7 @@ TEST_F(DdsMonitorTopicsTest, type_discovered) // Wait for the monitor to publish the next message ASSERT_TRUE(reader_->wait_for_unread_message(test::monitor::MAX_WAITING_TIME)); - ASSERT_EQ(reader_->take_next_sample(&topics, &info), ReturnCode_t::RETCODE_OK); + ASSERT_EQ(reader_->take_next_sample(&topics, &info), RETCODE_OK); ASSERT_EQ(info.instance_state, ALIVE_INSTANCE_STATE); // Verify that the content of the MonitoringTopics published by the Monitor is correct @@ -244,7 +239,7 @@ TEST_F(DdsMonitorTopicsTest, type_mismatch) // Wait for the monitor to publish the next message ASSERT_TRUE(reader_->wait_for_unread_message(test::monitor::MAX_WAITING_TIME)); - ASSERT_EQ(reader_->take_next_sample(&topics, &info), ReturnCode_t::RETCODE_OK); + ASSERT_EQ(reader_->take_next_sample(&topics, &info), RETCODE_OK); ASSERT_EQ(info.instance_state, ALIVE_INSTANCE_STATE); // Verify that the content of the MonitoringTopics published by the Monitor is correct @@ -274,7 +269,7 @@ TEST_F(DdsMonitorTopicsTest, qos_mismatch) // Wait for the monitor to publish the next message ASSERT_TRUE(reader_->wait_for_unread_message(test::monitor::MAX_WAITING_TIME)); - ASSERT_EQ(reader_->take_next_sample(&topics, &info), ReturnCode_t::RETCODE_OK); + ASSERT_EQ(reader_->take_next_sample(&topics, &info), RETCODE_OK); ASSERT_EQ(info.instance_state, ALIVE_INSTANCE_STATE); // Verify that the content of the MonitoringTopics published by the Monitor is correct diff --git a/ddspipe_core/test/unittest/monitoring/topics/logging/CMakeLists.txt b/ddspipe_core/test/unittest/monitoring/topics/logging/CMakeLists.txt index 52f890ab..01839ffe 100644 --- a/ddspipe_core/test/unittest/monitoring/topics/logging/CMakeLists.txt +++ b/ddspipe_core/test/unittest/monitoring/topics/logging/CMakeLists.txt @@ -25,13 +25,6 @@ file( "${PROJECT_SOURCE_DIR}/include/*.ipp" ) -# Exclude types' files depending on the Fast DDS version -if ("${fastrtps_VERSION}" VERSION_LESS 2.13) - list(FILTER LIBRARY_SOURCES EXCLUDE REGEX "v2/") -else() - list(FILTER LIBRARY_SOURCES EXCLUDE REGEX "v1/") -endif() - all_library_sources( "${TEST_SOURCES}" "${LIBRARY_SOURCES}" @@ -47,7 +40,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES fastcdr - fastrtps + fastdds cpp_utils ) diff --git a/ddspipe_core/test/unittest/types/dynamic_types/CMakeLists.txt b/ddspipe_core/test/unittest/types/dynamic_types/CMakeLists.txt index 7417fe5f..5a129e9b 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/CMakeLists.txt +++ b/ddspipe_core/test/unittest/types/dynamic_types/CMakeLists.txt @@ -12,57 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -#################### -# dtypes_idl_tests # -#################### - -set(TEST_NAME dtypes_idl_tests) - -# Determine Fast DDS version -if ("${fastrtps_VERSION}" VERSION_LESS 2.13) - set(DDS_TYPES_VERSION "v1") -else() - set(DDS_TYPES_VERSION "v2") -endif() - -# Add to test sources every FastDDSGen file generated -file(GLOB DATATYPE_SOURCES_CXX "types/${DDS_TYPES_VERSION}/**/*.cxx") -set(TEST_SOURCES - dtypes_idl_tests.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/types/dynamic_types/schema_idl.cpp - ${DATATYPE_SOURCES_CXX} - ) - -set(TEST_LIST - ) - -set(TEST_EXTRA_LIBRARIES - fastcdr - fastrtps - cpp_utils - $<$:iphlpapi$Shlwapi> - ) - -# Add to needed sources every .idl file -file( - GLOB - RESULT_SOURCES_IDL - RELATIVE - "${CMAKE_CURRENT_SOURCE_DIR}" - "types/${DDS_TYPES_VERSION}/idls/*.idl") - -set(TEST_NEEDED_SOURCES - ${RESULT_SOURCES_IDL} - ) - -add_unittest_executable( - "${TEST_NAME}" - "${TEST_SOURCES}" - "${TEST_LIST}" - "${TEST_EXTRA_LIBRARIES}" - "${TEST_NEEDED_SOURCES}" - ) - #################### # dtypes_msg_tests # #################### @@ -70,7 +19,7 @@ add_unittest_executable( set(TEST_NAME dtypes_msg_tests) # Add to test sources every FastDDSGen file generated -file(GLOB DATATYPE_SOURCES_CXX "types/${DDS_TYPES_VERSION}/**/*.cxx") +file(GLOB DATATYPE_SOURCES_CXX "types/**/*.cxx") set(TEST_SOURCES dtypes_msg_tests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/types/dynamic_types/schema_msg.cpp @@ -82,7 +31,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES fastcdr - fastrtps + fastdds cpp_utils $<$:iphlpapi$Shlwapi> ) @@ -93,7 +42,7 @@ file( RESULT_SOURCES_MSG RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" - "types/${DDS_TYPES_VERSION}/msgs/*.msg") + "types/msgs/*.msg") set(TEST_NEEDED_SOURCES ${RESULT_SOURCES_MSG} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/dtypes_idl_tests.cpp b/ddspipe_core/test/unittest/types/dynamic_types/dtypes_idl_tests.cpp deleted file mode 100644 index 401fe14e..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/dtypes_idl_tests.cpp +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright 2021 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. - -#include - -#include -#include - -#include -#include - -#include - -#include - -#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - #include "types/v1/all_types.hpp" -#else - #include "types/v2/all_types.hpp" -#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - -using namespace eprosima; - -namespace test { - -std::string read_idl_from_file_( - const std::string& file_name) -{ - return utils::file_to_string(file_name.c_str()); -} - -std::string file_name_by_type( - SupportedType type) -{ - #if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - return std::string("types/v1/idls/") + to_string(type) + ".idl"; - #else - return std::string("types/v2/idls/") + to_string(type) + ".idl"; - #endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 -} - -void compare_schemas( - const std::string& schema1, - const std::string& schema2) -{ - ASSERT_EQ(schema1, schema2); -} - -void execute_test_by_type( - SupportedType type) -{ - // Get IDL file in string with the value expected to be generated in the schema - std::string idl_file = read_idl_from_file_(file_name_by_type(type)); - - // Get Dynamic type - fastrtps::types::DynamicType_ptr dyn_type = get_dynamic_type(type); - - // Get schema generated - std::string schema = ddspipe::core::types::idl::generate_idl_schema(dyn_type); - - // Compare schemas - compare_schemas(idl_file, schema); -} - -} // namespace test - -class ParametrizedTests : public ::testing::TestWithParam -{ -public: - - void SetUp() - { - type_ = GetParam(); - } - - test::SupportedType type_; -}; - -/** - * TODO - */ -TEST_P(ParametrizedTests, msg_schema_generation) -{ - test::execute_test_by_type(type_); -} - -INSTANTIATE_TEST_SUITE_P(dtypes_idl_tests, ParametrizedTests, ::testing::Values( - test::SupportedType::hello_world, - test::SupportedType::numeric_array, - test::SupportedType::char_sequence, - test::SupportedType::basic_struct, - test::SupportedType::basic_array_struct, - test::SupportedType::float_bounded_sequence, - test::SupportedType::arrays_and_sequences, - test::SupportedType::complex_nested_arrays, - test::SupportedType::enum_struct, - test::SupportedType::union_struct, - test::SupportedType::map_struct - )); - -int main( - int argc, - char** argv) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/dtypes_msg_tests.cpp b/ddspipe_core/test/unittest/types/dynamic_types/dtypes_msg_tests.cpp index 79f31941..c73e0429 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/dtypes_msg_tests.cpp +++ b/ddspipe_core/test/unittest/types/dynamic_types/dtypes_msg_tests.cpp @@ -13,17 +13,18 @@ // limitations under the License. #include + +#include + #include -#include #include #include -#include + #include -#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - #include "types/v1/all_types.hpp" -#else - #include "types/v2/all_types.hpp" -#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 + +#include + +#include "types/all_types.hpp" using namespace eprosima; @@ -38,11 +39,7 @@ std::string read_msg_from_file_( std::string file_name_by_type( SupportedType type) { - #if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - return std::string("types/v1/msgs/") + to_string(type) + ".msg"; - #else - return std::string("types/v2/msgs/") + to_string(type) + ".msg"; - #endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 + return std::string("types/msgs/") + to_string(type) + ".msg"; } void compare_schemas( @@ -58,8 +55,12 @@ void execute_test_by_type( // Get msg file in string with the value expected to be generated in the schema std::string msg_file = read_msg_from_file_(file_name_by_type(type)); + // Register TypeObject representation + register_type_object_representation(type); + // Get Dynamic type - fastrtps::types::DynamicType_ptr dyn_type = get_dynamic_type(type); + fastdds::dds::DynamicType::_ref_type dyn_type; + get_dynamic_type(type, dyn_type); // Get schema generated std::string schema = ddspipe::core::types::msg::generate_ros2_schema(dyn_type); diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/all_types.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/all_types.hpp new file mode 100644 index 00000000..86316726 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/all_types.hpp @@ -0,0 +1,141 @@ +// Copyright 2022 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_types.hpp + */ + +/* + * USEFUL COMMAND + * + * for TYPE in hello_world numeric_array char_sequence basic_struct basic_array_struct float_bounded_sequence arrays_and_sequences complex_nested_arrays; do ${FASTDDSGEN_WS}/scripts/fastddsgen -replace -d ${WS}/src/recorder/ddsrecorder/test/unittest/dynamic_types/types/type_objects/ -typeobject -cs ${WS}/src/recorder/ddsrecorder/test/unittest/dynamic_types/types/idls/${TYPE}.idl; done + */ + +#pragma once + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "type_objects/arrays_and_sequences.hpp" +#include "type_objects/arrays_and_sequencesPubSubTypes.hpp" + +#include "type_objects/basic_array_struct.hpp" +#include "type_objects/basic_array_structPubSubTypes.hpp" + +#include "type_objects/basic_struct.hpp" +#include "type_objects/basic_structPubSubTypes.hpp" + +#include "type_objects/char_sequence.hpp" +#include "type_objects/char_sequencePubSubTypes.hpp" + +#include "type_objects/complex_nested_arrays.hpp" +#include "type_objects/complex_nested_arraysPubSubTypes.hpp" + +#include "type_objects/float_bounded_sequence.hpp" +#include "type_objects/float_bounded_sequencePubSubTypes.hpp" + +#include "type_objects/hello_world.hpp" +#include "type_objects/hello_worldPubSubTypes.hpp" + +#include "type_objects/numeric_array.hpp" +#include "type_objects/numeric_arrayPubSubTypes.hpp" + +namespace test { + +ENUMERATION_BUILDER( + SupportedType, + hello_world, + numeric_array, + char_sequence, + basic_struct, + basic_array_struct, + float_bounded_sequence, + arrays_and_sequences, + complex_nested_arrays, + ); + +void register_type_object_representation( + const SupportedType& type) +{ + using namespace eprosima::fastdds::dds; + + TypeSupport type_support; + + if (type == SupportedType::arrays_and_sequences) + { + type_support.reset(new arrays_and_sequencesPubSubType()); + } + else if (type == SupportedType::basic_array_struct) + { + type_support.reset(new basic_array_structPubSubType()); + } + else if (type == SupportedType::basic_struct) + { + type_support.reset(new basic_structPubSubType()); + } + else if (type == SupportedType::char_sequence) + { + type_support.reset(new char_sequencePubSubType()); + } + else if (type == SupportedType::complex_nested_arrays) + { + type_support.reset(new complex_nested_arraysPubSubType()); + } + else if (type == SupportedType::float_bounded_sequence) + { + type_support.reset(new float_bounded_sequencePubSubType()); + } + else if (type == SupportedType::hello_world) + { + type_support.reset(new hello_worldPubSubType()); + } + else if (type == SupportedType::numeric_array) + { + type_support.reset(new numeric_arrayPubSubType()); + } + else + { + ASSERT_FALSE(true) << "Type not supported"; + } + + type_support->register_type_object_representation(); +} + +void get_dynamic_type( + const SupportedType& type, + eprosima::fastdds::dds::DynamicType::_ref_type& dyn_type) +{ + auto type_name = to_string(type); + + // Find TypeObjects for the type + eprosima::fastdds::dds::xtypes::TypeObjectPair type_objs; + ASSERT_EQ(eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_objects( + type_name, type_objs), + eprosima::fastdds::dds::RETCODE_OK); + + // Create DynamicType from TypeObject + dyn_type = eprosima::fastdds::dds::DynamicTypeBuilderFactory::get_instance()->create_type_w_type_object( + type_objs.complete_type_object)->build(); +} + +} /* namespace test */ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/arrays_and_sequences.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/idls/arrays_and_sequences.idl similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/arrays_and_sequences.idl rename to ddspipe_core/test/unittest/types/dynamic_types/types/idls/arrays_and_sequences.idl diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/basic_array_struct.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/idls/basic_array_struct.idl similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/basic_array_struct.idl rename to ddspipe_core/test/unittest/types/dynamic_types/types/idls/basic_array_struct.idl diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/basic_struct.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/idls/basic_struct.idl similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/basic_struct.idl rename to ddspipe_core/test/unittest/types/dynamic_types/types/idls/basic_struct.idl diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/char_sequence.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/idls/char_sequence.idl similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/char_sequence.idl rename to ddspipe_core/test/unittest/types/dynamic_types/types/idls/char_sequence.idl diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/complex_nested_arrays.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/idls/complex_nested_arrays.idl similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/complex_nested_arrays.idl rename to ddspipe_core/test/unittest/types/dynamic_types/types/idls/complex_nested_arrays.idl diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/float_bounded_sequence.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/idls/float_bounded_sequence.idl similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/float_bounded_sequence.idl rename to ddspipe_core/test/unittest/types/dynamic_types/types/idls/float_bounded_sequence.idl diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/hello_world.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/idls/hello_world.idl similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/hello_world.idl rename to ddspipe_core/test/unittest/types/dynamic_types/types/idls/hello_world.idl diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/numeric_array.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/idls/numeric_array.idl similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/numeric_array.idl rename to ddspipe_core/test/unittest/types/dynamic_types/types/idls/numeric_array.idl diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/msgs/arrays_and_sequences.msg b/ddspipe_core/test/unittest/types/dynamic_types/types/msgs/arrays_and_sequences.msg similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v1/msgs/arrays_and_sequences.msg rename to ddspipe_core/test/unittest/types/dynamic_types/types/msgs/arrays_and_sequences.msg diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/msgs/basic_array_struct.msg b/ddspipe_core/test/unittest/types/dynamic_types/types/msgs/basic_array_struct.msg similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v1/msgs/basic_array_struct.msg rename to ddspipe_core/test/unittest/types/dynamic_types/types/msgs/basic_array_struct.msg diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/msgs/basic_struct.msg b/ddspipe_core/test/unittest/types/dynamic_types/types/msgs/basic_struct.msg similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v1/msgs/basic_struct.msg rename to ddspipe_core/test/unittest/types/dynamic_types/types/msgs/basic_struct.msg diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/msgs/char_sequence.msg b/ddspipe_core/test/unittest/types/dynamic_types/types/msgs/char_sequence.msg new file mode 100644 index 00000000..467a04b3 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/msgs/char_sequence.msg @@ -0,0 +1 @@ +char[] chars diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/msgs/complex_nested_arrays.msg b/ddspipe_core/test/unittest/types/dynamic_types/types/msgs/complex_nested_arrays.msg similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v1/msgs/complex_nested_arrays.msg rename to ddspipe_core/test/unittest/types/dynamic_types/types/msgs/complex_nested_arrays.msg diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/msgs/float_bounded_sequence.msg b/ddspipe_core/test/unittest/types/dynamic_types/types/msgs/float_bounded_sequence.msg similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v1/msgs/float_bounded_sequence.msg rename to ddspipe_core/test/unittest/types/dynamic_types/types/msgs/float_bounded_sequence.msg diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/msgs/hello_world.msg b/ddspipe_core/test/unittest/types/dynamic_types/types/msgs/hello_world.msg similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v1/msgs/hello_world.msg rename to ddspipe_core/test/unittest/types/dynamic_types/types/msgs/hello_world.msg diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/msgs/numeric_array.msg b/ddspipe_core/test/unittest/types/dynamic_types/types/msgs/numeric_array.msg similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v1/msgs/numeric_array.msg rename to ddspipe_core/test/unittest/types/dynamic_types/types/msgs/numeric_array.msg diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequences.h b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequences.hpp similarity index 66% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequences.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequences.hpp index cf8bc69f..e94655a4 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequences.h +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequences.hpp @@ -13,32 +13,20 @@ // limitations under the License. /*! - * @file arrays_and_sequences.h + * @file arrays_and_sequences.hpp * This header file contains the declaration of the described types in the IDL file. * * This file was generated by the tool fastddsgen. */ -#include -#include "arrays_and_sequencesv1.h" - -#if FASTCDR_VERSION_MAJOR > 1 - -#ifndef _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_H_ -#define _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_H_ +#ifndef FAST_DDS_GENERATED__ARRAYS_AND_SEQUENCES_HPP +#define FAST_DDS_GENERATED__ARRAYS_AND_SEQUENCES_HPP #include -#include #include -#include -#include +#include #include -#include -#include -#include - - #if defined(_WIN32) #if defined(EPROSIMA_USER_DLL_EXPORT) @@ -64,17 +52,6 @@ #define ARRAYS_AND_SEQUENCES_DllAPI #endif // _WIN32 -namespace eprosima { -namespace fastcdr { -class Cdr; -class CdrSizeCalculator; -} // namespace fastcdr -} // namespace eprosima - - - - - /*! * @brief This class represents the structure AnInternalObject defined by the user in the IDL file. * @ingroup arrays_and_sequences @@ -86,73 +63,117 @@ class AnInternalObject /*! * @brief Default constructor. */ - eProsima_user_DllExport AnInternalObject(); + eProsima_user_DllExport AnInternalObject() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~AnInternalObject(); + eProsima_user_DllExport ~AnInternalObject() + { + } /*! * @brief Copy constructor. * @param x Reference to the object AnInternalObject that will be copied. */ eProsima_user_DllExport AnInternalObject( - const AnInternalObject& x); + const AnInternalObject& x) + { + m_x = x.m_x; + + m_positive = x.m_positive; + + } /*! * @brief Move constructor. * @param x Reference to the object AnInternalObject that will be copied. */ eProsima_user_DllExport AnInternalObject( - AnInternalObject&& x) noexcept; + AnInternalObject&& x) noexcept + { + m_x = x.m_x; + m_positive = x.m_positive; + } /*! * @brief Copy assignment. * @param x Reference to the object AnInternalObject that will be copied. */ eProsima_user_DllExport AnInternalObject& operator =( - const AnInternalObject& x); + const AnInternalObject& x) + { + + m_x = x.m_x; + + m_positive = x.m_positive; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object AnInternalObject that will be copied. */ eProsima_user_DllExport AnInternalObject& operator =( - AnInternalObject&& x) noexcept; + AnInternalObject&& x) noexcept + { + + m_x = x.m_x; + m_positive = x.m_positive; + return *this; + } /*! * @brief Comparison operator. * @param x AnInternalObject object to compare. */ eProsima_user_DllExport bool operator ==( - const AnInternalObject& x) const; + const AnInternalObject& x) const + { + return (m_x == x.m_x && + m_positive == x.m_positive); + } /*! * @brief Comparison operator. * @param x AnInternalObject object to compare. */ eProsima_user_DllExport bool operator !=( - const AnInternalObject& x) const; + const AnInternalObject& x) const + { + return !(*this == x); + } /*! * @brief This function sets a value in member x * @param _x New value for member x */ eProsima_user_DllExport void x( - float _x); + float _x) + { + m_x = _x; + } /*! * @brief This function returns the value of member x * @return Value of member x */ - eProsima_user_DllExport float x() const; + eProsima_user_DllExport float x() const + { + return m_x; + } /*! * @brief This function returns a reference to member x * @return Reference to member x */ - eProsima_user_DllExport float& x(); + eProsima_user_DllExport float& x() + { + return m_x; + } /*! @@ -160,19 +181,30 @@ class AnInternalObject * @param _positive New value for member positive */ eProsima_user_DllExport void positive( - bool _positive); + bool _positive) + { + m_positive = _positive; + } /*! * @brief This function returns the value of member positive * @return Value of member positive */ - eProsima_user_DllExport bool positive() const; + eProsima_user_DllExport bool positive() const + { + return m_positive; + } /*! * @brief This function returns a reference to member positive * @return Reference to member positive */ - eProsima_user_DllExport bool& positive(); + eProsima_user_DllExport bool& positive() + { + return m_positive; + } + + private: @@ -180,8 +212,6 @@ class AnInternalObject bool m_positive{false}; }; - - /*! * @brief This class represents the structure arrays_and_sequences defined by the user in the IDL file. * @ingroup arrays_and_sequences @@ -193,80 +223,134 @@ class arrays_and_sequences /*! * @brief Default constructor. */ - eProsima_user_DllExport arrays_and_sequences(); + eProsima_user_DllExport arrays_and_sequences() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~arrays_and_sequences(); + eProsima_user_DllExport ~arrays_and_sequences() + { + } /*! * @brief Copy constructor. * @param x Reference to the object arrays_and_sequences that will be copied. */ eProsima_user_DllExport arrays_and_sequences( - const arrays_and_sequences& x); + const arrays_and_sequences& x) + { + m_unlimited_vector = x.m_unlimited_vector; + + m_limited_vector = x.m_limited_vector; + + m_limited_array = x.m_limited_array; + + } /*! * @brief Move constructor. * @param x Reference to the object arrays_and_sequences that will be copied. */ eProsima_user_DllExport arrays_and_sequences( - arrays_and_sequences&& x) noexcept; + arrays_and_sequences&& x) noexcept + { + m_unlimited_vector = std::move(x.m_unlimited_vector); + m_limited_vector = std::move(x.m_limited_vector); + m_limited_array = std::move(x.m_limited_array); + } /*! * @brief Copy assignment. * @param x Reference to the object arrays_and_sequences that will be copied. */ eProsima_user_DllExport arrays_and_sequences& operator =( - const arrays_and_sequences& x); + const arrays_and_sequences& x) + { + + m_unlimited_vector = x.m_unlimited_vector; + + m_limited_vector = x.m_limited_vector; + + m_limited_array = x.m_limited_array; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object arrays_and_sequences that will be copied. */ eProsima_user_DllExport arrays_and_sequences& operator =( - arrays_and_sequences&& x) noexcept; + arrays_and_sequences&& x) noexcept + { + + m_unlimited_vector = std::move(x.m_unlimited_vector); + m_limited_vector = std::move(x.m_limited_vector); + m_limited_array = std::move(x.m_limited_array); + return *this; + } /*! * @brief Comparison operator. * @param x arrays_and_sequences object to compare. */ eProsima_user_DllExport bool operator ==( - const arrays_and_sequences& x) const; + const arrays_and_sequences& x) const + { + return (m_unlimited_vector == x.m_unlimited_vector && + m_limited_vector == x.m_limited_vector && + m_limited_array == x.m_limited_array); + } /*! * @brief Comparison operator. * @param x arrays_and_sequences object to compare. */ eProsima_user_DllExport bool operator !=( - const arrays_and_sequences& x) const; + const arrays_and_sequences& x) const + { + return !(*this == x); + } /*! * @brief This function copies the value in member unlimited_vector * @param _unlimited_vector New value to be copied in member unlimited_vector */ eProsima_user_DllExport void unlimited_vector( - const std::vector& _unlimited_vector); + const std::vector& _unlimited_vector) + { + m_unlimited_vector = _unlimited_vector; + } /*! * @brief This function moves the value in member unlimited_vector * @param _unlimited_vector New value to be moved in member unlimited_vector */ eProsima_user_DllExport void unlimited_vector( - std::vector&& _unlimited_vector); + std::vector&& _unlimited_vector) + { + m_unlimited_vector = std::move(_unlimited_vector); + } /*! * @brief This function returns a constant reference to member unlimited_vector * @return Constant reference to member unlimited_vector */ - eProsima_user_DllExport const std::vector& unlimited_vector() const; + eProsima_user_DllExport const std::vector& unlimited_vector() const + { + return m_unlimited_vector; + } /*! * @brief This function returns a reference to member unlimited_vector * @return Reference to member unlimited_vector */ - eProsima_user_DllExport std::vector& unlimited_vector(); + eProsima_user_DllExport std::vector& unlimited_vector() + { + return m_unlimited_vector; + } /*! @@ -274,26 +358,38 @@ class arrays_and_sequences * @param _limited_vector New value to be copied in member limited_vector */ eProsima_user_DllExport void limited_vector( - const std::vector& _limited_vector); + const std::vector& _limited_vector) + { + m_limited_vector = _limited_vector; + } /*! * @brief This function moves the value in member limited_vector * @param _limited_vector New value to be moved in member limited_vector */ eProsima_user_DllExport void limited_vector( - std::vector&& _limited_vector); + std::vector&& _limited_vector) + { + m_limited_vector = std::move(_limited_vector); + } /*! * @brief This function returns a constant reference to member limited_vector * @return Constant reference to member limited_vector */ - eProsima_user_DllExport const std::vector& limited_vector() const; + eProsima_user_DllExport const std::vector& limited_vector() const + { + return m_limited_vector; + } /*! * @brief This function returns a reference to member limited_vector * @return Reference to member limited_vector */ - eProsima_user_DllExport std::vector& limited_vector(); + eProsima_user_DllExport std::vector& limited_vector() + { + return m_limited_vector; + } /*! @@ -301,26 +397,40 @@ class arrays_and_sequences * @param _limited_array New value to be copied in member limited_array */ eProsima_user_DllExport void limited_array( - const std::array& _limited_array); + const std::array& _limited_array) + { + m_limited_array = _limited_array; + } /*! * @brief This function moves the value in member limited_array * @param _limited_array New value to be moved in member limited_array */ eProsima_user_DllExport void limited_array( - std::array&& _limited_array); + std::array&& _limited_array) + { + m_limited_array = std::move(_limited_array); + } /*! * @brief This function returns a constant reference to member limited_array * @return Constant reference to member limited_array */ - eProsima_user_DllExport const std::array& limited_array() const; + eProsima_user_DllExport const std::array& limited_array() const + { + return m_limited_array; + } /*! * @brief This function returns a reference to member limited_array * @return Reference to member limited_array */ - eProsima_user_DllExport std::array& limited_array(); + eProsima_user_DllExport std::array& limited_array() + { + return m_limited_array; + } + + private: @@ -330,8 +440,6 @@ class arrays_and_sequences }; -#endif // _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_H_ - +#endif // _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_HPP_ -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesCdrAux.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesCdrAux.hpp similarity index 86% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesCdrAux.hpp rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesCdrAux.hpp index adbc610d..d777ee1c 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesCdrAux.hpp +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesCdrAux.hpp @@ -19,10 +19,10 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCESCDRAUX_HPP_ -#define _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCESCDRAUX_HPP_ +#ifndef FAST_DDS_GENERATED__ARRAYS_AND_SEQUENCESCDRAUX_HPP +#define FAST_DDS_GENERATED__ARRAYS_AND_SEQUENCESCDRAUX_HPP -#include "arrays_and_sequences.h" +#include "arrays_and_sequences.hpp" constexpr uint32_t arrays_and_sequences_max_cdr_typesize {261UL}; constexpr uint32_t arrays_and_sequences_max_key_cdr_typesize {0UL}; @@ -37,14 +37,10 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const AnInternalObject& data); - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const arrays_and_sequences& data); @@ -53,5 +49,5 @@ eProsima_user_DllExport void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCESCDRAUX_HPP_ +#endif // FAST_DDS_GENERATED__ARRAYS_AND_SEQUENCESCDRAUX_HPP diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesCdrAux.ipp b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesCdrAux.ipp similarity index 94% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesCdrAux.ipp rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesCdrAux.ipp index e9c3ff29..a4a8d321 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesCdrAux.ipp +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesCdrAux.ipp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCESCDRAUX_IPP_ -#define _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCESCDRAUX_IPP_ +#ifndef FAST_DDS_GENERATED__ARRAYS_AND_SEQUENCESCDRAUX_IPP +#define FAST_DDS_GENERATED__ARRAYS_AND_SEQUENCESCDRAUX_IPP #include "arrays_and_sequencesCdrAux.hpp" @@ -34,8 +34,6 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { - - template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -115,11 +113,14 @@ void serialize_key( eprosima::fastcdr::Cdr& scdr, const AnInternalObject& data) { + static_cast(scdr); static_cast(data); -} + scdr << data.x(); + scdr << data.positive(); +} template<> @@ -209,8 +210,15 @@ void serialize_key( eprosima::fastcdr::Cdr& scdr, const arrays_and_sequences& data) { + static_cast(scdr); static_cast(data); + scdr << data.unlimited_vector(); + + scdr << data.limited_vector(); + + scdr << data.limited_array(); + } @@ -218,5 +226,5 @@ void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCESCDRAUX_IPP_ +#endif // FAST_DDS_GENERATED__ARRAYS_AND_SEQUENCESCDRAUX_IPP diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesPubSubTypes.cxx new file mode 100644 index 00000000..27b3d723 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesPubSubTypes.cxx @@ -0,0 +1,398 @@ +// 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 arrays_and_sequencesPubSubTypes.cpp + * This header file contains the implementation of the serialization functions. + * + * This file was generated by the tool fastddsgen. + */ + +#include "arrays_and_sequencesPubSubTypes.hpp" + +#include +#include + +#include "arrays_and_sequencesCdrAux.hpp" +#include "arrays_and_sequencesTypeObjectSupport.hpp" + +using SerializedPayload_t = eprosima::fastdds::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t; +using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; + +AnInternalObjectPubSubType::AnInternalObjectPubSubType() +{ + set_name("AnInternalObject"); + uint32_t type_size = AnInternalObject_max_cdr_typesize; + type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = AnInternalObject_max_key_cdr_typesize > 16 ? AnInternalObject_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); +} + +AnInternalObjectPubSubType::~AnInternalObjectPubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool AnInternalObjectPubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const AnInternalObject* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); + payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + ser.set_encoding_flag( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + ser << *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool AnInternalObjectPubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + AnInternalObject* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + deser >> *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + return true; +} + +uint32_t AnInternalObjectPubSubType::calculate_serialized_size( + const void* const data, + DataRepresentationId_t data_representation) +{ + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +} + +void* AnInternalObjectPubSubType::create_data() +{ + return reinterpret_cast(new AnInternalObject()); +} + +void AnInternalObjectPubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool AnInternalObjectPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + AnInternalObject data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool AnInternalObjectPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const AnInternalObject* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + AnInternalObject_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); + ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); + eprosima::fastcdr::serialize_key(ser, *p_type); + if (force_md5 || AnInternalObject_max_key_cdr_typesize > 16) + { + md5_.init(); + md5_.update(key_buffer_, static_cast(ser.get_serialized_data_length())); + md5_.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle.value[i] = md5_.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle.value[i] = key_buffer_[i]; + } + } + return true; +} + +void AnInternalObjectPubSubType::register_type_object_representation() +{ + register_AnInternalObject_type_identifier(type_identifiers_); +} + +arrays_and_sequencesPubSubType::arrays_and_sequencesPubSubType() +{ + set_name("arrays_and_sequences"); + uint32_t type_size = arrays_and_sequences_max_cdr_typesize; + type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = arrays_and_sequences_max_key_cdr_typesize > 16 ? arrays_and_sequences_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); +} + +arrays_and_sequencesPubSubType::~arrays_and_sequencesPubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool arrays_and_sequencesPubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const arrays_and_sequences* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); + payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + ser.set_encoding_flag( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + ser << *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool arrays_and_sequencesPubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + arrays_and_sequences* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + deser >> *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + return true; +} + +uint32_t arrays_and_sequencesPubSubType::calculate_serialized_size( + const void* const data, + DataRepresentationId_t data_representation) +{ + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +} + +void* arrays_and_sequencesPubSubType::create_data() +{ + return reinterpret_cast(new arrays_and_sequences()); +} + +void arrays_and_sequencesPubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool arrays_and_sequencesPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + arrays_and_sequences data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool arrays_and_sequencesPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const arrays_and_sequences* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + arrays_and_sequences_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); + ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); + eprosima::fastcdr::serialize_key(ser, *p_type); + if (force_md5 || arrays_and_sequences_max_key_cdr_typesize > 16) + { + md5_.init(); + md5_.update(key_buffer_, static_cast(ser.get_serialized_data_length())); + md5_.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle.value[i] = md5_.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle.value[i] = key_buffer_[i]; + } + } + return true; +} + +void arrays_and_sequencesPubSubType::register_type_object_representation() +{ + register_arrays_and_sequences_type_identifier(type_identifiers_); +} + + +// Include auxiliary functions like for serializing/deserializing. +#include "arrays_and_sequencesCdrAux.ipp" diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesPubSubTypes.hpp similarity index 58% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesPubSubTypes.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesPubSubTypes.hpp index e7c10171..f6cb7c3c 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesPubSubTypes.h +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesPubSubTypes.hpp @@ -13,31 +13,29 @@ // limitations under the License. /*! - * @file arrays_and_sequencesPubSubTypes.h + * @file arrays_and_sequencesPubSubTypes.hpp * This header file contains the declaration of the serialization functions. * * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_PUBSUBTYPES_H_ +#ifndef FAST_DDS_GENERATED__ARRAYS_AND_SEQUENCES_PUBSUBTYPES_HPP +#define FAST_DDS_GENERATED__ARRAYS_AND_SEQUENCES_PUBSUBTYPES_HPP #include #include -#include -#include -#include +#include +#include +#include -#include "arrays_and_sequences.h" +#include "arrays_and_sequences.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated arrays_and_sequences is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER - - +#endif // FASTDDS_GEN_API_VER /*! @@ -55,41 +53,36 @@ class AnInternalObjectPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport ~AnInternalObjectPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t& payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + eProsima_user_DllExport uint32_t calculate_serialized_size( + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + eProsima_user_DllExport bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport bool compute_key( + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -99,13 +92,9 @@ class AnInternalObjectPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -123,12 +112,12 @@ class AnInternalObjectPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; +private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; +}; /*! * @brief This class represents the TopicDataType of the type arrays_and_sequences defined by the user in the IDL file. @@ -145,41 +134,36 @@ class arrays_and_sequencesPubSubType : public eprosima::fastdds::dds::TopicDataT eProsima_user_DllExport ~arrays_and_sequencesPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t& payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + eProsima_user_DllExport uint32_t calculate_serialized_size( + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + eProsima_user_DllExport bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport bool compute_key( + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -189,13 +173,9 @@ class arrays_and_sequencesPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -213,10 +193,12 @@ class arrays_and_sequencesPubSubType : public eprosima::fastdds::dds::TopicDataT #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; -#endif // _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_PUBSUBTYPES_H_ +#endif // FAST_DDS_GENERATED__ARRAYS_AND_SEQUENCES_PUBSUBTYPES_HPP diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesTypeObjectSupport.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesTypeObjectSupport.cxx new file mode 100644 index 00000000..06defd21 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesTypeObjectSupport.cxx @@ -0,0 +1,341 @@ +// 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 arrays_and_sequencesTypeObjectSupport.cxx + * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#include "arrays_and_sequencesTypeObjectSupport.hpp" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "arrays_and_sequences.hpp" + + +using namespace eprosima::fastdds::dds::xtypes; + +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_AnInternalObject_type_identifier( + TypeIdentifierPair& type_ids_AnInternalObject) +{ + + ReturnCode_t return_code_AnInternalObject {eprosima::fastdds::dds::RETCODE_OK}; + return_code_AnInternalObject = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "AnInternalObject", type_ids_AnInternalObject); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_AnInternalObject) + { + StructTypeFlag struct_flags_AnInternalObject = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_AnInternalObject = "AnInternalObject"; + eprosima::fastcdr::optional type_ann_builtin_AnInternalObject; + eprosima::fastcdr::optional ann_custom_AnInternalObject; + CompleteTypeDetail detail_AnInternalObject = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_AnInternalObject, ann_custom_AnInternalObject, type_name_AnInternalObject.to_string()); + CompleteStructHeader header_AnInternalObject; + header_AnInternalObject = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_AnInternalObject); + CompleteStructMemberSeq member_seq_AnInternalObject; + { + TypeIdentifierPair type_ids_x; + ReturnCode_t return_code_x {eprosima::fastdds::dds::RETCODE_OK}; + return_code_x = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_float", type_ids_x); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_x) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "x Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_x = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_x = 0x00000000; + bool common_x_ec {false}; + CommonStructMember common_x {TypeObjectUtils::build_common_struct_member(member_id_x, member_flags_x, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_x, common_x_ec))}; + if (!common_x_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure x member TypeIdentifier inconsistent."); + return; + } + MemberName name_x = "x"; + eprosima::fastcdr::optional member_ann_builtin_x; + ann_custom_AnInternalObject.reset(); + CompleteMemberDetail detail_x = TypeObjectUtils::build_complete_member_detail(name_x, member_ann_builtin_x, ann_custom_AnInternalObject); + CompleteStructMember member_x = TypeObjectUtils::build_complete_struct_member(common_x, detail_x); + TypeObjectUtils::add_complete_struct_member(member_seq_AnInternalObject, member_x); + } + { + TypeIdentifierPair type_ids_positive; + ReturnCode_t return_code_positive {eprosima::fastdds::dds::RETCODE_OK}; + return_code_positive = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_bool", type_ids_positive); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_positive) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "positive Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_positive = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_positive = 0x00000001; + bool common_positive_ec {false}; + CommonStructMember common_positive {TypeObjectUtils::build_common_struct_member(member_id_positive, member_flags_positive, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_positive, common_positive_ec))}; + if (!common_positive_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure positive member TypeIdentifier inconsistent."); + return; + } + MemberName name_positive = "positive"; + eprosima::fastcdr::optional member_ann_builtin_positive; + ann_custom_AnInternalObject.reset(); + CompleteMemberDetail detail_positive = TypeObjectUtils::build_complete_member_detail(name_positive, member_ann_builtin_positive, ann_custom_AnInternalObject); + CompleteStructMember member_positive = TypeObjectUtils::build_complete_struct_member(common_positive, detail_positive); + TypeObjectUtils::add_complete_struct_member(member_seq_AnInternalObject, member_positive); + } + CompleteStructType struct_type_AnInternalObject = TypeObjectUtils::build_complete_struct_type(struct_flags_AnInternalObject, header_AnInternalObject, member_seq_AnInternalObject); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_AnInternalObject, type_name_AnInternalObject.to_string(), type_ids_AnInternalObject)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "AnInternalObject already registered in TypeObjectRegistry for a different type."); + } + } +} +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_arrays_and_sequences_type_identifier( + TypeIdentifierPair& type_ids_arrays_and_sequences) +{ + + ReturnCode_t return_code_arrays_and_sequences {eprosima::fastdds::dds::RETCODE_OK}; + return_code_arrays_and_sequences = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "arrays_and_sequences", type_ids_arrays_and_sequences); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_arrays_and_sequences) + { + StructTypeFlag struct_flags_arrays_and_sequences = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_arrays_and_sequences = "arrays_and_sequences"; + eprosima::fastcdr::optional type_ann_builtin_arrays_and_sequences; + eprosima::fastcdr::optional ann_custom_arrays_and_sequences; + CompleteTypeDetail detail_arrays_and_sequences = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_arrays_and_sequences, ann_custom_arrays_and_sequences, type_name_arrays_and_sequences.to_string()); + CompleteStructHeader header_arrays_and_sequences; + header_arrays_and_sequences = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_arrays_and_sequences); + CompleteStructMemberSeq member_seq_arrays_and_sequences; + { + TypeIdentifierPair type_ids_unlimited_vector; + ReturnCode_t return_code_unlimited_vector {eprosima::fastdds::dds::RETCODE_OK}; + return_code_unlimited_vector = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_sequence_AnInternalObject_unbounded", type_ids_unlimited_vector); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_unlimited_vector) + { + return_code_unlimited_vector = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "AnInternalObject", type_ids_unlimited_vector); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_unlimited_vector) + { + ::register_AnInternalObject_type_identifier(type_ids_unlimited_vector); + } + bool element_identifier_anonymous_sequence_AnInternalObject_unbounded_ec {false}; + TypeIdentifier* element_identifier_anonymous_sequence_AnInternalObject_unbounded {new TypeIdentifier(TypeObjectUtils::retrieve_complete_type_identifier(type_ids_unlimited_vector, element_identifier_anonymous_sequence_AnInternalObject_unbounded_ec))}; + if (!element_identifier_anonymous_sequence_AnInternalObject_unbounded_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Sequence element TypeIdentifier inconsistent."); + return; + } + EquivalenceKind equiv_kind_anonymous_sequence_AnInternalObject_unbounded = EK_COMPLETE; + if (TK_NONE == type_ids_unlimited_vector.type_identifier2()._d()) + { + equiv_kind_anonymous_sequence_AnInternalObject_unbounded = EK_BOTH; + } + CollectionElementFlag element_flags_anonymous_sequence_AnInternalObject_unbounded = 0; + PlainCollectionHeader header_anonymous_sequence_AnInternalObject_unbounded = TypeObjectUtils::build_plain_collection_header(equiv_kind_anonymous_sequence_AnInternalObject_unbounded, element_flags_anonymous_sequence_AnInternalObject_unbounded); + { + SBound bound = 0; + PlainSequenceSElemDefn seq_sdefn = TypeObjectUtils::build_plain_sequence_s_elem_defn(header_anonymous_sequence_AnInternalObject_unbounded, bound, + eprosima::fastcdr::external(element_identifier_anonymous_sequence_AnInternalObject_unbounded)); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_sequence_type_identifier(seq_sdefn, "anonymous_sequence_AnInternalObject_unbounded", type_ids_unlimited_vector)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_sequence_AnInternalObject_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_unlimited_vector = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_unlimited_vector = 0x00000000; + bool common_unlimited_vector_ec {false}; + CommonStructMember common_unlimited_vector {TypeObjectUtils::build_common_struct_member(member_id_unlimited_vector, member_flags_unlimited_vector, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_unlimited_vector, common_unlimited_vector_ec))}; + if (!common_unlimited_vector_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure unlimited_vector member TypeIdentifier inconsistent."); + return; + } + MemberName name_unlimited_vector = "unlimited_vector"; + eprosima::fastcdr::optional member_ann_builtin_unlimited_vector; + ann_custom_arrays_and_sequences.reset(); + CompleteMemberDetail detail_unlimited_vector = TypeObjectUtils::build_complete_member_detail(name_unlimited_vector, member_ann_builtin_unlimited_vector, ann_custom_arrays_and_sequences); + CompleteStructMember member_unlimited_vector = TypeObjectUtils::build_complete_struct_member(common_unlimited_vector, detail_unlimited_vector); + TypeObjectUtils::add_complete_struct_member(member_seq_arrays_and_sequences, member_unlimited_vector); + } + { + TypeIdentifierPair type_ids_limited_vector; + ReturnCode_t return_code_limited_vector {eprosima::fastdds::dds::RETCODE_OK}; + return_code_limited_vector = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_sequence_AnInternalObject_10", type_ids_limited_vector); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_limited_vector) + { + return_code_limited_vector = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "AnInternalObject", type_ids_limited_vector); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_limited_vector) + { + ::register_AnInternalObject_type_identifier(type_ids_limited_vector); + } + bool element_identifier_anonymous_sequence_AnInternalObject_10_ec {false}; + TypeIdentifier* element_identifier_anonymous_sequence_AnInternalObject_10 {new TypeIdentifier(TypeObjectUtils::retrieve_complete_type_identifier(type_ids_limited_vector, element_identifier_anonymous_sequence_AnInternalObject_10_ec))}; + if (!element_identifier_anonymous_sequence_AnInternalObject_10_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Sequence element TypeIdentifier inconsistent."); + return; + } + EquivalenceKind equiv_kind_anonymous_sequence_AnInternalObject_10 = EK_COMPLETE; + if (TK_NONE == type_ids_limited_vector.type_identifier2()._d()) + { + equiv_kind_anonymous_sequence_AnInternalObject_10 = EK_BOTH; + } + CollectionElementFlag element_flags_anonymous_sequence_AnInternalObject_10 = 0; + PlainCollectionHeader header_anonymous_sequence_AnInternalObject_10 = TypeObjectUtils::build_plain_collection_header(equiv_kind_anonymous_sequence_AnInternalObject_10, element_flags_anonymous_sequence_AnInternalObject_10); + { + SBound bound = static_cast(10); + PlainSequenceSElemDefn seq_sdefn = TypeObjectUtils::build_plain_sequence_s_elem_defn(header_anonymous_sequence_AnInternalObject_10, bound, + eprosima::fastcdr::external(element_identifier_anonymous_sequence_AnInternalObject_10)); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_sequence_type_identifier(seq_sdefn, "anonymous_sequence_AnInternalObject_10", type_ids_limited_vector)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_sequence_AnInternalObject_10 already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_limited_vector = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_limited_vector = 0x00000001; + bool common_limited_vector_ec {false}; + CommonStructMember common_limited_vector {TypeObjectUtils::build_common_struct_member(member_id_limited_vector, member_flags_limited_vector, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_limited_vector, common_limited_vector_ec))}; + if (!common_limited_vector_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure limited_vector member TypeIdentifier inconsistent."); + return; + } + MemberName name_limited_vector = "limited_vector"; + eprosima::fastcdr::optional member_ann_builtin_limited_vector; + ann_custom_arrays_and_sequences.reset(); + CompleteMemberDetail detail_limited_vector = TypeObjectUtils::build_complete_member_detail(name_limited_vector, member_ann_builtin_limited_vector, ann_custom_arrays_and_sequences); + CompleteStructMember member_limited_vector = TypeObjectUtils::build_complete_struct_member(common_limited_vector, detail_limited_vector); + TypeObjectUtils::add_complete_struct_member(member_seq_arrays_and_sequences, member_limited_vector); + } + { + TypeIdentifierPair type_ids_limited_array; + ReturnCode_t return_code_limited_array {eprosima::fastdds::dds::RETCODE_OK}; + return_code_limited_array = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_array_AnInternalObject_10", type_ids_limited_array); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_limited_array) + { + return_code_limited_array = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "AnInternalObject", type_ids_limited_array); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_limited_array) + { + ::register_AnInternalObject_type_identifier(type_ids_limited_array); + } + bool element_identifier_anonymous_array_AnInternalObject_10_ec {false}; + TypeIdentifier* element_identifier_anonymous_array_AnInternalObject_10 {new TypeIdentifier(TypeObjectUtils::retrieve_complete_type_identifier(type_ids_limited_array, element_identifier_anonymous_array_AnInternalObject_10_ec))}; + if (!element_identifier_anonymous_array_AnInternalObject_10_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Array element TypeIdentifier inconsistent."); + return; + } + EquivalenceKind equiv_kind_anonymous_array_AnInternalObject_10 = EK_COMPLETE; + if (TK_NONE == type_ids_limited_array.type_identifier2()._d()) + { + equiv_kind_anonymous_array_AnInternalObject_10 = EK_BOTH; + } + CollectionElementFlag element_flags_anonymous_array_AnInternalObject_10 = 0; + PlainCollectionHeader header_anonymous_array_AnInternalObject_10 = TypeObjectUtils::build_plain_collection_header(equiv_kind_anonymous_array_AnInternalObject_10, element_flags_anonymous_array_AnInternalObject_10); + { + SBoundSeq array_bound_seq; + TypeObjectUtils::add_array_dimension(array_bound_seq, static_cast(10)); + + PlainArraySElemDefn array_sdefn = TypeObjectUtils::build_plain_array_s_elem_defn(header_anonymous_array_AnInternalObject_10, array_bound_seq, + eprosima::fastcdr::external(element_identifier_anonymous_array_AnInternalObject_10)); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_array_type_identifier(array_sdefn, "anonymous_array_AnInternalObject_10", type_ids_limited_array)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_array_AnInternalObject_10 already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_limited_array = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_limited_array = 0x00000002; + bool common_limited_array_ec {false}; + CommonStructMember common_limited_array {TypeObjectUtils::build_common_struct_member(member_id_limited_array, member_flags_limited_array, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_limited_array, common_limited_array_ec))}; + if (!common_limited_array_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure limited_array member TypeIdentifier inconsistent."); + return; + } + MemberName name_limited_array = "limited_array"; + eprosima::fastcdr::optional member_ann_builtin_limited_array; + ann_custom_arrays_and_sequences.reset(); + CompleteMemberDetail detail_limited_array = TypeObjectUtils::build_complete_member_detail(name_limited_array, member_ann_builtin_limited_array, ann_custom_arrays_and_sequences); + CompleteStructMember member_limited_array = TypeObjectUtils::build_complete_struct_member(common_limited_array, detail_limited_array); + TypeObjectUtils::add_complete_struct_member(member_seq_arrays_and_sequences, member_limited_array); + } + CompleteStructType struct_type_arrays_and_sequences = TypeObjectUtils::build_complete_struct_type(struct_flags_arrays_and_sequences, header_arrays_and_sequences, member_seq_arrays_and_sequences); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_arrays_and_sequences, type_name_arrays_and_sequences.to_string(), type_ids_arrays_and_sequences)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "arrays_and_sequences already registered in TypeObjectRegistry for a different type."); + } + } +} + diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesTypeObjectSupport.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesTypeObjectSupport.hpp new file mode 100644 index 00000000..43f145f3 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesTypeObjectSupport.hpp @@ -0,0 +1,68 @@ +// 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 arrays_and_sequencesTypeObjectSupport.hpp + * Header file containing the API required to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef FAST_DDS_GENERATED__ARRAYS_AND_SEQUENCES_TYPE_OBJECT_SUPPORT_HPP +#define FAST_DDS_GENERATED__ARRAYS_AND_SEQUENCES_TYPE_OBJECT_SUPPORT_HPP + +#include + + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +/** + * @brief Register AnInternalObject related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_AnInternalObject_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); +/** + * @brief Register arrays_and_sequences related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_arrays_and_sequences_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); + + +#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +#endif // FAST_DDS_GENERATED__ARRAYS_AND_SEQUENCES_TYPE_OBJECT_SUPPORT_HPP diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_struct.h b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_struct.hpp similarity index 67% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_struct.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_struct.hpp index a8aa5e9d..1352a2e4 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_struct.h +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_struct.hpp @@ -13,32 +13,18 @@ // limitations under the License. /*! - * @file basic_array_struct.h + * @file basic_array_struct.hpp * This header file contains the declaration of the described types in the IDL file. * * This file was generated by the tool fastddsgen. */ -#include -#include "basic_array_structv1.h" - -#if FASTCDR_VERSION_MAJOR > 1 - -#ifndef _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCT_H_ -#define _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCT_H_ +#ifndef FAST_DDS_GENERATED__BASIC_ARRAY_STRUCT_HPP +#define FAST_DDS_GENERATED__BASIC_ARRAY_STRUCT_HPP #include -#include #include -#include -#include -#include - -#include -#include -#include - - +#include #if defined(_WIN32) #if defined(EPROSIMA_USER_DLL_EXPORT) @@ -64,17 +50,6 @@ #define BASIC_ARRAY_STRUCT_DllAPI #endif // _WIN32 -namespace eprosima { -namespace fastcdr { -class Cdr; -class CdrSizeCalculator; -} // namespace fastcdr -} // namespace eprosima - - - - - /*! * @brief This class represents the structure TheOtherObjectInArray defined by the user in the IDL file. * @ingroup basic_array_struct @@ -86,73 +61,117 @@ class TheOtherObjectInArray /*! * @brief Default constructor. */ - eProsima_user_DllExport TheOtherObjectInArray(); + eProsima_user_DllExport TheOtherObjectInArray() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~TheOtherObjectInArray(); + eProsima_user_DllExport ~TheOtherObjectInArray() + { + } /*! * @brief Copy constructor. * @param x Reference to the object TheOtherObjectInArray that will be copied. */ eProsima_user_DllExport TheOtherObjectInArray( - const TheOtherObjectInArray& x); + const TheOtherObjectInArray& x) + { + m_some_num = x.m_some_num; + + m_positive = x.m_positive; + + } /*! * @brief Move constructor. * @param x Reference to the object TheOtherObjectInArray that will be copied. */ eProsima_user_DllExport TheOtherObjectInArray( - TheOtherObjectInArray&& x) noexcept; + TheOtherObjectInArray&& x) noexcept + { + m_some_num = x.m_some_num; + m_positive = x.m_positive; + } /*! * @brief Copy assignment. * @param x Reference to the object TheOtherObjectInArray that will be copied. */ eProsima_user_DllExport TheOtherObjectInArray& operator =( - const TheOtherObjectInArray& x); + const TheOtherObjectInArray& x) + { + + m_some_num = x.m_some_num; + + m_positive = x.m_positive; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object TheOtherObjectInArray that will be copied. */ eProsima_user_DllExport TheOtherObjectInArray& operator =( - TheOtherObjectInArray&& x) noexcept; + TheOtherObjectInArray&& x) noexcept + { + + m_some_num = x.m_some_num; + m_positive = x.m_positive; + return *this; + } /*! * @brief Comparison operator. * @param x TheOtherObjectInArray object to compare. */ eProsima_user_DllExport bool operator ==( - const TheOtherObjectInArray& x) const; + const TheOtherObjectInArray& x) const + { + return (m_some_num == x.m_some_num && + m_positive == x.m_positive); + } /*! * @brief Comparison operator. * @param x TheOtherObjectInArray object to compare. */ eProsima_user_DllExport bool operator !=( - const TheOtherObjectInArray& x) const; + const TheOtherObjectInArray& x) const + { + return !(*this == x); + } /*! * @brief This function sets a value in member some_num * @param _some_num New value for member some_num */ eProsima_user_DllExport void some_num( - int32_t _some_num); + int32_t _some_num) + { + m_some_num = _some_num; + } /*! * @brief This function returns the value of member some_num * @return Value of member some_num */ - eProsima_user_DllExport int32_t some_num() const; + eProsima_user_DllExport int32_t some_num() const + { + return m_some_num; + } /*! * @brief This function returns a reference to member some_num * @return Reference to member some_num */ - eProsima_user_DllExport int32_t& some_num(); + eProsima_user_DllExport int32_t& some_num() + { + return m_some_num; + } /*! @@ -160,19 +179,30 @@ class TheOtherObjectInArray * @param _positive New value for member positive */ eProsima_user_DllExport void positive( - bool _positive); + bool _positive) + { + m_positive = _positive; + } /*! * @brief This function returns the value of member positive * @return Value of member positive */ - eProsima_user_DllExport bool positive() const; + eProsima_user_DllExport bool positive() const + { + return m_positive; + } /*! * @brief This function returns a reference to member positive * @return Reference to member positive */ - eProsima_user_DllExport bool& positive(); + eProsima_user_DllExport bool& positive() + { + return m_positive; + } + + private: @@ -180,8 +210,6 @@ class TheOtherObjectInArray bool m_positive{false}; }; - - /*! * @brief This class represents the structure basic_array_struct defined by the user in the IDL file. * @ingroup basic_array_struct @@ -193,73 +221,117 @@ class basic_array_struct /*! * @brief Default constructor. */ - eProsima_user_DllExport basic_array_struct(); + eProsima_user_DllExport basic_array_struct() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~basic_array_struct(); + eProsima_user_DllExport ~basic_array_struct() + { + } /*! * @brief Copy constructor. * @param x Reference to the object basic_array_struct that will be copied. */ eProsima_user_DllExport basic_array_struct( - const basic_array_struct& x); + const basic_array_struct& x) + { + m_index = x.m_index; + + m_sub_structs = x.m_sub_structs; + + } /*! * @brief Move constructor. * @param x Reference to the object basic_array_struct that will be copied. */ eProsima_user_DllExport basic_array_struct( - basic_array_struct&& x) noexcept; + basic_array_struct&& x) noexcept + { + m_index = x.m_index; + m_sub_structs = std::move(x.m_sub_structs); + } /*! * @brief Copy assignment. * @param x Reference to the object basic_array_struct that will be copied. */ eProsima_user_DllExport basic_array_struct& operator =( - const basic_array_struct& x); + const basic_array_struct& x) + { + + m_index = x.m_index; + + m_sub_structs = x.m_sub_structs; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object basic_array_struct that will be copied. */ eProsima_user_DllExport basic_array_struct& operator =( - basic_array_struct&& x) noexcept; + basic_array_struct&& x) noexcept + { + + m_index = x.m_index; + m_sub_structs = std::move(x.m_sub_structs); + return *this; + } /*! * @brief Comparison operator. * @param x basic_array_struct object to compare. */ eProsima_user_DllExport bool operator ==( - const basic_array_struct& x) const; + const basic_array_struct& x) const + { + return (m_index == x.m_index && + m_sub_structs == x.m_sub_structs); + } /*! * @brief Comparison operator. * @param x basic_array_struct object to compare. */ eProsima_user_DllExport bool operator !=( - const basic_array_struct& x) const; + const basic_array_struct& x) const + { + return !(*this == x); + } /*! * @brief This function sets a value in member index * @param _index New value for member index */ eProsima_user_DllExport void index( - uint32_t _index); + uint32_t _index) + { + m_index = _index; + } /*! * @brief This function returns the value of member index * @return Value of member index */ - eProsima_user_DllExport uint32_t index() const; + eProsima_user_DllExport uint32_t index() const + { + return m_index; + } /*! * @brief This function returns a reference to member index * @return Reference to member index */ - eProsima_user_DllExport uint32_t& index(); + eProsima_user_DllExport uint32_t& index() + { + return m_index; + } /*! @@ -267,26 +339,40 @@ class basic_array_struct * @param _sub_structs New value to be copied in member sub_structs */ eProsima_user_DllExport void sub_structs( - const std::array& _sub_structs); + const std::array& _sub_structs) + { + m_sub_structs = _sub_structs; + } /*! * @brief This function moves the value in member sub_structs * @param _sub_structs New value to be moved in member sub_structs */ eProsima_user_DllExport void sub_structs( - std::array&& _sub_structs); + std::array&& _sub_structs) + { + m_sub_structs = std::move(_sub_structs); + } /*! * @brief This function returns a constant reference to member sub_structs * @return Constant reference to member sub_structs */ - eProsima_user_DllExport const std::array& sub_structs() const; + eProsima_user_DllExport const std::array& sub_structs() const + { + return m_sub_structs; + } /*! * @brief This function returns a reference to member sub_structs * @return Reference to member sub_structs */ - eProsima_user_DllExport std::array& sub_structs(); + eProsima_user_DllExport std::array& sub_structs() + { + return m_sub_structs; + } + + private: @@ -295,8 +381,6 @@ class basic_array_struct }; -#endif // _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCT_H_ - +#endif // _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCT_HPP_ -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structCdrAux.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structCdrAux.hpp similarity index 87% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structCdrAux.hpp rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structCdrAux.hpp index 0ef831d5..3bbf1a9a 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structCdrAux.hpp +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structCdrAux.hpp @@ -19,10 +19,10 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCTCDRAUX_HPP_ -#define _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCTCDRAUX_HPP_ +#ifndef FAST_DDS_GENERATED__BASIC_ARRAY_STRUCTCDRAUX_HPP +#define FAST_DDS_GENERATED__BASIC_ARRAY_STRUCTCDRAUX_HPP -#include "basic_array_struct.h" +#include "basic_array_struct.hpp" constexpr uint32_t basic_array_struct_max_cdr_typesize {69UL}; constexpr uint32_t basic_array_struct_max_key_cdr_typesize {0UL}; @@ -37,14 +37,10 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const TheOtherObjectInArray& data); - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const basic_array_struct& data); @@ -53,5 +49,5 @@ eProsima_user_DllExport void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCTCDRAUX_HPP_ +#endif // FAST_DDS_GENERATED__BASIC_ARRAY_STRUCTCDRAUX_HPP diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structCdrAux.ipp b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structCdrAux.ipp similarity index 95% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structCdrAux.ipp rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structCdrAux.ipp index fafd51bf..306a17d3 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structCdrAux.ipp +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structCdrAux.ipp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCTCDRAUX_IPP_ -#define _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCTCDRAUX_IPP_ +#ifndef FAST_DDS_GENERATED__BASIC_ARRAY_STRUCTCDRAUX_IPP +#define FAST_DDS_GENERATED__BASIC_ARRAY_STRUCTCDRAUX_IPP #include "basic_array_structCdrAux.hpp" @@ -34,8 +34,6 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { - - template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -115,11 +113,14 @@ void serialize_key( eprosima::fastcdr::Cdr& scdr, const TheOtherObjectInArray& data) { + static_cast(scdr); static_cast(data); -} + scdr << data.some_num(); + scdr << data.positive(); +} template<> @@ -201,8 +202,13 @@ void serialize_key( eprosima::fastcdr::Cdr& scdr, const basic_array_struct& data) { + static_cast(scdr); static_cast(data); + scdr << data.index(); + + scdr << data.sub_structs(); + } @@ -210,5 +216,5 @@ void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCTCDRAUX_IPP_ +#endif // FAST_DDS_GENERATED__BASIC_ARRAY_STRUCTCDRAUX_IPP diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structPubSubTypes.cxx new file mode 100644 index 00000000..1831718b --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structPubSubTypes.cxx @@ -0,0 +1,398 @@ +// 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 basic_array_structPubSubTypes.cpp + * This header file contains the implementation of the serialization functions. + * + * This file was generated by the tool fastddsgen. + */ + +#include "basic_array_structPubSubTypes.hpp" + +#include +#include + +#include "basic_array_structCdrAux.hpp" +#include "basic_array_structTypeObjectSupport.hpp" + +using SerializedPayload_t = eprosima::fastdds::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t; +using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; + +TheOtherObjectInArrayPubSubType::TheOtherObjectInArrayPubSubType() +{ + set_name("TheOtherObjectInArray"); + uint32_t type_size = TheOtherObjectInArray_max_cdr_typesize; + type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = TheOtherObjectInArray_max_key_cdr_typesize > 16 ? TheOtherObjectInArray_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); +} + +TheOtherObjectInArrayPubSubType::~TheOtherObjectInArrayPubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool TheOtherObjectInArrayPubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const TheOtherObjectInArray* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); + payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + ser.set_encoding_flag( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + ser << *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool TheOtherObjectInArrayPubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + TheOtherObjectInArray* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + deser >> *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + return true; +} + +uint32_t TheOtherObjectInArrayPubSubType::calculate_serialized_size( + const void* const data, + DataRepresentationId_t data_representation) +{ + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +} + +void* TheOtherObjectInArrayPubSubType::create_data() +{ + return reinterpret_cast(new TheOtherObjectInArray()); +} + +void TheOtherObjectInArrayPubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool TheOtherObjectInArrayPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + TheOtherObjectInArray data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool TheOtherObjectInArrayPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const TheOtherObjectInArray* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + TheOtherObjectInArray_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); + ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); + eprosima::fastcdr::serialize_key(ser, *p_type); + if (force_md5 || TheOtherObjectInArray_max_key_cdr_typesize > 16) + { + md5_.init(); + md5_.update(key_buffer_, static_cast(ser.get_serialized_data_length())); + md5_.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle.value[i] = md5_.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle.value[i] = key_buffer_[i]; + } + } + return true; +} + +void TheOtherObjectInArrayPubSubType::register_type_object_representation() +{ + register_TheOtherObjectInArray_type_identifier(type_identifiers_); +} + +basic_array_structPubSubType::basic_array_structPubSubType() +{ + set_name("basic_array_struct"); + uint32_t type_size = basic_array_struct_max_cdr_typesize; + type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = basic_array_struct_max_key_cdr_typesize > 16 ? basic_array_struct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); +} + +basic_array_structPubSubType::~basic_array_structPubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool basic_array_structPubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const basic_array_struct* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); + payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + ser.set_encoding_flag( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + ser << *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool basic_array_structPubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + basic_array_struct* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + deser >> *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + return true; +} + +uint32_t basic_array_structPubSubType::calculate_serialized_size( + const void* const data, + DataRepresentationId_t data_representation) +{ + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +} + +void* basic_array_structPubSubType::create_data() +{ + return reinterpret_cast(new basic_array_struct()); +} + +void basic_array_structPubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool basic_array_structPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + basic_array_struct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool basic_array_structPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const basic_array_struct* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + basic_array_struct_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); + ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); + eprosima::fastcdr::serialize_key(ser, *p_type); + if (force_md5 || basic_array_struct_max_key_cdr_typesize > 16) + { + md5_.init(); + md5_.update(key_buffer_, static_cast(ser.get_serialized_data_length())); + md5_.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle.value[i] = md5_.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle.value[i] = key_buffer_[i]; + } + } + return true; +} + +void basic_array_structPubSubType::register_type_object_representation() +{ + register_basic_array_struct_type_identifier(type_identifiers_); +} + + +// Include auxiliary functions like for serializing/deserializing. +#include "basic_array_structCdrAux.ipp" diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structPubSubTypes.hpp similarity index 58% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structPubSubTypes.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structPubSubTypes.hpp index 33c7ade9..64c85f8e 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structPubSubTypes.h +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structPubSubTypes.hpp @@ -13,31 +13,29 @@ // limitations under the License. /*! - * @file basic_array_structPubSubTypes.h + * @file basic_array_structPubSubTypes.hpp * This header file contains the declaration of the serialization functions. * * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCT_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCT_PUBSUBTYPES_H_ +#ifndef FAST_DDS_GENERATED__BASIC_ARRAY_STRUCT_PUBSUBTYPES_HPP +#define FAST_DDS_GENERATED__BASIC_ARRAY_STRUCT_PUBSUBTYPES_HPP #include #include -#include -#include -#include +#include +#include +#include -#include "basic_array_struct.h" +#include "basic_array_struct.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated basic_array_struct is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER - - +#endif // FASTDDS_GEN_API_VER /*! @@ -55,41 +53,36 @@ class TheOtherObjectInArrayPubSubType : public eprosima::fastdds::dds::TopicData eProsima_user_DllExport ~TheOtherObjectInArrayPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t& payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + eProsima_user_DllExport uint32_t calculate_serialized_size( + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + eProsima_user_DllExport bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport bool compute_key( + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -99,13 +92,9 @@ class TheOtherObjectInArrayPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -123,12 +112,12 @@ class TheOtherObjectInArrayPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; +private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; +}; /*! * @brief This class represents the TopicDataType of the type basic_array_struct defined by the user in the IDL file. @@ -145,41 +134,36 @@ class basic_array_structPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport ~basic_array_structPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t& payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + eProsima_user_DllExport uint32_t calculate_serialized_size( + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + eProsima_user_DllExport bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport bool compute_key( + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -189,13 +173,9 @@ class basic_array_structPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -213,10 +193,12 @@ class basic_array_structPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; -#endif // _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCT_PUBSUBTYPES_H_ +#endif // FAST_DDS_GENERATED__BASIC_ARRAY_STRUCT_PUBSUBTYPES_HPP diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structTypeObjectSupport.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structTypeObjectSupport.cxx new file mode 100644 index 00000000..242ea811 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structTypeObjectSupport.cxx @@ -0,0 +1,251 @@ +// 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 basic_array_structTypeObjectSupport.cxx + * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#include "basic_array_structTypeObjectSupport.hpp" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "basic_array_struct.hpp" + + +using namespace eprosima::fastdds::dds::xtypes; + +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_TheOtherObjectInArray_type_identifier( + TypeIdentifierPair& type_ids_TheOtherObjectInArray) +{ + + ReturnCode_t return_code_TheOtherObjectInArray {eprosima::fastdds::dds::RETCODE_OK}; + return_code_TheOtherObjectInArray = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "TheOtherObjectInArray", type_ids_TheOtherObjectInArray); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_TheOtherObjectInArray) + { + StructTypeFlag struct_flags_TheOtherObjectInArray = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_TheOtherObjectInArray = "TheOtherObjectInArray"; + eprosima::fastcdr::optional type_ann_builtin_TheOtherObjectInArray; + eprosima::fastcdr::optional ann_custom_TheOtherObjectInArray; + CompleteTypeDetail detail_TheOtherObjectInArray = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_TheOtherObjectInArray, ann_custom_TheOtherObjectInArray, type_name_TheOtherObjectInArray.to_string()); + CompleteStructHeader header_TheOtherObjectInArray; + header_TheOtherObjectInArray = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_TheOtherObjectInArray); + CompleteStructMemberSeq member_seq_TheOtherObjectInArray; + { + TypeIdentifierPair type_ids_some_num; + ReturnCode_t return_code_some_num {eprosima::fastdds::dds::RETCODE_OK}; + return_code_some_num = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_int32_t", type_ids_some_num); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_some_num) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "some_num Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_some_num = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_some_num = 0x00000000; + bool common_some_num_ec {false}; + CommonStructMember common_some_num {TypeObjectUtils::build_common_struct_member(member_id_some_num, member_flags_some_num, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_some_num, common_some_num_ec))}; + if (!common_some_num_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure some_num member TypeIdentifier inconsistent."); + return; + } + MemberName name_some_num = "some_num"; + eprosima::fastcdr::optional member_ann_builtin_some_num; + ann_custom_TheOtherObjectInArray.reset(); + CompleteMemberDetail detail_some_num = TypeObjectUtils::build_complete_member_detail(name_some_num, member_ann_builtin_some_num, ann_custom_TheOtherObjectInArray); + CompleteStructMember member_some_num = TypeObjectUtils::build_complete_struct_member(common_some_num, detail_some_num); + TypeObjectUtils::add_complete_struct_member(member_seq_TheOtherObjectInArray, member_some_num); + } + { + TypeIdentifierPair type_ids_positive; + ReturnCode_t return_code_positive {eprosima::fastdds::dds::RETCODE_OK}; + return_code_positive = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_bool", type_ids_positive); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_positive) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "positive Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_positive = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_positive = 0x00000001; + bool common_positive_ec {false}; + CommonStructMember common_positive {TypeObjectUtils::build_common_struct_member(member_id_positive, member_flags_positive, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_positive, common_positive_ec))}; + if (!common_positive_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure positive member TypeIdentifier inconsistent."); + return; + } + MemberName name_positive = "positive"; + eprosima::fastcdr::optional member_ann_builtin_positive; + ann_custom_TheOtherObjectInArray.reset(); + CompleteMemberDetail detail_positive = TypeObjectUtils::build_complete_member_detail(name_positive, member_ann_builtin_positive, ann_custom_TheOtherObjectInArray); + CompleteStructMember member_positive = TypeObjectUtils::build_complete_struct_member(common_positive, detail_positive); + TypeObjectUtils::add_complete_struct_member(member_seq_TheOtherObjectInArray, member_positive); + } + CompleteStructType struct_type_TheOtherObjectInArray = TypeObjectUtils::build_complete_struct_type(struct_flags_TheOtherObjectInArray, header_TheOtherObjectInArray, member_seq_TheOtherObjectInArray); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_TheOtherObjectInArray, type_name_TheOtherObjectInArray.to_string(), type_ids_TheOtherObjectInArray)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "TheOtherObjectInArray already registered in TypeObjectRegistry for a different type."); + } + } +} +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_basic_array_struct_type_identifier( + TypeIdentifierPair& type_ids_basic_array_struct) +{ + + ReturnCode_t return_code_basic_array_struct {eprosima::fastdds::dds::RETCODE_OK}; + return_code_basic_array_struct = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "basic_array_struct", type_ids_basic_array_struct); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_basic_array_struct) + { + StructTypeFlag struct_flags_basic_array_struct = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_basic_array_struct = "basic_array_struct"; + eprosima::fastcdr::optional type_ann_builtin_basic_array_struct; + eprosima::fastcdr::optional ann_custom_basic_array_struct; + CompleteTypeDetail detail_basic_array_struct = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_basic_array_struct, ann_custom_basic_array_struct, type_name_basic_array_struct.to_string()); + CompleteStructHeader header_basic_array_struct; + header_basic_array_struct = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_basic_array_struct); + CompleteStructMemberSeq member_seq_basic_array_struct; + { + TypeIdentifierPair type_ids_index; + ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK}; + return_code_index = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_uint32_t", type_ids_index); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_index) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "index Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_index = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_index = 0x00000000; + bool common_index_ec {false}; + CommonStructMember common_index {TypeObjectUtils::build_common_struct_member(member_id_index, member_flags_index, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_index, common_index_ec))}; + if (!common_index_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure index member TypeIdentifier inconsistent."); + return; + } + MemberName name_index = "index"; + eprosima::fastcdr::optional member_ann_builtin_index; + ann_custom_basic_array_struct.reset(); + CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_basic_array_struct); + CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index); + TypeObjectUtils::add_complete_struct_member(member_seq_basic_array_struct, member_index); + } + { + TypeIdentifierPair type_ids_sub_structs; + ReturnCode_t return_code_sub_structs {eprosima::fastdds::dds::RETCODE_OK}; + return_code_sub_structs = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_array_TheOtherObjectInArray_5", type_ids_sub_structs); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_sub_structs) + { + return_code_sub_structs = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "TheOtherObjectInArray", type_ids_sub_structs); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_sub_structs) + { + ::register_TheOtherObjectInArray_type_identifier(type_ids_sub_structs); + } + bool element_identifier_anonymous_array_TheOtherObjectInArray_5_ec {false}; + TypeIdentifier* element_identifier_anonymous_array_TheOtherObjectInArray_5 {new TypeIdentifier(TypeObjectUtils::retrieve_complete_type_identifier(type_ids_sub_structs, element_identifier_anonymous_array_TheOtherObjectInArray_5_ec))}; + if (!element_identifier_anonymous_array_TheOtherObjectInArray_5_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Array element TypeIdentifier inconsistent."); + return; + } + EquivalenceKind equiv_kind_anonymous_array_TheOtherObjectInArray_5 = EK_COMPLETE; + if (TK_NONE == type_ids_sub_structs.type_identifier2()._d()) + { + equiv_kind_anonymous_array_TheOtherObjectInArray_5 = EK_BOTH; + } + CollectionElementFlag element_flags_anonymous_array_TheOtherObjectInArray_5 = 0; + PlainCollectionHeader header_anonymous_array_TheOtherObjectInArray_5 = TypeObjectUtils::build_plain_collection_header(equiv_kind_anonymous_array_TheOtherObjectInArray_5, element_flags_anonymous_array_TheOtherObjectInArray_5); + { + SBoundSeq array_bound_seq; + TypeObjectUtils::add_array_dimension(array_bound_seq, static_cast(5)); + + PlainArraySElemDefn array_sdefn = TypeObjectUtils::build_plain_array_s_elem_defn(header_anonymous_array_TheOtherObjectInArray_5, array_bound_seq, + eprosima::fastcdr::external(element_identifier_anonymous_array_TheOtherObjectInArray_5)); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_array_type_identifier(array_sdefn, "anonymous_array_TheOtherObjectInArray_5", type_ids_sub_structs)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_array_TheOtherObjectInArray_5 already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_sub_structs = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_sub_structs = 0x00000001; + bool common_sub_structs_ec {false}; + CommonStructMember common_sub_structs {TypeObjectUtils::build_common_struct_member(member_id_sub_structs, member_flags_sub_structs, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_sub_structs, common_sub_structs_ec))}; + if (!common_sub_structs_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure sub_structs member TypeIdentifier inconsistent."); + return; + } + MemberName name_sub_structs = "sub_structs"; + eprosima::fastcdr::optional member_ann_builtin_sub_structs; + ann_custom_basic_array_struct.reset(); + CompleteMemberDetail detail_sub_structs = TypeObjectUtils::build_complete_member_detail(name_sub_structs, member_ann_builtin_sub_structs, ann_custom_basic_array_struct); + CompleteStructMember member_sub_structs = TypeObjectUtils::build_complete_struct_member(common_sub_structs, detail_sub_structs); + TypeObjectUtils::add_complete_struct_member(member_seq_basic_array_struct, member_sub_structs); + } + CompleteStructType struct_type_basic_array_struct = TypeObjectUtils::build_complete_struct_type(struct_flags_basic_array_struct, header_basic_array_struct, member_seq_basic_array_struct); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_basic_array_struct, type_name_basic_array_struct.to_string(), type_ids_basic_array_struct)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "basic_array_struct already registered in TypeObjectRegistry for a different type."); + } + } +} + diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structTypeObjectSupport.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structTypeObjectSupport.hpp new file mode 100644 index 00000000..afa3f5f9 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structTypeObjectSupport.hpp @@ -0,0 +1,68 @@ +// 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 basic_array_structTypeObjectSupport.hpp + * Header file containing the API required to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef FAST_DDS_GENERATED__BASIC_ARRAY_STRUCT_TYPE_OBJECT_SUPPORT_HPP +#define FAST_DDS_GENERATED__BASIC_ARRAY_STRUCT_TYPE_OBJECT_SUPPORT_HPP + +#include + + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +/** + * @brief Register TheOtherObjectInArray related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_TheOtherObjectInArray_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); +/** + * @brief Register basic_array_struct related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_basic_array_struct_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); + + +#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +#endif // FAST_DDS_GENERATED__BASIC_ARRAY_STRUCT_TYPE_OBJECT_SUPPORT_HPP diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_struct.h b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_struct.hpp similarity index 69% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_struct.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_struct.hpp index a7ee0514..9ba4805a 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_struct.h +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_struct.hpp @@ -13,32 +13,17 @@ // limitations under the License. /*! - * @file basic_struct.h + * @file basic_struct.hpp * This header file contains the declaration of the described types in the IDL file. * * This file was generated by the tool fastddsgen. */ -#include -#include "basic_structv1.h" +#ifndef FAST_DDS_GENERATED__BASIC_STRUCT_HPP +#define FAST_DDS_GENERATED__BASIC_STRUCT_HPP -#if FASTCDR_VERSION_MAJOR > 1 - -#ifndef _FAST_DDS_GENERATED_BASIC_STRUCT_H_ -#define _FAST_DDS_GENERATED_BASIC_STRUCT_H_ - -#include -#include #include -#include -#include -#include - -#include -#include -#include - - +#include #if defined(_WIN32) #if defined(EPROSIMA_USER_DLL_EXPORT) @@ -64,17 +49,6 @@ #define BASIC_STRUCT_DllAPI #endif // _WIN32 -namespace eprosima { -namespace fastcdr { -class Cdr; -class CdrSizeCalculator; -} // namespace fastcdr -} // namespace eprosima - - - - - /*! * @brief This class represents the structure TheOtherObject defined by the user in the IDL file. * @ingroup basic_struct @@ -86,81 +60,118 @@ class TheOtherObject /*! * @brief Default constructor. */ - eProsima_user_DllExport TheOtherObject(); + eProsima_user_DllExport TheOtherObject() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~TheOtherObject(); + eProsima_user_DllExport ~TheOtherObject() + { + } /*! * @brief Copy constructor. * @param x Reference to the object TheOtherObject that will be copied. */ eProsima_user_DllExport TheOtherObject( - const TheOtherObject& x); + const TheOtherObject& x) + { + m_some_num = x.m_some_num; + + } /*! * @brief Move constructor. * @param x Reference to the object TheOtherObject that will be copied. */ eProsima_user_DllExport TheOtherObject( - TheOtherObject&& x) noexcept; + TheOtherObject&& x) noexcept + { + m_some_num = x.m_some_num; + } /*! * @brief Copy assignment. * @param x Reference to the object TheOtherObject that will be copied. */ eProsima_user_DllExport TheOtherObject& operator =( - const TheOtherObject& x); + const TheOtherObject& x) + { + + m_some_num = x.m_some_num; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object TheOtherObject that will be copied. */ eProsima_user_DllExport TheOtherObject& operator =( - TheOtherObject&& x) noexcept; + TheOtherObject&& x) noexcept + { + + m_some_num = x.m_some_num; + return *this; + } /*! * @brief Comparison operator. * @param x TheOtherObject object to compare. */ eProsima_user_DllExport bool operator ==( - const TheOtherObject& x) const; + const TheOtherObject& x) const + { + return (m_some_num == x.m_some_num); + } /*! * @brief Comparison operator. * @param x TheOtherObject object to compare. */ eProsima_user_DllExport bool operator !=( - const TheOtherObject& x) const; + const TheOtherObject& x) const + { + return !(*this == x); + } /*! * @brief This function sets a value in member some_num * @param _some_num New value for member some_num */ eProsima_user_DllExport void some_num( - int32_t _some_num); + int32_t _some_num) + { + m_some_num = _some_num; + } /*! * @brief This function returns the value of member some_num * @return Value of member some_num */ - eProsima_user_DllExport int32_t some_num() const; + eProsima_user_DllExport int32_t some_num() const + { + return m_some_num; + } /*! * @brief This function returns a reference to member some_num * @return Reference to member some_num */ - eProsima_user_DllExport int32_t& some_num(); + eProsima_user_DllExport int32_t& some_num() + { + return m_some_num; + } + + private: int32_t m_some_num{0}; }; - - /*! * @brief This class represents the structure basic_struct defined by the user in the IDL file. * @ingroup basic_struct @@ -172,80 +183,122 @@ class basic_struct /*! * @brief Default constructor. */ - eProsima_user_DllExport basic_struct(); + eProsima_user_DllExport basic_struct() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~basic_struct(); + eProsima_user_DllExport ~basic_struct() + { + } /*! * @brief Copy constructor. * @param x Reference to the object basic_struct that will be copied. */ eProsima_user_DllExport basic_struct( - const basic_struct& x); + const basic_struct& x) + { + m_sub_struct = x.m_sub_struct; + + } /*! * @brief Move constructor. * @param x Reference to the object basic_struct that will be copied. */ eProsima_user_DllExport basic_struct( - basic_struct&& x) noexcept; + basic_struct&& x) noexcept + { + m_sub_struct = std::move(x.m_sub_struct); + } /*! * @brief Copy assignment. * @param x Reference to the object basic_struct that will be copied. */ eProsima_user_DllExport basic_struct& operator =( - const basic_struct& x); + const basic_struct& x) + { + + m_sub_struct = x.m_sub_struct; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object basic_struct that will be copied. */ eProsima_user_DllExport basic_struct& operator =( - basic_struct&& x) noexcept; + basic_struct&& x) noexcept + { + + m_sub_struct = std::move(x.m_sub_struct); + return *this; + } /*! * @brief Comparison operator. * @param x basic_struct object to compare. */ eProsima_user_DllExport bool operator ==( - const basic_struct& x) const; + const basic_struct& x) const + { + return (m_sub_struct == x.m_sub_struct); + } /*! * @brief Comparison operator. * @param x basic_struct object to compare. */ eProsima_user_DllExport bool operator !=( - const basic_struct& x) const; + const basic_struct& x) const + { + return !(*this == x); + } /*! * @brief This function copies the value in member sub_struct * @param _sub_struct New value to be copied in member sub_struct */ eProsima_user_DllExport void sub_struct( - const TheOtherObject& _sub_struct); + const TheOtherObject& _sub_struct) + { + m_sub_struct = _sub_struct; + } /*! * @brief This function moves the value in member sub_struct * @param _sub_struct New value to be moved in member sub_struct */ eProsima_user_DllExport void sub_struct( - TheOtherObject&& _sub_struct); + TheOtherObject&& _sub_struct) + { + m_sub_struct = std::move(_sub_struct); + } /*! * @brief This function returns a constant reference to member sub_struct * @return Constant reference to member sub_struct */ - eProsima_user_DllExport const TheOtherObject& sub_struct() const; + eProsima_user_DllExport const TheOtherObject& sub_struct() const + { + return m_sub_struct; + } /*! * @brief This function returns a reference to member sub_struct * @return Reference to member sub_struct */ - eProsima_user_DllExport TheOtherObject& sub_struct(); + eProsima_user_DllExport TheOtherObject& sub_struct() + { + return m_sub_struct; + } + + private: @@ -253,8 +306,6 @@ class basic_struct }; -#endif // _FAST_DDS_GENERATED_BASIC_STRUCT_H_ - +#endif // _FAST_DDS_GENERATED_BASIC_STRUCT_HPP_ -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structCdrAux.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structCdrAux.hpp similarity index 88% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structCdrAux.hpp rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structCdrAux.hpp index 45b59460..ac32e369 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structCdrAux.hpp +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structCdrAux.hpp @@ -19,10 +19,10 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_BASIC_STRUCTCDRAUX_HPP_ -#define _FAST_DDS_GENERATED_BASIC_STRUCTCDRAUX_HPP_ +#ifndef FAST_DDS_GENERATED__BASIC_STRUCTCDRAUX_HPP +#define FAST_DDS_GENERATED__BASIC_STRUCTCDRAUX_HPP -#include "basic_struct.h" +#include "basic_struct.hpp" constexpr uint32_t basic_struct_max_cdr_typesize {12UL}; constexpr uint32_t basic_struct_max_key_cdr_typesize {0UL}; @@ -37,14 +37,10 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const TheOtherObject& data); - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const basic_struct& data); @@ -53,5 +49,5 @@ eProsima_user_DllExport void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_BASIC_STRUCTCDRAUX_HPP_ +#endif // FAST_DDS_GENERATED__BASIC_STRUCTCDRAUX_HPP diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structCdrAux.ipp b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structCdrAux.ipp similarity index 94% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structCdrAux.ipp rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structCdrAux.ipp index 474987db..1d587488 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structCdrAux.ipp +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structCdrAux.ipp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_BASIC_STRUCTCDRAUX_IPP_ -#define _FAST_DDS_GENERATED_BASIC_STRUCTCDRAUX_IPP_ +#ifndef FAST_DDS_GENERATED__BASIC_STRUCTCDRAUX_IPP +#define FAST_DDS_GENERATED__BASIC_STRUCTCDRAUX_IPP #include "basic_structCdrAux.hpp" @@ -34,8 +34,6 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { - - template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -107,11 +105,12 @@ void serialize_key( eprosima::fastcdr::Cdr& scdr, const TheOtherObject& data) { + static_cast(scdr); static_cast(data); -} - + scdr << data.some_num(); +} template<> @@ -185,8 +184,15 @@ void serialize_key( eprosima::fastcdr::Cdr& scdr, const basic_struct& data) { + extern void serialize_key( + Cdr& scdr, + const TheOtherObject& data); + + static_cast(scdr); static_cast(data); + serialize_key(scdr, data.sub_struct()); + } @@ -194,5 +200,5 @@ void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_BASIC_STRUCTCDRAUX_IPP_ +#endif // FAST_DDS_GENERATED__BASIC_STRUCTCDRAUX_IPP diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structPubSubTypes.cxx new file mode 100644 index 00000000..be5833ac --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structPubSubTypes.cxx @@ -0,0 +1,398 @@ +// 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 basic_structPubSubTypes.cpp + * This header file contains the implementation of the serialization functions. + * + * This file was generated by the tool fastddsgen. + */ + +#include "basic_structPubSubTypes.hpp" + +#include +#include + +#include "basic_structCdrAux.hpp" +#include "basic_structTypeObjectSupport.hpp" + +using SerializedPayload_t = eprosima::fastdds::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t; +using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; + +TheOtherObjectPubSubType::TheOtherObjectPubSubType() +{ + set_name("TheOtherObject"); + uint32_t type_size = TheOtherObject_max_cdr_typesize; + type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = TheOtherObject_max_key_cdr_typesize > 16 ? TheOtherObject_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); +} + +TheOtherObjectPubSubType::~TheOtherObjectPubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool TheOtherObjectPubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const TheOtherObject* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); + payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + ser.set_encoding_flag( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + ser << *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool TheOtherObjectPubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + TheOtherObject* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + deser >> *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + return true; +} + +uint32_t TheOtherObjectPubSubType::calculate_serialized_size( + const void* const data, + DataRepresentationId_t data_representation) +{ + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +} + +void* TheOtherObjectPubSubType::create_data() +{ + return reinterpret_cast(new TheOtherObject()); +} + +void TheOtherObjectPubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool TheOtherObjectPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + TheOtherObject data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool TheOtherObjectPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const TheOtherObject* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + TheOtherObject_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); + ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); + eprosima::fastcdr::serialize_key(ser, *p_type); + if (force_md5 || TheOtherObject_max_key_cdr_typesize > 16) + { + md5_.init(); + md5_.update(key_buffer_, static_cast(ser.get_serialized_data_length())); + md5_.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle.value[i] = md5_.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle.value[i] = key_buffer_[i]; + } + } + return true; +} + +void TheOtherObjectPubSubType::register_type_object_representation() +{ + register_TheOtherObject_type_identifier(type_identifiers_); +} + +basic_structPubSubType::basic_structPubSubType() +{ + set_name("basic_struct"); + uint32_t type_size = basic_struct_max_cdr_typesize; + type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = basic_struct_max_key_cdr_typesize > 16 ? basic_struct_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); +} + +basic_structPubSubType::~basic_structPubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool basic_structPubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const basic_struct* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); + payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + ser.set_encoding_flag( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + ser << *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool basic_structPubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + basic_struct* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + deser >> *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + return true; +} + +uint32_t basic_structPubSubType::calculate_serialized_size( + const void* const data, + DataRepresentationId_t data_representation) +{ + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +} + +void* basic_structPubSubType::create_data() +{ + return reinterpret_cast(new basic_struct()); +} + +void basic_structPubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool basic_structPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + basic_struct data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool basic_structPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const basic_struct* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + basic_struct_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); + ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); + eprosima::fastcdr::serialize_key(ser, *p_type); + if (force_md5 || basic_struct_max_key_cdr_typesize > 16) + { + md5_.init(); + md5_.update(key_buffer_, static_cast(ser.get_serialized_data_length())); + md5_.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle.value[i] = md5_.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle.value[i] = key_buffer_[i]; + } + } + return true; +} + +void basic_structPubSubType::register_type_object_representation() +{ + register_basic_struct_type_identifier(type_identifiers_); +} + + +// Include auxiliary functions like for serializing/deserializing. +#include "basic_structCdrAux.ipp" diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structPubSubTypes.hpp similarity index 57% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structPubSubTypes.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structPubSubTypes.hpp index 042149ca..a1e0a185 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structPubSubTypes.h +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structPubSubTypes.hpp @@ -13,31 +13,29 @@ // limitations under the License. /*! - * @file basic_structPubSubTypes.h + * @file basic_structPubSubTypes.hpp * This header file contains the declaration of the serialization functions. * * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_BASIC_STRUCT_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_BASIC_STRUCT_PUBSUBTYPES_H_ +#ifndef FAST_DDS_GENERATED__BASIC_STRUCT_PUBSUBTYPES_HPP +#define FAST_DDS_GENERATED__BASIC_STRUCT_PUBSUBTYPES_HPP #include #include -#include -#include -#include +#include +#include +#include -#include "basic_struct.h" +#include "basic_struct.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated basic_struct is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER - - +#endif // FASTDDS_GEN_API_VER /*! @@ -55,41 +53,36 @@ class TheOtherObjectPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport ~TheOtherObjectPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t& payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + eProsima_user_DllExport uint32_t calculate_serialized_size( + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + eProsima_user_DllExport bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport bool compute_key( + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -99,13 +92,9 @@ class TheOtherObjectPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -123,12 +112,12 @@ class TheOtherObjectPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; +private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; +}; /*! * @brief This class represents the TopicDataType of the type basic_struct defined by the user in the IDL file. @@ -145,41 +134,36 @@ class basic_structPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport ~basic_structPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t& payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + eProsima_user_DllExport uint32_t calculate_serialized_size( + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + eProsima_user_DllExport bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport bool compute_key( + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -189,13 +173,9 @@ class basic_structPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -213,10 +193,12 @@ class basic_structPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; -#endif // _FAST_DDS_GENERATED_BASIC_STRUCT_PUBSUBTYPES_H_ +#endif // FAST_DDS_GENERATED__BASIC_STRUCT_PUBSUBTYPES_HPP diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structTypeObjectSupport.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structTypeObjectSupport.cxx new file mode 100644 index 00000000..b57ea0db --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structTypeObjectSupport.cxx @@ -0,0 +1,157 @@ +// 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 basic_structTypeObjectSupport.cxx + * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#include "basic_structTypeObjectSupport.hpp" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "basic_struct.hpp" + + +using namespace eprosima::fastdds::dds::xtypes; + +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_TheOtherObject_type_identifier( + TypeIdentifierPair& type_ids_TheOtherObject) +{ + + ReturnCode_t return_code_TheOtherObject {eprosima::fastdds::dds::RETCODE_OK}; + return_code_TheOtherObject = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "TheOtherObject", type_ids_TheOtherObject); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_TheOtherObject) + { + StructTypeFlag struct_flags_TheOtherObject = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_TheOtherObject = "TheOtherObject"; + eprosima::fastcdr::optional type_ann_builtin_TheOtherObject; + eprosima::fastcdr::optional ann_custom_TheOtherObject; + CompleteTypeDetail detail_TheOtherObject = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_TheOtherObject, ann_custom_TheOtherObject, type_name_TheOtherObject.to_string()); + CompleteStructHeader header_TheOtherObject; + header_TheOtherObject = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_TheOtherObject); + CompleteStructMemberSeq member_seq_TheOtherObject; + { + TypeIdentifierPair type_ids_some_num; + ReturnCode_t return_code_some_num {eprosima::fastdds::dds::RETCODE_OK}; + return_code_some_num = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_int32_t", type_ids_some_num); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_some_num) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "some_num Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_some_num = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_some_num = 0x00000000; + bool common_some_num_ec {false}; + CommonStructMember common_some_num {TypeObjectUtils::build_common_struct_member(member_id_some_num, member_flags_some_num, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_some_num, common_some_num_ec))}; + if (!common_some_num_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure some_num member TypeIdentifier inconsistent."); + return; + } + MemberName name_some_num = "some_num"; + eprosima::fastcdr::optional member_ann_builtin_some_num; + ann_custom_TheOtherObject.reset(); + CompleteMemberDetail detail_some_num = TypeObjectUtils::build_complete_member_detail(name_some_num, member_ann_builtin_some_num, ann_custom_TheOtherObject); + CompleteStructMember member_some_num = TypeObjectUtils::build_complete_struct_member(common_some_num, detail_some_num); + TypeObjectUtils::add_complete_struct_member(member_seq_TheOtherObject, member_some_num); + } + CompleteStructType struct_type_TheOtherObject = TypeObjectUtils::build_complete_struct_type(struct_flags_TheOtherObject, header_TheOtherObject, member_seq_TheOtherObject); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_TheOtherObject, type_name_TheOtherObject.to_string(), type_ids_TheOtherObject)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "TheOtherObject already registered in TypeObjectRegistry for a different type."); + } + } +} +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_basic_struct_type_identifier( + TypeIdentifierPair& type_ids_basic_struct) +{ + + ReturnCode_t return_code_basic_struct {eprosima::fastdds::dds::RETCODE_OK}; + return_code_basic_struct = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "basic_struct", type_ids_basic_struct); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_basic_struct) + { + StructTypeFlag struct_flags_basic_struct = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_basic_struct = "basic_struct"; + eprosima::fastcdr::optional type_ann_builtin_basic_struct; + eprosima::fastcdr::optional ann_custom_basic_struct; + CompleteTypeDetail detail_basic_struct = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_basic_struct, ann_custom_basic_struct, type_name_basic_struct.to_string()); + CompleteStructHeader header_basic_struct; + header_basic_struct = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_basic_struct); + CompleteStructMemberSeq member_seq_basic_struct; + { + TypeIdentifierPair type_ids_sub_struct; + ReturnCode_t return_code_sub_struct {eprosima::fastdds::dds::RETCODE_OK}; + return_code_sub_struct = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "TheOtherObject", type_ids_sub_struct); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_sub_struct) + { + ::register_TheOtherObject_type_identifier(type_ids_sub_struct); + } + StructMemberFlag member_flags_sub_struct = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_sub_struct = 0x00000000; + bool common_sub_struct_ec {false}; + CommonStructMember common_sub_struct {TypeObjectUtils::build_common_struct_member(member_id_sub_struct, member_flags_sub_struct, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_sub_struct, common_sub_struct_ec))}; + if (!common_sub_struct_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure sub_struct member TypeIdentifier inconsistent."); + return; + } + MemberName name_sub_struct = "sub_struct"; + eprosima::fastcdr::optional member_ann_builtin_sub_struct; + ann_custom_basic_struct.reset(); + CompleteMemberDetail detail_sub_struct = TypeObjectUtils::build_complete_member_detail(name_sub_struct, member_ann_builtin_sub_struct, ann_custom_basic_struct); + CompleteStructMember member_sub_struct = TypeObjectUtils::build_complete_struct_member(common_sub_struct, detail_sub_struct); + TypeObjectUtils::add_complete_struct_member(member_seq_basic_struct, member_sub_struct); + } + CompleteStructType struct_type_basic_struct = TypeObjectUtils::build_complete_struct_type(struct_flags_basic_struct, header_basic_struct, member_seq_basic_struct); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_basic_struct, type_name_basic_struct.to_string(), type_ids_basic_struct)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "basic_struct already registered in TypeObjectRegistry for a different type."); + } + } +} + diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structTypeObjectSupport.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structTypeObjectSupport.hpp new file mode 100644 index 00000000..d2cc9a74 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structTypeObjectSupport.hpp @@ -0,0 +1,68 @@ +// 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 basic_structTypeObjectSupport.hpp + * Header file containing the API required to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef FAST_DDS_GENERATED__BASIC_STRUCT_TYPE_OBJECT_SUPPORT_HPP +#define FAST_DDS_GENERATED__BASIC_STRUCT_TYPE_OBJECT_SUPPORT_HPP + +#include + + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +/** + * @brief Register TheOtherObject related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_TheOtherObject_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); +/** + * @brief Register basic_struct related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_basic_struct_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); + + +#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +#endif // FAST_DDS_GENERATED__BASIC_STRUCT_TYPE_OBJECT_SUPPORT_HPP diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequence.h b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequence.hpp similarity index 74% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequence.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequence.hpp index dcd658a9..98e9d533 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequence.h +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequence.hpp @@ -13,32 +13,19 @@ // limitations under the License. /*! - * @file char_sequence.h + * @file char_sequence.hpp * This header file contains the declaration of the described types in the IDL file. * * This file was generated by the tool fastddsgen. */ -#include -#include "char_sequencev1.h" +#ifndef FAST_DDS_GENERATED__CHAR_SEQUENCE_HPP +#define FAST_DDS_GENERATED__CHAR_SEQUENCE_HPP -#if FASTCDR_VERSION_MAJOR > 1 - -#ifndef _FAST_DDS_GENERATED_CHAR_SEQUENCE_H_ -#define _FAST_DDS_GENERATED_CHAR_SEQUENCE_H_ - -#include -#include #include -#include -#include +#include #include -#include -#include -#include - - #if defined(_WIN32) #if defined(EPROSIMA_USER_DLL_EXPORT) @@ -64,19 +51,6 @@ #define CHAR_SEQUENCE_DllAPI #endif // _WIN32 -namespace eprosima { -namespace fastcdr { -class Cdr; -class CdrSizeCalculator; -} // namespace fastcdr -} // namespace eprosima - - - - - - - /*! * @brief This class represents the structure char_sequence defined by the user in the IDL file. * @ingroup char_sequence @@ -88,80 +62,122 @@ class char_sequence /*! * @brief Default constructor. */ - eProsima_user_DllExport char_sequence(); + eProsima_user_DllExport char_sequence() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~char_sequence(); + eProsima_user_DllExport ~char_sequence() + { + } /*! * @brief Copy constructor. * @param x Reference to the object char_sequence that will be copied. */ eProsima_user_DllExport char_sequence( - const char_sequence& x); + const char_sequence& x) + { + m_chars = x.m_chars; + + } /*! * @brief Move constructor. * @param x Reference to the object char_sequence that will be copied. */ eProsima_user_DllExport char_sequence( - char_sequence&& x) noexcept; + char_sequence&& x) noexcept + { + m_chars = std::move(x.m_chars); + } /*! * @brief Copy assignment. * @param x Reference to the object char_sequence that will be copied. */ eProsima_user_DllExport char_sequence& operator =( - const char_sequence& x); + const char_sequence& x) + { + + m_chars = x.m_chars; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object char_sequence that will be copied. */ eProsima_user_DllExport char_sequence& operator =( - char_sequence&& x) noexcept; + char_sequence&& x) noexcept + { + + m_chars = std::move(x.m_chars); + return *this; + } /*! * @brief Comparison operator. * @param x char_sequence object to compare. */ eProsima_user_DllExport bool operator ==( - const char_sequence& x) const; + const char_sequence& x) const + { + return (m_chars == x.m_chars); + } /*! * @brief Comparison operator. * @param x char_sequence object to compare. */ eProsima_user_DllExport bool operator !=( - const char_sequence& x) const; + const char_sequence& x) const + { + return !(*this == x); + } /*! * @brief This function copies the value in member chars * @param _chars New value to be copied in member chars */ eProsima_user_DllExport void chars( - const std::vector& _chars); + const std::vector& _chars) + { + m_chars = _chars; + } /*! * @brief This function moves the value in member chars * @param _chars New value to be moved in member chars */ eProsima_user_DllExport void chars( - std::vector&& _chars); + std::vector&& _chars) + { + m_chars = std::move(_chars); + } /*! * @brief This function returns a constant reference to member chars * @return Constant reference to member chars */ - eProsima_user_DllExport const std::vector& chars() const; + eProsima_user_DllExport const std::vector& chars() const + { + return m_chars; + } /*! * @brief This function returns a reference to member chars * @return Reference to member chars */ - eProsima_user_DllExport std::vector& chars(); + eProsima_user_DllExport std::vector& chars() + { + return m_chars; + } + + private: @@ -169,8 +185,6 @@ class char_sequence }; -#endif // _FAST_DDS_GENERATED_CHAR_SEQUENCE_H_ - +#endif // _FAST_DDS_GENERATED_CHAR_SEQUENCE_HPP_ -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequenceCdrAux.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequenceCdrAux.hpp similarity index 85% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequenceCdrAux.hpp rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequenceCdrAux.hpp index 405e325c..a1d9b9ad 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequenceCdrAux.hpp +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequenceCdrAux.hpp @@ -19,10 +19,10 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_CHAR_SEQUENCECDRAUX_HPP_ -#define _FAST_DDS_GENERATED_CHAR_SEQUENCECDRAUX_HPP_ +#ifndef FAST_DDS_GENERATED__CHAR_SEQUENCECDRAUX_HPP +#define FAST_DDS_GENERATED__CHAR_SEQUENCECDRAUX_HPP -#include "char_sequence.h" +#include "char_sequence.hpp" constexpr uint32_t char_sequence_max_cdr_typesize {8UL}; constexpr uint32_t char_sequence_max_key_cdr_typesize {0UL}; @@ -34,10 +34,6 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; - - - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const char_sequence& data); @@ -46,5 +42,5 @@ eProsima_user_DllExport void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_CHAR_SEQUENCECDRAUX_HPP_ +#endif // FAST_DDS_GENERATED__CHAR_SEQUENCECDRAUX_HPP diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequenceCdrAux.ipp b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequenceCdrAux.ipp similarity index 94% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequenceCdrAux.ipp rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequenceCdrAux.ipp index 8939ae4b..a0ed4a86 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequenceCdrAux.ipp +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequenceCdrAux.ipp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_CHAR_SEQUENCECDRAUX_IPP_ -#define _FAST_DDS_GENERATED_CHAR_SEQUENCECDRAUX_IPP_ +#ifndef FAST_DDS_GENERATED__CHAR_SEQUENCECDRAUX_IPP +#define FAST_DDS_GENERATED__CHAR_SEQUENCECDRAUX_IPP #include "char_sequenceCdrAux.hpp" @@ -34,10 +34,6 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { - - - - template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -109,8 +105,11 @@ void serialize_key( eprosima::fastcdr::Cdr& scdr, const char_sequence& data) { + static_cast(scdr); static_cast(data); + scdr << data.chars(); + } @@ -118,5 +117,5 @@ void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_CHAR_SEQUENCECDRAUX_IPP_ +#endif // FAST_DDS_GENERATED__CHAR_SEQUENCECDRAUX_IPP diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequencePubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequencePubSubTypes.cxx similarity index 50% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequencePubSubTypes.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequencePubSubTypes.cxx index 3dd6bcf6..2fef40d1 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequencePubSubTypes.cxx +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequencePubSubTypes.cxx @@ -19,65 +19,56 @@ * This file was generated by the tool fastddsgen. */ +#include "char_sequencePubSubTypes.hpp" +#include #include -#include "char_sequencePubSubTypes.h" #include "char_sequenceCdrAux.hpp" +#include "char_sequenceTypeObjectSupport.hpp" -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; +using SerializedPayload_t = eprosima::fastdds::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - - - - char_sequencePubSubType::char_sequencePubSubType() { - setName("char_sequence"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(char_sequence::getMaxCdrSerializedSize()); -#else - char_sequence_max_cdr_typesize; -#endif + set_name("char_sequence"); + uint32_t type_size = char_sequence_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = char_sequence_max_key_cdr_typesize > 16 ? char_sequence_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = char_sequence_max_key_cdr_typesize > 16 ? char_sequence_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } char_sequencePubSubType::~char_sequencePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool char_sequencePubSubType::serialize( - void* data, - SerializedPayload_t* payload, + const void* const data, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { - char_sequence* p_type = static_cast(data); + const char_sequence* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; ser.set_encoding_flag( data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -92,16 +83,12 @@ bool char_sequencePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool char_sequencePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -110,18 +97,14 @@ bool char_sequencePubSubType::deserialize( char_sequence* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); // Deserialize encapsulation. deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -134,90 +117,101 @@ bool char_sequencePubSubType::deserialize( return true; } -std::function char_sequencePubSubType::getSerializedSizeProvider( - void* data, +uint32_t char_sequencePubSubType::calculate_serialized_size( + const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } } -void* char_sequencePubSubType::createData() +void* char_sequencePubSubType::create_data() { return reinterpret_cast(new char_sequence()); } -void char_sequencePubSubType::deleteData( +void char_sequencePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool char_sequencePubSubType::getKey( - void* data, - InstanceHandle_t* handle, +bool char_sequencePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + char_sequence data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool char_sequencePubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } - char_sequence* p_type = static_cast(data); + const char_sequence* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), char_sequence_max_key_cdr_typesize); // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); + ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || char_sequence_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + md5_.init(); + md5_.update(key_buffer_, static_cast(ser.get_serialized_data_length())); + md5_.finalize(); for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; } +void char_sequencePubSubType::register_type_object_representation() +{ + register_char_sequence_type_identifier(type_identifiers_); +} + + +// Include auxiliary functions like for serializing/deserializing. +#include "char_sequenceCdrAux.ipp" diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequencePubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequencePubSubTypes.hpp similarity index 59% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequencePubSubTypes.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequencePubSubTypes.hpp index 53dfa6eb..bf0c5369 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequencePubSubTypes.h +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequencePubSubTypes.hpp @@ -13,33 +13,29 @@ // limitations under the License. /*! - * @file char_sequencePubSubTypes.h + * @file char_sequencePubSubTypes.hpp * This header file contains the declaration of the serialization functions. * * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_CHAR_SEQUENCE_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_CHAR_SEQUENCE_PUBSUBTYPES_H_ +#ifndef FAST_DDS_GENERATED__CHAR_SEQUENCE_PUBSUBTYPES_HPP +#define FAST_DDS_GENERATED__CHAR_SEQUENCE_PUBSUBTYPES_HPP #include #include -#include -#include -#include +#include +#include +#include -#include "char_sequence.h" +#include "char_sequence.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated char_sequence is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER - - - - +#endif // FASTDDS_GEN_API_VER /*! @@ -57,41 +53,36 @@ class char_sequencePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport ~char_sequencePubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t& payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + eProsima_user_DllExport uint32_t calculate_serialized_size( + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + eProsima_user_DllExport bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport bool compute_key( + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, + bool force_md5 = false) override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void* create_data() override; + + eProsima_user_DllExport void delete_data( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -101,13 +92,9 @@ class char_sequencePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -125,10 +112,12 @@ class char_sequencePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; -#endif // _FAST_DDS_GENERATED_CHAR_SEQUENCE_PUBSUBTYPES_H_ +#endif // FAST_DDS_GENERATED__CHAR_SEQUENCE_PUBSUBTYPES_HPP diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequenceTypeObjectSupport.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequenceTypeObjectSupport.cxx new file mode 100644 index 00000000..24ddf288 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequenceTypeObjectSupport.cxx @@ -0,0 +1,132 @@ +// 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 char_sequenceTypeObjectSupport.cxx + * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#include "char_sequenceTypeObjectSupport.hpp" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "char_sequence.hpp" + + +using namespace eprosima::fastdds::dds::xtypes; + +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_char_sequence_type_identifier( + TypeIdentifierPair& type_ids_char_sequence) +{ + + ReturnCode_t return_code_char_sequence {eprosima::fastdds::dds::RETCODE_OK}; + return_code_char_sequence = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "char_sequence", type_ids_char_sequence); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_char_sequence) + { + StructTypeFlag struct_flags_char_sequence = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_char_sequence = "char_sequence"; + eprosima::fastcdr::optional type_ann_builtin_char_sequence; + eprosima::fastcdr::optional ann_custom_char_sequence; + CompleteTypeDetail detail_char_sequence = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_char_sequence, ann_custom_char_sequence, type_name_char_sequence.to_string()); + CompleteStructHeader header_char_sequence; + header_char_sequence = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_char_sequence); + CompleteStructMemberSeq member_seq_char_sequence; + { + TypeIdentifierPair type_ids_chars; + ReturnCode_t return_code_chars {eprosima::fastdds::dds::RETCODE_OK}; + return_code_chars = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_sequence_char_unbounded", type_ids_chars); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_chars) + { + return_code_chars = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_char", type_ids_chars); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_chars) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "Sequence element TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + bool element_identifier_anonymous_sequence_char_unbounded_ec {false}; + TypeIdentifier* element_identifier_anonymous_sequence_char_unbounded {new TypeIdentifier(TypeObjectUtils::retrieve_complete_type_identifier(type_ids_chars, element_identifier_anonymous_sequence_char_unbounded_ec))}; + if (!element_identifier_anonymous_sequence_char_unbounded_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Sequence element TypeIdentifier inconsistent."); + return; + } + EquivalenceKind equiv_kind_anonymous_sequence_char_unbounded = EK_COMPLETE; + if (TK_NONE == type_ids_chars.type_identifier2()._d()) + { + equiv_kind_anonymous_sequence_char_unbounded = EK_BOTH; + } + CollectionElementFlag element_flags_anonymous_sequence_char_unbounded = 0; + PlainCollectionHeader header_anonymous_sequence_char_unbounded = TypeObjectUtils::build_plain_collection_header(equiv_kind_anonymous_sequence_char_unbounded, element_flags_anonymous_sequence_char_unbounded); + { + SBound bound = 0; + PlainSequenceSElemDefn seq_sdefn = TypeObjectUtils::build_plain_sequence_s_elem_defn(header_anonymous_sequence_char_unbounded, bound, + eprosima::fastcdr::external(element_identifier_anonymous_sequence_char_unbounded)); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_sequence_type_identifier(seq_sdefn, "anonymous_sequence_char_unbounded", type_ids_chars)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_sequence_char_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_chars = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_chars = 0x00000000; + bool common_chars_ec {false}; + CommonStructMember common_chars {TypeObjectUtils::build_common_struct_member(member_id_chars, member_flags_chars, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_chars, common_chars_ec))}; + if (!common_chars_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure chars member TypeIdentifier inconsistent."); + return; + } + MemberName name_chars = "chars"; + eprosima::fastcdr::optional member_ann_builtin_chars; + ann_custom_char_sequence.reset(); + CompleteMemberDetail detail_chars = TypeObjectUtils::build_complete_member_detail(name_chars, member_ann_builtin_chars, ann_custom_char_sequence); + CompleteStructMember member_chars = TypeObjectUtils::build_complete_struct_member(common_chars, detail_chars); + TypeObjectUtils::add_complete_struct_member(member_seq_char_sequence, member_chars); + } + CompleteStructType struct_type_char_sequence = TypeObjectUtils::build_complete_struct_type(struct_flags_char_sequence, header_char_sequence, member_seq_char_sequence); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_char_sequence, type_name_char_sequence.to_string(), type_ids_char_sequence)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "char_sequence already registered in TypeObjectRegistry for a different type."); + } + } +} + diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequenceTypeObjectSupport.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequenceTypeObjectSupport.hpp new file mode 100644 index 00000000..45d4779e --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequenceTypeObjectSupport.hpp @@ -0,0 +1,56 @@ +// 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 char_sequenceTypeObjectSupport.hpp + * Header file containing the API required to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef FAST_DDS_GENERATED__CHAR_SEQUENCE_TYPE_OBJECT_SUPPORT_HPP +#define FAST_DDS_GENERATED__CHAR_SEQUENCE_TYPE_OBJECT_SUPPORT_HPP + +#include + + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +/** + * @brief Register char_sequence related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_char_sequence_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); + + +#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +#endif // FAST_DDS_GENERATED__CHAR_SEQUENCE_TYPE_OBJECT_SUPPORT_HPP diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arrays.h b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arrays.hpp similarity index 66% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arrays.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arrays.hpp index 43ed4961..1f7a722b 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arrays.h +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arrays.hpp @@ -13,32 +13,22 @@ // limitations under the License. /*! - * @file complex_nested_arrays.h + * @file complex_nested_arrays.hpp * This header file contains the declaration of the described types in the IDL file. * * This file was generated by the tool fastddsgen. */ -#include -#include "complex_nested_arraysv1.h" - -#if FASTCDR_VERSION_MAJOR > 1 - -#ifndef _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYS_H_ -#define _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYS_H_ +#ifndef FAST_DDS_GENERATED__COMPLEX_NESTED_ARRAYS_HPP +#define FAST_DDS_GENERATED__COMPLEX_NESTED_ARRAYS_HPP #include -#include #include -#include #include +#include #include #include -#include -#include - - #if defined(_WIN32) #if defined(EPROSIMA_USER_DLL_EXPORT) @@ -64,17 +54,6 @@ #define COMPLEX_NESTED_ARRAYS_DllAPI #endif // _WIN32 -namespace eprosima { -namespace fastcdr { -class Cdr; -class CdrSizeCalculator; -} // namespace fastcdr -} // namespace eprosima - - - - - /*! * @brief This class represents the structure ThirdLevelElement defined by the user in the IDL file. * @ingroup complex_nested_arrays @@ -86,73 +65,117 @@ class ThirdLevelElement /*! * @brief Default constructor. */ - eProsima_user_DllExport ThirdLevelElement(); + eProsima_user_DllExport ThirdLevelElement() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~ThirdLevelElement(); + eProsima_user_DllExport ~ThirdLevelElement() + { + } /*! * @brief Copy constructor. * @param x Reference to the object ThirdLevelElement that will be copied. */ eProsima_user_DllExport ThirdLevelElement( - const ThirdLevelElement& x); + const ThirdLevelElement& x) + { + m_x = x.m_x; + + m_y = x.m_y; + + } /*! * @brief Move constructor. * @param x Reference to the object ThirdLevelElement that will be copied. */ eProsima_user_DllExport ThirdLevelElement( - ThirdLevelElement&& x) noexcept; + ThirdLevelElement&& x) noexcept + { + m_x = x.m_x; + m_y = x.m_y; + } /*! * @brief Copy assignment. * @param x Reference to the object ThirdLevelElement that will be copied. */ eProsima_user_DllExport ThirdLevelElement& operator =( - const ThirdLevelElement& x); + const ThirdLevelElement& x) + { + + m_x = x.m_x; + + m_y = x.m_y; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object ThirdLevelElement that will be copied. */ eProsima_user_DllExport ThirdLevelElement& operator =( - ThirdLevelElement&& x) noexcept; + ThirdLevelElement&& x) noexcept + { + + m_x = x.m_x; + m_y = x.m_y; + return *this; + } /*! * @brief Comparison operator. * @param x ThirdLevelElement object to compare. */ eProsima_user_DllExport bool operator ==( - const ThirdLevelElement& x) const; + const ThirdLevelElement& x) const + { + return (m_x == x.m_x && + m_y == x.m_y); + } /*! * @brief Comparison operator. * @param x ThirdLevelElement object to compare. */ eProsima_user_DllExport bool operator !=( - const ThirdLevelElement& x) const; + const ThirdLevelElement& x) const + { + return !(*this == x); + } /*! * @brief This function sets a value in member x * @param _x New value for member x */ eProsima_user_DllExport void x( - double _x); + double _x) + { + m_x = _x; + } /*! * @brief This function returns the value of member x * @return Value of member x */ - eProsima_user_DllExport double x() const; + eProsima_user_DllExport double x() const + { + return m_x; + } /*! * @brief This function returns a reference to member x * @return Reference to member x */ - eProsima_user_DllExport double& x(); + eProsima_user_DllExport double& x() + { + return m_x; + } /*! @@ -160,19 +183,30 @@ class ThirdLevelElement * @param _y New value for member y */ eProsima_user_DllExport void y( - double _y); + double _y) + { + m_y = _y; + } /*! * @brief This function returns the value of member y * @return Value of member y */ - eProsima_user_DllExport double y() const; + eProsima_user_DllExport double y() const + { + return m_y; + } /*! * @brief This function returns a reference to member y * @return Reference to member y */ - eProsima_user_DllExport double& y(); + eProsima_user_DllExport double& y() + { + return m_y; + } + + private: @@ -180,10 +214,6 @@ class ThirdLevelElement double m_y{0.0}; }; - - - - /*! * @brief This class represents the structure SecondLevelElement defined by the user in the IDL file. * @ingroup complex_nested_arrays @@ -195,80 +225,127 @@ class SecondLevelElement /*! * @brief Default constructor. */ - eProsima_user_DllExport SecondLevelElement(); + eProsima_user_DllExport SecondLevelElement() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~SecondLevelElement(); + eProsima_user_DllExport ~SecondLevelElement() + { + } /*! * @brief Copy constructor. * @param x Reference to the object SecondLevelElement that will be copied. */ eProsima_user_DllExport SecondLevelElement( - const SecondLevelElement& x); + const SecondLevelElement& x) + { + m_an_element_alone = x.m_an_element_alone; + + m_a_limited_other_value = x.m_a_limited_other_value; + + } /*! * @brief Move constructor. * @param x Reference to the object SecondLevelElement that will be copied. */ eProsima_user_DllExport SecondLevelElement( - SecondLevelElement&& x) noexcept; + SecondLevelElement&& x) noexcept + { + m_an_element_alone = std::move(x.m_an_element_alone); + m_a_limited_other_value = std::move(x.m_a_limited_other_value); + } /*! * @brief Copy assignment. * @param x Reference to the object SecondLevelElement that will be copied. */ eProsima_user_DllExport SecondLevelElement& operator =( - const SecondLevelElement& x); + const SecondLevelElement& x) + { + + m_an_element_alone = x.m_an_element_alone; + + m_a_limited_other_value = x.m_a_limited_other_value; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object SecondLevelElement that will be copied. */ eProsima_user_DllExport SecondLevelElement& operator =( - SecondLevelElement&& x) noexcept; + SecondLevelElement&& x) noexcept + { + + m_an_element_alone = std::move(x.m_an_element_alone); + m_a_limited_other_value = std::move(x.m_a_limited_other_value); + return *this; + } /*! * @brief Comparison operator. * @param x SecondLevelElement object to compare. */ eProsima_user_DllExport bool operator ==( - const SecondLevelElement& x) const; + const SecondLevelElement& x) const + { + return (m_an_element_alone == x.m_an_element_alone && + m_a_limited_other_value == x.m_a_limited_other_value); + } /*! * @brief Comparison operator. * @param x SecondLevelElement object to compare. */ eProsima_user_DllExport bool operator !=( - const SecondLevelElement& x) const; + const SecondLevelElement& x) const + { + return !(*this == x); + } /*! * @brief This function copies the value in member an_element_alone * @param _an_element_alone New value to be copied in member an_element_alone */ eProsima_user_DllExport void an_element_alone( - const ThirdLevelElement& _an_element_alone); + const ThirdLevelElement& _an_element_alone) + { + m_an_element_alone = _an_element_alone; + } /*! * @brief This function moves the value in member an_element_alone * @param _an_element_alone New value to be moved in member an_element_alone */ eProsima_user_DllExport void an_element_alone( - ThirdLevelElement&& _an_element_alone); + ThirdLevelElement&& _an_element_alone) + { + m_an_element_alone = std::move(_an_element_alone); + } /*! * @brief This function returns a constant reference to member an_element_alone * @return Constant reference to member an_element_alone */ - eProsima_user_DllExport const ThirdLevelElement& an_element_alone() const; + eProsima_user_DllExport const ThirdLevelElement& an_element_alone() const + { + return m_an_element_alone; + } /*! * @brief This function returns a reference to member an_element_alone * @return Reference to member an_element_alone */ - eProsima_user_DllExport ThirdLevelElement& an_element_alone(); + eProsima_user_DllExport ThirdLevelElement& an_element_alone() + { + return m_an_element_alone; + } /*! @@ -276,26 +353,40 @@ class SecondLevelElement * @param _a_limited_other_value New value to be copied in member a_limited_other_value */ eProsima_user_DllExport void a_limited_other_value( - const std::vector& _a_limited_other_value); + const std::vector& _a_limited_other_value) + { + m_a_limited_other_value = _a_limited_other_value; + } /*! * @brief This function moves the value in member a_limited_other_value * @param _a_limited_other_value New value to be moved in member a_limited_other_value */ eProsima_user_DllExport void a_limited_other_value( - std::vector&& _a_limited_other_value); + std::vector&& _a_limited_other_value) + { + m_a_limited_other_value = std::move(_a_limited_other_value); + } /*! * @brief This function returns a constant reference to member a_limited_other_value * @return Constant reference to member a_limited_other_value */ - eProsima_user_DllExport const std::vector& a_limited_other_value() const; + eProsima_user_DllExport const std::vector& a_limited_other_value() const + { + return m_a_limited_other_value; + } /*! * @brief This function returns a reference to member a_limited_other_value * @return Reference to member a_limited_other_value */ - eProsima_user_DllExport std::vector& a_limited_other_value(); + eProsima_user_DllExport std::vector& a_limited_other_value() + { + return m_a_limited_other_value; + } + + private: @@ -303,8 +394,6 @@ class SecondLevelElement std::vector m_a_limited_other_value; }; - - /*! * @brief This class represents the structure FirstLevelElement defined by the user in the IDL file. * @ingroup complex_nested_arrays @@ -316,80 +405,134 @@ class FirstLevelElement /*! * @brief Default constructor. */ - eProsima_user_DllExport FirstLevelElement(); + eProsima_user_DllExport FirstLevelElement() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~FirstLevelElement(); + eProsima_user_DllExport ~FirstLevelElement() + { + } /*! * @brief Copy constructor. * @param x Reference to the object FirstLevelElement that will be copied. */ eProsima_user_DllExport FirstLevelElement( - const FirstLevelElement& x); + const FirstLevelElement& x) + { + m_useless_name = x.m_useless_name; + + m_sub = x.m_sub; + + m_an_element_alone = x.m_an_element_alone; + + } /*! * @brief Move constructor. * @param x Reference to the object FirstLevelElement that will be copied. */ eProsima_user_DllExport FirstLevelElement( - FirstLevelElement&& x) noexcept; + FirstLevelElement&& x) noexcept + { + m_useless_name = std::move(x.m_useless_name); + m_sub = std::move(x.m_sub); + m_an_element_alone = std::move(x.m_an_element_alone); + } /*! * @brief Copy assignment. * @param x Reference to the object FirstLevelElement that will be copied. */ eProsima_user_DllExport FirstLevelElement& operator =( - const FirstLevelElement& x); + const FirstLevelElement& x) + { + + m_useless_name = x.m_useless_name; + + m_sub = x.m_sub; + + m_an_element_alone = x.m_an_element_alone; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object FirstLevelElement that will be copied. */ eProsima_user_DllExport FirstLevelElement& operator =( - FirstLevelElement&& x) noexcept; + FirstLevelElement&& x) noexcept + { + + m_useless_name = std::move(x.m_useless_name); + m_sub = std::move(x.m_sub); + m_an_element_alone = std::move(x.m_an_element_alone); + return *this; + } /*! * @brief Comparison operator. * @param x FirstLevelElement object to compare. */ eProsima_user_DllExport bool operator ==( - const FirstLevelElement& x) const; + const FirstLevelElement& x) const + { + return (m_useless_name == x.m_useless_name && + m_sub == x.m_sub && + m_an_element_alone == x.m_an_element_alone); + } /*! * @brief Comparison operator. * @param x FirstLevelElement object to compare. */ eProsima_user_DllExport bool operator !=( - const FirstLevelElement& x) const; + const FirstLevelElement& x) const + { + return !(*this == x); + } /*! * @brief This function copies the value in member useless_name * @param _useless_name New value to be copied in member useless_name */ eProsima_user_DllExport void useless_name( - const std::string& _useless_name); + const std::string& _useless_name) + { + m_useless_name = _useless_name; + } /*! * @brief This function moves the value in member useless_name * @param _useless_name New value to be moved in member useless_name */ eProsima_user_DllExport void useless_name( - std::string&& _useless_name); + std::string&& _useless_name) + { + m_useless_name = std::move(_useless_name); + } /*! * @brief This function returns a constant reference to member useless_name * @return Constant reference to member useless_name */ - eProsima_user_DllExport const std::string& useless_name() const; + eProsima_user_DllExport const std::string& useless_name() const + { + return m_useless_name; + } /*! * @brief This function returns a reference to member useless_name * @return Reference to member useless_name */ - eProsima_user_DllExport std::string& useless_name(); + eProsima_user_DllExport std::string& useless_name() + { + return m_useless_name; + } /*! @@ -397,26 +540,38 @@ class FirstLevelElement * @param _sub New value to be copied in member sub */ eProsima_user_DllExport void sub( - const std::vector& _sub); + const std::vector& _sub) + { + m_sub = _sub; + } /*! * @brief This function moves the value in member sub * @param _sub New value to be moved in member sub */ eProsima_user_DllExport void sub( - std::vector&& _sub); + std::vector&& _sub) + { + m_sub = std::move(_sub); + } /*! * @brief This function returns a constant reference to member sub * @return Constant reference to member sub */ - eProsima_user_DllExport const std::vector& sub() const; + eProsima_user_DllExport const std::vector& sub() const + { + return m_sub; + } /*! * @brief This function returns a reference to member sub * @return Reference to member sub */ - eProsima_user_DllExport std::vector& sub(); + eProsima_user_DllExport std::vector& sub() + { + return m_sub; + } /*! @@ -424,26 +579,40 @@ class FirstLevelElement * @param _an_element_alone New value to be copied in member an_element_alone */ eProsima_user_DllExport void an_element_alone( - const ThirdLevelElement& _an_element_alone); + const ThirdLevelElement& _an_element_alone) + { + m_an_element_alone = _an_element_alone; + } /*! * @brief This function moves the value in member an_element_alone * @param _an_element_alone New value to be moved in member an_element_alone */ eProsima_user_DllExport void an_element_alone( - ThirdLevelElement&& _an_element_alone); + ThirdLevelElement&& _an_element_alone) + { + m_an_element_alone = std::move(_an_element_alone); + } /*! * @brief This function returns a constant reference to member an_element_alone * @return Constant reference to member an_element_alone */ - eProsima_user_DllExport const ThirdLevelElement& an_element_alone() const; + eProsima_user_DllExport const ThirdLevelElement& an_element_alone() const + { + return m_an_element_alone; + } /*! * @brief This function returns a reference to member an_element_alone * @return Reference to member an_element_alone */ - eProsima_user_DllExport ThirdLevelElement& an_element_alone(); + eProsima_user_DllExport ThirdLevelElement& an_element_alone() + { + return m_an_element_alone; + } + + private: @@ -452,8 +621,6 @@ class FirstLevelElement ThirdLevelElement m_an_element_alone; }; - - /*! * @brief This class represents the structure complex_nested_arrays defined by the user in the IDL file. * @ingroup complex_nested_arrays @@ -465,80 +632,122 @@ class complex_nested_arrays /*! * @brief Default constructor. */ - eProsima_user_DllExport complex_nested_arrays(); + eProsima_user_DllExport complex_nested_arrays() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~complex_nested_arrays(); + eProsima_user_DllExport ~complex_nested_arrays() + { + } /*! * @brief Copy constructor. * @param x Reference to the object complex_nested_arrays that will be copied. */ eProsima_user_DllExport complex_nested_arrays( - const complex_nested_arrays& x); + const complex_nested_arrays& x) + { + m_array_of_elements = x.m_array_of_elements; + + } /*! * @brief Move constructor. * @param x Reference to the object complex_nested_arrays that will be copied. */ eProsima_user_DllExport complex_nested_arrays( - complex_nested_arrays&& x) noexcept; + complex_nested_arrays&& x) noexcept + { + m_array_of_elements = std::move(x.m_array_of_elements); + } /*! * @brief Copy assignment. * @param x Reference to the object complex_nested_arrays that will be copied. */ eProsima_user_DllExport complex_nested_arrays& operator =( - const complex_nested_arrays& x); + const complex_nested_arrays& x) + { + + m_array_of_elements = x.m_array_of_elements; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object complex_nested_arrays that will be copied. */ eProsima_user_DllExport complex_nested_arrays& operator =( - complex_nested_arrays&& x) noexcept; + complex_nested_arrays&& x) noexcept + { + + m_array_of_elements = std::move(x.m_array_of_elements); + return *this; + } /*! * @brief Comparison operator. * @param x complex_nested_arrays object to compare. */ eProsima_user_DllExport bool operator ==( - const complex_nested_arrays& x) const; + const complex_nested_arrays& x) const + { + return (m_array_of_elements == x.m_array_of_elements); + } /*! * @brief Comparison operator. * @param x complex_nested_arrays object to compare. */ eProsima_user_DllExport bool operator !=( - const complex_nested_arrays& x) const; + const complex_nested_arrays& x) const + { + return !(*this == x); + } /*! * @brief This function copies the value in member array_of_elements * @param _array_of_elements New value to be copied in member array_of_elements */ eProsima_user_DllExport void array_of_elements( - const std::array& _array_of_elements); + const std::array& _array_of_elements) + { + m_array_of_elements = _array_of_elements; + } /*! * @brief This function moves the value in member array_of_elements * @param _array_of_elements New value to be moved in member array_of_elements */ eProsima_user_DllExport void array_of_elements( - std::array&& _array_of_elements); + std::array&& _array_of_elements) + { + m_array_of_elements = std::move(_array_of_elements); + } /*! * @brief This function returns a constant reference to member array_of_elements * @return Constant reference to member array_of_elements */ - eProsima_user_DllExport const std::array& array_of_elements() const; + eProsima_user_DllExport const std::array& array_of_elements() const + { + return m_array_of_elements; + } /*! * @brief This function returns a reference to member array_of_elements * @return Reference to member array_of_elements */ - eProsima_user_DllExport std::array& array_of_elements(); + eProsima_user_DllExport std::array& array_of_elements() + { + return m_array_of_elements; + } + + private: @@ -546,8 +755,6 @@ class complex_nested_arrays }; -#endif // _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYS_H_ - +#endif // _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYS_HPP_ -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysCdrAux.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysCdrAux.hpp similarity index 89% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysCdrAux.hpp rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysCdrAux.hpp index c8b7f3c1..d5085176 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysCdrAux.hpp +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysCdrAux.hpp @@ -19,10 +19,10 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYSCDRAUX_HPP_ -#define _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYSCDRAUX_HPP_ +#ifndef FAST_DDS_GENERATED__COMPLEX_NESTED_ARRAYSCDRAUX_HPP +#define FAST_DDS_GENERATED__COMPLEX_NESTED_ARRAYSCDRAUX_HPP -#include "complex_nested_arrays.h" +#include "complex_nested_arrays.hpp" constexpr uint32_t FirstLevelElement_max_cdr_typesize {296UL}; constexpr uint32_t FirstLevelElement_max_key_cdr_typesize {0UL}; @@ -43,28 +43,18 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const ThirdLevelElement& data); - - - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const SecondLevelElement& data); - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const FirstLevelElement& data); - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const complex_nested_arrays& data); @@ -73,5 +63,5 @@ eProsima_user_DllExport void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYSCDRAUX_HPP_ +#endif // FAST_DDS_GENERATED__COMPLEX_NESTED_ARRAYSCDRAUX_HPP diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysCdrAux.ipp b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysCdrAux.ipp similarity index 93% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysCdrAux.ipp rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysCdrAux.ipp index 89a965ad..143f7253 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysCdrAux.ipp +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysCdrAux.ipp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYSCDRAUX_IPP_ -#define _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYSCDRAUX_IPP_ +#ifndef FAST_DDS_GENERATED__COMPLEX_NESTED_ARRAYSCDRAUX_IPP +#define FAST_DDS_GENERATED__COMPLEX_NESTED_ARRAYSCDRAUX_IPP #include "complex_nested_arraysCdrAux.hpp" @@ -34,8 +34,6 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { - - template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -115,13 +113,14 @@ void serialize_key( eprosima::fastcdr::Cdr& scdr, const ThirdLevelElement& data) { + static_cast(scdr); static_cast(data); -} - - + scdr << data.x(); + scdr << data.y(); +} template<> @@ -203,11 +202,19 @@ void serialize_key( eprosima::fastcdr::Cdr& scdr, const SecondLevelElement& data) { + extern void serialize_key( + Cdr& scdr, + const ThirdLevelElement& data); + + + static_cast(scdr); static_cast(data); -} + serialize_key(scdr, data.an_element_alone()); + scdr << data.a_limited_other_value(); +} template<> @@ -297,11 +304,20 @@ void serialize_key( eprosima::fastcdr::Cdr& scdr, const FirstLevelElement& data) { + extern void serialize_key( + Cdr& scdr, + const ThirdLevelElement& data); + + static_cast(scdr); static_cast(data); -} + scdr << data.useless_name(); + scdr << data.sub(); + serialize_key(scdr, data.an_element_alone()); + +} template<> @@ -375,8 +391,11 @@ void serialize_key( eprosima::fastcdr::Cdr& scdr, const complex_nested_arrays& data) { + static_cast(scdr); static_cast(data); + scdr << data.array_of_elements(); + } @@ -384,5 +403,5 @@ void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYSCDRAUX_IPP_ +#endif // FAST_DDS_GENERATED__COMPLEX_NESTED_ARRAYSCDRAUX_IPP diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysPubSubTypes.cxx new file mode 100644 index 00000000..1797b2e6 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysPubSubTypes.cxx @@ -0,0 +1,760 @@ +// 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 complex_nested_arraysPubSubTypes.cpp + * This header file contains the implementation of the serialization functions. + * + * This file was generated by the tool fastddsgen. + */ + +#include "complex_nested_arraysPubSubTypes.hpp" + +#include +#include + +#include "complex_nested_arraysCdrAux.hpp" +#include "complex_nested_arraysTypeObjectSupport.hpp" + +using SerializedPayload_t = eprosima::fastdds::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t; +using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; + +ThirdLevelElementPubSubType::ThirdLevelElementPubSubType() +{ + set_name("ThirdLevelElement"); + uint32_t type_size = ThirdLevelElement_max_cdr_typesize; + type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = ThirdLevelElement_max_key_cdr_typesize > 16 ? ThirdLevelElement_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); +} + +ThirdLevelElementPubSubType::~ThirdLevelElementPubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool ThirdLevelElementPubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const ThirdLevelElement* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); + payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + ser.set_encoding_flag( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + ser << *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool ThirdLevelElementPubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + ThirdLevelElement* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + deser >> *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + return true; +} + +uint32_t ThirdLevelElementPubSubType::calculate_serialized_size( + const void* const data, + DataRepresentationId_t data_representation) +{ + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +} + +void* ThirdLevelElementPubSubType::create_data() +{ + return reinterpret_cast(new ThirdLevelElement()); +} + +void ThirdLevelElementPubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool ThirdLevelElementPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + ThirdLevelElement data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool ThirdLevelElementPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const ThirdLevelElement* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + ThirdLevelElement_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); + ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); + eprosima::fastcdr::serialize_key(ser, *p_type); + if (force_md5 || ThirdLevelElement_max_key_cdr_typesize > 16) + { + md5_.init(); + md5_.update(key_buffer_, static_cast(ser.get_serialized_data_length())); + md5_.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle.value[i] = md5_.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle.value[i] = key_buffer_[i]; + } + } + return true; +} + +void ThirdLevelElementPubSubType::register_type_object_representation() +{ + register_ThirdLevelElement_type_identifier(type_identifiers_); +} + +SecondLevelElementPubSubType::SecondLevelElementPubSubType() +{ + set_name("SecondLevelElement"); + uint32_t type_size = SecondLevelElement_max_cdr_typesize; + type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = SecondLevelElement_max_key_cdr_typesize > 16 ? SecondLevelElement_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); +} + +SecondLevelElementPubSubType::~SecondLevelElementPubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool SecondLevelElementPubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const SecondLevelElement* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); + payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + ser.set_encoding_flag( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + ser << *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool SecondLevelElementPubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + SecondLevelElement* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + deser >> *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + return true; +} + +uint32_t SecondLevelElementPubSubType::calculate_serialized_size( + const void* const data, + DataRepresentationId_t data_representation) +{ + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +} + +void* SecondLevelElementPubSubType::create_data() +{ + return reinterpret_cast(new SecondLevelElement()); +} + +void SecondLevelElementPubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool SecondLevelElementPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + SecondLevelElement data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool SecondLevelElementPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const SecondLevelElement* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + SecondLevelElement_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); + ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); + eprosima::fastcdr::serialize_key(ser, *p_type); + if (force_md5 || SecondLevelElement_max_key_cdr_typesize > 16) + { + md5_.init(); + md5_.update(key_buffer_, static_cast(ser.get_serialized_data_length())); + md5_.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle.value[i] = md5_.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle.value[i] = key_buffer_[i]; + } + } + return true; +} + +void SecondLevelElementPubSubType::register_type_object_representation() +{ + register_SecondLevelElement_type_identifier(type_identifiers_); +} + +FirstLevelElementPubSubType::FirstLevelElementPubSubType() +{ + set_name("FirstLevelElement"); + uint32_t type_size = FirstLevelElement_max_cdr_typesize; + type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = FirstLevelElement_max_key_cdr_typesize > 16 ? FirstLevelElement_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); +} + +FirstLevelElementPubSubType::~FirstLevelElementPubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool FirstLevelElementPubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const FirstLevelElement* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); + payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + ser.set_encoding_flag( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + ser << *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool FirstLevelElementPubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + FirstLevelElement* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + deser >> *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + return true; +} + +uint32_t FirstLevelElementPubSubType::calculate_serialized_size( + const void* const data, + DataRepresentationId_t data_representation) +{ + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +} + +void* FirstLevelElementPubSubType::create_data() +{ + return reinterpret_cast(new FirstLevelElement()); +} + +void FirstLevelElementPubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool FirstLevelElementPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + FirstLevelElement data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool FirstLevelElementPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const FirstLevelElement* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + FirstLevelElement_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); + ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); + eprosima::fastcdr::serialize_key(ser, *p_type); + if (force_md5 || FirstLevelElement_max_key_cdr_typesize > 16) + { + md5_.init(); + md5_.update(key_buffer_, static_cast(ser.get_serialized_data_length())); + md5_.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle.value[i] = md5_.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle.value[i] = key_buffer_[i]; + } + } + return true; +} + +void FirstLevelElementPubSubType::register_type_object_representation() +{ + register_FirstLevelElement_type_identifier(type_identifiers_); +} + +complex_nested_arraysPubSubType::complex_nested_arraysPubSubType() +{ + set_name("complex_nested_arrays"); + uint32_t type_size = complex_nested_arrays_max_cdr_typesize; + type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = complex_nested_arrays_max_key_cdr_typesize > 16 ? complex_nested_arrays_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); +} + +complex_nested_arraysPubSubType::~complex_nested_arraysPubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool complex_nested_arraysPubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const complex_nested_arrays* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); + payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + ser.set_encoding_flag( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + ser << *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool complex_nested_arraysPubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + complex_nested_arrays* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + deser >> *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + return true; +} + +uint32_t complex_nested_arraysPubSubType::calculate_serialized_size( + const void* const data, + DataRepresentationId_t data_representation) +{ + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +} + +void* complex_nested_arraysPubSubType::create_data() +{ + return reinterpret_cast(new complex_nested_arrays()); +} + +void complex_nested_arraysPubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool complex_nested_arraysPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + complex_nested_arrays data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool complex_nested_arraysPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + const complex_nested_arrays* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + complex_nested_arrays_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); + ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); + eprosima::fastcdr::serialize_key(ser, *p_type); + if (force_md5 || complex_nested_arrays_max_key_cdr_typesize > 16) + { + md5_.init(); + md5_.update(key_buffer_, static_cast(ser.get_serialized_data_length())); + md5_.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle.value[i] = md5_.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle.value[i] = key_buffer_[i]; + } + } + return true; +} + +void complex_nested_arraysPubSubType::register_type_object_representation() +{ + register_complex_nested_arrays_type_identifier(type_identifiers_); +} + + +// Include auxiliary functions like for serializing/deserializing. +#include "complex_nested_arraysCdrAux.ipp" diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysPubSubTypes.hpp similarity index 56% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysPubSubTypes.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysPubSubTypes.hpp index ccf44d80..5d9d8177 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysPubSubTypes.h +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysPubSubTypes.hpp @@ -13,31 +13,29 @@ // limitations under the License. /*! - * @file complex_nested_arraysPubSubTypes.h + * @file complex_nested_arraysPubSubTypes.hpp * This header file contains the declaration of the serialization functions. * * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYS_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYS_PUBSUBTYPES_H_ +#ifndef FAST_DDS_GENERATED__COMPLEX_NESTED_ARRAYS_PUBSUBTYPES_HPP +#define FAST_DDS_GENERATED__COMPLEX_NESTED_ARRAYS_PUBSUBTYPES_HPP #include #include -#include -#include -#include +#include +#include +#include -#include "complex_nested_arrays.h" +#include "complex_nested_arrays.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated complex_nested_arrays is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER - - +#endif // FASTDDS_GEN_API_VER /*! @@ -55,41 +53,36 @@ class ThirdLevelElementPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport ~ThirdLevelElementPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t& payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + eProsima_user_DllExport uint32_t calculate_serialized_size( + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + eProsima_user_DllExport bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport bool compute_key( + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -99,13 +92,9 @@ class ThirdLevelElementPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -123,14 +112,12 @@ class ThirdLevelElementPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - - +private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; +}; /*! * @brief This class represents the TopicDataType of the type SecondLevelElement defined by the user in the IDL file. @@ -147,41 +134,36 @@ class SecondLevelElementPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport ~SecondLevelElementPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t& payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + eProsima_user_DllExport uint32_t calculate_serialized_size( + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + eProsima_user_DllExport bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport bool compute_key( + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -191,13 +173,9 @@ class SecondLevelElementPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -215,12 +193,12 @@ class SecondLevelElementPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; +private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; +}; /*! * @brief This class represents the TopicDataType of the type FirstLevelElement defined by the user in the IDL file. @@ -237,41 +215,36 @@ class FirstLevelElementPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport ~FirstLevelElementPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t& payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + eProsima_user_DllExport uint32_t calculate_serialized_size( + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + eProsima_user_DllExport bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport bool compute_key( + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -281,13 +254,9 @@ class FirstLevelElementPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -305,12 +274,12 @@ class FirstLevelElementPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; +private: + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; +}; /*! * @brief This class represents the TopicDataType of the type complex_nested_arrays defined by the user in the IDL file. @@ -327,41 +296,36 @@ class complex_nested_arraysPubSubType : public eprosima::fastdds::dds::TopicData eProsima_user_DllExport ~complex_nested_arraysPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t& payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + eProsima_user_DllExport uint32_t calculate_serialized_size( + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + eProsima_user_DllExport bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport bool compute_key( + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -371,13 +335,9 @@ class complex_nested_arraysPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -395,10 +355,12 @@ class complex_nested_arraysPubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; -#endif // _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYS_PUBSUBTYPES_H_ +#endif // FAST_DDS_GENERATED__COMPLEX_NESTED_ARRAYS_PUBSUBTYPES_HPP diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysTypeObjectSupport.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysTypeObjectSupport.cxx new file mode 100644 index 00000000..2e9d0cf4 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysTypeObjectSupport.cxx @@ -0,0 +1,493 @@ +// 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 complex_nested_arraysTypeObjectSupport.cxx + * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#include "complex_nested_arraysTypeObjectSupport.hpp" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "complex_nested_arrays.hpp" + + +using namespace eprosima::fastdds::dds::xtypes; + +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_ThirdLevelElement_type_identifier( + TypeIdentifierPair& type_ids_ThirdLevelElement) +{ + + ReturnCode_t return_code_ThirdLevelElement {eprosima::fastdds::dds::RETCODE_OK}; + return_code_ThirdLevelElement = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "ThirdLevelElement", type_ids_ThirdLevelElement); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_ThirdLevelElement) + { + StructTypeFlag struct_flags_ThirdLevelElement = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_ThirdLevelElement = "ThirdLevelElement"; + eprosima::fastcdr::optional type_ann_builtin_ThirdLevelElement; + eprosima::fastcdr::optional ann_custom_ThirdLevelElement; + CompleteTypeDetail detail_ThirdLevelElement = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_ThirdLevelElement, ann_custom_ThirdLevelElement, type_name_ThirdLevelElement.to_string()); + CompleteStructHeader header_ThirdLevelElement; + header_ThirdLevelElement = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_ThirdLevelElement); + CompleteStructMemberSeq member_seq_ThirdLevelElement; + { + TypeIdentifierPair type_ids_x; + ReturnCode_t return_code_x {eprosima::fastdds::dds::RETCODE_OK}; + return_code_x = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_double", type_ids_x); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_x) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "x Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_x = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_x = 0x00000000; + bool common_x_ec {false}; + CommonStructMember common_x {TypeObjectUtils::build_common_struct_member(member_id_x, member_flags_x, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_x, common_x_ec))}; + if (!common_x_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure x member TypeIdentifier inconsistent."); + return; + } + MemberName name_x = "x"; + eprosima::fastcdr::optional member_ann_builtin_x; + ann_custom_ThirdLevelElement.reset(); + CompleteMemberDetail detail_x = TypeObjectUtils::build_complete_member_detail(name_x, member_ann_builtin_x, ann_custom_ThirdLevelElement); + CompleteStructMember member_x = TypeObjectUtils::build_complete_struct_member(common_x, detail_x); + TypeObjectUtils::add_complete_struct_member(member_seq_ThirdLevelElement, member_x); + } + { + TypeIdentifierPair type_ids_y; + ReturnCode_t return_code_y {eprosima::fastdds::dds::RETCODE_OK}; + return_code_y = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_double", type_ids_y); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_y) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "y Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_y = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_y = 0x00000001; + bool common_y_ec {false}; + CommonStructMember common_y {TypeObjectUtils::build_common_struct_member(member_id_y, member_flags_y, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_y, common_y_ec))}; + if (!common_y_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure y member TypeIdentifier inconsistent."); + return; + } + MemberName name_y = "y"; + eprosima::fastcdr::optional member_ann_builtin_y; + ann_custom_ThirdLevelElement.reset(); + CompleteMemberDetail detail_y = TypeObjectUtils::build_complete_member_detail(name_y, member_ann_builtin_y, ann_custom_ThirdLevelElement); + CompleteStructMember member_y = TypeObjectUtils::build_complete_struct_member(common_y, detail_y); + TypeObjectUtils::add_complete_struct_member(member_seq_ThirdLevelElement, member_y); + } + CompleteStructType struct_type_ThirdLevelElement = TypeObjectUtils::build_complete_struct_type(struct_flags_ThirdLevelElement, header_ThirdLevelElement, member_seq_ThirdLevelElement); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_ThirdLevelElement, type_name_ThirdLevelElement.to_string(), type_ids_ThirdLevelElement)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "ThirdLevelElement already registered in TypeObjectRegistry for a different type."); + } + } +} +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_SecondLevelElement_type_identifier( + TypeIdentifierPair& type_ids_SecondLevelElement) +{ + + ReturnCode_t return_code_SecondLevelElement {eprosima::fastdds::dds::RETCODE_OK}; + return_code_SecondLevelElement = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "SecondLevelElement", type_ids_SecondLevelElement); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_SecondLevelElement) + { + StructTypeFlag struct_flags_SecondLevelElement = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_SecondLevelElement = "SecondLevelElement"; + eprosima::fastcdr::optional type_ann_builtin_SecondLevelElement; + eprosima::fastcdr::optional ann_custom_SecondLevelElement; + CompleteTypeDetail detail_SecondLevelElement = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_SecondLevelElement, ann_custom_SecondLevelElement, type_name_SecondLevelElement.to_string()); + CompleteStructHeader header_SecondLevelElement; + header_SecondLevelElement = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_SecondLevelElement); + CompleteStructMemberSeq member_seq_SecondLevelElement; + { + TypeIdentifierPair type_ids_an_element_alone; + ReturnCode_t return_code_an_element_alone {eprosima::fastdds::dds::RETCODE_OK}; + return_code_an_element_alone = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "ThirdLevelElement", type_ids_an_element_alone); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_an_element_alone) + { + ::register_ThirdLevelElement_type_identifier(type_ids_an_element_alone); + } + StructMemberFlag member_flags_an_element_alone = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_an_element_alone = 0x00000000; + bool common_an_element_alone_ec {false}; + CommonStructMember common_an_element_alone {TypeObjectUtils::build_common_struct_member(member_id_an_element_alone, member_flags_an_element_alone, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_an_element_alone, common_an_element_alone_ec))}; + if (!common_an_element_alone_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure an_element_alone member TypeIdentifier inconsistent."); + return; + } + MemberName name_an_element_alone = "an_element_alone"; + eprosima::fastcdr::optional member_ann_builtin_an_element_alone; + ann_custom_SecondLevelElement.reset(); + CompleteMemberDetail detail_an_element_alone = TypeObjectUtils::build_complete_member_detail(name_an_element_alone, member_ann_builtin_an_element_alone, ann_custom_SecondLevelElement); + CompleteStructMember member_an_element_alone = TypeObjectUtils::build_complete_struct_member(common_an_element_alone, detail_an_element_alone); + TypeObjectUtils::add_complete_struct_member(member_seq_SecondLevelElement, member_an_element_alone); + } + { + TypeIdentifierPair type_ids_a_limited_other_value; + ReturnCode_t return_code_a_limited_other_value {eprosima::fastdds::dds::RETCODE_OK}; + return_code_a_limited_other_value = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_sequence_ThirdLevelElement_1", type_ids_a_limited_other_value); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_a_limited_other_value) + { + return_code_a_limited_other_value = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "ThirdLevelElement", type_ids_a_limited_other_value); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_a_limited_other_value) + { + ::register_ThirdLevelElement_type_identifier(type_ids_a_limited_other_value); + } + bool element_identifier_anonymous_sequence_ThirdLevelElement_1_ec {false}; + TypeIdentifier* element_identifier_anonymous_sequence_ThirdLevelElement_1 {new TypeIdentifier(TypeObjectUtils::retrieve_complete_type_identifier(type_ids_a_limited_other_value, element_identifier_anonymous_sequence_ThirdLevelElement_1_ec))}; + if (!element_identifier_anonymous_sequence_ThirdLevelElement_1_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Sequence element TypeIdentifier inconsistent."); + return; + } + EquivalenceKind equiv_kind_anonymous_sequence_ThirdLevelElement_1 = EK_COMPLETE; + if (TK_NONE == type_ids_a_limited_other_value.type_identifier2()._d()) + { + equiv_kind_anonymous_sequence_ThirdLevelElement_1 = EK_BOTH; + } + CollectionElementFlag element_flags_anonymous_sequence_ThirdLevelElement_1 = 0; + PlainCollectionHeader header_anonymous_sequence_ThirdLevelElement_1 = TypeObjectUtils::build_plain_collection_header(equiv_kind_anonymous_sequence_ThirdLevelElement_1, element_flags_anonymous_sequence_ThirdLevelElement_1); + { + SBound bound = static_cast(1); + PlainSequenceSElemDefn seq_sdefn = TypeObjectUtils::build_plain_sequence_s_elem_defn(header_anonymous_sequence_ThirdLevelElement_1, bound, + eprosima::fastcdr::external(element_identifier_anonymous_sequence_ThirdLevelElement_1)); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_sequence_type_identifier(seq_sdefn, "anonymous_sequence_ThirdLevelElement_1", type_ids_a_limited_other_value)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_sequence_ThirdLevelElement_1 already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_a_limited_other_value = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_a_limited_other_value = 0x00000001; + bool common_a_limited_other_value_ec {false}; + CommonStructMember common_a_limited_other_value {TypeObjectUtils::build_common_struct_member(member_id_a_limited_other_value, member_flags_a_limited_other_value, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_a_limited_other_value, common_a_limited_other_value_ec))}; + if (!common_a_limited_other_value_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure a_limited_other_value member TypeIdentifier inconsistent."); + return; + } + MemberName name_a_limited_other_value = "a_limited_other_value"; + eprosima::fastcdr::optional member_ann_builtin_a_limited_other_value; + ann_custom_SecondLevelElement.reset(); + CompleteMemberDetail detail_a_limited_other_value = TypeObjectUtils::build_complete_member_detail(name_a_limited_other_value, member_ann_builtin_a_limited_other_value, ann_custom_SecondLevelElement); + CompleteStructMember member_a_limited_other_value = TypeObjectUtils::build_complete_struct_member(common_a_limited_other_value, detail_a_limited_other_value); + TypeObjectUtils::add_complete_struct_member(member_seq_SecondLevelElement, member_a_limited_other_value); + } + CompleteStructType struct_type_SecondLevelElement = TypeObjectUtils::build_complete_struct_type(struct_flags_SecondLevelElement, header_SecondLevelElement, member_seq_SecondLevelElement); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_SecondLevelElement, type_name_SecondLevelElement.to_string(), type_ids_SecondLevelElement)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "SecondLevelElement already registered in TypeObjectRegistry for a different type."); + } + } +} +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_FirstLevelElement_type_identifier( + TypeIdentifierPair& type_ids_FirstLevelElement) +{ + + ReturnCode_t return_code_FirstLevelElement {eprosima::fastdds::dds::RETCODE_OK}; + return_code_FirstLevelElement = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "FirstLevelElement", type_ids_FirstLevelElement); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_FirstLevelElement) + { + StructTypeFlag struct_flags_FirstLevelElement = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_FirstLevelElement = "FirstLevelElement"; + eprosima::fastcdr::optional type_ann_builtin_FirstLevelElement; + eprosima::fastcdr::optional ann_custom_FirstLevelElement; + CompleteTypeDetail detail_FirstLevelElement = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_FirstLevelElement, ann_custom_FirstLevelElement, type_name_FirstLevelElement.to_string()); + CompleteStructHeader header_FirstLevelElement; + header_FirstLevelElement = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_FirstLevelElement); + CompleteStructMemberSeq member_seq_FirstLevelElement; + { + TypeIdentifierPair type_ids_useless_name; + ReturnCode_t return_code_useless_name {eprosima::fastdds::dds::RETCODE_OK}; + return_code_useless_name = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_string_unbounded", type_ids_useless_name); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_useless_name) + { + { + SBound bound = 0; + StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, + "anonymous_string_unbounded", type_ids_useless_name)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_useless_name = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_useless_name = 0x00000000; + bool common_useless_name_ec {false}; + CommonStructMember common_useless_name {TypeObjectUtils::build_common_struct_member(member_id_useless_name, member_flags_useless_name, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_useless_name, common_useless_name_ec))}; + if (!common_useless_name_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure useless_name member TypeIdentifier inconsistent."); + return; + } + MemberName name_useless_name = "useless_name"; + eprosima::fastcdr::optional member_ann_builtin_useless_name; + ann_custom_FirstLevelElement.reset(); + CompleteMemberDetail detail_useless_name = TypeObjectUtils::build_complete_member_detail(name_useless_name, member_ann_builtin_useless_name, ann_custom_FirstLevelElement); + CompleteStructMember member_useless_name = TypeObjectUtils::build_complete_struct_member(common_useless_name, detail_useless_name); + TypeObjectUtils::add_complete_struct_member(member_seq_FirstLevelElement, member_useless_name); + } + { + TypeIdentifierPair type_ids_sub; + ReturnCode_t return_code_sub {eprosima::fastdds::dds::RETCODE_OK}; + return_code_sub = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_sequence_SecondLevelElement_unbounded", type_ids_sub); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_sub) + { + return_code_sub = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "SecondLevelElement", type_ids_sub); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_sub) + { + ::register_SecondLevelElement_type_identifier(type_ids_sub); + } + bool element_identifier_anonymous_sequence_SecondLevelElement_unbounded_ec {false}; + TypeIdentifier* element_identifier_anonymous_sequence_SecondLevelElement_unbounded {new TypeIdentifier(TypeObjectUtils::retrieve_complete_type_identifier(type_ids_sub, element_identifier_anonymous_sequence_SecondLevelElement_unbounded_ec))}; + if (!element_identifier_anonymous_sequence_SecondLevelElement_unbounded_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Sequence element TypeIdentifier inconsistent."); + return; + } + EquivalenceKind equiv_kind_anonymous_sequence_SecondLevelElement_unbounded = EK_COMPLETE; + if (TK_NONE == type_ids_sub.type_identifier2()._d()) + { + equiv_kind_anonymous_sequence_SecondLevelElement_unbounded = EK_BOTH; + } + CollectionElementFlag element_flags_anonymous_sequence_SecondLevelElement_unbounded = 0; + PlainCollectionHeader header_anonymous_sequence_SecondLevelElement_unbounded = TypeObjectUtils::build_plain_collection_header(equiv_kind_anonymous_sequence_SecondLevelElement_unbounded, element_flags_anonymous_sequence_SecondLevelElement_unbounded); + { + SBound bound = 0; + PlainSequenceSElemDefn seq_sdefn = TypeObjectUtils::build_plain_sequence_s_elem_defn(header_anonymous_sequence_SecondLevelElement_unbounded, bound, + eprosima::fastcdr::external(element_identifier_anonymous_sequence_SecondLevelElement_unbounded)); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_sequence_type_identifier(seq_sdefn, "anonymous_sequence_SecondLevelElement_unbounded", type_ids_sub)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_sequence_SecondLevelElement_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_sub = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_sub = 0x00000001; + bool common_sub_ec {false}; + CommonStructMember common_sub {TypeObjectUtils::build_common_struct_member(member_id_sub, member_flags_sub, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_sub, common_sub_ec))}; + if (!common_sub_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure sub member TypeIdentifier inconsistent."); + return; + } + MemberName name_sub = "sub"; + eprosima::fastcdr::optional member_ann_builtin_sub; + ann_custom_FirstLevelElement.reset(); + CompleteMemberDetail detail_sub = TypeObjectUtils::build_complete_member_detail(name_sub, member_ann_builtin_sub, ann_custom_FirstLevelElement); + CompleteStructMember member_sub = TypeObjectUtils::build_complete_struct_member(common_sub, detail_sub); + TypeObjectUtils::add_complete_struct_member(member_seq_FirstLevelElement, member_sub); + } + { + TypeIdentifierPair type_ids_an_element_alone; + ReturnCode_t return_code_an_element_alone {eprosima::fastdds::dds::RETCODE_OK}; + return_code_an_element_alone = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "ThirdLevelElement", type_ids_an_element_alone); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_an_element_alone) + { + ::register_ThirdLevelElement_type_identifier(type_ids_an_element_alone); + } + StructMemberFlag member_flags_an_element_alone = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_an_element_alone = 0x00000002; + bool common_an_element_alone_ec {false}; + CommonStructMember common_an_element_alone {TypeObjectUtils::build_common_struct_member(member_id_an_element_alone, member_flags_an_element_alone, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_an_element_alone, common_an_element_alone_ec))}; + if (!common_an_element_alone_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure an_element_alone member TypeIdentifier inconsistent."); + return; + } + MemberName name_an_element_alone = "an_element_alone"; + eprosima::fastcdr::optional member_ann_builtin_an_element_alone; + ann_custom_FirstLevelElement.reset(); + CompleteMemberDetail detail_an_element_alone = TypeObjectUtils::build_complete_member_detail(name_an_element_alone, member_ann_builtin_an_element_alone, ann_custom_FirstLevelElement); + CompleteStructMember member_an_element_alone = TypeObjectUtils::build_complete_struct_member(common_an_element_alone, detail_an_element_alone); + TypeObjectUtils::add_complete_struct_member(member_seq_FirstLevelElement, member_an_element_alone); + } + CompleteStructType struct_type_FirstLevelElement = TypeObjectUtils::build_complete_struct_type(struct_flags_FirstLevelElement, header_FirstLevelElement, member_seq_FirstLevelElement); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_FirstLevelElement, type_name_FirstLevelElement.to_string(), type_ids_FirstLevelElement)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "FirstLevelElement already registered in TypeObjectRegistry for a different type."); + } + } +} +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_complex_nested_arrays_type_identifier( + TypeIdentifierPair& type_ids_complex_nested_arrays) +{ + + ReturnCode_t return_code_complex_nested_arrays {eprosima::fastdds::dds::RETCODE_OK}; + return_code_complex_nested_arrays = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "complex_nested_arrays", type_ids_complex_nested_arrays); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_complex_nested_arrays) + { + StructTypeFlag struct_flags_complex_nested_arrays = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_complex_nested_arrays = "complex_nested_arrays"; + eprosima::fastcdr::optional type_ann_builtin_complex_nested_arrays; + eprosima::fastcdr::optional ann_custom_complex_nested_arrays; + CompleteTypeDetail detail_complex_nested_arrays = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_complex_nested_arrays, ann_custom_complex_nested_arrays, type_name_complex_nested_arrays.to_string()); + CompleteStructHeader header_complex_nested_arrays; + header_complex_nested_arrays = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_complex_nested_arrays); + CompleteStructMemberSeq member_seq_complex_nested_arrays; + { + TypeIdentifierPair type_ids_array_of_elements; + ReturnCode_t return_code_array_of_elements {eprosima::fastdds::dds::RETCODE_OK}; + return_code_array_of_elements = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_array_FirstLevelElement_3", type_ids_array_of_elements); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_array_of_elements) + { + return_code_array_of_elements = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "FirstLevelElement", type_ids_array_of_elements); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_array_of_elements) + { + ::register_FirstLevelElement_type_identifier(type_ids_array_of_elements); + } + bool element_identifier_anonymous_array_FirstLevelElement_3_ec {false}; + TypeIdentifier* element_identifier_anonymous_array_FirstLevelElement_3 {new TypeIdentifier(TypeObjectUtils::retrieve_complete_type_identifier(type_ids_array_of_elements, element_identifier_anonymous_array_FirstLevelElement_3_ec))}; + if (!element_identifier_anonymous_array_FirstLevelElement_3_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Array element TypeIdentifier inconsistent."); + return; + } + EquivalenceKind equiv_kind_anonymous_array_FirstLevelElement_3 = EK_COMPLETE; + if (TK_NONE == type_ids_array_of_elements.type_identifier2()._d()) + { + equiv_kind_anonymous_array_FirstLevelElement_3 = EK_BOTH; + } + CollectionElementFlag element_flags_anonymous_array_FirstLevelElement_3 = 0; + PlainCollectionHeader header_anonymous_array_FirstLevelElement_3 = TypeObjectUtils::build_plain_collection_header(equiv_kind_anonymous_array_FirstLevelElement_3, element_flags_anonymous_array_FirstLevelElement_3); + { + SBoundSeq array_bound_seq; + TypeObjectUtils::add_array_dimension(array_bound_seq, static_cast(3)); + + PlainArraySElemDefn array_sdefn = TypeObjectUtils::build_plain_array_s_elem_defn(header_anonymous_array_FirstLevelElement_3, array_bound_seq, + eprosima::fastcdr::external(element_identifier_anonymous_array_FirstLevelElement_3)); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_array_type_identifier(array_sdefn, "anonymous_array_FirstLevelElement_3", type_ids_array_of_elements)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_array_FirstLevelElement_3 already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_array_of_elements = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_array_of_elements = 0x00000000; + bool common_array_of_elements_ec {false}; + CommonStructMember common_array_of_elements {TypeObjectUtils::build_common_struct_member(member_id_array_of_elements, member_flags_array_of_elements, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_array_of_elements, common_array_of_elements_ec))}; + if (!common_array_of_elements_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure array_of_elements member TypeIdentifier inconsistent."); + return; + } + MemberName name_array_of_elements = "array_of_elements"; + eprosima::fastcdr::optional member_ann_builtin_array_of_elements; + ann_custom_complex_nested_arrays.reset(); + CompleteMemberDetail detail_array_of_elements = TypeObjectUtils::build_complete_member_detail(name_array_of_elements, member_ann_builtin_array_of_elements, ann_custom_complex_nested_arrays); + CompleteStructMember member_array_of_elements = TypeObjectUtils::build_complete_struct_member(common_array_of_elements, detail_array_of_elements); + TypeObjectUtils::add_complete_struct_member(member_seq_complex_nested_arrays, member_array_of_elements); + } + CompleteStructType struct_type_complex_nested_arrays = TypeObjectUtils::build_complete_struct_type(struct_flags_complex_nested_arrays, header_complex_nested_arrays, member_seq_complex_nested_arrays); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_complex_nested_arrays, type_name_complex_nested_arrays.to_string(), type_ids_complex_nested_arrays)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "complex_nested_arrays already registered in TypeObjectRegistry for a different type."); + } + } +} + diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysTypeObjectSupport.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysTypeObjectSupport.hpp new file mode 100644 index 00000000..aec5bb21 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysTypeObjectSupport.hpp @@ -0,0 +1,92 @@ +// 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 complex_nested_arraysTypeObjectSupport.hpp + * Header file containing the API required to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef FAST_DDS_GENERATED__COMPLEX_NESTED_ARRAYS_TYPE_OBJECT_SUPPORT_HPP +#define FAST_DDS_GENERATED__COMPLEX_NESTED_ARRAYS_TYPE_OBJECT_SUPPORT_HPP + +#include + + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +/** + * @brief Register ThirdLevelElement related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_ThirdLevelElement_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); +/** + * @brief Register SecondLevelElement related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_SecondLevelElement_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); +/** + * @brief Register FirstLevelElement related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_FirstLevelElement_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); +/** + * @brief Register complex_nested_arrays related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_complex_nested_arrays_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); + + +#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +#endif // FAST_DDS_GENERATED__COMPLEX_NESTED_ARRAYS_TYPE_OBJECT_SUPPORT_HPP diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequence.h b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequence.hpp similarity index 72% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequence.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequence.hpp index 589247f3..641f52d9 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequence.h +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequence.hpp @@ -13,32 +13,19 @@ // limitations under the License. /*! - * @file float_bounded_sequence.h + * @file float_bounded_sequence.hpp * This header file contains the declaration of the described types in the IDL file. * * This file was generated by the tool fastddsgen. */ -#include -#include "float_bounded_sequencev1.h" +#ifndef FAST_DDS_GENERATED__FLOAT_BOUNDED_SEQUENCE_HPP +#define FAST_DDS_GENERATED__FLOAT_BOUNDED_SEQUENCE_HPP -#if FASTCDR_VERSION_MAJOR > 1 - -#ifndef _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCE_H_ -#define _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCE_H_ - -#include -#include #include -#include -#include +#include #include -#include -#include -#include - - #if defined(_WIN32) #if defined(EPROSIMA_USER_DLL_EXPORT) @@ -64,19 +51,6 @@ #define FLOAT_BOUNDED_SEQUENCE_DllAPI #endif // _WIN32 -namespace eprosima { -namespace fastcdr { -class Cdr; -class CdrSizeCalculator; -} // namespace fastcdr -} // namespace eprosima - - - - - - - /*! * @brief This class represents the structure float_bounded_sequence defined by the user in the IDL file. * @ingroup float_bounded_sequence @@ -88,80 +62,122 @@ class float_bounded_sequence /*! * @brief Default constructor. */ - eProsima_user_DllExport float_bounded_sequence(); + eProsima_user_DllExport float_bounded_sequence() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~float_bounded_sequence(); + eProsima_user_DllExport ~float_bounded_sequence() + { + } /*! * @brief Copy constructor. * @param x Reference to the object float_bounded_sequence that will be copied. */ eProsima_user_DllExport float_bounded_sequence( - const float_bounded_sequence& x); + const float_bounded_sequence& x) + { + m_numbers = x.m_numbers; + + } /*! * @brief Move constructor. * @param x Reference to the object float_bounded_sequence that will be copied. */ eProsima_user_DllExport float_bounded_sequence( - float_bounded_sequence&& x) noexcept; + float_bounded_sequence&& x) noexcept + { + m_numbers = std::move(x.m_numbers); + } /*! * @brief Copy assignment. * @param x Reference to the object float_bounded_sequence that will be copied. */ eProsima_user_DllExport float_bounded_sequence& operator =( - const float_bounded_sequence& x); + const float_bounded_sequence& x) + { + + m_numbers = x.m_numbers; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object float_bounded_sequence that will be copied. */ eProsima_user_DllExport float_bounded_sequence& operator =( - float_bounded_sequence&& x) noexcept; + float_bounded_sequence&& x) noexcept + { + + m_numbers = std::move(x.m_numbers); + return *this; + } /*! * @brief Comparison operator. * @param x float_bounded_sequence object to compare. */ eProsima_user_DllExport bool operator ==( - const float_bounded_sequence& x) const; + const float_bounded_sequence& x) const + { + return (m_numbers == x.m_numbers); + } /*! * @brief Comparison operator. * @param x float_bounded_sequence object to compare. */ eProsima_user_DllExport bool operator !=( - const float_bounded_sequence& x) const; + const float_bounded_sequence& x) const + { + return !(*this == x); + } /*! * @brief This function copies the value in member numbers * @param _numbers New value to be copied in member numbers */ eProsima_user_DllExport void numbers( - const std::vector& _numbers); + const std::vector& _numbers) + { + m_numbers = _numbers; + } /*! * @brief This function moves the value in member numbers * @param _numbers New value to be moved in member numbers */ eProsima_user_DllExport void numbers( - std::vector&& _numbers); + std::vector&& _numbers) + { + m_numbers = std::move(_numbers); + } /*! * @brief This function returns a constant reference to member numbers * @return Constant reference to member numbers */ - eProsima_user_DllExport const std::vector& numbers() const; + eProsima_user_DllExport const std::vector& numbers() const + { + return m_numbers; + } /*! * @brief This function returns a reference to member numbers * @return Reference to member numbers */ - eProsima_user_DllExport std::vector& numbers(); + eProsima_user_DllExport std::vector& numbers() + { + return m_numbers; + } + + private: @@ -169,8 +185,6 @@ class float_bounded_sequence }; -#endif // _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCE_H_ - +#endif // _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCE_HPP_ -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequenceCdrAux.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequenceCdrAux.hpp similarity index 84% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequenceCdrAux.hpp rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequenceCdrAux.hpp index 3dd5f268..d41f390b 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequenceCdrAux.hpp +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequenceCdrAux.hpp @@ -19,10 +19,10 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCECDRAUX_HPP_ -#define _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCECDRAUX_HPP_ +#ifndef FAST_DDS_GENERATED__FLOAT_BOUNDED_SEQUENCECDRAUX_HPP +#define FAST_DDS_GENERATED__FLOAT_BOUNDED_SEQUENCECDRAUX_HPP -#include "float_bounded_sequence.h" +#include "float_bounded_sequence.hpp" constexpr uint32_t float_bounded_sequence_max_cdr_typesize {60UL}; constexpr uint32_t float_bounded_sequence_max_key_cdr_typesize {0UL}; @@ -34,10 +34,6 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; - - - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const float_bounded_sequence& data); @@ -46,5 +42,5 @@ eProsima_user_DllExport void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCECDRAUX_HPP_ +#endif // FAST_DDS_GENERATED__FLOAT_BOUNDED_SEQUENCECDRAUX_HPP diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequenceCdrAux.ipp b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequenceCdrAux.ipp similarity index 94% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequenceCdrAux.ipp rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequenceCdrAux.ipp index 38b04790..59ec9e74 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequenceCdrAux.ipp +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequenceCdrAux.ipp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCECDRAUX_IPP_ -#define _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCECDRAUX_IPP_ +#ifndef FAST_DDS_GENERATED__FLOAT_BOUNDED_SEQUENCECDRAUX_IPP +#define FAST_DDS_GENERATED__FLOAT_BOUNDED_SEQUENCECDRAUX_IPP #include "float_bounded_sequenceCdrAux.hpp" @@ -34,10 +34,6 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { - - - - template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -109,8 +105,11 @@ void serialize_key( eprosima::fastcdr::Cdr& scdr, const float_bounded_sequence& data) { + static_cast(scdr); static_cast(data); + scdr << data.numbers(); + } @@ -118,5 +117,5 @@ void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCECDRAUX_IPP_ +#endif // FAST_DDS_GENERATED__FLOAT_BOUNDED_SEQUENCECDRAUX_IPP diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequencePubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequencePubSubTypes.cxx similarity index 50% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequencePubSubTypes.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequencePubSubTypes.cxx index 4fba25e6..5381942f 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequencePubSubTypes.cxx +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequencePubSubTypes.cxx @@ -19,65 +19,56 @@ * This file was generated by the tool fastddsgen. */ +#include "float_bounded_sequencePubSubTypes.hpp" +#include #include -#include "float_bounded_sequencePubSubTypes.h" #include "float_bounded_sequenceCdrAux.hpp" +#include "float_bounded_sequenceTypeObjectSupport.hpp" -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; +using SerializedPayload_t = eprosima::fastdds::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - - - - float_bounded_sequencePubSubType::float_bounded_sequencePubSubType() { - setName("float_bounded_sequence"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(float_bounded_sequence::getMaxCdrSerializedSize()); -#else - float_bounded_sequence_max_cdr_typesize; -#endif + set_name("float_bounded_sequence"); + uint32_t type_size = float_bounded_sequence_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = float_bounded_sequence_max_key_cdr_typesize > 16 ? float_bounded_sequence_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = float_bounded_sequence_max_key_cdr_typesize > 16 ? float_bounded_sequence_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } float_bounded_sequencePubSubType::~float_bounded_sequencePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool float_bounded_sequencePubSubType::serialize( - void* data, - SerializedPayload_t* payload, + const void* const data, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { - float_bounded_sequence* p_type = static_cast(data); + const float_bounded_sequence* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; ser.set_encoding_flag( data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -92,16 +83,12 @@ bool float_bounded_sequencePubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool float_bounded_sequencePubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -110,18 +97,14 @@ bool float_bounded_sequencePubSubType::deserialize( float_bounded_sequence* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); // Deserialize encapsulation. deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -134,90 +117,101 @@ bool float_bounded_sequencePubSubType::deserialize( return true; } -std::function float_bounded_sequencePubSubType::getSerializedSizeProvider( - void* data, +uint32_t float_bounded_sequencePubSubType::calculate_serialized_size( + const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } } -void* float_bounded_sequencePubSubType::createData() +void* float_bounded_sequencePubSubType::create_data() { return reinterpret_cast(new float_bounded_sequence()); } -void float_bounded_sequencePubSubType::deleteData( +void float_bounded_sequencePubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool float_bounded_sequencePubSubType::getKey( - void* data, - InstanceHandle_t* handle, +bool float_bounded_sequencePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + float_bounded_sequence data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool float_bounded_sequencePubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } - float_bounded_sequence* p_type = static_cast(data); + const float_bounded_sequence* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), float_bounded_sequence_max_key_cdr_typesize); // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); + ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || float_bounded_sequence_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + md5_.init(); + md5_.update(key_buffer_, static_cast(ser.get_serialized_data_length())); + md5_.finalize(); for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; } +void float_bounded_sequencePubSubType::register_type_object_representation() +{ + register_float_bounded_sequence_type_identifier(type_identifiers_); +} + + +// Include auxiliary functions like for serializing/deserializing. +#include "float_bounded_sequenceCdrAux.ipp" diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequencePubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequencePubSubTypes.hpp similarity index 59% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequencePubSubTypes.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequencePubSubTypes.hpp index cbdad218..f4529c6a 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequencePubSubTypes.h +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequencePubSubTypes.hpp @@ -13,33 +13,29 @@ // limitations under the License. /*! - * @file float_bounded_sequencePubSubTypes.h + * @file float_bounded_sequencePubSubTypes.hpp * This header file contains the declaration of the serialization functions. * * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCE_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCE_PUBSUBTYPES_H_ +#ifndef FAST_DDS_GENERATED__FLOAT_BOUNDED_SEQUENCE_PUBSUBTYPES_HPP +#define FAST_DDS_GENERATED__FLOAT_BOUNDED_SEQUENCE_PUBSUBTYPES_HPP #include #include -#include -#include -#include +#include +#include +#include -#include "float_bounded_sequence.h" +#include "float_bounded_sequence.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated float_bounded_sequence is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER - - - - +#endif // FASTDDS_GEN_API_VER /*! @@ -57,41 +53,36 @@ class float_bounded_sequencePubSubType : public eprosima::fastdds::dds::TopicDat eProsima_user_DllExport ~float_bounded_sequencePubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t& payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + eProsima_user_DllExport uint32_t calculate_serialized_size( + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + eProsima_user_DllExport bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport bool compute_key( + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, + bool force_md5 = false) override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void* create_data() override; + + eProsima_user_DllExport void delete_data( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -101,13 +92,9 @@ class float_bounded_sequencePubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -125,10 +112,12 @@ class float_bounded_sequencePubSubType : public eprosima::fastdds::dds::TopicDat #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; -#endif // _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCE_PUBSUBTYPES_H_ +#endif // FAST_DDS_GENERATED__FLOAT_BOUNDED_SEQUENCE_PUBSUBTYPES_HPP diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequenceTypeObjectSupport.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequenceTypeObjectSupport.cxx new file mode 100644 index 00000000..aa6108f6 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequenceTypeObjectSupport.cxx @@ -0,0 +1,132 @@ +// 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 float_bounded_sequenceTypeObjectSupport.cxx + * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#include "float_bounded_sequenceTypeObjectSupport.hpp" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "float_bounded_sequence.hpp" + + +using namespace eprosima::fastdds::dds::xtypes; + +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_float_bounded_sequence_type_identifier( + TypeIdentifierPair& type_ids_float_bounded_sequence) +{ + + ReturnCode_t return_code_float_bounded_sequence {eprosima::fastdds::dds::RETCODE_OK}; + return_code_float_bounded_sequence = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "float_bounded_sequence", type_ids_float_bounded_sequence); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_float_bounded_sequence) + { + StructTypeFlag struct_flags_float_bounded_sequence = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_float_bounded_sequence = "float_bounded_sequence"; + eprosima::fastcdr::optional type_ann_builtin_float_bounded_sequence; + eprosima::fastcdr::optional ann_custom_float_bounded_sequence; + CompleteTypeDetail detail_float_bounded_sequence = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_float_bounded_sequence, ann_custom_float_bounded_sequence, type_name_float_bounded_sequence.to_string()); + CompleteStructHeader header_float_bounded_sequence; + header_float_bounded_sequence = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_float_bounded_sequence); + CompleteStructMemberSeq member_seq_float_bounded_sequence; + { + TypeIdentifierPair type_ids_numbers; + ReturnCode_t return_code_numbers {eprosima::fastdds::dds::RETCODE_OK}; + return_code_numbers = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_sequence_float_13", type_ids_numbers); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_numbers) + { + return_code_numbers = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_float", type_ids_numbers); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_numbers) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "Sequence element TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + bool element_identifier_anonymous_sequence_float_13_ec {false}; + TypeIdentifier* element_identifier_anonymous_sequence_float_13 {new TypeIdentifier(TypeObjectUtils::retrieve_complete_type_identifier(type_ids_numbers, element_identifier_anonymous_sequence_float_13_ec))}; + if (!element_identifier_anonymous_sequence_float_13_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Sequence element TypeIdentifier inconsistent."); + return; + } + EquivalenceKind equiv_kind_anonymous_sequence_float_13 = EK_COMPLETE; + if (TK_NONE == type_ids_numbers.type_identifier2()._d()) + { + equiv_kind_anonymous_sequence_float_13 = EK_BOTH; + } + CollectionElementFlag element_flags_anonymous_sequence_float_13 = 0; + PlainCollectionHeader header_anonymous_sequence_float_13 = TypeObjectUtils::build_plain_collection_header(equiv_kind_anonymous_sequence_float_13, element_flags_anonymous_sequence_float_13); + { + SBound bound = static_cast(13); + PlainSequenceSElemDefn seq_sdefn = TypeObjectUtils::build_plain_sequence_s_elem_defn(header_anonymous_sequence_float_13, bound, + eprosima::fastcdr::external(element_identifier_anonymous_sequence_float_13)); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_sequence_type_identifier(seq_sdefn, "anonymous_sequence_float_13", type_ids_numbers)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_sequence_float_13 already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_numbers = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_numbers = 0x00000000; + bool common_numbers_ec {false}; + CommonStructMember common_numbers {TypeObjectUtils::build_common_struct_member(member_id_numbers, member_flags_numbers, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_numbers, common_numbers_ec))}; + if (!common_numbers_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure numbers member TypeIdentifier inconsistent."); + return; + } + MemberName name_numbers = "numbers"; + eprosima::fastcdr::optional member_ann_builtin_numbers; + ann_custom_float_bounded_sequence.reset(); + CompleteMemberDetail detail_numbers = TypeObjectUtils::build_complete_member_detail(name_numbers, member_ann_builtin_numbers, ann_custom_float_bounded_sequence); + CompleteStructMember member_numbers = TypeObjectUtils::build_complete_struct_member(common_numbers, detail_numbers); + TypeObjectUtils::add_complete_struct_member(member_seq_float_bounded_sequence, member_numbers); + } + CompleteStructType struct_type_float_bounded_sequence = TypeObjectUtils::build_complete_struct_type(struct_flags_float_bounded_sequence, header_float_bounded_sequence, member_seq_float_bounded_sequence); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_float_bounded_sequence, type_name_float_bounded_sequence.to_string(), type_ids_float_bounded_sequence)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "float_bounded_sequence already registered in TypeObjectRegistry for a different type."); + } + } +} + diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequenceTypeObjectSupport.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequenceTypeObjectSupport.hpp new file mode 100644 index 00000000..78dab6b6 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequenceTypeObjectSupport.hpp @@ -0,0 +1,56 @@ +// 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 float_bounded_sequenceTypeObjectSupport.hpp + * Header file containing the API required to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef FAST_DDS_GENERATED__FLOAT_BOUNDED_SEQUENCE_TYPE_OBJECT_SUPPORT_HPP +#define FAST_DDS_GENERATED__FLOAT_BOUNDED_SEQUENCE_TYPE_OBJECT_SUPPORT_HPP + +#include + + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +/** + * @brief Register float_bounded_sequence related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_float_bounded_sequence_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); + + +#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +#endif // FAST_DDS_GENERATED__FLOAT_BOUNDED_SEQUENCE_TYPE_OBJECT_SUPPORT_HPP diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_world.h b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_world.hpp similarity index 69% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_world.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_world.hpp index 0b5eaad1..27ca777d 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_world.h +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_world.hpp @@ -13,32 +13,19 @@ // limitations under the License. /*! - * @file hello_world.h + * @file hello_world.hpp * This header file contains the declaration of the described types in the IDL file. * * This file was generated by the tool fastddsgen. */ -#include -#include "hello_worldv1.h" +#ifndef FAST_DDS_GENERATED__HELLO_WORLD_HPP +#define FAST_DDS_GENERATED__HELLO_WORLD_HPP -#if FASTCDR_VERSION_MAJOR > 1 - -#ifndef _FAST_DDS_GENERATED_HELLO_WORLD_H_ -#define _FAST_DDS_GENERATED_HELLO_WORLD_H_ - -#include -#include #include -#include #include -#include - +#include #include -#include -#include - - #if defined(_WIN32) #if defined(EPROSIMA_USER_DLL_EXPORT) @@ -64,17 +51,6 @@ #define HELLO_WORLD_DllAPI #endif // _WIN32 -namespace eprosima { -namespace fastcdr { -class Cdr; -class CdrSizeCalculator; -} // namespace fastcdr -} // namespace eprosima - - - - - /*! * @brief This class represents the structure hello_world defined by the user in the IDL file. * @ingroup hello_world @@ -86,73 +62,117 @@ class hello_world /*! * @brief Default constructor. */ - eProsima_user_DllExport hello_world(); + eProsima_user_DllExport hello_world() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~hello_world(); + eProsima_user_DllExport ~hello_world() + { + } /*! * @brief Copy constructor. * @param x Reference to the object hello_world that will be copied. */ eProsima_user_DllExport hello_world( - const hello_world& x); + const hello_world& x) + { + m_index = x.m_index; + + m_message = x.m_message; + + } /*! * @brief Move constructor. * @param x Reference to the object hello_world that will be copied. */ eProsima_user_DllExport hello_world( - hello_world&& x) noexcept; + hello_world&& x) noexcept + { + m_index = x.m_index; + m_message = std::move(x.m_message); + } /*! * @brief Copy assignment. * @param x Reference to the object hello_world that will be copied. */ eProsima_user_DllExport hello_world& operator =( - const hello_world& x); + const hello_world& x) + { + + m_index = x.m_index; + + m_message = x.m_message; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object hello_world that will be copied. */ eProsima_user_DllExport hello_world& operator =( - hello_world&& x) noexcept; + hello_world&& x) noexcept + { + + m_index = x.m_index; + m_message = std::move(x.m_message); + return *this; + } /*! * @brief Comparison operator. * @param x hello_world object to compare. */ eProsima_user_DllExport bool operator ==( - const hello_world& x) const; + const hello_world& x) const + { + return (m_index == x.m_index && + m_message == x.m_message); + } /*! * @brief Comparison operator. * @param x hello_world object to compare. */ eProsima_user_DllExport bool operator !=( - const hello_world& x) const; + const hello_world& x) const + { + return !(*this == x); + } /*! * @brief This function sets a value in member index * @param _index New value for member index */ eProsima_user_DllExport void index( - uint32_t _index); + uint32_t _index) + { + m_index = _index; + } /*! * @brief This function returns the value of member index * @return Value of member index */ - eProsima_user_DllExport uint32_t index() const; + eProsima_user_DllExport uint32_t index() const + { + return m_index; + } /*! * @brief This function returns a reference to member index * @return Reference to member index */ - eProsima_user_DllExport uint32_t& index(); + eProsima_user_DllExport uint32_t& index() + { + return m_index; + } /*! @@ -160,26 +180,40 @@ class hello_world * @param _message New value to be copied in member message */ eProsima_user_DllExport void message( - const std::string& _message); + const std::string& _message) + { + m_message = _message; + } /*! * @brief This function moves the value in member message * @param _message New value to be moved in member message */ eProsima_user_DllExport void message( - std::string&& _message); + std::string&& _message) + { + m_message = std::move(_message); + } /*! * @brief This function returns a constant reference to member message * @return Constant reference to member message */ - eProsima_user_DllExport const std::string& message() const; + eProsima_user_DllExport const std::string& message() const + { + return m_message; + } /*! * @brief This function returns a reference to member message * @return Reference to member message */ - eProsima_user_DllExport std::string& message(); + eProsima_user_DllExport std::string& message() + { + return m_message; + } + + private: @@ -188,8 +222,6 @@ class hello_world }; -#endif // _FAST_DDS_GENERATED_HELLO_WORLD_H_ - +#endif // _FAST_DDS_GENERATED_HELLO_WORLD_HPP_ -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldCdrAux.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldCdrAux.hpp similarity index 86% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldCdrAux.hpp rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldCdrAux.hpp index 06dd7ebb..4837eee8 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldCdrAux.hpp +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldCdrAux.hpp @@ -19,10 +19,10 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_HELLO_WORLDCDRAUX_HPP_ -#define _FAST_DDS_GENERATED_HELLO_WORLDCDRAUX_HPP_ +#ifndef FAST_DDS_GENERATED__HELLO_WORLDCDRAUX_HPP +#define FAST_DDS_GENERATED__HELLO_WORLDCDRAUX_HPP -#include "hello_world.h" +#include "hello_world.hpp" constexpr uint32_t hello_world_max_cdr_typesize {268UL}; constexpr uint32_t hello_world_max_key_cdr_typesize {0UL}; @@ -34,8 +34,6 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const hello_world& data); @@ -44,5 +42,5 @@ eProsima_user_DllExport void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_HELLO_WORLDCDRAUX_HPP_ +#endif // FAST_DDS_GENERATED__HELLO_WORLDCDRAUX_HPP diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldCdrAux.ipp b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldCdrAux.ipp similarity index 94% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldCdrAux.ipp rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldCdrAux.ipp index cc6654cd..689099b3 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldCdrAux.ipp +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldCdrAux.ipp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_HELLO_WORLDCDRAUX_IPP_ -#define _FAST_DDS_GENERATED_HELLO_WORLDCDRAUX_IPP_ +#ifndef FAST_DDS_GENERATED__HELLO_WORLDCDRAUX_IPP +#define FAST_DDS_GENERATED__HELLO_WORLDCDRAUX_IPP #include "hello_worldCdrAux.hpp" @@ -34,8 +34,6 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { - - template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -115,8 +113,13 @@ void serialize_key( eprosima::fastcdr::Cdr& scdr, const hello_world& data) { + static_cast(scdr); static_cast(data); + scdr << data.index(); + + scdr << data.message(); + } @@ -124,5 +127,5 @@ void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_HELLO_WORLDCDRAUX_IPP_ +#endif // FAST_DDS_GENERATED__HELLO_WORLDCDRAUX_IPP diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldPubSubTypes.cxx similarity index 50% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldPubSubTypes.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldPubSubTypes.cxx index a3b93e2f..98a314b3 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldPubSubTypes.cxx +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldPubSubTypes.cxx @@ -19,63 +19,56 @@ * This file was generated by the tool fastddsgen. */ +#include "hello_worldPubSubTypes.hpp" +#include #include -#include "hello_worldPubSubTypes.h" #include "hello_worldCdrAux.hpp" +#include "hello_worldTypeObjectSupport.hpp" -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; +using SerializedPayload_t = eprosima::fastdds::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - - hello_worldPubSubType::hello_worldPubSubType() { - setName("hello_world"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(hello_world::getMaxCdrSerializedSize()); -#else - hello_world_max_cdr_typesize; -#endif + set_name("hello_world"); + uint32_t type_size = hello_world_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = hello_world_max_key_cdr_typesize > 16 ? hello_world_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = hello_world_max_key_cdr_typesize > 16 ? hello_world_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } hello_worldPubSubType::~hello_worldPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool hello_worldPubSubType::serialize( - void* data, - SerializedPayload_t* payload, + const void* const data, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { - hello_world* p_type = static_cast(data); + const hello_world* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; ser.set_encoding_flag( data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool hello_worldPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool hello_worldPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool hello_worldPubSubType::deserialize( hello_world* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); // Deserialize encapsulation. deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,90 +117,101 @@ bool hello_worldPubSubType::deserialize( return true; } -std::function hello_worldPubSubType::getSerializedSizeProvider( - void* data, +uint32_t hello_worldPubSubType::calculate_serialized_size( + const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } } -void* hello_worldPubSubType::createData() +void* hello_worldPubSubType::create_data() { return reinterpret_cast(new hello_world()); } -void hello_worldPubSubType::deleteData( +void hello_worldPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool hello_worldPubSubType::getKey( - void* data, - InstanceHandle_t* handle, +bool hello_worldPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + hello_world data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool hello_worldPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } - hello_world* p_type = static_cast(data); + const hello_world* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), hello_world_max_key_cdr_typesize); // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); + ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || hello_world_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + md5_.init(); + md5_.update(key_buffer_, static_cast(ser.get_serialized_data_length())); + md5_.finalize(); for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; } +void hello_worldPubSubType::register_type_object_representation() +{ + register_hello_world_type_identifier(type_identifiers_); +} + + +// Include auxiliary functions like for serializing/deserializing. +#include "hello_worldCdrAux.ipp" diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldPubSubTypes.hpp similarity index 59% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldPubSubTypes.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldPubSubTypes.hpp index 69aa2245..660a72a8 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldPubSubTypes.h +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldPubSubTypes.hpp @@ -13,31 +13,29 @@ // limitations under the License. /*! - * @file hello_worldPubSubTypes.h + * @file hello_worldPubSubTypes.hpp * This header file contains the declaration of the serialization functions. * * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_HELLO_WORLD_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_HELLO_WORLD_PUBSUBTYPES_H_ +#ifndef FAST_DDS_GENERATED__HELLO_WORLD_PUBSUBTYPES_HPP +#define FAST_DDS_GENERATED__HELLO_WORLD_PUBSUBTYPES_HPP #include #include -#include -#include -#include +#include +#include +#include -#include "hello_world.h" +#include "hello_world.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated hello_world is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER - - +#endif // FASTDDS_GEN_API_VER /*! @@ -55,41 +53,36 @@ class hello_worldPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport ~hello_worldPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t& payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + eProsima_user_DllExport uint32_t calculate_serialized_size( + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + eProsima_user_DllExport bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport bool compute_key( + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -99,13 +92,9 @@ class hello_worldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -123,10 +112,12 @@ class hello_worldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; -#endif // _FAST_DDS_GENERATED_HELLO_WORLD_PUBSUBTYPES_H_ +#endif // FAST_DDS_GENERATED__HELLO_WORLD_PUBSUBTYPES_HPP diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldTypeObjectSupport.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldTypeObjectSupport.cxx new file mode 100644 index 00000000..1c19ab81 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldTypeObjectSupport.cxx @@ -0,0 +1,138 @@ +// 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 hello_worldTypeObjectSupport.cxx + * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#include "hello_worldTypeObjectSupport.hpp" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "hello_world.hpp" + + +using namespace eprosima::fastdds::dds::xtypes; + +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_hello_world_type_identifier( + TypeIdentifierPair& type_ids_hello_world) +{ + + ReturnCode_t return_code_hello_world {eprosima::fastdds::dds::RETCODE_OK}; + return_code_hello_world = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "hello_world", type_ids_hello_world); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_hello_world) + { + StructTypeFlag struct_flags_hello_world = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_hello_world = "hello_world"; + eprosima::fastcdr::optional type_ann_builtin_hello_world; + eprosima::fastcdr::optional ann_custom_hello_world; + CompleteTypeDetail detail_hello_world = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_hello_world, ann_custom_hello_world, type_name_hello_world.to_string()); + CompleteStructHeader header_hello_world; + header_hello_world = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_hello_world); + CompleteStructMemberSeq member_seq_hello_world; + { + TypeIdentifierPair type_ids_index; + ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK}; + return_code_index = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_uint32_t", type_ids_index); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_index) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "index Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_index = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_index = 0x00000000; + bool common_index_ec {false}; + CommonStructMember common_index {TypeObjectUtils::build_common_struct_member(member_id_index, member_flags_index, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_index, common_index_ec))}; + if (!common_index_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure index member TypeIdentifier inconsistent."); + return; + } + MemberName name_index = "index"; + eprosima::fastcdr::optional member_ann_builtin_index; + ann_custom_hello_world.reset(); + CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_hello_world); + CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index); + TypeObjectUtils::add_complete_struct_member(member_seq_hello_world, member_index); + } + { + TypeIdentifierPair type_ids_message; + ReturnCode_t return_code_message {eprosima::fastdds::dds::RETCODE_OK}; + return_code_message = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_string_unbounded", type_ids_message); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_message) + { + { + SBound bound = 0; + StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, + "anonymous_string_unbounded", type_ids_message)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_message = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_message = 0x00000001; + bool common_message_ec {false}; + CommonStructMember common_message {TypeObjectUtils::build_common_struct_member(member_id_message, member_flags_message, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_message, common_message_ec))}; + if (!common_message_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure message member TypeIdentifier inconsistent."); + return; + } + MemberName name_message = "message"; + eprosima::fastcdr::optional member_ann_builtin_message; + ann_custom_hello_world.reset(); + CompleteMemberDetail detail_message = TypeObjectUtils::build_complete_member_detail(name_message, member_ann_builtin_message, ann_custom_hello_world); + CompleteStructMember member_message = TypeObjectUtils::build_complete_struct_member(common_message, detail_message); + TypeObjectUtils::add_complete_struct_member(member_seq_hello_world, member_message); + } + CompleteStructType struct_type_hello_world = TypeObjectUtils::build_complete_struct_type(struct_flags_hello_world, header_hello_world, member_seq_hello_world); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_hello_world, type_name_hello_world.to_string(), type_ids_hello_world)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "hello_world already registered in TypeObjectRegistry for a different type."); + } + } +} + diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldTypeObjectSupport.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldTypeObjectSupport.hpp new file mode 100644 index 00000000..d0a80dd8 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldTypeObjectSupport.hpp @@ -0,0 +1,56 @@ +// 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 hello_worldTypeObjectSupport.hpp + * Header file containing the API required to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef FAST_DDS_GENERATED__HELLO_WORLD_TYPE_OBJECT_SUPPORT_HPP +#define FAST_DDS_GENERATED__HELLO_WORLD_TYPE_OBJECT_SUPPORT_HPP + +#include + + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +/** + * @brief Register hello_world related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_hello_world_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); + + +#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +#endif // FAST_DDS_GENERATED__HELLO_WORLD_TYPE_OBJECT_SUPPORT_HPP diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_array.h b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_array.hpp similarity index 73% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_array.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_array.hpp index 60777854..a78917ad 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_array.h +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_array.hpp @@ -13,32 +13,18 @@ // limitations under the License. /*! - * @file numeric_array.h + * @file numeric_array.hpp * This header file contains the declaration of the described types in the IDL file. * * This file was generated by the tool fastddsgen. */ -#include -#include "numeric_arrayv1.h" - -#if FASTCDR_VERSION_MAJOR > 1 - -#ifndef _FAST_DDS_GENERATED_NUMERIC_ARRAY_H_ -#define _FAST_DDS_GENERATED_NUMERIC_ARRAY_H_ +#ifndef FAST_DDS_GENERATED__NUMERIC_ARRAY_HPP +#define FAST_DDS_GENERATED__NUMERIC_ARRAY_HPP #include -#include #include -#include -#include -#include - -#include -#include -#include - - +#include #if defined(_WIN32) #if defined(EPROSIMA_USER_DLL_EXPORT) @@ -64,17 +50,6 @@ #define NUMERIC_ARRAY_DllAPI #endif // _WIN32 -namespace eprosima { -namespace fastcdr { -class Cdr; -class CdrSizeCalculator; -} // namespace fastcdr -} // namespace eprosima - - - - - /*! * @brief This class represents the structure numeric_array defined by the user in the IDL file. * @ingroup numeric_array @@ -86,80 +61,122 @@ class numeric_array /*! * @brief Default constructor. */ - eProsima_user_DllExport numeric_array(); + eProsima_user_DllExport numeric_array() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~numeric_array(); + eProsima_user_DllExport ~numeric_array() + { + } /*! * @brief Copy constructor. * @param x Reference to the object numeric_array that will be copied. */ eProsima_user_DllExport numeric_array( - const numeric_array& x); + const numeric_array& x) + { + m_points = x.m_points; + + } /*! * @brief Move constructor. * @param x Reference to the object numeric_array that will be copied. */ eProsima_user_DllExport numeric_array( - numeric_array&& x) noexcept; + numeric_array&& x) noexcept + { + m_points = std::move(x.m_points); + } /*! * @brief Copy assignment. * @param x Reference to the object numeric_array that will be copied. */ eProsima_user_DllExport numeric_array& operator =( - const numeric_array& x); + const numeric_array& x) + { + + m_points = x.m_points; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object numeric_array that will be copied. */ eProsima_user_DllExport numeric_array& operator =( - numeric_array&& x) noexcept; + numeric_array&& x) noexcept + { + + m_points = std::move(x.m_points); + return *this; + } /*! * @brief Comparison operator. * @param x numeric_array object to compare. */ eProsima_user_DllExport bool operator ==( - const numeric_array& x) const; + const numeric_array& x) const + { + return (m_points == x.m_points); + } /*! * @brief Comparison operator. * @param x numeric_array object to compare. */ eProsima_user_DllExport bool operator !=( - const numeric_array& x) const; + const numeric_array& x) const + { + return !(*this == x); + } /*! * @brief This function copies the value in member points * @param _points New value to be copied in member points */ eProsima_user_DllExport void points( - const std::array& _points); + const std::array& _points) + { + m_points = _points; + } /*! * @brief This function moves the value in member points * @param _points New value to be moved in member points */ eProsima_user_DllExport void points( - std::array&& _points); + std::array&& _points) + { + m_points = std::move(_points); + } /*! * @brief This function returns a constant reference to member points * @return Constant reference to member points */ - eProsima_user_DllExport const std::array& points() const; + eProsima_user_DllExport const std::array& points() const + { + return m_points; + } /*! * @brief This function returns a reference to member points * @return Reference to member points */ - eProsima_user_DllExport std::array& points(); + eProsima_user_DllExport std::array& points() + { + return m_points; + } + + private: @@ -167,8 +184,6 @@ class numeric_array }; -#endif // _FAST_DDS_GENERATED_NUMERIC_ARRAY_H_ - +#endif // _FAST_DDS_GENERATED_NUMERIC_ARRAY_HPP_ -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayCdrAux.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayCdrAux.hpp similarity index 86% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayCdrAux.hpp rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayCdrAux.hpp index 29e623c1..a00c7007 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayCdrAux.hpp +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayCdrAux.hpp @@ -19,10 +19,10 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_NUMERIC_ARRAYCDRAUX_HPP_ -#define _FAST_DDS_GENERATED_NUMERIC_ARRAYCDRAUX_HPP_ +#ifndef FAST_DDS_GENERATED__NUMERIC_ARRAYCDRAUX_HPP +#define FAST_DDS_GENERATED__NUMERIC_ARRAYCDRAUX_HPP -#include "numeric_array.h" +#include "numeric_array.hpp" constexpr uint32_t numeric_array_max_cdr_typesize {16UL}; constexpr uint32_t numeric_array_max_key_cdr_typesize {0UL}; @@ -34,8 +34,6 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const numeric_array& data); @@ -44,5 +42,5 @@ eProsima_user_DllExport void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_NUMERIC_ARRAYCDRAUX_HPP_ +#endif // FAST_DDS_GENERATED__NUMERIC_ARRAYCDRAUX_HPP diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayCdrAux.ipp b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayCdrAux.ipp similarity index 94% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayCdrAux.ipp rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayCdrAux.ipp index 81c35d24..f7363c3a 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayCdrAux.ipp +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayCdrAux.ipp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_NUMERIC_ARRAYCDRAUX_IPP_ -#define _FAST_DDS_GENERATED_NUMERIC_ARRAYCDRAUX_IPP_ +#ifndef FAST_DDS_GENERATED__NUMERIC_ARRAYCDRAUX_IPP +#define FAST_DDS_GENERATED__NUMERIC_ARRAYCDRAUX_IPP #include "numeric_arrayCdrAux.hpp" @@ -34,8 +34,6 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { - - template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -107,8 +105,11 @@ void serialize_key( eprosima::fastcdr::Cdr& scdr, const numeric_array& data) { + static_cast(scdr); static_cast(data); + scdr << data.points(); + } @@ -116,5 +117,5 @@ void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_NUMERIC_ARRAYCDRAUX_IPP_ +#endif // FAST_DDS_GENERATED__NUMERIC_ARRAYCDRAUX_IPP diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayPubSubTypes.cxx similarity index 50% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayPubSubTypes.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayPubSubTypes.cxx index ad9c3508..736b1168 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayPubSubTypes.cxx +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayPubSubTypes.cxx @@ -19,63 +19,56 @@ * This file was generated by the tool fastddsgen. */ +#include "numeric_arrayPubSubTypes.hpp" +#include #include -#include "numeric_arrayPubSubTypes.h" #include "numeric_arrayCdrAux.hpp" +#include "numeric_arrayTypeObjectSupport.hpp" -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; +using SerializedPayload_t = eprosima::fastdds::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - - numeric_arrayPubSubType::numeric_arrayPubSubType() { - setName("numeric_array"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(numeric_array::getMaxCdrSerializedSize()); -#else - numeric_array_max_cdr_typesize; -#endif + set_name("numeric_array"); + uint32_t type_size = numeric_array_max_cdr_typesize; type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = numeric_array_max_key_cdr_typesize > 16 ? numeric_array_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = numeric_array_max_key_cdr_typesize > 16 ? numeric_array_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } numeric_arrayPubSubType::~numeric_arrayPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool numeric_arrayPubSubType::serialize( - void* data, - SerializedPayload_t* payload, + const void* const data, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { - numeric_array* p_type = static_cast(data); + const numeric_array* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 + payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; ser.set_encoding_flag( data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -90,16 +83,12 @@ bool numeric_arrayPubSubType::serialize( } // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool numeric_arrayPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool numeric_arrayPubSubType::deserialize( numeric_array* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); // Deserialize encapsulation. deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,90 +117,101 @@ bool numeric_arrayPubSubType::deserialize( return true; } -std::function numeric_arrayPubSubType::getSerializedSizeProvider( - void* data, +uint32_t numeric_arrayPubSubType::calculate_serialized_size( + const void* const data, DataRepresentationId_t data_representation) { - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } } -void* numeric_arrayPubSubType::createData() +void* numeric_arrayPubSubType::create_data() { return reinterpret_cast(new numeric_array()); } -void numeric_arrayPubSubType::deleteData( +void numeric_arrayPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool numeric_arrayPubSubType::getKey( - void* data, - InstanceHandle_t* handle, +bool numeric_arrayPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + numeric_array data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool numeric_arrayPubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } - numeric_array* p_type = static_cast(data); + const numeric_array* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), numeric_array_max_key_cdr_typesize); // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); + ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || numeric_array_max_key_cdr_typesize > 16) { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + md5_.init(); + md5_.update(key_buffer_, static_cast(ser.get_serialized_data_length())); + md5_.finalize(); for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; } +void numeric_arrayPubSubType::register_type_object_representation() +{ + register_numeric_array_type_identifier(type_identifiers_); +} + + +// Include auxiliary functions like for serializing/deserializing. +#include "numeric_arrayCdrAux.ipp" diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayPubSubTypes.hpp similarity index 59% rename from ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayPubSubTypes.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayPubSubTypes.hpp index 413df6d9..3f8dce29 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayPubSubTypes.h +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayPubSubTypes.hpp @@ -13,31 +13,29 @@ // limitations under the License. /*! - * @file numeric_arrayPubSubTypes.h + * @file numeric_arrayPubSubTypes.hpp * This header file contains the declaration of the serialization functions. * * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_NUMERIC_ARRAY_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_NUMERIC_ARRAY_PUBSUBTYPES_H_ +#ifndef FAST_DDS_GENERATED__NUMERIC_ARRAY_PUBSUBTYPES_HPP +#define FAST_DDS_GENERATED__NUMERIC_ARRAY_PUBSUBTYPES_HPP #include #include -#include -#include -#include +#include +#include +#include -#include "numeric_array.h" +#include "numeric_array.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated numeric_array is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER - - +#endif // FASTDDS_GEN_API_VER /*! @@ -55,41 +53,36 @@ class numeric_arrayPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport ~numeric_arrayPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t& payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + eProsima_user_DllExport uint32_t calculate_serialized_size( + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + eProsima_user_DllExport bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport bool compute_key( + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -99,13 +92,9 @@ class numeric_arrayPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -123,10 +112,12 @@ class numeric_arrayPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; -#endif // _FAST_DDS_GENERATED_NUMERIC_ARRAY_PUBSUBTYPES_H_ +#endif // FAST_DDS_GENERATED__NUMERIC_ARRAY_PUBSUBTYPES_HPP diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayTypeObjectSupport.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayTypeObjectSupport.cxx new file mode 100644 index 00000000..22b35f27 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayTypeObjectSupport.cxx @@ -0,0 +1,134 @@ +// 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 numeric_arrayTypeObjectSupport.cxx + * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#include "numeric_arrayTypeObjectSupport.hpp" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "numeric_array.hpp" + + +using namespace eprosima::fastdds::dds::xtypes; + +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_numeric_array_type_identifier( + TypeIdentifierPair& type_ids_numeric_array) +{ + + ReturnCode_t return_code_numeric_array {eprosima::fastdds::dds::RETCODE_OK}; + return_code_numeric_array = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "numeric_array", type_ids_numeric_array); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_numeric_array) + { + StructTypeFlag struct_flags_numeric_array = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_numeric_array = "numeric_array"; + eprosima::fastcdr::optional type_ann_builtin_numeric_array; + eprosima::fastcdr::optional ann_custom_numeric_array; + CompleteTypeDetail detail_numeric_array = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_numeric_array, ann_custom_numeric_array, type_name_numeric_array.to_string()); + CompleteStructHeader header_numeric_array; + header_numeric_array = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_numeric_array); + CompleteStructMemberSeq member_seq_numeric_array; + { + TypeIdentifierPair type_ids_points; + ReturnCode_t return_code_points {eprosima::fastdds::dds::RETCODE_OK}; + return_code_points = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_array_int32_t_3", type_ids_points); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_points) + { + return_code_points = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_int32_t", type_ids_points); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_points) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "Array element TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + bool element_identifier_anonymous_array_int32_t_3_ec {false}; + TypeIdentifier* element_identifier_anonymous_array_int32_t_3 {new TypeIdentifier(TypeObjectUtils::retrieve_complete_type_identifier(type_ids_points, element_identifier_anonymous_array_int32_t_3_ec))}; + if (!element_identifier_anonymous_array_int32_t_3_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Array element TypeIdentifier inconsistent."); + return; + } + EquivalenceKind equiv_kind_anonymous_array_int32_t_3 = EK_COMPLETE; + if (TK_NONE == type_ids_points.type_identifier2()._d()) + { + equiv_kind_anonymous_array_int32_t_3 = EK_BOTH; + } + CollectionElementFlag element_flags_anonymous_array_int32_t_3 = 0; + PlainCollectionHeader header_anonymous_array_int32_t_3 = TypeObjectUtils::build_plain_collection_header(equiv_kind_anonymous_array_int32_t_3, element_flags_anonymous_array_int32_t_3); + { + SBoundSeq array_bound_seq; + TypeObjectUtils::add_array_dimension(array_bound_seq, static_cast(3)); + + PlainArraySElemDefn array_sdefn = TypeObjectUtils::build_plain_array_s_elem_defn(header_anonymous_array_int32_t_3, array_bound_seq, + eprosima::fastcdr::external(element_identifier_anonymous_array_int32_t_3)); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_array_type_identifier(array_sdefn, "anonymous_array_int32_t_3", type_ids_points)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_array_int32_t_3 already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_points = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_points = 0x00000000; + bool common_points_ec {false}; + CommonStructMember common_points {TypeObjectUtils::build_common_struct_member(member_id_points, member_flags_points, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_points, common_points_ec))}; + if (!common_points_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure points member TypeIdentifier inconsistent."); + return; + } + MemberName name_points = "points"; + eprosima::fastcdr::optional member_ann_builtin_points; + ann_custom_numeric_array.reset(); + CompleteMemberDetail detail_points = TypeObjectUtils::build_complete_member_detail(name_points, member_ann_builtin_points, ann_custom_numeric_array); + CompleteStructMember member_points = TypeObjectUtils::build_complete_struct_member(common_points, detail_points); + TypeObjectUtils::add_complete_struct_member(member_seq_numeric_array, member_points); + } + CompleteStructType struct_type_numeric_array = TypeObjectUtils::build_complete_struct_type(struct_flags_numeric_array, header_numeric_array, member_seq_numeric_array); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_numeric_array, type_name_numeric_array.to_string(), type_ids_numeric_array)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "numeric_array already registered in TypeObjectRegistry for a different type."); + } + } +} + diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayTypeObjectSupport.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayTypeObjectSupport.hpp new file mode 100644 index 00000000..b6219fd7 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayTypeObjectSupport.hpp @@ -0,0 +1,56 @@ +// 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 numeric_arrayTypeObjectSupport.hpp + * Header file containing the API required to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef FAST_DDS_GENERATED__NUMERIC_ARRAY_TYPE_OBJECT_SUPPORT_HPP +#define FAST_DDS_GENERATED__NUMERIC_ARRAY_TYPE_OBJECT_SUPPORT_HPP + +#include + + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +/** + * @brief Register numeric_array related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_numeric_array_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); + + +#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +#endif // FAST_DDS_GENERATED__NUMERIC_ARRAY_TYPE_OBJECT_SUPPORT_HPP diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/all_types.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/all_types.hpp deleted file mode 100644 index 65fa0566..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/all_types.hpp +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright 2022 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_types.hpp - */ - -/* - * USEFUL COMMAND - * - * for TYPE in hello_world numeric_array char_sequence basic_struct basic_array_struct float_bounded_sequence arrays_and_sequences complex_nested_arrays; do ${FASTDDSGEN_WS}/scripts/fastddsgen -replace -d ${WS}/src/recorder/ddsrecorder/test/unittest/dynamic_types/types/type_objects/ -typeobject -cs ${WS}/src/recorder/ddsrecorder/test/unittest/dynamic_types/types/idls/${TYPE}.idl; done - */ - -#pragma once - -#include -#include -#include - -#include -#include -#include - -#include "type_objects/hello_worldTypeObject.h" -#include "type_objects/numeric_arrayTypeObject.h" -#include "type_objects/char_sequenceTypeObject.h" -#include "type_objects/basic_structTypeObject.h" -#include "type_objects/basic_array_structTypeObject.h" -#include "type_objects/float_bounded_sequenceTypeObject.h" -#include "type_objects/arrays_and_sequencesTypeObject.h" -#include "type_objects/complex_nested_arraysTypeObject.h" -#include "type_objects/enum_structTypeObject.h" -#include "type_objects/union_structTypeObject.h" -#include "type_objects/map_structTypeObject.h" - -namespace test { - -ENUMERATION_BUILDER( - SupportedType, - hello_world, - numeric_array, - char_sequence, - basic_struct, - basic_array_struct, - float_bounded_sequence, - arrays_and_sequences, - complex_nested_arrays, - enum_struct, - union_struct, // NOTE: default case currently not supported in dynamic types - map_struct - ); - -eprosima::fastrtps::types::DynamicType_ptr get_dynamic_type( - SupportedType type) -{ - registerhello_worldTypes(); - registernumeric_arrayTypes(); - registerchar_sequenceTypes(); - registerbasic_structTypes(); - registerbasic_array_structTypes(); - registerfloat_bounded_sequenceTypes(); - registerarrays_and_sequencesTypes(); - registercomplex_nested_arraysTypes(); - registerenum_structTypes(); - registerunion_structTypes(); - registermap_structTypes(); - - auto type_name = to_string(type); - - auto type_obj_factory = eprosima::fastrtps::types::TypeObjectFactory::get_instance(); - auto type_id = type_obj_factory->get_type_identifier(type_name, true); - if (type_id == nullptr) - { - throw eprosima::utils::InconsistencyException("Not Type Id"); - } - - auto type_obj = type_obj_factory->get_type_object(type_id); - if (type_obj == nullptr) - { - throw eprosima::utils::InconsistencyException("Not Type Object"); - } - - return type_obj_factory->build_dynamic_type(type_name, type_id, type_obj); -} - -} /* namespace test */ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/enum_struct.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/enum_struct.idl deleted file mode 100644 index c40eae6e..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/enum_struct.idl +++ /dev/null @@ -1,12 +0,0 @@ -enum ColorEnum -{ - RED, - GREEN, - BLUE -}; - -struct enum_struct -{ - unsigned long index; - ColorEnum enum_value; -}; diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/map_struct.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/map_struct.idl deleted file mode 100644 index d4d19acb..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/map_struct.idl +++ /dev/null @@ -1,4 +0,0 @@ -struct map_struct -{ - map my_map; -}; diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/union_struct.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/union_struct.idl deleted file mode 100644 index 3967f961..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/union_struct.idl +++ /dev/null @@ -1,15 +0,0 @@ -union MyUnion switch (long) -{ - case 1: - octet octet_value; - case 2: - long long_value; - case 3: - string string_value; -}; - -struct union_struct -{ - unsigned long index; - MyUnion union_value; -}; diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/msgs/char_sequence.msg b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/msgs/char_sequence.msg deleted file mode 100644 index bf4b2456..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/msgs/char_sequence.msg +++ /dev/null @@ -1 +0,0 @@ -int8[] chars diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequences.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequences.cxx deleted file mode 100644 index da1b66da..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequences.cxx +++ /dev/null @@ -1,520 +0,0 @@ -// 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 arrays_and_sequences.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "arrays_and_sequences.h" -#include "arrays_and_sequencesTypeObject.h" -#include - -#include -using namespace eprosima::fastcdr::exception; - -#include - -AnInternalObject::AnInternalObject() -{ - // m_x com.eprosima.idl.parser.typecode.PrimitiveTypeCode@47ef968d - m_x = 0.0; - // m_positive com.eprosima.idl.parser.typecode.PrimitiveTypeCode@23e028a9 - m_positive = false; - - // Just to register all known types - registerarrays_and_sequencesTypes(); -} - -AnInternalObject::~AnInternalObject() -{ - - -} - -AnInternalObject::AnInternalObject( - const AnInternalObject& x) -{ - m_x = x.m_x; - m_positive = x.m_positive; -} - -AnInternalObject::AnInternalObject( - AnInternalObject&& x) noexcept -{ - m_x = x.m_x; - m_positive = x.m_positive; -} - -AnInternalObject& AnInternalObject::operator =( - const AnInternalObject& x) -{ - - m_x = x.m_x; - m_positive = x.m_positive; - - return *this; -} - -AnInternalObject& AnInternalObject::operator =( - AnInternalObject&& x) noexcept -{ - - m_x = x.m_x; - m_positive = x.m_positive; - - return *this; -} - -bool AnInternalObject::operator ==( - const AnInternalObject& x) const -{ - - return (m_x == x.m_x && m_positive == x.m_positive); -} - -bool AnInternalObject::operator !=( - const AnInternalObject& x) const -{ - return !(*this == x); -} - -size_t AnInternalObject::getMaxCdrSerializedSize( - size_t current_alignment) -{ - size_t initial_alignment = current_alignment; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); - - - - return current_alignment - initial_alignment; -} - -size_t AnInternalObject::getCdrSerializedSize( - const AnInternalObject& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); - - - - return current_alignment - initial_alignment; -} - -void AnInternalObject::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - - scdr << m_x; - scdr << m_positive; - -} - -void AnInternalObject::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - - dcdr >> m_x; - dcdr >> m_positive; -} - -/*! - * @brief This function sets a value in member x - * @param _x New value for member x - */ -void AnInternalObject::x( - float _x) -{ - m_x = _x; -} - -/*! - * @brief This function returns the value of member x - * @return Value of member x - */ -float AnInternalObject::x() const -{ - return m_x; -} - -/*! - * @brief This function returns a reference to member x - * @return Reference to member x - */ -float& AnInternalObject::x() -{ - return m_x; -} - -/*! - * @brief This function sets a value in member positive - * @param _positive New value for member positive - */ -void AnInternalObject::positive( - bool _positive) -{ - m_positive = _positive; -} - -/*! - * @brief This function returns the value of member positive - * @return Value of member positive - */ -bool AnInternalObject::positive() const -{ - return m_positive; -} - -/*! - * @brief This function returns a reference to member positive - * @return Reference to member positive - */ -bool& AnInternalObject::positive() -{ - return m_positive; -} - - -size_t AnInternalObject::getKeyMaxCdrSerializedSize( - size_t current_alignment) -{ - size_t current_align = current_alignment; - - - - - - return current_align; -} - -bool AnInternalObject::isKeyDefined() -{ - return false; -} - -void AnInternalObject::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; - -} - -arrays_and_sequences::arrays_and_sequences() -{ - // m_unlimited_vector com.eprosima.idl.parser.typecode.SequenceTypeCode@42eca56e - - // m_limited_vector com.eprosima.idl.parser.typecode.SequenceTypeCode@52f759d7 - - // m_limited_array com.eprosima.idl.parser.typecode.ArrayTypeCode@7cbd213e - - - // Just to register all known types - registerarrays_and_sequencesTypes(); -} - -arrays_and_sequences::~arrays_and_sequences() -{ - - - -} - -arrays_and_sequences::arrays_and_sequences( - const arrays_and_sequences& x) -{ - m_unlimited_vector = x.m_unlimited_vector; - m_limited_vector = x.m_limited_vector; - m_limited_array = x.m_limited_array; -} - -arrays_and_sequences::arrays_and_sequences( - arrays_and_sequences&& x) noexcept -{ - m_unlimited_vector = std::move(x.m_unlimited_vector); - m_limited_vector = std::move(x.m_limited_vector); - m_limited_array = std::move(x.m_limited_array); -} - -arrays_and_sequences& arrays_and_sequences::operator =( - const arrays_and_sequences& x) -{ - - m_unlimited_vector = x.m_unlimited_vector; - m_limited_vector = x.m_limited_vector; - m_limited_array = x.m_limited_array; - - return *this; -} - -arrays_and_sequences& arrays_and_sequences::operator =( - arrays_and_sequences&& x) noexcept -{ - - m_unlimited_vector = std::move(x.m_unlimited_vector); - m_limited_vector = std::move(x.m_limited_vector); - m_limited_array = std::move(x.m_limited_array); - - return *this; -} - -bool arrays_and_sequences::operator ==( - const arrays_and_sequences& x) const -{ - - return (m_unlimited_vector == x.m_unlimited_vector && m_limited_vector == x.m_limited_vector && m_limited_array == x.m_limited_array); -} - -bool arrays_and_sequences::operator !=( - const arrays_and_sequences& x) const -{ - return !(*this == x); -} - -size_t arrays_and_sequences::getMaxCdrSerializedSize( - size_t current_alignment) -{ - size_t initial_alignment = current_alignment; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - for(size_t a = 0; a < 100; ++a) - { - current_alignment += AnInternalObject::getMaxCdrSerializedSize(current_alignment);} - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - for(size_t a = 0; a < 10; ++a) - { - current_alignment += AnInternalObject::getMaxCdrSerializedSize(current_alignment);} - - - for(size_t a = 0; a < (10); ++a) - { - current_alignment += AnInternalObject::getMaxCdrSerializedSize(current_alignment);} - - return current_alignment - initial_alignment; -} - -size_t arrays_and_sequences::getCdrSerializedSize( - const arrays_and_sequences& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - for(size_t a = 0; a < data.unlimited_vector().size(); ++a) - { - current_alignment += AnInternalObject::getCdrSerializedSize(data.unlimited_vector().at(a), current_alignment);} - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - for(size_t a = 0; a < data.limited_vector().size(); ++a) - { - current_alignment += AnInternalObject::getCdrSerializedSize(data.limited_vector().at(a), current_alignment);} - - - for(size_t a = 0; a < data.limited_array().size(); ++a) - { - current_alignment += AnInternalObject::getCdrSerializedSize(data.limited_array().at(a), current_alignment); - } - - return current_alignment - initial_alignment; -} - -void arrays_and_sequences::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - - scdr << m_unlimited_vector; - scdr << m_limited_vector; - scdr << m_limited_array; - - -} - -void arrays_and_sequences::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - - dcdr >> m_unlimited_vector; - dcdr >> m_limited_vector; - dcdr >> m_limited_array; - -} - -/*! - * @brief This function copies the value in member unlimited_vector - * @param _unlimited_vector New value to be copied in member unlimited_vector - */ -void arrays_and_sequences::unlimited_vector( - const std::vector& _unlimited_vector) -{ - m_unlimited_vector = _unlimited_vector; -} - -/*! - * @brief This function moves the value in member unlimited_vector - * @param _unlimited_vector New value to be moved in member unlimited_vector - */ -void arrays_and_sequences::unlimited_vector( - std::vector&& _unlimited_vector) -{ - m_unlimited_vector = std::move(_unlimited_vector); -} - -/*! - * @brief This function returns a constant reference to member unlimited_vector - * @return Constant reference to member unlimited_vector - */ -const std::vector& arrays_and_sequences::unlimited_vector() const -{ - return m_unlimited_vector; -} - -/*! - * @brief This function returns a reference to member unlimited_vector - * @return Reference to member unlimited_vector - */ -std::vector& arrays_and_sequences::unlimited_vector() -{ - return m_unlimited_vector; -} -/*! - * @brief This function copies the value in member limited_vector - * @param _limited_vector New value to be copied in member limited_vector - */ -void arrays_and_sequences::limited_vector( - const std::vector& _limited_vector) -{ - m_limited_vector = _limited_vector; -} - -/*! - * @brief This function moves the value in member limited_vector - * @param _limited_vector New value to be moved in member limited_vector - */ -void arrays_and_sequences::limited_vector( - std::vector&& _limited_vector) -{ - m_limited_vector = std::move(_limited_vector); -} - -/*! - * @brief This function returns a constant reference to member limited_vector - * @return Constant reference to member limited_vector - */ -const std::vector& arrays_and_sequences::limited_vector() const -{ - return m_limited_vector; -} - -/*! - * @brief This function returns a reference to member limited_vector - * @return Reference to member limited_vector - */ -std::vector& arrays_and_sequences::limited_vector() -{ - return m_limited_vector; -} -/*! - * @brief This function copies the value in member limited_array - * @param _limited_array New value to be copied in member limited_array - */ -void arrays_and_sequences::limited_array( - const std::array& _limited_array) -{ - m_limited_array = _limited_array; -} - -/*! - * @brief This function moves the value in member limited_array - * @param _limited_array New value to be moved in member limited_array - */ -void arrays_and_sequences::limited_array( - std::array&& _limited_array) -{ - m_limited_array = std::move(_limited_array); -} - -/*! - * @brief This function returns a constant reference to member limited_array - * @return Constant reference to member limited_array - */ -const std::array& arrays_and_sequences::limited_array() const -{ - return m_limited_array; -} - -/*! - * @brief This function returns a reference to member limited_array - * @return Reference to member limited_array - */ -std::array& arrays_and_sequences::limited_array() -{ - return m_limited_array; -} - -size_t arrays_and_sequences::getKeyMaxCdrSerializedSize( - size_t current_alignment) -{ - size_t current_align = current_alignment; - - - - - - - return current_align; -} - -bool arrays_and_sequences::isKeyDefined() -{ - return false; -} - -void arrays_and_sequences::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; - -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequences.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequences.h deleted file mode 100644 index 32b71e9c..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequences.h +++ /dev/null @@ -1,427 +0,0 @@ -// 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 arrays_and_sequences.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifndef _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_H_ -#define _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_H_ - - -#include - -#include -#include -#include -#include -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(arrays_and_sequences_SOURCE) -#define arrays_and_sequences_DllAPI __declspec( dllexport ) -#else -#define arrays_and_sequences_DllAPI __declspec( dllimport ) -#endif // arrays_and_sequences_SOURCE -#else -#define arrays_and_sequences_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define arrays_and_sequences_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - -/*! - * @brief This class represents the structure AnInternalObject defined by the user in the IDL file. - * @ingroup ARRAYS_AND_SEQUENCES - */ -class AnInternalObject -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport AnInternalObject(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~AnInternalObject(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object AnInternalObject that will be copied. - */ - eProsima_user_DllExport AnInternalObject( - const AnInternalObject& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object AnInternalObject that will be copied. - */ - eProsima_user_DllExport AnInternalObject( - AnInternalObject&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object AnInternalObject that will be copied. - */ - eProsima_user_DllExport AnInternalObject& operator =( - const AnInternalObject& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object AnInternalObject that will be copied. - */ - eProsima_user_DllExport AnInternalObject& operator =( - AnInternalObject&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x AnInternalObject object to compare. - */ - eProsima_user_DllExport bool operator ==( - const AnInternalObject& x) const; - - /*! - * @brief Comparison operator. - * @param x AnInternalObject object to compare. - */ - eProsima_user_DllExport bool operator !=( - const AnInternalObject& x) const; - - /*! - * @brief This function sets a value in member x - * @param _x New value for member x - */ - eProsima_user_DllExport void x( - float _x); - - /*! - * @brief This function returns the value of member x - * @return Value of member x - */ - eProsima_user_DllExport float x() const; - - /*! - * @brief This function returns a reference to member x - * @return Reference to member x - */ - eProsima_user_DllExport float& x(); - - /*! - * @brief This function sets a value in member positive - * @param _positive New value for member positive - */ - eProsima_user_DllExport void positive( - bool _positive); - - /*! - * @brief This function returns the value of member positive - * @return Value of member positive - */ - eProsima_user_DllExport bool positive() const; - - /*! - * @brief This function returns a reference to member positive - * @return Reference to member positive - */ - eProsima_user_DllExport bool& positive(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const AnInternalObject& data, - size_t current_alignment = 0); - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - /*! - * @brief This function returns the maximum serialized size of the Key of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - -private: - - float m_x; - bool m_positive; -}; -/*! - * @brief This class represents the structure arrays_and_sequences defined by the user in the IDL file. - * @ingroup ARRAYS_AND_SEQUENCES - */ -class arrays_and_sequences -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport arrays_and_sequences(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~arrays_and_sequences(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object arrays_and_sequences that will be copied. - */ - eProsima_user_DllExport arrays_and_sequences( - const arrays_and_sequences& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object arrays_and_sequences that will be copied. - */ - eProsima_user_DllExport arrays_and_sequences( - arrays_and_sequences&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object arrays_and_sequences that will be copied. - */ - eProsima_user_DllExport arrays_and_sequences& operator =( - const arrays_and_sequences& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object arrays_and_sequences that will be copied. - */ - eProsima_user_DllExport arrays_and_sequences& operator =( - arrays_and_sequences&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x arrays_and_sequences object to compare. - */ - eProsima_user_DllExport bool operator ==( - const arrays_and_sequences& x) const; - - /*! - * @brief Comparison operator. - * @param x arrays_and_sequences object to compare. - */ - eProsima_user_DllExport bool operator !=( - const arrays_and_sequences& x) const; - - /*! - * @brief This function copies the value in member unlimited_vector - * @param _unlimited_vector New value to be copied in member unlimited_vector - */ - eProsima_user_DllExport void unlimited_vector( - const std::vector& _unlimited_vector); - - /*! - * @brief This function moves the value in member unlimited_vector - * @param _unlimited_vector New value to be moved in member unlimited_vector - */ - eProsima_user_DllExport void unlimited_vector( - std::vector&& _unlimited_vector); - - /*! - * @brief This function returns a constant reference to member unlimited_vector - * @return Constant reference to member unlimited_vector - */ - eProsima_user_DllExport const std::vector& unlimited_vector() const; - - /*! - * @brief This function returns a reference to member unlimited_vector - * @return Reference to member unlimited_vector - */ - eProsima_user_DllExport std::vector& unlimited_vector(); - /*! - * @brief This function copies the value in member limited_vector - * @param _limited_vector New value to be copied in member limited_vector - */ - eProsima_user_DllExport void limited_vector( - const std::vector& _limited_vector); - - /*! - * @brief This function moves the value in member limited_vector - * @param _limited_vector New value to be moved in member limited_vector - */ - eProsima_user_DllExport void limited_vector( - std::vector&& _limited_vector); - - /*! - * @brief This function returns a constant reference to member limited_vector - * @return Constant reference to member limited_vector - */ - eProsima_user_DllExport const std::vector& limited_vector() const; - - /*! - * @brief This function returns a reference to member limited_vector - * @return Reference to member limited_vector - */ - eProsima_user_DllExport std::vector& limited_vector(); - /*! - * @brief This function copies the value in member limited_array - * @param _limited_array New value to be copied in member limited_array - */ - eProsima_user_DllExport void limited_array( - const std::array& _limited_array); - - /*! - * @brief This function moves the value in member limited_array - * @param _limited_array New value to be moved in member limited_array - */ - eProsima_user_DllExport void limited_array( - std::array&& _limited_array); - - /*! - * @brief This function returns a constant reference to member limited_array - * @return Constant reference to member limited_array - */ - eProsima_user_DllExport const std::array& limited_array() const; - - /*! - * @brief This function returns a reference to member limited_array - * @return Reference to member limited_array - */ - eProsima_user_DllExport std::array& limited_array(); - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const arrays_and_sequences& data, - size_t current_alignment = 0); - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - /*! - * @brief This function returns the maximum serialized size of the Key of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - -private: - - std::vector m_unlimited_vector; - std::vector m_limited_vector; - std::array m_limited_array; -}; - -#endif // _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesPubSubTypes.cxx deleted file mode 100644 index 56d15be3..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesPubSubTypes.cxx +++ /dev/null @@ -1,309 +0,0 @@ -// 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 arrays_and_sequencesPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#include -#include - -#include "arrays_and_sequencesPubSubTypes.h" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; - -AnInternalObjectPubSubType::AnInternalObjectPubSubType() -{ - setName("AnInternalObject"); - auto type_size = AnInternalObject::getMaxCdrSerializedSize(); - type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ - m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ - m_isGetKeyDefined = AnInternalObject::isKeyDefined(); - size_t keyLength = AnInternalObject::getKeyMaxCdrSerializedSize() > 16 ? - AnInternalObject::getKeyMaxCdrSerializedSize() : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -AnInternalObjectPubSubType::~AnInternalObjectPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool AnInternalObjectPubSubType::serialize( - void* data, - SerializedPayload_t* payload) -{ - AnInternalObject* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - // Serialize encapsulation - ser.serialize_encapsulation(); - - try - { - // Serialize the object. - p_type->serialize(ser); - } - catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) - { - return false; - } - - // Get the serialized length - payload->length = static_cast(ser.getSerializedDataLength()); - return true; -} - -bool AnInternalObjectPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - //Convert DATA to pointer of your type - AnInternalObject* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - p_type->deserialize(deser); - } - catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) - { - return false; - } - - return true; -} - -std::function AnInternalObjectPubSubType::getSerializedSizeProvider( - void* data) -{ - return [data]() -> uint32_t - { - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - }; -} - -void* AnInternalObjectPubSubType::createData() -{ - return reinterpret_cast(new AnInternalObject()); -} - -void AnInternalObjectPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool AnInternalObjectPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - AnInternalObject* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - AnInternalObject::getKeyMaxCdrSerializedSize()); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); - p_type->serializeKey(ser); - if (force_md5 || AnInternalObject::getKeyMaxCdrSerializedSize() > 16) - { - m_md5.init(); - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - -arrays_and_sequencesPubSubType::arrays_and_sequencesPubSubType() -{ - setName("arrays_and_sequences"); - auto type_size = arrays_and_sequences::getMaxCdrSerializedSize(); - type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ - m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ - m_isGetKeyDefined = arrays_and_sequences::isKeyDefined(); - size_t keyLength = arrays_and_sequences::getKeyMaxCdrSerializedSize() > 16 ? - arrays_and_sequences::getKeyMaxCdrSerializedSize() : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -arrays_and_sequencesPubSubType::~arrays_and_sequencesPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool arrays_and_sequencesPubSubType::serialize( - void* data, - SerializedPayload_t* payload) -{ - arrays_and_sequences* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - // Serialize encapsulation - ser.serialize_encapsulation(); - - try - { - // Serialize the object. - p_type->serialize(ser); - } - catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) - { - return false; - } - - // Get the serialized length - payload->length = static_cast(ser.getSerializedDataLength()); - return true; -} - -bool arrays_and_sequencesPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - //Convert DATA to pointer of your type - arrays_and_sequences* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - p_type->deserialize(deser); - } - catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) - { - return false; - } - - return true; -} - -std::function arrays_and_sequencesPubSubType::getSerializedSizeProvider( - void* data) -{ - return [data]() -> uint32_t - { - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - }; -} - -void* arrays_and_sequencesPubSubType::createData() -{ - return reinterpret_cast(new arrays_and_sequences()); -} - -void arrays_and_sequencesPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool arrays_and_sequencesPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - arrays_and_sequences* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - arrays_and_sequences::getKeyMaxCdrSerializedSize()); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); - p_type->serializeKey(ser); - if (force_md5 || arrays_and_sequences::getKeyMaxCdrSerializedSize() > 16) - { - m_md5.init(); - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesPubSubTypes.h deleted file mode 100644 index 0ef7d1b9..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesPubSubTypes.h +++ /dev/null @@ -1,165 +0,0 @@ -// 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 arrays_and_sequencesPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#ifndef _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_PUBSUBTYPES_H_ - -#include -#include - -#include "arrays_and_sequences.h" - -#if !defined(GEN_API_VER) || (GEN_API_VER != 1) -#error \ - Generated arrays_and_sequences is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER - -/*! - * @brief This class represents the TopicDataType of the type AnInternalObject defined by the user in the IDL file. - * @ingroup ARRAYS_AND_SEQUENCES - */ -class AnInternalObjectPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef AnInternalObject type; - - eProsima_user_DllExport AnInternalObjectPubSubType(); - - eProsima_user_DllExport virtual ~AnInternalObjectPubSubType() override; - - eProsima_user_DllExport virtual bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; - - eProsima_user_DllExport virtual bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport virtual std::function getSerializedSizeProvider( - void* data) override; - - eProsima_user_DllExport virtual bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport virtual void* createData() override; - - eProsima_user_DllExport virtual void deleteData( - void* data) override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - new (memory) AnInternalObject(); - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; -}; -/*! - * @brief This class represents the TopicDataType of the type arrays_and_sequences defined by the user in the IDL file. - * @ingroup ARRAYS_AND_SEQUENCES - */ -class arrays_and_sequencesPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef arrays_and_sequences type; - - eProsima_user_DllExport arrays_and_sequencesPubSubType(); - - eProsima_user_DllExport virtual ~arrays_and_sequencesPubSubType() override; - - eProsima_user_DllExport virtual bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; - - eProsima_user_DllExport virtual bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport virtual std::function getSerializedSizeProvider( - void* data) override; - - eProsima_user_DllExport virtual bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport virtual void* createData() override; - - eProsima_user_DllExport virtual void deleteData( - void* data) override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - (void)memory; - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; -}; - -#endif // _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_PUBSUBTYPES_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesTypeObject.cxx deleted file mode 100644 index b6e19eaf..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesTypeObject.cxx +++ /dev/null @@ -1,487 +0,0 @@ -// 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 arrays_and_sequencesTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { char dummy; } -#endif - -#include "arrays_and_sequences.h" -#include "arrays_and_sequencesTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerarrays_and_sequencesTypes() -{ - TypeObjectFactory *factory = TypeObjectFactory::get_instance(); - factory->add_type_object("AnInternalObject", GetAnInternalObjectIdentifier(true), - GetAnInternalObjectObject(true)); - factory->add_type_object("AnInternalObject", GetAnInternalObjectIdentifier(false), - GetAnInternalObjectObject(false)); - - factory->add_type_object("arrays_and_sequences", Getarrays_and_sequencesIdentifier(true), - Getarrays_and_sequencesObject(true)); - factory->add_type_object("arrays_and_sequences", Getarrays_and_sequencesIdentifier(false), - Getarrays_and_sequencesObject(false)); - -} - -const TypeIdentifier* GetAnInternalObjectIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("AnInternalObject", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetAnInternalObjectObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("AnInternalObject", complete); -} - -const TypeObject* GetAnInternalObjectObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("AnInternalObject", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteAnInternalObjectObject(); - } - //else - return GetMinimalAnInternalObjectObject(); -} - -const TypeObject* GetMinimalAnInternalObjectObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("AnInternalObject", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_x; - mst_x.common().member_id(memberId++); - mst_x.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_x.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_x.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_x.common().member_flags().IS_OPTIONAL(false); - mst_x.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_x.common().member_flags().IS_KEY(false); - mst_x.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_x.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("float", false)); - - MD5 x_hash("x"); - for(int i = 0; i < 4; ++i) - { - mst_x.detail().name_hash()[i] = x_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_x); - - MinimalStructMember mst_positive; - mst_positive.common().member_id(memberId++); - mst_positive.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_positive.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_positive.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_positive.common().member_flags().IS_OPTIONAL(false); - mst_positive.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_positive.common().member_flags().IS_KEY(false); - mst_positive.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_positive.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - MD5 positive_hash("positive"); - for(int i = 0; i < 4; ++i) - { - mst_positive.detail().name_hash()[i] = positive_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_positive); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - SerializedPayload_t payload(static_cast( - MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("AnInternalObject", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("AnInternalObject", false); -} - -const TypeObject* GetCompleteAnInternalObjectObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("AnInternalObject", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_x; - cst_x.common().member_id(memberId++); - cst_x.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_x.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_x.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_x.common().member_flags().IS_OPTIONAL(false); - cst_x.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_x.common().member_flags().IS_KEY(false); - cst_x.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_x.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("float", false)); - - cst_x.detail().name("x"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_x); - - CompleteStructMember cst_positive; - cst_positive.common().member_id(memberId++); - cst_positive.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_positive.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_positive.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_positive.common().member_flags().IS_OPTIONAL(false); - cst_positive.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_positive.common().member_flags().IS_KEY(false); - cst_positive.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_positive.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - cst_positive.detail().name("positive"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_positive); - - - // Header - type_object->complete().struct_type().header().detail().type_name("AnInternalObject"); - // TODO inheritance - - - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - SerializedPayload_t payload(static_cast( - CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("AnInternalObject", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("AnInternalObject", true); -} - -const TypeIdentifier* Getarrays_and_sequencesIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("arrays_and_sequences", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - Getarrays_and_sequencesObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("arrays_and_sequences", complete); -} - -const TypeObject* Getarrays_and_sequencesObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("arrays_and_sequences", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompletearrays_and_sequencesObject(); - } - //else - return GetMinimalarrays_and_sequencesObject(); -} - -const TypeObject* GetMinimalarrays_and_sequencesObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("arrays_and_sequences", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_unlimited_vector; - mst_unlimited_vector.common().member_id(memberId++); - mst_unlimited_vector.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_unlimited_vector.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_unlimited_vector.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_unlimited_vector.common().member_flags().IS_OPTIONAL(false); - mst_unlimited_vector.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_unlimited_vector.common().member_flags().IS_KEY(false); - mst_unlimited_vector.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_unlimited_vector.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("AnInternalObject", 0, false)); - - - MD5 unlimited_vector_hash("unlimited_vector"); - for(int i = 0; i < 4; ++i) - { - mst_unlimited_vector.detail().name_hash()[i] = unlimited_vector_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_unlimited_vector); - - MinimalStructMember mst_limited_vector; - mst_limited_vector.common().member_id(memberId++); - mst_limited_vector.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_limited_vector.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_limited_vector.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_limited_vector.common().member_flags().IS_OPTIONAL(false); - mst_limited_vector.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_limited_vector.common().member_flags().IS_KEY(false); - mst_limited_vector.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_limited_vector.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("AnInternalObject", 10, false)); - - - MD5 limited_vector_hash("limited_vector"); - for(int i = 0; i < 4; ++i) - { - mst_limited_vector.detail().name_hash()[i] = limited_vector_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_limited_vector); - - MinimalStructMember mst_limited_array; - mst_limited_array.common().member_id(memberId++); - mst_limited_array.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_limited_array.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_limited_array.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_limited_array.common().member_flags().IS_OPTIONAL(false); - mst_limited_array.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_limited_array.common().member_flags().IS_KEY(false); - mst_limited_array.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_limited_array.common().member_type_id(*TypeObjectFactory::get_instance()->get_array_identifier("AnInternalObject", {10}, false)); - - - MD5 limited_array_hash("limited_array"); - for(int i = 0; i < 4; ++i) - { - mst_limited_array.detail().name_hash()[i] = limited_array_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_limited_array); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - SerializedPayload_t payload(static_cast( - MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("arrays_and_sequences", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("arrays_and_sequences", false); -} - -const TypeObject* GetCompletearrays_and_sequencesObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("arrays_and_sequences", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_unlimited_vector; - cst_unlimited_vector.common().member_id(memberId++); - cst_unlimited_vector.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_unlimited_vector.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_unlimited_vector.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_unlimited_vector.common().member_flags().IS_OPTIONAL(false); - cst_unlimited_vector.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_unlimited_vector.common().member_flags().IS_KEY(false); - cst_unlimited_vector.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_unlimited_vector.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("AnInternalObject", 0, true)); - - - cst_unlimited_vector.detail().name("unlimited_vector"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_unlimited_vector); - - CompleteStructMember cst_limited_vector; - cst_limited_vector.common().member_id(memberId++); - cst_limited_vector.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_limited_vector.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_limited_vector.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_limited_vector.common().member_flags().IS_OPTIONAL(false); - cst_limited_vector.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_limited_vector.common().member_flags().IS_KEY(false); - cst_limited_vector.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_limited_vector.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("AnInternalObject", 10, true)); - - - cst_limited_vector.detail().name("limited_vector"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_limited_vector); - - CompleteStructMember cst_limited_array; - cst_limited_array.common().member_id(memberId++); - cst_limited_array.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_limited_array.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_limited_array.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_limited_array.common().member_flags().IS_OPTIONAL(false); - cst_limited_array.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_limited_array.common().member_flags().IS_KEY(false); - cst_limited_array.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_limited_array.common().member_type_id(*TypeObjectFactory::get_instance()->get_array_identifier("AnInternalObject", {10}, true)); - - - cst_limited_array.detail().name("limited_array"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_limited_array); - - - // Header - type_object->complete().struct_type().header().detail().type_name("arrays_and_sequences"); - // TODO inheritance - - - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - SerializedPayload_t payload(static_cast( - CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("arrays_and_sequences", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("arrays_and_sequences", true); -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesTypeObject.h deleted file mode 100644 index 4ad8329f..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesTypeObject.h +++ /dev/null @@ -1,72 +0,0 @@ -// 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 arrays_and_sequencesTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifndef _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_TYPE_OBJECT_H_ - - -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define eProsima_user_DllExport -#endif // if defined(_WIN32) - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(arrays_and_sequences_SOURCE) -#define arrays_and_sequences_DllAPI __declspec( dllexport ) -#else -#define arrays_and_sequences_DllAPI __declspec( dllimport ) -#endif // arrays_and_sequences_SOURCE -#else -#define arrays_and_sequences_DllAPI -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define arrays_and_sequences_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registerarrays_and_sequencesTypes(); - -eProsima_user_DllExport const TypeIdentifier* GetAnInternalObjectIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetAnInternalObjectObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalAnInternalObjectObject(); -eProsima_user_DllExport const TypeObject* GetCompleteAnInternalObjectObject(); - -eProsima_user_DllExport const TypeIdentifier* Getarrays_and_sequencesIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* Getarrays_and_sequencesObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalarrays_and_sequencesObject(); -eProsima_user_DllExport const TypeObject* GetCompletearrays_and_sequencesObject(); - - -#endif // _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_TYPE_OBJECT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_struct.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_struct.cxx deleted file mode 100644 index 0d39bc85..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_struct.cxx +++ /dev/null @@ -1,442 +0,0 @@ -// 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 basic_array_struct.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "basic_array_struct.h" -#include "basic_array_structTypeObject.h" -#include - -#include -using namespace eprosima::fastcdr::exception; - -#include - -TheOtherObjectInArray::TheOtherObjectInArray() -{ - // m_some_num com.eprosima.idl.parser.typecode.PrimitiveTypeCode@32709393 - m_some_num = 0; - // m_positive com.eprosima.idl.parser.typecode.PrimitiveTypeCode@3d99d22e - m_positive = false; - - // Just to register all known types - registerbasic_array_structTypes(); -} - -TheOtherObjectInArray::~TheOtherObjectInArray() -{ - - -} - -TheOtherObjectInArray::TheOtherObjectInArray( - const TheOtherObjectInArray& x) -{ - m_some_num = x.m_some_num; - m_positive = x.m_positive; -} - -TheOtherObjectInArray::TheOtherObjectInArray( - TheOtherObjectInArray&& x) noexcept -{ - m_some_num = x.m_some_num; - m_positive = x.m_positive; -} - -TheOtherObjectInArray& TheOtherObjectInArray::operator =( - const TheOtherObjectInArray& x) -{ - - m_some_num = x.m_some_num; - m_positive = x.m_positive; - - return *this; -} - -TheOtherObjectInArray& TheOtherObjectInArray::operator =( - TheOtherObjectInArray&& x) noexcept -{ - - m_some_num = x.m_some_num; - m_positive = x.m_positive; - - return *this; -} - -bool TheOtherObjectInArray::operator ==( - const TheOtherObjectInArray& x) const -{ - - return (m_some_num == x.m_some_num && m_positive == x.m_positive); -} - -bool TheOtherObjectInArray::operator !=( - const TheOtherObjectInArray& x) const -{ - return !(*this == x); -} - -size_t TheOtherObjectInArray::getMaxCdrSerializedSize( - size_t current_alignment) -{ - size_t initial_alignment = current_alignment; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); - - - - return current_alignment - initial_alignment; -} - -size_t TheOtherObjectInArray::getCdrSerializedSize( - const TheOtherObjectInArray& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); - - - - return current_alignment - initial_alignment; -} - -void TheOtherObjectInArray::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - - scdr << m_some_num; - scdr << m_positive; - -} - -void TheOtherObjectInArray::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - - dcdr >> m_some_num; - dcdr >> m_positive; -} - -/*! - * @brief This function sets a value in member some_num - * @param _some_num New value for member some_num - */ -void TheOtherObjectInArray::some_num( - int32_t _some_num) -{ - m_some_num = _some_num; -} - -/*! - * @brief This function returns the value of member some_num - * @return Value of member some_num - */ -int32_t TheOtherObjectInArray::some_num() const -{ - return m_some_num; -} - -/*! - * @brief This function returns a reference to member some_num - * @return Reference to member some_num - */ -int32_t& TheOtherObjectInArray::some_num() -{ - return m_some_num; -} - -/*! - * @brief This function sets a value in member positive - * @param _positive New value for member positive - */ -void TheOtherObjectInArray::positive( - bool _positive) -{ - m_positive = _positive; -} - -/*! - * @brief This function returns the value of member positive - * @return Value of member positive - */ -bool TheOtherObjectInArray::positive() const -{ - return m_positive; -} - -/*! - * @brief This function returns a reference to member positive - * @return Reference to member positive - */ -bool& TheOtherObjectInArray::positive() -{ - return m_positive; -} - - -size_t TheOtherObjectInArray::getKeyMaxCdrSerializedSize( - size_t current_alignment) -{ - size_t current_align = current_alignment; - - - - - - return current_align; -} - -bool TheOtherObjectInArray::isKeyDefined() -{ - return false; -} - -void TheOtherObjectInArray::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; - -} - -basic_array_struct::basic_array_struct() -{ - // m_index com.eprosima.idl.parser.typecode.PrimitiveTypeCode@50d0686 - m_index = 0; - // m_sub_structs com.eprosima.idl.parser.typecode.ArrayTypeCode@1e7c7811 - - - // Just to register all known types - registerbasic_array_structTypes(); -} - -basic_array_struct::~basic_array_struct() -{ - - -} - -basic_array_struct::basic_array_struct( - const basic_array_struct& x) -{ - m_index = x.m_index; - m_sub_structs = x.m_sub_structs; -} - -basic_array_struct::basic_array_struct( - basic_array_struct&& x) noexcept -{ - m_index = x.m_index; - m_sub_structs = std::move(x.m_sub_structs); -} - -basic_array_struct& basic_array_struct::operator =( - const basic_array_struct& x) -{ - - m_index = x.m_index; - m_sub_structs = x.m_sub_structs; - - return *this; -} - -basic_array_struct& basic_array_struct::operator =( - basic_array_struct&& x) noexcept -{ - - m_index = x.m_index; - m_sub_structs = std::move(x.m_sub_structs); - - return *this; -} - -bool basic_array_struct::operator ==( - const basic_array_struct& x) const -{ - - return (m_index == x.m_index && m_sub_structs == x.m_sub_structs); -} - -bool basic_array_struct::operator !=( - const basic_array_struct& x) const -{ - return !(*this == x); -} - -size_t basic_array_struct::getMaxCdrSerializedSize( - size_t current_alignment) -{ - size_t initial_alignment = current_alignment; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - - for(size_t a = 0; a < (5); ++a) - { - current_alignment += TheOtherObjectInArray::getMaxCdrSerializedSize(current_alignment);} - - return current_alignment - initial_alignment; -} - -size_t basic_array_struct::getCdrSerializedSize( - const basic_array_struct& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - - for(size_t a = 0; a < data.sub_structs().size(); ++a) - { - current_alignment += TheOtherObjectInArray::getCdrSerializedSize(data.sub_structs().at(a), current_alignment); - } - - return current_alignment - initial_alignment; -} - -void basic_array_struct::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - - scdr << m_index; - scdr << m_sub_structs; - - -} - -void basic_array_struct::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - - dcdr >> m_index; - dcdr >> m_sub_structs; - -} - -/*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ -void basic_array_struct::index( - uint32_t _index) -{ - m_index = _index; -} - -/*! - * @brief This function returns the value of member index - * @return Value of member index - */ -uint32_t basic_array_struct::index() const -{ - return m_index; -} - -/*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ -uint32_t& basic_array_struct::index() -{ - return m_index; -} - -/*! - * @brief This function copies the value in member sub_structs - * @param _sub_structs New value to be copied in member sub_structs - */ -void basic_array_struct::sub_structs( - const std::array& _sub_structs) -{ - m_sub_structs = _sub_structs; -} - -/*! - * @brief This function moves the value in member sub_structs - * @param _sub_structs New value to be moved in member sub_structs - */ -void basic_array_struct::sub_structs( - std::array&& _sub_structs) -{ - m_sub_structs = std::move(_sub_structs); -} - -/*! - * @brief This function returns a constant reference to member sub_structs - * @return Constant reference to member sub_structs - */ -const std::array& basic_array_struct::sub_structs() const -{ - return m_sub_structs; -} - -/*! - * @brief This function returns a reference to member sub_structs - * @return Reference to member sub_structs - */ -std::array& basic_array_struct::sub_structs() -{ - return m_sub_structs; -} - -size_t basic_array_struct::getKeyMaxCdrSerializedSize( - size_t current_alignment) -{ - size_t current_align = current_alignment; - - - - - - return current_align; -} - -bool basic_array_struct::isKeyDefined() -{ - return false; -} - -void basic_array_struct::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; - -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_struct.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_struct.h deleted file mode 100644 index 920978d7..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_struct.h +++ /dev/null @@ -1,395 +0,0 @@ -// 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 basic_array_struct.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifndef _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCT_H_ -#define _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCT_H_ - - -#include - -#include -#include -#include -#include -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(basic_array_struct_SOURCE) -#define basic_array_struct_DllAPI __declspec( dllexport ) -#else -#define basic_array_struct_DllAPI __declspec( dllimport ) -#endif // basic_array_struct_SOURCE -#else -#define basic_array_struct_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define basic_array_struct_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - -/*! - * @brief This class represents the structure TheOtherObjectInArray defined by the user in the IDL file. - * @ingroup BASIC_ARRAY_STRUCT - */ -class TheOtherObjectInArray -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport TheOtherObjectInArray(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~TheOtherObjectInArray(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object TheOtherObjectInArray that will be copied. - */ - eProsima_user_DllExport TheOtherObjectInArray( - const TheOtherObjectInArray& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object TheOtherObjectInArray that will be copied. - */ - eProsima_user_DllExport TheOtherObjectInArray( - TheOtherObjectInArray&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object TheOtherObjectInArray that will be copied. - */ - eProsima_user_DllExport TheOtherObjectInArray& operator =( - const TheOtherObjectInArray& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object TheOtherObjectInArray that will be copied. - */ - eProsima_user_DllExport TheOtherObjectInArray& operator =( - TheOtherObjectInArray&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x TheOtherObjectInArray object to compare. - */ - eProsima_user_DllExport bool operator ==( - const TheOtherObjectInArray& x) const; - - /*! - * @brief Comparison operator. - * @param x TheOtherObjectInArray object to compare. - */ - eProsima_user_DllExport bool operator !=( - const TheOtherObjectInArray& x) const; - - /*! - * @brief This function sets a value in member some_num - * @param _some_num New value for member some_num - */ - eProsima_user_DllExport void some_num( - int32_t _some_num); - - /*! - * @brief This function returns the value of member some_num - * @return Value of member some_num - */ - eProsima_user_DllExport int32_t some_num() const; - - /*! - * @brief This function returns a reference to member some_num - * @return Reference to member some_num - */ - eProsima_user_DllExport int32_t& some_num(); - - /*! - * @brief This function sets a value in member positive - * @param _positive New value for member positive - */ - eProsima_user_DllExport void positive( - bool _positive); - - /*! - * @brief This function returns the value of member positive - * @return Value of member positive - */ - eProsima_user_DllExport bool positive() const; - - /*! - * @brief This function returns a reference to member positive - * @return Reference to member positive - */ - eProsima_user_DllExport bool& positive(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const TheOtherObjectInArray& data, - size_t current_alignment = 0); - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - /*! - * @brief This function returns the maximum serialized size of the Key of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - -private: - - int32_t m_some_num; - bool m_positive; -}; -/*! - * @brief This class represents the structure basic_array_struct defined by the user in the IDL file. - * @ingroup BASIC_ARRAY_STRUCT - */ -class basic_array_struct -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport basic_array_struct(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~basic_array_struct(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object basic_array_struct that will be copied. - */ - eProsima_user_DllExport basic_array_struct( - const basic_array_struct& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object basic_array_struct that will be copied. - */ - eProsima_user_DllExport basic_array_struct( - basic_array_struct&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object basic_array_struct that will be copied. - */ - eProsima_user_DllExport basic_array_struct& operator =( - const basic_array_struct& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object basic_array_struct that will be copied. - */ - eProsima_user_DllExport basic_array_struct& operator =( - basic_array_struct&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x basic_array_struct object to compare. - */ - eProsima_user_DllExport bool operator ==( - const basic_array_struct& x) const; - - /*! - * @brief Comparison operator. - * @param x basic_array_struct object to compare. - */ - eProsima_user_DllExport bool operator !=( - const basic_array_struct& x) const; - - /*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ - eProsima_user_DllExport void index( - uint32_t _index); - - /*! - * @brief This function returns the value of member index - * @return Value of member index - */ - eProsima_user_DllExport uint32_t index() const; - - /*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ - eProsima_user_DllExport uint32_t& index(); - - /*! - * @brief This function copies the value in member sub_structs - * @param _sub_structs New value to be copied in member sub_structs - */ - eProsima_user_DllExport void sub_structs( - const std::array& _sub_structs); - - /*! - * @brief This function moves the value in member sub_structs - * @param _sub_structs New value to be moved in member sub_structs - */ - eProsima_user_DllExport void sub_structs( - std::array&& _sub_structs); - - /*! - * @brief This function returns a constant reference to member sub_structs - * @return Constant reference to member sub_structs - */ - eProsima_user_DllExport const std::array& sub_structs() const; - - /*! - * @brief This function returns a reference to member sub_structs - * @return Reference to member sub_structs - */ - eProsima_user_DllExport std::array& sub_structs(); - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const basic_array_struct& data, - size_t current_alignment = 0); - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - /*! - * @brief This function returns the maximum serialized size of the Key of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - -private: - - uint32_t m_index; - std::array m_sub_structs; -}; - -#endif // _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_structPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_structPubSubTypes.cxx deleted file mode 100644 index dd4dff4e..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_structPubSubTypes.cxx +++ /dev/null @@ -1,309 +0,0 @@ -// 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 basic_array_structPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#include -#include - -#include "basic_array_structPubSubTypes.h" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; - -TheOtherObjectInArrayPubSubType::TheOtherObjectInArrayPubSubType() -{ - setName("TheOtherObjectInArray"); - auto type_size = TheOtherObjectInArray::getMaxCdrSerializedSize(); - type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ - m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ - m_isGetKeyDefined = TheOtherObjectInArray::isKeyDefined(); - size_t keyLength = TheOtherObjectInArray::getKeyMaxCdrSerializedSize() > 16 ? - TheOtherObjectInArray::getKeyMaxCdrSerializedSize() : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -TheOtherObjectInArrayPubSubType::~TheOtherObjectInArrayPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool TheOtherObjectInArrayPubSubType::serialize( - void* data, - SerializedPayload_t* payload) -{ - TheOtherObjectInArray* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - // Serialize encapsulation - ser.serialize_encapsulation(); - - try - { - // Serialize the object. - p_type->serialize(ser); - } - catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) - { - return false; - } - - // Get the serialized length - payload->length = static_cast(ser.getSerializedDataLength()); - return true; -} - -bool TheOtherObjectInArrayPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - //Convert DATA to pointer of your type - TheOtherObjectInArray* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - p_type->deserialize(deser); - } - catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) - { - return false; - } - - return true; -} - -std::function TheOtherObjectInArrayPubSubType::getSerializedSizeProvider( - void* data) -{ - return [data]() -> uint32_t - { - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - }; -} - -void* TheOtherObjectInArrayPubSubType::createData() -{ - return reinterpret_cast(new TheOtherObjectInArray()); -} - -void TheOtherObjectInArrayPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool TheOtherObjectInArrayPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - TheOtherObjectInArray* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - TheOtherObjectInArray::getKeyMaxCdrSerializedSize()); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); - p_type->serializeKey(ser); - if (force_md5 || TheOtherObjectInArray::getKeyMaxCdrSerializedSize() > 16) - { - m_md5.init(); - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - -basic_array_structPubSubType::basic_array_structPubSubType() -{ - setName("basic_array_struct"); - auto type_size = basic_array_struct::getMaxCdrSerializedSize(); - type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ - m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ - m_isGetKeyDefined = basic_array_struct::isKeyDefined(); - size_t keyLength = basic_array_struct::getKeyMaxCdrSerializedSize() > 16 ? - basic_array_struct::getKeyMaxCdrSerializedSize() : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -basic_array_structPubSubType::~basic_array_structPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool basic_array_structPubSubType::serialize( - void* data, - SerializedPayload_t* payload) -{ - basic_array_struct* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - // Serialize encapsulation - ser.serialize_encapsulation(); - - try - { - // Serialize the object. - p_type->serialize(ser); - } - catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) - { - return false; - } - - // Get the serialized length - payload->length = static_cast(ser.getSerializedDataLength()); - return true; -} - -bool basic_array_structPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - //Convert DATA to pointer of your type - basic_array_struct* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - p_type->deserialize(deser); - } - catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) - { - return false; - } - - return true; -} - -std::function basic_array_structPubSubType::getSerializedSizeProvider( - void* data) -{ - return [data]() -> uint32_t - { - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - }; -} - -void* basic_array_structPubSubType::createData() -{ - return reinterpret_cast(new basic_array_struct()); -} - -void basic_array_structPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool basic_array_structPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - basic_array_struct* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - basic_array_struct::getKeyMaxCdrSerializedSize()); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); - p_type->serializeKey(ser); - if (force_md5 || basic_array_struct::getKeyMaxCdrSerializedSize() > 16) - { - m_md5.init(); - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_structPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_structPubSubTypes.h deleted file mode 100644 index e382e8d4..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_structPubSubTypes.h +++ /dev/null @@ -1,165 +0,0 @@ -// 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 basic_array_structPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#ifndef _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCT_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCT_PUBSUBTYPES_H_ - -#include -#include - -#include "basic_array_struct.h" - -#if !defined(GEN_API_VER) || (GEN_API_VER != 1) -#error \ - Generated basic_array_struct is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER - -/*! - * @brief This class represents the TopicDataType of the type TheOtherObjectInArray defined by the user in the IDL file. - * @ingroup BASIC_ARRAY_STRUCT - */ -class TheOtherObjectInArrayPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef TheOtherObjectInArray type; - - eProsima_user_DllExport TheOtherObjectInArrayPubSubType(); - - eProsima_user_DllExport virtual ~TheOtherObjectInArrayPubSubType() override; - - eProsima_user_DllExport virtual bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; - - eProsima_user_DllExport virtual bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport virtual std::function getSerializedSizeProvider( - void* data) override; - - eProsima_user_DllExport virtual bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport virtual void* createData() override; - - eProsima_user_DllExport virtual void deleteData( - void* data) override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - new (memory) TheOtherObjectInArray(); - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; -}; -/*! - * @brief This class represents the TopicDataType of the type basic_array_struct defined by the user in the IDL file. - * @ingroup BASIC_ARRAY_STRUCT - */ -class basic_array_structPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef basic_array_struct type; - - eProsima_user_DllExport basic_array_structPubSubType(); - - eProsima_user_DllExport virtual ~basic_array_structPubSubType() override; - - eProsima_user_DllExport virtual bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; - - eProsima_user_DllExport virtual bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport virtual std::function getSerializedSizeProvider( - void* data) override; - - eProsima_user_DllExport virtual bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport virtual void* createData() override; - - eProsima_user_DllExport virtual void deleteData( - void* data) override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - new (memory) basic_array_struct(); - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; -}; - -#endif // _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCT_PUBSUBTYPES_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_structTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_structTypeObject.cxx deleted file mode 100644 index 29f15c6f..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_structTypeObject.cxx +++ /dev/null @@ -1,450 +0,0 @@ -// 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 basic_array_structTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { char dummy; } -#endif - -#include "basic_array_struct.h" -#include "basic_array_structTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerbasic_array_structTypes() -{ - TypeObjectFactory *factory = TypeObjectFactory::get_instance(); - factory->add_type_object("TheOtherObjectInArray", GetTheOtherObjectInArrayIdentifier(true), - GetTheOtherObjectInArrayObject(true)); - factory->add_type_object("TheOtherObjectInArray", GetTheOtherObjectInArrayIdentifier(false), - GetTheOtherObjectInArrayObject(false)); - - factory->add_type_object("basic_array_struct", Getbasic_array_structIdentifier(true), - Getbasic_array_structObject(true)); - factory->add_type_object("basic_array_struct", Getbasic_array_structIdentifier(false), - Getbasic_array_structObject(false)); - -} - -const TypeIdentifier* GetTheOtherObjectInArrayIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("TheOtherObjectInArray", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetTheOtherObjectInArrayObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("TheOtherObjectInArray", complete); -} - -const TypeObject* GetTheOtherObjectInArrayObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("TheOtherObjectInArray", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteTheOtherObjectInArrayObject(); - } - //else - return GetMinimalTheOtherObjectInArrayObject(); -} - -const TypeObject* GetMinimalTheOtherObjectInArrayObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("TheOtherObjectInArray", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_some_num; - mst_some_num.common().member_id(memberId++); - mst_some_num.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_some_num.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_some_num.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_some_num.common().member_flags().IS_OPTIONAL(false); - mst_some_num.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_some_num.common().member_flags().IS_KEY(false); - mst_some_num.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_some_num.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - - MD5 some_num_hash("some_num"); - for(int i = 0; i < 4; ++i) - { - mst_some_num.detail().name_hash()[i] = some_num_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_some_num); - - MinimalStructMember mst_positive; - mst_positive.common().member_id(memberId++); - mst_positive.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_positive.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_positive.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_positive.common().member_flags().IS_OPTIONAL(false); - mst_positive.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_positive.common().member_flags().IS_KEY(false); - mst_positive.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_positive.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - MD5 positive_hash("positive"); - for(int i = 0; i < 4; ++i) - { - mst_positive.detail().name_hash()[i] = positive_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_positive); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - SerializedPayload_t payload(static_cast( - MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("TheOtherObjectInArray", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("TheOtherObjectInArray", false); -} - -const TypeObject* GetCompleteTheOtherObjectInArrayObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("TheOtherObjectInArray", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_some_num; - cst_some_num.common().member_id(memberId++); - cst_some_num.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_some_num.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_some_num.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_some_num.common().member_flags().IS_OPTIONAL(false); - cst_some_num.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_some_num.common().member_flags().IS_KEY(false); - cst_some_num.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_some_num.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - - cst_some_num.detail().name("some_num"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_some_num); - - CompleteStructMember cst_positive; - cst_positive.common().member_id(memberId++); - cst_positive.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_positive.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_positive.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_positive.common().member_flags().IS_OPTIONAL(false); - cst_positive.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_positive.common().member_flags().IS_KEY(false); - cst_positive.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_positive.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - cst_positive.detail().name("positive"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_positive); - - - // Header - type_object->complete().struct_type().header().detail().type_name("TheOtherObjectInArray"); - // TODO inheritance - - - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - SerializedPayload_t payload(static_cast( - CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("TheOtherObjectInArray", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("TheOtherObjectInArray", true); -} - -const TypeIdentifier* Getbasic_array_structIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("basic_array_struct", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - Getbasic_array_structObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("basic_array_struct", complete); -} - -const TypeObject* Getbasic_array_structObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("basic_array_struct", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompletebasic_array_structObject(); - } - //else - return GetMinimalbasic_array_structObject(); -} - -const TypeObject* GetMinimalbasic_array_structObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("basic_array_struct", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_index; - mst_index.common().member_id(memberId++); - mst_index.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_index.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_index.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_index.common().member_flags().IS_OPTIONAL(false); - mst_index.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_index.common().member_flags().IS_KEY(false); - mst_index.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_index.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); - - MD5 index_hash("index"); - for(int i = 0; i < 4; ++i) - { - mst_index.detail().name_hash()[i] = index_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_index); - - MinimalStructMember mst_sub_structs; - mst_sub_structs.common().member_id(memberId++); - mst_sub_structs.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_sub_structs.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_sub_structs.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_sub_structs.common().member_flags().IS_OPTIONAL(false); - mst_sub_structs.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_sub_structs.common().member_flags().IS_KEY(false); - mst_sub_structs.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_sub_structs.common().member_type_id(*TypeObjectFactory::get_instance()->get_array_identifier("TheOtherObjectInArray", {5}, false)); - - - MD5 sub_structs_hash("sub_structs"); - for(int i = 0; i < 4; ++i) - { - mst_sub_structs.detail().name_hash()[i] = sub_structs_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_sub_structs); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - SerializedPayload_t payload(static_cast( - MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("basic_array_struct", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("basic_array_struct", false); -} - -const TypeObject* GetCompletebasic_array_structObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("basic_array_struct", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_index; - cst_index.common().member_id(memberId++); - cst_index.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_index.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_index.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_index.common().member_flags().IS_OPTIONAL(false); - cst_index.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_index.common().member_flags().IS_KEY(false); - cst_index.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_index.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); - - cst_index.detail().name("index"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_index); - - CompleteStructMember cst_sub_structs; - cst_sub_structs.common().member_id(memberId++); - cst_sub_structs.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_sub_structs.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_sub_structs.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_sub_structs.common().member_flags().IS_OPTIONAL(false); - cst_sub_structs.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_sub_structs.common().member_flags().IS_KEY(false); - cst_sub_structs.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_sub_structs.common().member_type_id(*TypeObjectFactory::get_instance()->get_array_identifier("TheOtherObjectInArray", {5}, true)); - - - cst_sub_structs.detail().name("sub_structs"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_sub_structs); - - - // Header - type_object->complete().struct_type().header().detail().type_name("basic_array_struct"); - // TODO inheritance - - - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - SerializedPayload_t payload(static_cast( - CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("basic_array_struct", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("basic_array_struct", true); -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_structTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_structTypeObject.h deleted file mode 100644 index 097559ae..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_structTypeObject.h +++ /dev/null @@ -1,72 +0,0 @@ -// 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 basic_array_structTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifndef _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCT_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCT_TYPE_OBJECT_H_ - - -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define eProsima_user_DllExport -#endif // if defined(_WIN32) - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(basic_array_struct_SOURCE) -#define basic_array_struct_DllAPI __declspec( dllexport ) -#else -#define basic_array_struct_DllAPI __declspec( dllimport ) -#endif // basic_array_struct_SOURCE -#else -#define basic_array_struct_DllAPI -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define basic_array_struct_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registerbasic_array_structTypes(); - -eProsima_user_DllExport const TypeIdentifier* GetTheOtherObjectInArrayIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetTheOtherObjectInArrayObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalTheOtherObjectInArrayObject(); -eProsima_user_DllExport const TypeObject* GetCompleteTheOtherObjectInArrayObject(); - -eProsima_user_DllExport const TypeIdentifier* Getbasic_array_structIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* Getbasic_array_structObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalbasic_array_structObject(); -eProsima_user_DllExport const TypeObject* GetCompletebasic_array_structObject(); - - -#endif // _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCT_TYPE_OBJECT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_struct.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_struct.cxx deleted file mode 100644 index 009a888b..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_struct.cxx +++ /dev/null @@ -1,339 +0,0 @@ -// 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 basic_struct.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "basic_struct.h" -#include "basic_structTypeObject.h" -#include - -#include -using namespace eprosima::fastcdr::exception; - -#include - -TheOtherObject::TheOtherObject() -{ - // m_some_num com.eprosima.idl.parser.typecode.PrimitiveTypeCode@3cef309d - m_some_num = 0; - - // Just to register all known types - registerbasic_structTypes(); -} - -TheOtherObject::~TheOtherObject() -{ -} - -TheOtherObject::TheOtherObject( - const TheOtherObject& x) -{ - m_some_num = x.m_some_num; -} - -TheOtherObject::TheOtherObject( - TheOtherObject&& x) noexcept -{ - m_some_num = x.m_some_num; -} - -TheOtherObject& TheOtherObject::operator =( - const TheOtherObject& x) -{ - - m_some_num = x.m_some_num; - - return *this; -} - -TheOtherObject& TheOtherObject::operator =( - TheOtherObject&& x) noexcept -{ - - m_some_num = x.m_some_num; - - return *this; -} - -bool TheOtherObject::operator ==( - const TheOtherObject& x) const -{ - - return (m_some_num == x.m_some_num); -} - -bool TheOtherObject::operator !=( - const TheOtherObject& x) const -{ - return !(*this == x); -} - -size_t TheOtherObject::getMaxCdrSerializedSize( - size_t current_alignment) -{ - size_t initial_alignment = current_alignment; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - return current_alignment - initial_alignment; -} - -size_t TheOtherObject::getCdrSerializedSize( - const TheOtherObject& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - return current_alignment - initial_alignment; -} - -void TheOtherObject::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - - scdr << m_some_num; - -} - -void TheOtherObject::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - - dcdr >> m_some_num; -} - -/*! - * @brief This function sets a value in member some_num - * @param _some_num New value for member some_num - */ -void TheOtherObject::some_num( - int32_t _some_num) -{ - m_some_num = _some_num; -} - -/*! - * @brief This function returns the value of member some_num - * @return Value of member some_num - */ -int32_t TheOtherObject::some_num() const -{ - return m_some_num; -} - -/*! - * @brief This function returns a reference to member some_num - * @return Reference to member some_num - */ -int32_t& TheOtherObject::some_num() -{ - return m_some_num; -} - - -size_t TheOtherObject::getKeyMaxCdrSerializedSize( - size_t current_alignment) -{ - size_t current_align = current_alignment; - - - - return current_align; -} - -bool TheOtherObject::isKeyDefined() -{ - return false; -} - -void TheOtherObject::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; - -} - -basic_struct::basic_struct() -{ - // m_sub_struct com.eprosima.fastdds.idl.parser.typecode.StructTypeCode@5bcea91b - - - // Just to register all known types - registerbasic_structTypes(); -} - -basic_struct::~basic_struct() -{ -} - -basic_struct::basic_struct( - const basic_struct& x) -{ - m_sub_struct = x.m_sub_struct; -} - -basic_struct::basic_struct( - basic_struct&& x) noexcept -{ - m_sub_struct = std::move(x.m_sub_struct); -} - -basic_struct& basic_struct::operator =( - const basic_struct& x) -{ - - m_sub_struct = x.m_sub_struct; - - return *this; -} - -basic_struct& basic_struct::operator =( - basic_struct&& x) noexcept -{ - - m_sub_struct = std::move(x.m_sub_struct); - - return *this; -} - -bool basic_struct::operator ==( - const basic_struct& x) const -{ - - return (m_sub_struct == x.m_sub_struct); -} - -bool basic_struct::operator !=( - const basic_struct& x) const -{ - return !(*this == x); -} - -size_t basic_struct::getMaxCdrSerializedSize( - size_t current_alignment) -{ - size_t initial_alignment = current_alignment; - - - current_alignment += TheOtherObject::getMaxCdrSerializedSize(current_alignment); - - return current_alignment - initial_alignment; -} - -size_t basic_struct::getCdrSerializedSize( - const basic_struct& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - - current_alignment += TheOtherObject::getCdrSerializedSize(data.sub_struct(), current_alignment); - - return current_alignment - initial_alignment; -} - -void basic_struct::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - - scdr << m_sub_struct; - -} - -void basic_struct::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - - dcdr >> m_sub_struct; -} - -/*! - * @brief This function copies the value in member sub_struct - * @param _sub_struct New value to be copied in member sub_struct - */ -void basic_struct::sub_struct( - const TheOtherObject& _sub_struct) -{ - m_sub_struct = _sub_struct; -} - -/*! - * @brief This function moves the value in member sub_struct - * @param _sub_struct New value to be moved in member sub_struct - */ -void basic_struct::sub_struct( - TheOtherObject&& _sub_struct) -{ - m_sub_struct = std::move(_sub_struct); -} - -/*! - * @brief This function returns a constant reference to member sub_struct - * @return Constant reference to member sub_struct - */ -const TheOtherObject& basic_struct::sub_struct() const -{ - return m_sub_struct; -} - -/*! - * @brief This function returns a reference to member sub_struct - * @return Reference to member sub_struct - */ -TheOtherObject& basic_struct::sub_struct() -{ - return m_sub_struct; -} - -size_t basic_struct::getKeyMaxCdrSerializedSize( - size_t current_alignment) -{ - size_t current_align = current_alignment; - - - - return current_align; -} - -bool basic_struct::isKeyDefined() -{ - return false; -} - -void basic_struct::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; - -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_struct.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_struct.h deleted file mode 100644 index 53e1fe9e..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_struct.h +++ /dev/null @@ -1,355 +0,0 @@ -// 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 basic_struct.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifndef _FAST_DDS_GENERATED_BASIC_STRUCT_H_ -#define _FAST_DDS_GENERATED_BASIC_STRUCT_H_ - - -#include - -#include -#include -#include -#include -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(basic_struct_SOURCE) -#define basic_struct_DllAPI __declspec( dllexport ) -#else -#define basic_struct_DllAPI __declspec( dllimport ) -#endif // basic_struct_SOURCE -#else -#define basic_struct_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define basic_struct_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - -/*! - * @brief This class represents the structure TheOtherObject defined by the user in the IDL file. - * @ingroup BASIC_STRUCT - */ -class TheOtherObject -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport TheOtherObject(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~TheOtherObject(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object TheOtherObject that will be copied. - */ - eProsima_user_DllExport TheOtherObject( - const TheOtherObject& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object TheOtherObject that will be copied. - */ - eProsima_user_DllExport TheOtherObject( - TheOtherObject&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object TheOtherObject that will be copied. - */ - eProsima_user_DllExport TheOtherObject& operator =( - const TheOtherObject& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object TheOtherObject that will be copied. - */ - eProsima_user_DllExport TheOtherObject& operator =( - TheOtherObject&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x TheOtherObject object to compare. - */ - eProsima_user_DllExport bool operator ==( - const TheOtherObject& x) const; - - /*! - * @brief Comparison operator. - * @param x TheOtherObject object to compare. - */ - eProsima_user_DllExport bool operator !=( - const TheOtherObject& x) const; - - /*! - * @brief This function sets a value in member some_num - * @param _some_num New value for member some_num - */ - eProsima_user_DllExport void some_num( - int32_t _some_num); - - /*! - * @brief This function returns the value of member some_num - * @return Value of member some_num - */ - eProsima_user_DllExport int32_t some_num() const; - - /*! - * @brief This function returns a reference to member some_num - * @return Reference to member some_num - */ - eProsima_user_DllExport int32_t& some_num(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const TheOtherObject& data, - size_t current_alignment = 0); - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - /*! - * @brief This function returns the maximum serialized size of the Key of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - -private: - - int32_t m_some_num; -}; -/*! - * @brief This class represents the structure basic_struct defined by the user in the IDL file. - * @ingroup BASIC_STRUCT - */ -class basic_struct -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport basic_struct(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~basic_struct(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object basic_struct that will be copied. - */ - eProsima_user_DllExport basic_struct( - const basic_struct& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object basic_struct that will be copied. - */ - eProsima_user_DllExport basic_struct( - basic_struct&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object basic_struct that will be copied. - */ - eProsima_user_DllExport basic_struct& operator =( - const basic_struct& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object basic_struct that will be copied. - */ - eProsima_user_DllExport basic_struct& operator =( - basic_struct&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x basic_struct object to compare. - */ - eProsima_user_DllExport bool operator ==( - const basic_struct& x) const; - - /*! - * @brief Comparison operator. - * @param x basic_struct object to compare. - */ - eProsima_user_DllExport bool operator !=( - const basic_struct& x) const; - - /*! - * @brief This function copies the value in member sub_struct - * @param _sub_struct New value to be copied in member sub_struct - */ - eProsima_user_DllExport void sub_struct( - const TheOtherObject& _sub_struct); - - /*! - * @brief This function moves the value in member sub_struct - * @param _sub_struct New value to be moved in member sub_struct - */ - eProsima_user_DllExport void sub_struct( - TheOtherObject&& _sub_struct); - - /*! - * @brief This function returns a constant reference to member sub_struct - * @return Constant reference to member sub_struct - */ - eProsima_user_DllExport const TheOtherObject& sub_struct() const; - - /*! - * @brief This function returns a reference to member sub_struct - * @return Reference to member sub_struct - */ - eProsima_user_DllExport TheOtherObject& sub_struct(); - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const basic_struct& data, - size_t current_alignment = 0); - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - /*! - * @brief This function returns the maximum serialized size of the Key of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - -private: - - TheOtherObject m_sub_struct; -}; - -#endif // _FAST_DDS_GENERATED_BASIC_STRUCT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_structPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_structPubSubTypes.cxx deleted file mode 100644 index 04cc05b7..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_structPubSubTypes.cxx +++ /dev/null @@ -1,309 +0,0 @@ -// 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 basic_structPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#include -#include - -#include "basic_structPubSubTypes.h" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; - -TheOtherObjectPubSubType::TheOtherObjectPubSubType() -{ - setName("TheOtherObject"); - auto type_size = TheOtherObject::getMaxCdrSerializedSize(); - type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ - m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ - m_isGetKeyDefined = TheOtherObject::isKeyDefined(); - size_t keyLength = TheOtherObject::getKeyMaxCdrSerializedSize() > 16 ? - TheOtherObject::getKeyMaxCdrSerializedSize() : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -TheOtherObjectPubSubType::~TheOtherObjectPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool TheOtherObjectPubSubType::serialize( - void* data, - SerializedPayload_t* payload) -{ - TheOtherObject* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - // Serialize encapsulation - ser.serialize_encapsulation(); - - try - { - // Serialize the object. - p_type->serialize(ser); - } - catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) - { - return false; - } - - // Get the serialized length - payload->length = static_cast(ser.getSerializedDataLength()); - return true; -} - -bool TheOtherObjectPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - //Convert DATA to pointer of your type - TheOtherObject* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - p_type->deserialize(deser); - } - catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) - { - return false; - } - - return true; -} - -std::function TheOtherObjectPubSubType::getSerializedSizeProvider( - void* data) -{ - return [data]() -> uint32_t - { - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - }; -} - -void* TheOtherObjectPubSubType::createData() -{ - return reinterpret_cast(new TheOtherObject()); -} - -void TheOtherObjectPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool TheOtherObjectPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - TheOtherObject* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - TheOtherObject::getKeyMaxCdrSerializedSize()); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); - p_type->serializeKey(ser); - if (force_md5 || TheOtherObject::getKeyMaxCdrSerializedSize() > 16) - { - m_md5.init(); - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - -basic_structPubSubType::basic_structPubSubType() -{ - setName("basic_struct"); - auto type_size = basic_struct::getMaxCdrSerializedSize(); - type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ - m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ - m_isGetKeyDefined = basic_struct::isKeyDefined(); - size_t keyLength = basic_struct::getKeyMaxCdrSerializedSize() > 16 ? - basic_struct::getKeyMaxCdrSerializedSize() : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -basic_structPubSubType::~basic_structPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool basic_structPubSubType::serialize( - void* data, - SerializedPayload_t* payload) -{ - basic_struct* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - // Serialize encapsulation - ser.serialize_encapsulation(); - - try - { - // Serialize the object. - p_type->serialize(ser); - } - catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) - { - return false; - } - - // Get the serialized length - payload->length = static_cast(ser.getSerializedDataLength()); - return true; -} - -bool basic_structPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - //Convert DATA to pointer of your type - basic_struct* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - p_type->deserialize(deser); - } - catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) - { - return false; - } - - return true; -} - -std::function basic_structPubSubType::getSerializedSizeProvider( - void* data) -{ - return [data]() -> uint32_t - { - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - }; -} - -void* basic_structPubSubType::createData() -{ - return reinterpret_cast(new basic_struct()); -} - -void basic_structPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool basic_structPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - basic_struct* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - basic_struct::getKeyMaxCdrSerializedSize()); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); - p_type->serializeKey(ser); - if (force_md5 || basic_struct::getKeyMaxCdrSerializedSize() > 16) - { - m_md5.init(); - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_structPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_structPubSubTypes.h deleted file mode 100644 index cec5fc93..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_structPubSubTypes.h +++ /dev/null @@ -1,165 +0,0 @@ -// 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 basic_structPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#ifndef _FAST_DDS_GENERATED_BASIC_STRUCT_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_BASIC_STRUCT_PUBSUBTYPES_H_ - -#include -#include - -#include "basic_struct.h" - -#if !defined(GEN_API_VER) || (GEN_API_VER != 1) -#error \ - Generated basic_struct is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER - -/*! - * @brief This class represents the TopicDataType of the type TheOtherObject defined by the user in the IDL file. - * @ingroup BASIC_STRUCT - */ -class TheOtherObjectPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef TheOtherObject type; - - eProsima_user_DllExport TheOtherObjectPubSubType(); - - eProsima_user_DllExport virtual ~TheOtherObjectPubSubType() override; - - eProsima_user_DllExport virtual bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; - - eProsima_user_DllExport virtual bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport virtual std::function getSerializedSizeProvider( - void* data) override; - - eProsima_user_DllExport virtual bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport virtual void* createData() override; - - eProsima_user_DllExport virtual void deleteData( - void* data) override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - new (memory) TheOtherObject(); - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; -}; -/*! - * @brief This class represents the TopicDataType of the type basic_struct defined by the user in the IDL file. - * @ingroup BASIC_STRUCT - */ -class basic_structPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef basic_struct type; - - eProsima_user_DllExport basic_structPubSubType(); - - eProsima_user_DllExport virtual ~basic_structPubSubType() override; - - eProsima_user_DllExport virtual bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; - - eProsima_user_DllExport virtual bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport virtual std::function getSerializedSizeProvider( - void* data) override; - - eProsima_user_DllExport virtual bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport virtual void* createData() override; - - eProsima_user_DllExport virtual void deleteData( - void* data) override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - new (memory) basic_struct(); - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; -}; - -#endif // _FAST_DDS_GENERATED_BASIC_STRUCT_PUBSUBTYPES_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_structTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_structTypeObject.cxx deleted file mode 100644 index b881ad94..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_structTypeObject.cxx +++ /dev/null @@ -1,380 +0,0 @@ -// 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 basic_structTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { char dummy; } -#endif - -#include "basic_struct.h" -#include "basic_structTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerbasic_structTypes() -{ - TypeObjectFactory *factory = TypeObjectFactory::get_instance(); - factory->add_type_object("TheOtherObject", GetTheOtherObjectIdentifier(true), - GetTheOtherObjectObject(true)); - factory->add_type_object("TheOtherObject", GetTheOtherObjectIdentifier(false), - GetTheOtherObjectObject(false)); - - factory->add_type_object("basic_struct", Getbasic_structIdentifier(true), - Getbasic_structObject(true)); - factory->add_type_object("basic_struct", Getbasic_structIdentifier(false), - Getbasic_structObject(false)); - -} - -const TypeIdentifier* GetTheOtherObjectIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("TheOtherObject", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetTheOtherObjectObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("TheOtherObject", complete); -} - -const TypeObject* GetTheOtherObjectObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("TheOtherObject", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteTheOtherObjectObject(); - } - //else - return GetMinimalTheOtherObjectObject(); -} - -const TypeObject* GetMinimalTheOtherObjectObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("TheOtherObject", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_some_num; - mst_some_num.common().member_id(memberId++); - mst_some_num.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_some_num.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_some_num.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_some_num.common().member_flags().IS_OPTIONAL(false); - mst_some_num.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_some_num.common().member_flags().IS_KEY(false); - mst_some_num.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_some_num.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - - MD5 some_num_hash("some_num"); - for(int i = 0; i < 4; ++i) - { - mst_some_num.detail().name_hash()[i] = some_num_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_some_num); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - SerializedPayload_t payload(static_cast( - MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("TheOtherObject", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("TheOtherObject", false); -} - -const TypeObject* GetCompleteTheOtherObjectObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("TheOtherObject", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_some_num; - cst_some_num.common().member_id(memberId++); - cst_some_num.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_some_num.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_some_num.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_some_num.common().member_flags().IS_OPTIONAL(false); - cst_some_num.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_some_num.common().member_flags().IS_KEY(false); - cst_some_num.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_some_num.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - - cst_some_num.detail().name("some_num"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_some_num); - - - // Header - type_object->complete().struct_type().header().detail().type_name("TheOtherObject"); - // TODO inheritance - - - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - SerializedPayload_t payload(static_cast( - CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("TheOtherObject", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("TheOtherObject", true); -} - -const TypeIdentifier* Getbasic_structIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("basic_struct", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - Getbasic_structObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("basic_struct", complete); -} - -const TypeObject* Getbasic_structObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("basic_struct", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompletebasic_structObject(); - } - //else - return GetMinimalbasic_structObject(); -} - -const TypeObject* GetMinimalbasic_structObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("basic_struct", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_sub_struct; - mst_sub_struct.common().member_id(memberId++); - mst_sub_struct.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_sub_struct.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_sub_struct.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_sub_struct.common().member_flags().IS_OPTIONAL(false); - mst_sub_struct.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_sub_struct.common().member_flags().IS_KEY(false); - mst_sub_struct.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_sub_struct.common().member_type_id(*GetTheOtherObjectIdentifier(false)); - MD5 sub_struct_hash("sub_struct"); - for(int i = 0; i < 4; ++i) - { - mst_sub_struct.detail().name_hash()[i] = sub_struct_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_sub_struct); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - SerializedPayload_t payload(static_cast( - MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("basic_struct", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("basic_struct", false); -} - -const TypeObject* GetCompletebasic_structObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("basic_struct", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_sub_struct; - cst_sub_struct.common().member_id(memberId++); - cst_sub_struct.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_sub_struct.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_sub_struct.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_sub_struct.common().member_flags().IS_OPTIONAL(false); - cst_sub_struct.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_sub_struct.common().member_flags().IS_KEY(false); - cst_sub_struct.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_sub_struct.common().member_type_id(*GetTheOtherObjectIdentifier(true)); - cst_sub_struct.detail().name("sub_struct"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_sub_struct); - - - // Header - type_object->complete().struct_type().header().detail().type_name("basic_struct"); - // TODO inheritance - - - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - SerializedPayload_t payload(static_cast( - CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("basic_struct", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("basic_struct", true); -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_structTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_structTypeObject.h deleted file mode 100644 index 04ad8848..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_structTypeObject.h +++ /dev/null @@ -1,72 +0,0 @@ -// 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 basic_structTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifndef _FAST_DDS_GENERATED_BASIC_STRUCT_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_BASIC_STRUCT_TYPE_OBJECT_H_ - - -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define eProsima_user_DllExport -#endif // if defined(_WIN32) - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(basic_struct_SOURCE) -#define basic_struct_DllAPI __declspec( dllexport ) -#else -#define basic_struct_DllAPI __declspec( dllimport ) -#endif // basic_struct_SOURCE -#else -#define basic_struct_DllAPI -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define basic_struct_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registerbasic_structTypes(); - -eProsima_user_DllExport const TypeIdentifier* GetTheOtherObjectIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetTheOtherObjectObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalTheOtherObjectObject(); -eProsima_user_DllExport const TypeObject* GetCompleteTheOtherObjectObject(); - -eProsima_user_DllExport const TypeIdentifier* Getbasic_structIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* Getbasic_structObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalbasic_structObject(); -eProsima_user_DllExport const TypeObject* GetCompletebasic_structObject(); - - -#endif // _FAST_DDS_GENERATED_BASIC_STRUCT_TYPE_OBJECT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequence.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequence.cxx deleted file mode 100644 index 14eefab1..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequence.cxx +++ /dev/null @@ -1,200 +0,0 @@ -// 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 char_sequence.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "char_sequence.h" -#include "char_sequenceTypeObject.h" -#include - -#include -using namespace eprosima::fastcdr::exception; - -#include - -char_sequence::char_sequence() -{ - // m_chars com.eprosima.idl.parser.typecode.SequenceTypeCode@3fd7a715 - - - // Just to register all known types - registerchar_sequenceTypes(); -} - -char_sequence::~char_sequence() -{ -} - -char_sequence::char_sequence( - const char_sequence& x) -{ - m_chars = x.m_chars; -} - -char_sequence::char_sequence( - char_sequence&& x) noexcept -{ - m_chars = std::move(x.m_chars); -} - -char_sequence& char_sequence::operator =( - const char_sequence& x) -{ - - m_chars = x.m_chars; - - return *this; -} - -char_sequence& char_sequence::operator =( - char_sequence&& x) noexcept -{ - - m_chars = std::move(x.m_chars); - - return *this; -} - -bool char_sequence::operator ==( - const char_sequence& x) const -{ - - return (m_chars == x.m_chars); -} - -bool char_sequence::operator !=( - const char_sequence& x) const -{ - return !(*this == x); -} - -size_t char_sequence::getMaxCdrSerializedSize( - size_t current_alignment) -{ - size_t initial_alignment = current_alignment; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - current_alignment += (100 * 1) + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); - - - - return current_alignment - initial_alignment; -} - -size_t char_sequence::getCdrSerializedSize( - const char_sequence& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - if (data.chars().size() > 0) - { - current_alignment += (data.chars().size() * 1) + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); - } - - - - return current_alignment - initial_alignment; -} - -void char_sequence::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - - scdr << m_chars; -} - -void char_sequence::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - - dcdr >> m_chars;} - -/*! - * @brief This function copies the value in member chars - * @param _chars New value to be copied in member chars - */ -void char_sequence::chars( - const std::vector& _chars) -{ - m_chars = _chars; -} - -/*! - * @brief This function moves the value in member chars - * @param _chars New value to be moved in member chars - */ -void char_sequence::chars( - std::vector&& _chars) -{ - m_chars = std::move(_chars); -} - -/*! - * @brief This function returns a constant reference to member chars - * @return Constant reference to member chars - */ -const std::vector& char_sequence::chars() const -{ - return m_chars; -} - -/*! - * @brief This function returns a reference to member chars - * @return Reference to member chars - */ -std::vector& char_sequence::chars() -{ - return m_chars; -} - -size_t char_sequence::getKeyMaxCdrSerializedSize( - size_t current_alignment) -{ - size_t current_align = current_alignment; - - - - return current_align; -} - -bool char_sequence::isKeyDefined() -{ - return false; -} - -void char_sequence::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; - -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequence.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequence.h deleted file mode 100644 index 51c2bd1a..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequence.h +++ /dev/null @@ -1,214 +0,0 @@ -// 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 char_sequence.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifndef _FAST_DDS_GENERATED_CHAR_SEQUENCE_H_ -#define _FAST_DDS_GENERATED_CHAR_SEQUENCE_H_ - - -#include - -#include -#include -#include -#include -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(char_sequence_SOURCE) -#define char_sequence_DllAPI __declspec( dllexport ) -#else -#define char_sequence_DllAPI __declspec( dllimport ) -#endif // char_sequence_SOURCE -#else -#define char_sequence_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define char_sequence_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - -/*! - * @brief This class represents the structure char_sequence defined by the user in the IDL file. - * @ingroup CHAR_SEQUENCE - */ -class char_sequence -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport char_sequence(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~char_sequence(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object char_sequence that will be copied. - */ - eProsima_user_DllExport char_sequence( - const char_sequence& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object char_sequence that will be copied. - */ - eProsima_user_DllExport char_sequence( - char_sequence&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object char_sequence that will be copied. - */ - eProsima_user_DllExport char_sequence& operator =( - const char_sequence& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object char_sequence that will be copied. - */ - eProsima_user_DllExport char_sequence& operator =( - char_sequence&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x char_sequence object to compare. - */ - eProsima_user_DllExport bool operator ==( - const char_sequence& x) const; - - /*! - * @brief Comparison operator. - * @param x char_sequence object to compare. - */ - eProsima_user_DllExport bool operator !=( - const char_sequence& x) const; - - /*! - * @brief This function copies the value in member chars - * @param _chars New value to be copied in member chars - */ - eProsima_user_DllExport void chars( - const std::vector& _chars); - - /*! - * @brief This function moves the value in member chars - * @param _chars New value to be moved in member chars - */ - eProsima_user_DllExport void chars( - std::vector&& _chars); - - /*! - * @brief This function returns a constant reference to member chars - * @return Constant reference to member chars - */ - eProsima_user_DllExport const std::vector& chars() const; - - /*! - * @brief This function returns a reference to member chars - * @return Reference to member chars - */ - eProsima_user_DllExport std::vector& chars(); - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const char_sequence& data, - size_t current_alignment = 0); - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - /*! - * @brief This function returns the maximum serialized size of the Key of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - -private: - - std::vector m_chars; -}; - -#endif // _FAST_DDS_GENERATED_CHAR_SEQUENCE_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequencePubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequencePubSubTypes.cxx deleted file mode 100644 index d0fb01af..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequencePubSubTypes.cxx +++ /dev/null @@ -1,169 +0,0 @@ -// 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 char_sequencePubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#include -#include - -#include "char_sequencePubSubTypes.h" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; - -char_sequencePubSubType::char_sequencePubSubType() -{ - setName("char_sequence"); - auto type_size = char_sequence::getMaxCdrSerializedSize(); - type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ - m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ - m_isGetKeyDefined = char_sequence::isKeyDefined(); - size_t keyLength = char_sequence::getKeyMaxCdrSerializedSize() > 16 ? - char_sequence::getKeyMaxCdrSerializedSize() : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -char_sequencePubSubType::~char_sequencePubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool char_sequencePubSubType::serialize( - void* data, - SerializedPayload_t* payload) -{ - char_sequence* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - // Serialize encapsulation - ser.serialize_encapsulation(); - - try - { - // Serialize the object. - p_type->serialize(ser); - } - catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) - { - return false; - } - - // Get the serialized length - payload->length = static_cast(ser.getSerializedDataLength()); - return true; -} - -bool char_sequencePubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - //Convert DATA to pointer of your type - char_sequence* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - p_type->deserialize(deser); - } - catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) - { - return false; - } - - return true; -} - -std::function char_sequencePubSubType::getSerializedSizeProvider( - void* data) -{ - return [data]() -> uint32_t - { - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - }; -} - -void* char_sequencePubSubType::createData() -{ - return reinterpret_cast(new char_sequence()); -} - -void char_sequencePubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool char_sequencePubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - char_sequence* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - char_sequence::getKeyMaxCdrSerializedSize()); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); - p_type->serializeKey(ser); - if (force_md5 || char_sequence::getKeyMaxCdrSerializedSize() > 16) - { - m_md5.init(); - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequencePubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequencePubSubTypes.h deleted file mode 100644 index bfd9912d..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequencePubSubTypes.h +++ /dev/null @@ -1,101 +0,0 @@ -// 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 char_sequencePubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#ifndef _FAST_DDS_GENERATED_CHAR_SEQUENCE_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_CHAR_SEQUENCE_PUBSUBTYPES_H_ - -#include -#include - -#include "char_sequence.h" - -#if !defined(GEN_API_VER) || (GEN_API_VER != 1) -#error \ - Generated char_sequence is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER - -/*! - * @brief This class represents the TopicDataType of the type char_sequence defined by the user in the IDL file. - * @ingroup CHAR_SEQUENCE - */ -class char_sequencePubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef char_sequence type; - - eProsima_user_DllExport char_sequencePubSubType(); - - eProsima_user_DllExport virtual ~char_sequencePubSubType() override; - - eProsima_user_DllExport virtual bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; - - eProsima_user_DllExport virtual bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport virtual std::function getSerializedSizeProvider( - void* data) override; - - eProsima_user_DllExport virtual bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport virtual void* createData() override; - - eProsima_user_DllExport virtual void deleteData( - void* data) override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - (void)memory; - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; -}; - -#endif // _FAST_DDS_GENERATED_CHAR_SEQUENCE_PUBSUBTYPES_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequenceTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequenceTypeObject.cxx deleted file mode 100644 index 2bb805f5..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequenceTypeObject.cxx +++ /dev/null @@ -1,215 +0,0 @@ -// 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 char_sequenceTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { char dummy; } -#endif - -#include "char_sequence.h" -#include "char_sequenceTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerchar_sequenceTypes() -{ - TypeObjectFactory *factory = TypeObjectFactory::get_instance(); - factory->add_type_object("char_sequence", Getchar_sequenceIdentifier(true), - Getchar_sequenceObject(true)); - factory->add_type_object("char_sequence", Getchar_sequenceIdentifier(false), - Getchar_sequenceObject(false)); - -} - -const TypeIdentifier* Getchar_sequenceIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("char_sequence", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - Getchar_sequenceObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("char_sequence", complete); -} - -const TypeObject* Getchar_sequenceObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("char_sequence", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompletechar_sequenceObject(); - } - //else - return GetMinimalchar_sequenceObject(); -} - -const TypeObject* GetMinimalchar_sequenceObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("char_sequence", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_chars; - mst_chars.common().member_id(memberId++); - mst_chars.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_chars.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_chars.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_chars.common().member_flags().IS_OPTIONAL(false); - mst_chars.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_chars.common().member_flags().IS_KEY(false); - mst_chars.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_chars.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("char", 0, false)); - - - MD5 chars_hash("chars"); - for(int i = 0; i < 4; ++i) - { - mst_chars.detail().name_hash()[i] = chars_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_chars); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - SerializedPayload_t payload(static_cast( - MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("char_sequence", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("char_sequence", false); -} - -const TypeObject* GetCompletechar_sequenceObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("char_sequence", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_chars; - cst_chars.common().member_id(memberId++); - cst_chars.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_chars.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_chars.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_chars.common().member_flags().IS_OPTIONAL(false); - cst_chars.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_chars.common().member_flags().IS_KEY(false); - cst_chars.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_chars.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("char", 0, true)); - - - cst_chars.detail().name("chars"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_chars); - - - // Header - type_object->complete().struct_type().header().detail().type_name("char_sequence"); - // TODO inheritance - - - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - SerializedPayload_t payload(static_cast( - CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("char_sequence", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("char_sequence", true); -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequenceTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequenceTypeObject.h deleted file mode 100644 index 82e51f80..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequenceTypeObject.h +++ /dev/null @@ -1,65 +0,0 @@ -// 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 char_sequenceTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifndef _FAST_DDS_GENERATED_CHAR_SEQUENCE_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_CHAR_SEQUENCE_TYPE_OBJECT_H_ - - -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define eProsima_user_DllExport -#endif // if defined(_WIN32) - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(char_sequence_SOURCE) -#define char_sequence_DllAPI __declspec( dllexport ) -#else -#define char_sequence_DllAPI __declspec( dllimport ) -#endif // char_sequence_SOURCE -#else -#define char_sequence_DllAPI -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define char_sequence_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registerchar_sequenceTypes(); - -eProsima_user_DllExport const TypeIdentifier* Getchar_sequenceIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* Getchar_sequenceObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalchar_sequenceObject(); -eProsima_user_DllExport const TypeObject* GetCompletechar_sequenceObject(); - - -#endif // _FAST_DDS_GENERATED_CHAR_SEQUENCE_TYPE_OBJECT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arrays.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arrays.cxx deleted file mode 100644 index 2814386f..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arrays.cxx +++ /dev/null @@ -1,881 +0,0 @@ -// 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 complex_nested_arrays.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "complex_nested_arrays.h" -#include "complex_nested_arraysTypeObject.h" -#include - -#include -using namespace eprosima::fastcdr::exception; - -#include - -ThirdLevelElement::ThirdLevelElement() -{ - // m_x com.eprosima.idl.parser.typecode.PrimitiveTypeCode@47ef968d - m_x = 0.0; - // m_y com.eprosima.idl.parser.typecode.PrimitiveTypeCode@23e028a9 - m_y = 0.0; - - // Just to register all known types - registercomplex_nested_arraysTypes(); -} - -ThirdLevelElement::~ThirdLevelElement() -{ - - -} - -ThirdLevelElement::ThirdLevelElement( - const ThirdLevelElement& x) -{ - m_x = x.m_x; - m_y = x.m_y; -} - -ThirdLevelElement::ThirdLevelElement( - ThirdLevelElement&& x) noexcept -{ - m_x = x.m_x; - m_y = x.m_y; -} - -ThirdLevelElement& ThirdLevelElement::operator =( - const ThirdLevelElement& x) -{ - - m_x = x.m_x; - m_y = x.m_y; - - return *this; -} - -ThirdLevelElement& ThirdLevelElement::operator =( - ThirdLevelElement&& x) noexcept -{ - - m_x = x.m_x; - m_y = x.m_y; - - return *this; -} - -bool ThirdLevelElement::operator ==( - const ThirdLevelElement& x) const -{ - - return (m_x == x.m_x && m_y == x.m_y); -} - -bool ThirdLevelElement::operator !=( - const ThirdLevelElement& x) const -{ - return !(*this == x); -} - -size_t ThirdLevelElement::getMaxCdrSerializedSize( - size_t current_alignment) -{ - size_t initial_alignment = current_alignment; - - - current_alignment += 8 + eprosima::fastcdr::Cdr::alignment(current_alignment, 8); - - - current_alignment += 8 + eprosima::fastcdr::Cdr::alignment(current_alignment, 8); - - - - return current_alignment - initial_alignment; -} - -size_t ThirdLevelElement::getCdrSerializedSize( - const ThirdLevelElement& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - - current_alignment += 8 + eprosima::fastcdr::Cdr::alignment(current_alignment, 8); - - - current_alignment += 8 + eprosima::fastcdr::Cdr::alignment(current_alignment, 8); - - - - return current_alignment - initial_alignment; -} - -void ThirdLevelElement::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - - scdr << m_x; - scdr << m_y; - -} - -void ThirdLevelElement::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - - dcdr >> m_x; - dcdr >> m_y; -} - -/*! - * @brief This function sets a value in member x - * @param _x New value for member x - */ -void ThirdLevelElement::x( - double _x) -{ - m_x = _x; -} - -/*! - * @brief This function returns the value of member x - * @return Value of member x - */ -double ThirdLevelElement::x() const -{ - return m_x; -} - -/*! - * @brief This function returns a reference to member x - * @return Reference to member x - */ -double& ThirdLevelElement::x() -{ - return m_x; -} - -/*! - * @brief This function sets a value in member y - * @param _y New value for member y - */ -void ThirdLevelElement::y( - double _y) -{ - m_y = _y; -} - -/*! - * @brief This function returns the value of member y - * @return Value of member y - */ -double ThirdLevelElement::y() const -{ - return m_y; -} - -/*! - * @brief This function returns a reference to member y - * @return Reference to member y - */ -double& ThirdLevelElement::y() -{ - return m_y; -} - - -size_t ThirdLevelElement::getKeyMaxCdrSerializedSize( - size_t current_alignment) -{ - size_t current_align = current_alignment; - - - - - - return current_align; -} - -bool ThirdLevelElement::isKeyDefined() -{ - return false; -} - -void ThirdLevelElement::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; - -} - -SecondLevelElement::SecondLevelElement() -{ - // m_an_element_alone com.eprosima.fastdds.idl.parser.typecode.StructTypeCode@2db7a79b - - // m_a_limited_other_value com.eprosima.idl.parser.typecode.SequenceTypeCode@6950e31 - - - // Just to register all known types - registercomplex_nested_arraysTypes(); -} - -SecondLevelElement::~SecondLevelElement() -{ - - -} - -SecondLevelElement::SecondLevelElement( - const SecondLevelElement& x) -{ - m_an_element_alone = x.m_an_element_alone; - m_a_limited_other_value = x.m_a_limited_other_value; -} - -SecondLevelElement::SecondLevelElement( - SecondLevelElement&& x) noexcept -{ - m_an_element_alone = std::move(x.m_an_element_alone); - m_a_limited_other_value = std::move(x.m_a_limited_other_value); -} - -SecondLevelElement& SecondLevelElement::operator =( - const SecondLevelElement& x) -{ - - m_an_element_alone = x.m_an_element_alone; - m_a_limited_other_value = x.m_a_limited_other_value; - - return *this; -} - -SecondLevelElement& SecondLevelElement::operator =( - SecondLevelElement&& x) noexcept -{ - - m_an_element_alone = std::move(x.m_an_element_alone); - m_a_limited_other_value = std::move(x.m_a_limited_other_value); - - return *this; -} - -bool SecondLevelElement::operator ==( - const SecondLevelElement& x) const -{ - - return (m_an_element_alone == x.m_an_element_alone && m_a_limited_other_value == x.m_a_limited_other_value); -} - -bool SecondLevelElement::operator !=( - const SecondLevelElement& x) const -{ - return !(*this == x); -} - -size_t SecondLevelElement::getMaxCdrSerializedSize( - size_t current_alignment) -{ - size_t initial_alignment = current_alignment; - - - current_alignment += ThirdLevelElement::getMaxCdrSerializedSize(current_alignment); - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - for(size_t a = 0; a < 1; ++a) - { - current_alignment += ThirdLevelElement::getMaxCdrSerializedSize(current_alignment);} - - - return current_alignment - initial_alignment; -} - -size_t SecondLevelElement::getCdrSerializedSize( - const SecondLevelElement& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - - current_alignment += ThirdLevelElement::getCdrSerializedSize(data.an_element_alone(), current_alignment); - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - for(size_t a = 0; a < data.a_limited_other_value().size(); ++a) - { - current_alignment += ThirdLevelElement::getCdrSerializedSize(data.a_limited_other_value().at(a), current_alignment);} - - - return current_alignment - initial_alignment; -} - -void SecondLevelElement::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - - scdr << m_an_element_alone; - scdr << m_a_limited_other_value; - -} - -void SecondLevelElement::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - - dcdr >> m_an_element_alone; - dcdr >> m_a_limited_other_value; -} - -/*! - * @brief This function copies the value in member an_element_alone - * @param _an_element_alone New value to be copied in member an_element_alone - */ -void SecondLevelElement::an_element_alone( - const ThirdLevelElement& _an_element_alone) -{ - m_an_element_alone = _an_element_alone; -} - -/*! - * @brief This function moves the value in member an_element_alone - * @param _an_element_alone New value to be moved in member an_element_alone - */ -void SecondLevelElement::an_element_alone( - ThirdLevelElement&& _an_element_alone) -{ - m_an_element_alone = std::move(_an_element_alone); -} - -/*! - * @brief This function returns a constant reference to member an_element_alone - * @return Constant reference to member an_element_alone - */ -const ThirdLevelElement& SecondLevelElement::an_element_alone() const -{ - return m_an_element_alone; -} - -/*! - * @brief This function returns a reference to member an_element_alone - * @return Reference to member an_element_alone - */ -ThirdLevelElement& SecondLevelElement::an_element_alone() -{ - return m_an_element_alone; -} -/*! - * @brief This function copies the value in member a_limited_other_value - * @param _a_limited_other_value New value to be copied in member a_limited_other_value - */ -void SecondLevelElement::a_limited_other_value( - const std::vector& _a_limited_other_value) -{ - m_a_limited_other_value = _a_limited_other_value; -} - -/*! - * @brief This function moves the value in member a_limited_other_value - * @param _a_limited_other_value New value to be moved in member a_limited_other_value - */ -void SecondLevelElement::a_limited_other_value( - std::vector&& _a_limited_other_value) -{ - m_a_limited_other_value = std::move(_a_limited_other_value); -} - -/*! - * @brief This function returns a constant reference to member a_limited_other_value - * @return Constant reference to member a_limited_other_value - */ -const std::vector& SecondLevelElement::a_limited_other_value() const -{ - return m_a_limited_other_value; -} - -/*! - * @brief This function returns a reference to member a_limited_other_value - * @return Reference to member a_limited_other_value - */ -std::vector& SecondLevelElement::a_limited_other_value() -{ - return m_a_limited_other_value; -} - -size_t SecondLevelElement::getKeyMaxCdrSerializedSize( - size_t current_alignment) -{ - size_t current_align = current_alignment; - - - - - - return current_align; -} - -bool SecondLevelElement::isKeyDefined() -{ - return false; -} - -void SecondLevelElement::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; - -} - -FirstLevelElement::FirstLevelElement() -{ - // m_useless_name com.eprosima.idl.parser.typecode.StringTypeCode@5891e32e - m_useless_name =""; - // m_sub com.eprosima.idl.parser.typecode.SequenceTypeCode@cb0ed20 - - // m_an_element_alone com.eprosima.fastdds.idl.parser.typecode.StructTypeCode@2db7a79b - - - // Just to register all known types - registercomplex_nested_arraysTypes(); -} - -FirstLevelElement::~FirstLevelElement() -{ - - - -} - -FirstLevelElement::FirstLevelElement( - const FirstLevelElement& x) -{ - m_useless_name = x.m_useless_name; - m_sub = x.m_sub; - m_an_element_alone = x.m_an_element_alone; -} - -FirstLevelElement::FirstLevelElement( - FirstLevelElement&& x) noexcept -{ - m_useless_name = std::move(x.m_useless_name); - m_sub = std::move(x.m_sub); - m_an_element_alone = std::move(x.m_an_element_alone); -} - -FirstLevelElement& FirstLevelElement::operator =( - const FirstLevelElement& x) -{ - - m_useless_name = x.m_useless_name; - m_sub = x.m_sub; - m_an_element_alone = x.m_an_element_alone; - - return *this; -} - -FirstLevelElement& FirstLevelElement::operator =( - FirstLevelElement&& x) noexcept -{ - - m_useless_name = std::move(x.m_useless_name); - m_sub = std::move(x.m_sub); - m_an_element_alone = std::move(x.m_an_element_alone); - - return *this; -} - -bool FirstLevelElement::operator ==( - const FirstLevelElement& x) const -{ - - return (m_useless_name == x.m_useless_name && m_sub == x.m_sub && m_an_element_alone == x.m_an_element_alone); -} - -bool FirstLevelElement::operator !=( - const FirstLevelElement& x) const -{ - return !(*this == x); -} - -size_t FirstLevelElement::getMaxCdrSerializedSize( - size_t current_alignment) -{ - size_t initial_alignment = current_alignment; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + 255 + 1; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - for(size_t a = 0; a < 100; ++a) - { - current_alignment += SecondLevelElement::getMaxCdrSerializedSize(current_alignment);} - - current_alignment += ThirdLevelElement::getMaxCdrSerializedSize(current_alignment); - - return current_alignment - initial_alignment; -} - -size_t FirstLevelElement::getCdrSerializedSize( - const FirstLevelElement& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.useless_name().size() + 1; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - for(size_t a = 0; a < data.sub().size(); ++a) - { - current_alignment += SecondLevelElement::getCdrSerializedSize(data.sub().at(a), current_alignment);} - - current_alignment += ThirdLevelElement::getCdrSerializedSize(data.an_element_alone(), current_alignment); - - return current_alignment - initial_alignment; -} - -void FirstLevelElement::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - - scdr << m_useless_name.c_str(); - scdr << m_sub; - scdr << m_an_element_alone; - -} - -void FirstLevelElement::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - - dcdr >> m_useless_name; - dcdr >> m_sub; - dcdr >> m_an_element_alone; -} - -/*! - * @brief This function copies the value in member useless_name - * @param _useless_name New value to be copied in member useless_name - */ -void FirstLevelElement::useless_name( - const std::string& _useless_name) -{ - m_useless_name = _useless_name; -} - -/*! - * @brief This function moves the value in member useless_name - * @param _useless_name New value to be moved in member useless_name - */ -void FirstLevelElement::useless_name( - std::string&& _useless_name) -{ - m_useless_name = std::move(_useless_name); -} - -/*! - * @brief This function returns a constant reference to member useless_name - * @return Constant reference to member useless_name - */ -const std::string& FirstLevelElement::useless_name() const -{ - return m_useless_name; -} - -/*! - * @brief This function returns a reference to member useless_name - * @return Reference to member useless_name - */ -std::string& FirstLevelElement::useless_name() -{ - return m_useless_name; -} -/*! - * @brief This function copies the value in member sub - * @param _sub New value to be copied in member sub - */ -void FirstLevelElement::sub( - const std::vector& _sub) -{ - m_sub = _sub; -} - -/*! - * @brief This function moves the value in member sub - * @param _sub New value to be moved in member sub - */ -void FirstLevelElement::sub( - std::vector&& _sub) -{ - m_sub = std::move(_sub); -} - -/*! - * @brief This function returns a constant reference to member sub - * @return Constant reference to member sub - */ -const std::vector& FirstLevelElement::sub() const -{ - return m_sub; -} - -/*! - * @brief This function returns a reference to member sub - * @return Reference to member sub - */ -std::vector& FirstLevelElement::sub() -{ - return m_sub; -} -/*! - * @brief This function copies the value in member an_element_alone - * @param _an_element_alone New value to be copied in member an_element_alone - */ -void FirstLevelElement::an_element_alone( - const ThirdLevelElement& _an_element_alone) -{ - m_an_element_alone = _an_element_alone; -} - -/*! - * @brief This function moves the value in member an_element_alone - * @param _an_element_alone New value to be moved in member an_element_alone - */ -void FirstLevelElement::an_element_alone( - ThirdLevelElement&& _an_element_alone) -{ - m_an_element_alone = std::move(_an_element_alone); -} - -/*! - * @brief This function returns a constant reference to member an_element_alone - * @return Constant reference to member an_element_alone - */ -const ThirdLevelElement& FirstLevelElement::an_element_alone() const -{ - return m_an_element_alone; -} - -/*! - * @brief This function returns a reference to member an_element_alone - * @return Reference to member an_element_alone - */ -ThirdLevelElement& FirstLevelElement::an_element_alone() -{ - return m_an_element_alone; -} - -size_t FirstLevelElement::getKeyMaxCdrSerializedSize( - size_t current_alignment) -{ - size_t current_align = current_alignment; - - - - - - - return current_align; -} - -bool FirstLevelElement::isKeyDefined() -{ - return false; -} - -void FirstLevelElement::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; - -} - -complex_nested_arrays::complex_nested_arrays() -{ - // m_array_of_elements com.eprosima.idl.parser.typecode.ArrayTypeCode@1fc2b765 - - - // Just to register all known types - registercomplex_nested_arraysTypes(); -} - -complex_nested_arrays::~complex_nested_arrays() -{ -} - -complex_nested_arrays::complex_nested_arrays( - const complex_nested_arrays& x) -{ - m_array_of_elements = x.m_array_of_elements; -} - -complex_nested_arrays::complex_nested_arrays( - complex_nested_arrays&& x) noexcept -{ - m_array_of_elements = std::move(x.m_array_of_elements); -} - -complex_nested_arrays& complex_nested_arrays::operator =( - const complex_nested_arrays& x) -{ - - m_array_of_elements = x.m_array_of_elements; - - return *this; -} - -complex_nested_arrays& complex_nested_arrays::operator =( - complex_nested_arrays&& x) noexcept -{ - - m_array_of_elements = std::move(x.m_array_of_elements); - - return *this; -} - -bool complex_nested_arrays::operator ==( - const complex_nested_arrays& x) const -{ - - return (m_array_of_elements == x.m_array_of_elements); -} - -bool complex_nested_arrays::operator !=( - const complex_nested_arrays& x) const -{ - return !(*this == x); -} - -size_t complex_nested_arrays::getMaxCdrSerializedSize( - size_t current_alignment) -{ - size_t initial_alignment = current_alignment; - - - - for(size_t a = 0; a < (3); ++a) - { - current_alignment += FirstLevelElement::getMaxCdrSerializedSize(current_alignment);} - return current_alignment - initial_alignment; -} - -size_t complex_nested_arrays::getCdrSerializedSize( - const complex_nested_arrays& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - - - for(size_t a = 0; a < data.array_of_elements().size(); ++a) - { - current_alignment += FirstLevelElement::getCdrSerializedSize(data.array_of_elements().at(a), current_alignment); - } - return current_alignment - initial_alignment; -} - -void complex_nested_arrays::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - - scdr << m_array_of_elements; - - -} - -void complex_nested_arrays::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - - dcdr >> m_array_of_elements; - -} - -/*! - * @brief This function copies the value in member array_of_elements - * @param _array_of_elements New value to be copied in member array_of_elements - */ -void complex_nested_arrays::array_of_elements( - const std::array& _array_of_elements) -{ - m_array_of_elements = _array_of_elements; -} - -/*! - * @brief This function moves the value in member array_of_elements - * @param _array_of_elements New value to be moved in member array_of_elements - */ -void complex_nested_arrays::array_of_elements( - std::array&& _array_of_elements) -{ - m_array_of_elements = std::move(_array_of_elements); -} - -/*! - * @brief This function returns a constant reference to member array_of_elements - * @return Constant reference to member array_of_elements - */ -const std::array& complex_nested_arrays::array_of_elements() const -{ - return m_array_of_elements; -} - -/*! - * @brief This function returns a reference to member array_of_elements - * @return Reference to member array_of_elements - */ -std::array& complex_nested_arrays::array_of_elements() -{ - return m_array_of_elements; -} - -size_t complex_nested_arrays::getKeyMaxCdrSerializedSize( - size_t current_alignment) -{ - size_t current_align = current_alignment; - - - - return current_align; -} - -bool complex_nested_arrays::isKeyDefined() -{ - return false; -} - -void complex_nested_arrays::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; - -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arrays.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arrays.h deleted file mode 100644 index dd1b58ff..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arrays.h +++ /dev/null @@ -1,747 +0,0 @@ -// 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 complex_nested_arrays.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifndef _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYS_H_ -#define _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYS_H_ - - -#include - -#include -#include -#include -#include -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(complex_nested_arrays_SOURCE) -#define complex_nested_arrays_DllAPI __declspec( dllexport ) -#else -#define complex_nested_arrays_DllAPI __declspec( dllimport ) -#endif // complex_nested_arrays_SOURCE -#else -#define complex_nested_arrays_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define complex_nested_arrays_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - -/*! - * @brief This class represents the structure ThirdLevelElement defined by the user in the IDL file. - * @ingroup COMPLEX_NESTED_ARRAYS - */ -class ThirdLevelElement -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport ThirdLevelElement(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~ThirdLevelElement(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object ThirdLevelElement that will be copied. - */ - eProsima_user_DllExport ThirdLevelElement( - const ThirdLevelElement& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object ThirdLevelElement that will be copied. - */ - eProsima_user_DllExport ThirdLevelElement( - ThirdLevelElement&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object ThirdLevelElement that will be copied. - */ - eProsima_user_DllExport ThirdLevelElement& operator =( - const ThirdLevelElement& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object ThirdLevelElement that will be copied. - */ - eProsima_user_DllExport ThirdLevelElement& operator =( - ThirdLevelElement&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x ThirdLevelElement object to compare. - */ - eProsima_user_DllExport bool operator ==( - const ThirdLevelElement& x) const; - - /*! - * @brief Comparison operator. - * @param x ThirdLevelElement object to compare. - */ - eProsima_user_DllExport bool operator !=( - const ThirdLevelElement& x) const; - - /*! - * @brief This function sets a value in member x - * @param _x New value for member x - */ - eProsima_user_DllExport void x( - double _x); - - /*! - * @brief This function returns the value of member x - * @return Value of member x - */ - eProsima_user_DllExport double x() const; - - /*! - * @brief This function returns a reference to member x - * @return Reference to member x - */ - eProsima_user_DllExport double& x(); - - /*! - * @brief This function sets a value in member y - * @param _y New value for member y - */ - eProsima_user_DllExport void y( - double _y); - - /*! - * @brief This function returns the value of member y - * @return Value of member y - */ - eProsima_user_DllExport double y() const; - - /*! - * @brief This function returns a reference to member y - * @return Reference to member y - */ - eProsima_user_DllExport double& y(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const ThirdLevelElement& data, - size_t current_alignment = 0); - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - /*! - * @brief This function returns the maximum serialized size of the Key of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - -private: - - double m_x; - double m_y; -}; -/*! - * @brief This class represents the structure SecondLevelElement defined by the user in the IDL file. - * @ingroup COMPLEX_NESTED_ARRAYS - */ -class SecondLevelElement -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport SecondLevelElement(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~SecondLevelElement(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object SecondLevelElement that will be copied. - */ - eProsima_user_DllExport SecondLevelElement( - const SecondLevelElement& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object SecondLevelElement that will be copied. - */ - eProsima_user_DllExport SecondLevelElement( - SecondLevelElement&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object SecondLevelElement that will be copied. - */ - eProsima_user_DllExport SecondLevelElement& operator =( - const SecondLevelElement& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object SecondLevelElement that will be copied. - */ - eProsima_user_DllExport SecondLevelElement& operator =( - SecondLevelElement&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x SecondLevelElement object to compare. - */ - eProsima_user_DllExport bool operator ==( - const SecondLevelElement& x) const; - - /*! - * @brief Comparison operator. - * @param x SecondLevelElement object to compare. - */ - eProsima_user_DllExport bool operator !=( - const SecondLevelElement& x) const; - - /*! - * @brief This function copies the value in member an_element_alone - * @param _an_element_alone New value to be copied in member an_element_alone - */ - eProsima_user_DllExport void an_element_alone( - const ThirdLevelElement& _an_element_alone); - - /*! - * @brief This function moves the value in member an_element_alone - * @param _an_element_alone New value to be moved in member an_element_alone - */ - eProsima_user_DllExport void an_element_alone( - ThirdLevelElement&& _an_element_alone); - - /*! - * @brief This function returns a constant reference to member an_element_alone - * @return Constant reference to member an_element_alone - */ - eProsima_user_DllExport const ThirdLevelElement& an_element_alone() const; - - /*! - * @brief This function returns a reference to member an_element_alone - * @return Reference to member an_element_alone - */ - eProsima_user_DllExport ThirdLevelElement& an_element_alone(); - /*! - * @brief This function copies the value in member a_limited_other_value - * @param _a_limited_other_value New value to be copied in member a_limited_other_value - */ - eProsima_user_DllExport void a_limited_other_value( - const std::vector& _a_limited_other_value); - - /*! - * @brief This function moves the value in member a_limited_other_value - * @param _a_limited_other_value New value to be moved in member a_limited_other_value - */ - eProsima_user_DllExport void a_limited_other_value( - std::vector&& _a_limited_other_value); - - /*! - * @brief This function returns a constant reference to member a_limited_other_value - * @return Constant reference to member a_limited_other_value - */ - eProsima_user_DllExport const std::vector& a_limited_other_value() const; - - /*! - * @brief This function returns a reference to member a_limited_other_value - * @return Reference to member a_limited_other_value - */ - eProsima_user_DllExport std::vector& a_limited_other_value(); - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const SecondLevelElement& data, - size_t current_alignment = 0); - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - /*! - * @brief This function returns the maximum serialized size of the Key of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - -private: - - ThirdLevelElement m_an_element_alone; - std::vector m_a_limited_other_value; -}; -/*! - * @brief This class represents the structure FirstLevelElement defined by the user in the IDL file. - * @ingroup COMPLEX_NESTED_ARRAYS - */ -class FirstLevelElement -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport FirstLevelElement(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~FirstLevelElement(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object FirstLevelElement that will be copied. - */ - eProsima_user_DllExport FirstLevelElement( - const FirstLevelElement& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object FirstLevelElement that will be copied. - */ - eProsima_user_DllExport FirstLevelElement( - FirstLevelElement&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object FirstLevelElement that will be copied. - */ - eProsima_user_DllExport FirstLevelElement& operator =( - const FirstLevelElement& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object FirstLevelElement that will be copied. - */ - eProsima_user_DllExport FirstLevelElement& operator =( - FirstLevelElement&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x FirstLevelElement object to compare. - */ - eProsima_user_DllExport bool operator ==( - const FirstLevelElement& x) const; - - /*! - * @brief Comparison operator. - * @param x FirstLevelElement object to compare. - */ - eProsima_user_DllExport bool operator !=( - const FirstLevelElement& x) const; - - /*! - * @brief This function copies the value in member useless_name - * @param _useless_name New value to be copied in member useless_name - */ - eProsima_user_DllExport void useless_name( - const std::string& _useless_name); - - /*! - * @brief This function moves the value in member useless_name - * @param _useless_name New value to be moved in member useless_name - */ - eProsima_user_DllExport void useless_name( - std::string&& _useless_name); - - /*! - * @brief This function returns a constant reference to member useless_name - * @return Constant reference to member useless_name - */ - eProsima_user_DllExport const std::string& useless_name() const; - - /*! - * @brief This function returns a reference to member useless_name - * @return Reference to member useless_name - */ - eProsima_user_DllExport std::string& useless_name(); - /*! - * @brief This function copies the value in member sub - * @param _sub New value to be copied in member sub - */ - eProsima_user_DllExport void sub( - const std::vector& _sub); - - /*! - * @brief This function moves the value in member sub - * @param _sub New value to be moved in member sub - */ - eProsima_user_DllExport void sub( - std::vector&& _sub); - - /*! - * @brief This function returns a constant reference to member sub - * @return Constant reference to member sub - */ - eProsima_user_DllExport const std::vector& sub() const; - - /*! - * @brief This function returns a reference to member sub - * @return Reference to member sub - */ - eProsima_user_DllExport std::vector& sub(); - /*! - * @brief This function copies the value in member an_element_alone - * @param _an_element_alone New value to be copied in member an_element_alone - */ - eProsima_user_DllExport void an_element_alone( - const ThirdLevelElement& _an_element_alone); - - /*! - * @brief This function moves the value in member an_element_alone - * @param _an_element_alone New value to be moved in member an_element_alone - */ - eProsima_user_DllExport void an_element_alone( - ThirdLevelElement&& _an_element_alone); - - /*! - * @brief This function returns a constant reference to member an_element_alone - * @return Constant reference to member an_element_alone - */ - eProsima_user_DllExport const ThirdLevelElement& an_element_alone() const; - - /*! - * @brief This function returns a reference to member an_element_alone - * @return Reference to member an_element_alone - */ - eProsima_user_DllExport ThirdLevelElement& an_element_alone(); - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const FirstLevelElement& data, - size_t current_alignment = 0); - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - /*! - * @brief This function returns the maximum serialized size of the Key of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - -private: - - std::string m_useless_name; - std::vector m_sub; - ThirdLevelElement m_an_element_alone; -}; -/*! - * @brief This class represents the structure complex_nested_arrays defined by the user in the IDL file. - * @ingroup COMPLEX_NESTED_ARRAYS - */ -class complex_nested_arrays -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport complex_nested_arrays(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~complex_nested_arrays(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object complex_nested_arrays that will be copied. - */ - eProsima_user_DllExport complex_nested_arrays( - const complex_nested_arrays& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object complex_nested_arrays that will be copied. - */ - eProsima_user_DllExport complex_nested_arrays( - complex_nested_arrays&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object complex_nested_arrays that will be copied. - */ - eProsima_user_DllExport complex_nested_arrays& operator =( - const complex_nested_arrays& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object complex_nested_arrays that will be copied. - */ - eProsima_user_DllExport complex_nested_arrays& operator =( - complex_nested_arrays&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x complex_nested_arrays object to compare. - */ - eProsima_user_DllExport bool operator ==( - const complex_nested_arrays& x) const; - - /*! - * @brief Comparison operator. - * @param x complex_nested_arrays object to compare. - */ - eProsima_user_DllExport bool operator !=( - const complex_nested_arrays& x) const; - - /*! - * @brief This function copies the value in member array_of_elements - * @param _array_of_elements New value to be copied in member array_of_elements - */ - eProsima_user_DllExport void array_of_elements( - const std::array& _array_of_elements); - - /*! - * @brief This function moves the value in member array_of_elements - * @param _array_of_elements New value to be moved in member array_of_elements - */ - eProsima_user_DllExport void array_of_elements( - std::array&& _array_of_elements); - - /*! - * @brief This function returns a constant reference to member array_of_elements - * @return Constant reference to member array_of_elements - */ - eProsima_user_DllExport const std::array& array_of_elements() const; - - /*! - * @brief This function returns a reference to member array_of_elements - * @return Reference to member array_of_elements - */ - eProsima_user_DllExport std::array& array_of_elements(); - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const complex_nested_arrays& data, - size_t current_alignment = 0); - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - /*! - * @brief This function returns the maximum serialized size of the Key of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - -private: - - std::array m_array_of_elements; -}; - -#endif // _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYS_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arraysPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arraysPubSubTypes.cxx deleted file mode 100644 index 1b7c758f..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arraysPubSubTypes.cxx +++ /dev/null @@ -1,589 +0,0 @@ -// 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 complex_nested_arraysPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#include -#include - -#include "complex_nested_arraysPubSubTypes.h" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; - -ThirdLevelElementPubSubType::ThirdLevelElementPubSubType() -{ - setName("ThirdLevelElement"); - auto type_size = ThirdLevelElement::getMaxCdrSerializedSize(); - type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ - m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ - m_isGetKeyDefined = ThirdLevelElement::isKeyDefined(); - size_t keyLength = ThirdLevelElement::getKeyMaxCdrSerializedSize() > 16 ? - ThirdLevelElement::getKeyMaxCdrSerializedSize() : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -ThirdLevelElementPubSubType::~ThirdLevelElementPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool ThirdLevelElementPubSubType::serialize( - void* data, - SerializedPayload_t* payload) -{ - ThirdLevelElement* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - // Serialize encapsulation - ser.serialize_encapsulation(); - - try - { - // Serialize the object. - p_type->serialize(ser); - } - catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) - { - return false; - } - - // Get the serialized length - payload->length = static_cast(ser.getSerializedDataLength()); - return true; -} - -bool ThirdLevelElementPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - //Convert DATA to pointer of your type - ThirdLevelElement* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - p_type->deserialize(deser); - } - catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) - { - return false; - } - - return true; -} - -std::function ThirdLevelElementPubSubType::getSerializedSizeProvider( - void* data) -{ - return [data]() -> uint32_t - { - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - }; -} - -void* ThirdLevelElementPubSubType::createData() -{ - return reinterpret_cast(new ThirdLevelElement()); -} - -void ThirdLevelElementPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool ThirdLevelElementPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - ThirdLevelElement* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - ThirdLevelElement::getKeyMaxCdrSerializedSize()); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); - p_type->serializeKey(ser); - if (force_md5 || ThirdLevelElement::getKeyMaxCdrSerializedSize() > 16) - { - m_md5.init(); - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - -SecondLevelElementPubSubType::SecondLevelElementPubSubType() -{ - setName("SecondLevelElement"); - auto type_size = SecondLevelElement::getMaxCdrSerializedSize(); - type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ - m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ - m_isGetKeyDefined = SecondLevelElement::isKeyDefined(); - size_t keyLength = SecondLevelElement::getKeyMaxCdrSerializedSize() > 16 ? - SecondLevelElement::getKeyMaxCdrSerializedSize() : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -SecondLevelElementPubSubType::~SecondLevelElementPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool SecondLevelElementPubSubType::serialize( - void* data, - SerializedPayload_t* payload) -{ - SecondLevelElement* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - // Serialize encapsulation - ser.serialize_encapsulation(); - - try - { - // Serialize the object. - p_type->serialize(ser); - } - catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) - { - return false; - } - - // Get the serialized length - payload->length = static_cast(ser.getSerializedDataLength()); - return true; -} - -bool SecondLevelElementPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - //Convert DATA to pointer of your type - SecondLevelElement* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - p_type->deserialize(deser); - } - catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) - { - return false; - } - - return true; -} - -std::function SecondLevelElementPubSubType::getSerializedSizeProvider( - void* data) -{ - return [data]() -> uint32_t - { - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - }; -} - -void* SecondLevelElementPubSubType::createData() -{ - return reinterpret_cast(new SecondLevelElement()); -} - -void SecondLevelElementPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool SecondLevelElementPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - SecondLevelElement* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - SecondLevelElement::getKeyMaxCdrSerializedSize()); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); - p_type->serializeKey(ser); - if (force_md5 || SecondLevelElement::getKeyMaxCdrSerializedSize() > 16) - { - m_md5.init(); - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - -FirstLevelElementPubSubType::FirstLevelElementPubSubType() -{ - setName("FirstLevelElement"); - auto type_size = FirstLevelElement::getMaxCdrSerializedSize(); - type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ - m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ - m_isGetKeyDefined = FirstLevelElement::isKeyDefined(); - size_t keyLength = FirstLevelElement::getKeyMaxCdrSerializedSize() > 16 ? - FirstLevelElement::getKeyMaxCdrSerializedSize() : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -FirstLevelElementPubSubType::~FirstLevelElementPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool FirstLevelElementPubSubType::serialize( - void* data, - SerializedPayload_t* payload) -{ - FirstLevelElement* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - // Serialize encapsulation - ser.serialize_encapsulation(); - - try - { - // Serialize the object. - p_type->serialize(ser); - } - catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) - { - return false; - } - - // Get the serialized length - payload->length = static_cast(ser.getSerializedDataLength()); - return true; -} - -bool FirstLevelElementPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - //Convert DATA to pointer of your type - FirstLevelElement* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - p_type->deserialize(deser); - } - catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) - { - return false; - } - - return true; -} - -std::function FirstLevelElementPubSubType::getSerializedSizeProvider( - void* data) -{ - return [data]() -> uint32_t - { - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - }; -} - -void* FirstLevelElementPubSubType::createData() -{ - return reinterpret_cast(new FirstLevelElement()); -} - -void FirstLevelElementPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool FirstLevelElementPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - FirstLevelElement* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - FirstLevelElement::getKeyMaxCdrSerializedSize()); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); - p_type->serializeKey(ser); - if (force_md5 || FirstLevelElement::getKeyMaxCdrSerializedSize() > 16) - { - m_md5.init(); - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - -complex_nested_arraysPubSubType::complex_nested_arraysPubSubType() -{ - setName("complex_nested_arrays"); - auto type_size = complex_nested_arrays::getMaxCdrSerializedSize(); - type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ - m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ - m_isGetKeyDefined = complex_nested_arrays::isKeyDefined(); - size_t keyLength = complex_nested_arrays::getKeyMaxCdrSerializedSize() > 16 ? - complex_nested_arrays::getKeyMaxCdrSerializedSize() : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -complex_nested_arraysPubSubType::~complex_nested_arraysPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool complex_nested_arraysPubSubType::serialize( - void* data, - SerializedPayload_t* payload) -{ - complex_nested_arrays* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - // Serialize encapsulation - ser.serialize_encapsulation(); - - try - { - // Serialize the object. - p_type->serialize(ser); - } - catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) - { - return false; - } - - // Get the serialized length - payload->length = static_cast(ser.getSerializedDataLength()); - return true; -} - -bool complex_nested_arraysPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - //Convert DATA to pointer of your type - complex_nested_arrays* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - p_type->deserialize(deser); - } - catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) - { - return false; - } - - return true; -} - -std::function complex_nested_arraysPubSubType::getSerializedSizeProvider( - void* data) -{ - return [data]() -> uint32_t - { - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - }; -} - -void* complex_nested_arraysPubSubType::createData() -{ - return reinterpret_cast(new complex_nested_arrays()); -} - -void complex_nested_arraysPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool complex_nested_arraysPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - complex_nested_arrays* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - complex_nested_arrays::getKeyMaxCdrSerializedSize()); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); - p_type->serializeKey(ser); - if (force_md5 || complex_nested_arrays::getKeyMaxCdrSerializedSize() > 16) - { - m_md5.init(); - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arraysPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arraysPubSubTypes.h deleted file mode 100644 index 93e214af..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arraysPubSubTypes.h +++ /dev/null @@ -1,293 +0,0 @@ -// 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 complex_nested_arraysPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#ifndef _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYS_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYS_PUBSUBTYPES_H_ - -#include -#include - -#include "complex_nested_arrays.h" - -#if !defined(GEN_API_VER) || (GEN_API_VER != 1) -#error \ - Generated complex_nested_arrays is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER - -/*! - * @brief This class represents the TopicDataType of the type ThirdLevelElement defined by the user in the IDL file. - * @ingroup COMPLEX_NESTED_ARRAYS - */ -class ThirdLevelElementPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef ThirdLevelElement type; - - eProsima_user_DllExport ThirdLevelElementPubSubType(); - - eProsima_user_DllExport virtual ~ThirdLevelElementPubSubType() override; - - eProsima_user_DllExport virtual bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; - - eProsima_user_DllExport virtual bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport virtual std::function getSerializedSizeProvider( - void* data) override; - - eProsima_user_DllExport virtual bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport virtual void* createData() override; - - eProsima_user_DllExport virtual void deleteData( - void* data) override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - new (memory) ThirdLevelElement(); - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; -}; -/*! - * @brief This class represents the TopicDataType of the type SecondLevelElement defined by the user in the IDL file. - * @ingroup COMPLEX_NESTED_ARRAYS - */ -class SecondLevelElementPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef SecondLevelElement type; - - eProsima_user_DllExport SecondLevelElementPubSubType(); - - eProsima_user_DllExport virtual ~SecondLevelElementPubSubType() override; - - eProsima_user_DllExport virtual bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; - - eProsima_user_DllExport virtual bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport virtual std::function getSerializedSizeProvider( - void* data) override; - - eProsima_user_DllExport virtual bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport virtual void* createData() override; - - eProsima_user_DllExport virtual void deleteData( - void* data) override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - (void)memory; - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; -}; -/*! - * @brief This class represents the TopicDataType of the type FirstLevelElement defined by the user in the IDL file. - * @ingroup COMPLEX_NESTED_ARRAYS - */ -class FirstLevelElementPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef FirstLevelElement type; - - eProsima_user_DllExport FirstLevelElementPubSubType(); - - eProsima_user_DllExport virtual ~FirstLevelElementPubSubType() override; - - eProsima_user_DllExport virtual bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; - - eProsima_user_DllExport virtual bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport virtual std::function getSerializedSizeProvider( - void* data) override; - - eProsima_user_DllExport virtual bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport virtual void* createData() override; - - eProsima_user_DllExport virtual void deleteData( - void* data) override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - (void)memory; - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; -}; -/*! - * @brief This class represents the TopicDataType of the type complex_nested_arrays defined by the user in the IDL file. - * @ingroup COMPLEX_NESTED_ARRAYS - */ -class complex_nested_arraysPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef complex_nested_arrays type; - - eProsima_user_DllExport complex_nested_arraysPubSubType(); - - eProsima_user_DllExport virtual ~complex_nested_arraysPubSubType() override; - - eProsima_user_DllExport virtual bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; - - eProsima_user_DllExport virtual bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport virtual std::function getSerializedSizeProvider( - void* data) override; - - eProsima_user_DllExport virtual bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport virtual void* createData() override; - - eProsima_user_DllExport virtual void deleteData( - void* data) override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - (void)memory; - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; -}; - -#endif // _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYS_PUBSUBTYPES_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arraysTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arraysTypeObject.cxx deleted file mode 100644 index 2862811e..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arraysTypeObject.cxx +++ /dev/null @@ -1,856 +0,0 @@ -// 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 complex_nested_arraysTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { char dummy; } -#endif - -#include "complex_nested_arrays.h" -#include "complex_nested_arraysTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registercomplex_nested_arraysTypes() -{ - TypeObjectFactory *factory = TypeObjectFactory::get_instance(); - factory->add_type_object("ThirdLevelElement", GetThirdLevelElementIdentifier(true), - GetThirdLevelElementObject(true)); - factory->add_type_object("ThirdLevelElement", GetThirdLevelElementIdentifier(false), - GetThirdLevelElementObject(false)); - - factory->add_type_object("SecondLevelElement", GetSecondLevelElementIdentifier(true), - GetSecondLevelElementObject(true)); - factory->add_type_object("SecondLevelElement", GetSecondLevelElementIdentifier(false), - GetSecondLevelElementObject(false)); - - factory->add_type_object("FirstLevelElement", GetFirstLevelElementIdentifier(true), - GetFirstLevelElementObject(true)); - factory->add_type_object("FirstLevelElement", GetFirstLevelElementIdentifier(false), - GetFirstLevelElementObject(false)); - - factory->add_type_object("complex_nested_arrays", Getcomplex_nested_arraysIdentifier(true), - Getcomplex_nested_arraysObject(true)); - factory->add_type_object("complex_nested_arrays", Getcomplex_nested_arraysIdentifier(false), - Getcomplex_nested_arraysObject(false)); - -} - -const TypeIdentifier* GetThirdLevelElementIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("ThirdLevelElement", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetThirdLevelElementObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("ThirdLevelElement", complete); -} - -const TypeObject* GetThirdLevelElementObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("ThirdLevelElement", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteThirdLevelElementObject(); - } - //else - return GetMinimalThirdLevelElementObject(); -} - -const TypeObject* GetMinimalThirdLevelElementObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("ThirdLevelElement", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_x; - mst_x.common().member_id(memberId++); - mst_x.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_x.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_x.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_x.common().member_flags().IS_OPTIONAL(false); - mst_x.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_x.common().member_flags().IS_KEY(false); - mst_x.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_x.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("double", false)); - - MD5 x_hash("x"); - for(int i = 0; i < 4; ++i) - { - mst_x.detail().name_hash()[i] = x_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_x); - - MinimalStructMember mst_y; - mst_y.common().member_id(memberId++); - mst_y.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_y.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_y.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_y.common().member_flags().IS_OPTIONAL(false); - mst_y.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_y.common().member_flags().IS_KEY(false); - mst_y.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_y.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("double", false)); - - MD5 y_hash("y"); - for(int i = 0; i < 4; ++i) - { - mst_y.detail().name_hash()[i] = y_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_y); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - SerializedPayload_t payload(static_cast( - MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("ThirdLevelElement", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("ThirdLevelElement", false); -} - -const TypeObject* GetCompleteThirdLevelElementObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("ThirdLevelElement", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_x; - cst_x.common().member_id(memberId++); - cst_x.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_x.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_x.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_x.common().member_flags().IS_OPTIONAL(false); - cst_x.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_x.common().member_flags().IS_KEY(false); - cst_x.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_x.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("double", false)); - - cst_x.detail().name("x"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_x); - - CompleteStructMember cst_y; - cst_y.common().member_id(memberId++); - cst_y.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_y.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_y.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_y.common().member_flags().IS_OPTIONAL(false); - cst_y.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_y.common().member_flags().IS_KEY(false); - cst_y.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_y.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("double", false)); - - cst_y.detail().name("y"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_y); - - - // Header - type_object->complete().struct_type().header().detail().type_name("ThirdLevelElement"); - // TODO inheritance - - - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - SerializedPayload_t payload(static_cast( - CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("ThirdLevelElement", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("ThirdLevelElement", true); -} - -const TypeIdentifier* GetSecondLevelElementIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("SecondLevelElement", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetSecondLevelElementObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("SecondLevelElement", complete); -} - -const TypeObject* GetSecondLevelElementObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("SecondLevelElement", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteSecondLevelElementObject(); - } - //else - return GetMinimalSecondLevelElementObject(); -} - -const TypeObject* GetMinimalSecondLevelElementObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("SecondLevelElement", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_an_element_alone; - mst_an_element_alone.common().member_id(memberId++); - mst_an_element_alone.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_an_element_alone.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_an_element_alone.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_an_element_alone.common().member_flags().IS_OPTIONAL(false); - mst_an_element_alone.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_an_element_alone.common().member_flags().IS_KEY(false); - mst_an_element_alone.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_an_element_alone.common().member_type_id(*GetThirdLevelElementIdentifier(false)); - MD5 an_element_alone_hash("an_element_alone"); - for(int i = 0; i < 4; ++i) - { - mst_an_element_alone.detail().name_hash()[i] = an_element_alone_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_an_element_alone); - - MinimalStructMember mst_a_limited_other_value; - mst_a_limited_other_value.common().member_id(memberId++); - mst_a_limited_other_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_a_limited_other_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_a_limited_other_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_a_limited_other_value.common().member_flags().IS_OPTIONAL(false); - mst_a_limited_other_value.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_a_limited_other_value.common().member_flags().IS_KEY(false); - mst_a_limited_other_value.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_a_limited_other_value.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("ThirdLevelElement", 1, false)); - - - MD5 a_limited_other_value_hash("a_limited_other_value"); - for(int i = 0; i < 4; ++i) - { - mst_a_limited_other_value.detail().name_hash()[i] = a_limited_other_value_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_a_limited_other_value); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - SerializedPayload_t payload(static_cast( - MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("SecondLevelElement", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("SecondLevelElement", false); -} - -const TypeObject* GetCompleteSecondLevelElementObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("SecondLevelElement", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_an_element_alone; - cst_an_element_alone.common().member_id(memberId++); - cst_an_element_alone.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_an_element_alone.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_an_element_alone.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_an_element_alone.common().member_flags().IS_OPTIONAL(false); - cst_an_element_alone.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_an_element_alone.common().member_flags().IS_KEY(false); - cst_an_element_alone.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_an_element_alone.common().member_type_id(*GetThirdLevelElementIdentifier(true)); - cst_an_element_alone.detail().name("an_element_alone"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_an_element_alone); - - CompleteStructMember cst_a_limited_other_value; - cst_a_limited_other_value.common().member_id(memberId++); - cst_a_limited_other_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_a_limited_other_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_a_limited_other_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_a_limited_other_value.common().member_flags().IS_OPTIONAL(false); - cst_a_limited_other_value.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_a_limited_other_value.common().member_flags().IS_KEY(false); - cst_a_limited_other_value.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_a_limited_other_value.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("ThirdLevelElement", 1, true)); - - - cst_a_limited_other_value.detail().name("a_limited_other_value"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_a_limited_other_value); - - - // Header - type_object->complete().struct_type().header().detail().type_name("SecondLevelElement"); - // TODO inheritance - - - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - SerializedPayload_t payload(static_cast( - CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("SecondLevelElement", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("SecondLevelElement", true); -} - -const TypeIdentifier* GetFirstLevelElementIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("FirstLevelElement", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetFirstLevelElementObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("FirstLevelElement", complete); -} - -const TypeObject* GetFirstLevelElementObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("FirstLevelElement", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteFirstLevelElementObject(); - } - //else - return GetMinimalFirstLevelElementObject(); -} - -const TypeObject* GetMinimalFirstLevelElementObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("FirstLevelElement", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_useless_name; - mst_useless_name.common().member_id(memberId++); - mst_useless_name.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_useless_name.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_useless_name.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_useless_name.common().member_flags().IS_OPTIONAL(false); - mst_useless_name.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_useless_name.common().member_flags().IS_KEY(false); - mst_useless_name.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_useless_name.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - - MD5 useless_name_hash("useless_name"); - for(int i = 0; i < 4; ++i) - { - mst_useless_name.detail().name_hash()[i] = useless_name_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_useless_name); - - MinimalStructMember mst_sub; - mst_sub.common().member_id(memberId++); - mst_sub.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_sub.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_sub.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_sub.common().member_flags().IS_OPTIONAL(false); - mst_sub.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_sub.common().member_flags().IS_KEY(false); - mst_sub.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_sub.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("SecondLevelElement", 0, false)); - - - MD5 sub_hash("sub"); - for(int i = 0; i < 4; ++i) - { - mst_sub.detail().name_hash()[i] = sub_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_sub); - - MinimalStructMember mst_an_element_alone; - mst_an_element_alone.common().member_id(memberId++); - mst_an_element_alone.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_an_element_alone.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_an_element_alone.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_an_element_alone.common().member_flags().IS_OPTIONAL(false); - mst_an_element_alone.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_an_element_alone.common().member_flags().IS_KEY(false); - mst_an_element_alone.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_an_element_alone.common().member_type_id(*GetThirdLevelElementIdentifier(false)); - MD5 an_element_alone_hash("an_element_alone"); - for(int i = 0; i < 4; ++i) - { - mst_an_element_alone.detail().name_hash()[i] = an_element_alone_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_an_element_alone); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - SerializedPayload_t payload(static_cast( - MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("FirstLevelElement", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("FirstLevelElement", false); -} - -const TypeObject* GetCompleteFirstLevelElementObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("FirstLevelElement", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_useless_name; - cst_useless_name.common().member_id(memberId++); - cst_useless_name.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_useless_name.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_useless_name.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_useless_name.common().member_flags().IS_OPTIONAL(false); - cst_useless_name.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_useless_name.common().member_flags().IS_KEY(false); - cst_useless_name.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_useless_name.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - - cst_useless_name.detail().name("useless_name"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_useless_name); - - CompleteStructMember cst_sub; - cst_sub.common().member_id(memberId++); - cst_sub.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_sub.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_sub.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_sub.common().member_flags().IS_OPTIONAL(false); - cst_sub.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_sub.common().member_flags().IS_KEY(false); - cst_sub.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_sub.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("SecondLevelElement", 0, true)); - - - cst_sub.detail().name("sub"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_sub); - - CompleteStructMember cst_an_element_alone; - cst_an_element_alone.common().member_id(memberId++); - cst_an_element_alone.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_an_element_alone.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_an_element_alone.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_an_element_alone.common().member_flags().IS_OPTIONAL(false); - cst_an_element_alone.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_an_element_alone.common().member_flags().IS_KEY(false); - cst_an_element_alone.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_an_element_alone.common().member_type_id(*GetThirdLevelElementIdentifier(true)); - cst_an_element_alone.detail().name("an_element_alone"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_an_element_alone); - - - // Header - type_object->complete().struct_type().header().detail().type_name("FirstLevelElement"); - // TODO inheritance - - - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - SerializedPayload_t payload(static_cast( - CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("FirstLevelElement", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("FirstLevelElement", true); -} - -const TypeIdentifier* Getcomplex_nested_arraysIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("complex_nested_arrays", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - Getcomplex_nested_arraysObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("complex_nested_arrays", complete); -} - -const TypeObject* Getcomplex_nested_arraysObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("complex_nested_arrays", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompletecomplex_nested_arraysObject(); - } - //else - return GetMinimalcomplex_nested_arraysObject(); -} - -const TypeObject* GetMinimalcomplex_nested_arraysObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("complex_nested_arrays", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_array_of_elements; - mst_array_of_elements.common().member_id(memberId++); - mst_array_of_elements.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_array_of_elements.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_array_of_elements.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_array_of_elements.common().member_flags().IS_OPTIONAL(false); - mst_array_of_elements.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_array_of_elements.common().member_flags().IS_KEY(false); - mst_array_of_elements.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_array_of_elements.common().member_type_id(*TypeObjectFactory::get_instance()->get_array_identifier("FirstLevelElement", {3}, false)); - - - MD5 array_of_elements_hash("array_of_elements"); - for(int i = 0; i < 4; ++i) - { - mst_array_of_elements.detail().name_hash()[i] = array_of_elements_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_array_of_elements); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - SerializedPayload_t payload(static_cast( - MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("complex_nested_arrays", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("complex_nested_arrays", false); -} - -const TypeObject* GetCompletecomplex_nested_arraysObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("complex_nested_arrays", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_array_of_elements; - cst_array_of_elements.common().member_id(memberId++); - cst_array_of_elements.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_array_of_elements.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_array_of_elements.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_array_of_elements.common().member_flags().IS_OPTIONAL(false); - cst_array_of_elements.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_array_of_elements.common().member_flags().IS_KEY(false); - cst_array_of_elements.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_array_of_elements.common().member_type_id(*TypeObjectFactory::get_instance()->get_array_identifier("FirstLevelElement", {3}, true)); - - - cst_array_of_elements.detail().name("array_of_elements"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_array_of_elements); - - - // Header - type_object->complete().struct_type().header().detail().type_name("complex_nested_arrays"); - // TODO inheritance - - - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - SerializedPayload_t payload(static_cast( - CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("complex_nested_arrays", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("complex_nested_arrays", true); -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arraysTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arraysTypeObject.h deleted file mode 100644 index 6f071275..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arraysTypeObject.h +++ /dev/null @@ -1,86 +0,0 @@ -// 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 complex_nested_arraysTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifndef _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYS_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYS_TYPE_OBJECT_H_ - - -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define eProsima_user_DllExport -#endif // if defined(_WIN32) - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(complex_nested_arrays_SOURCE) -#define complex_nested_arrays_DllAPI __declspec( dllexport ) -#else -#define complex_nested_arrays_DllAPI __declspec( dllimport ) -#endif // complex_nested_arrays_SOURCE -#else -#define complex_nested_arrays_DllAPI -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define complex_nested_arrays_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registercomplex_nested_arraysTypes(); - -eProsima_user_DllExport const TypeIdentifier* GetThirdLevelElementIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetThirdLevelElementObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalThirdLevelElementObject(); -eProsima_user_DllExport const TypeObject* GetCompleteThirdLevelElementObject(); - -eProsima_user_DllExport const TypeIdentifier* GetSecondLevelElementIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetSecondLevelElementObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalSecondLevelElementObject(); -eProsima_user_DllExport const TypeObject* GetCompleteSecondLevelElementObject(); - -eProsima_user_DllExport const TypeIdentifier* GetFirstLevelElementIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetFirstLevelElementObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalFirstLevelElementObject(); -eProsima_user_DllExport const TypeObject* GetCompleteFirstLevelElementObject(); - -eProsima_user_DllExport const TypeIdentifier* Getcomplex_nested_arraysIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* Getcomplex_nested_arraysObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalcomplex_nested_arraysObject(); -eProsima_user_DllExport const TypeObject* GetCompletecomplex_nested_arraysObject(); - - -#endif // _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYS_TYPE_OBJECT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_struct.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_struct.cxx deleted file mode 100644 index 92a88b0a..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_struct.cxx +++ /dev/null @@ -1,229 +0,0 @@ -// 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 enum_struct.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "enum_struct.h" -#include "enum_structTypeObject.h" -#include - -#include -using namespace eprosima::fastcdr::exception; - -#include - -#define enum_struct_max_cdr_typesize 8ULL; - -#define enum_struct_max_key_cdr_typesize 0ULL; - - - -enum_struct::enum_struct() -{ - // unsigned long m_index - m_index = 0; - // ColorEnum m_enum_value - m_enum_value = ::RED; - - // Just to register all known types - registerenum_structTypes(); -} - -enum_struct::~enum_struct() -{ - - -} - -enum_struct::enum_struct( - const enum_struct& x) -{ - m_index = x.m_index; - m_enum_value = x.m_enum_value; -} - -enum_struct::enum_struct( - enum_struct&& x) noexcept -{ - m_index = x.m_index; - m_enum_value = x.m_enum_value; -} - -enum_struct& enum_struct::operator =( - const enum_struct& x) -{ - - m_index = x.m_index; - m_enum_value = x.m_enum_value; - - return *this; -} - -enum_struct& enum_struct::operator =( - enum_struct&& x) noexcept -{ - - m_index = x.m_index; - m_enum_value = x.m_enum_value; - - return *this; -} - -bool enum_struct::operator ==( - const enum_struct& x) const -{ - - return (m_index == x.m_index && m_enum_value == x.m_enum_value); -} - -bool enum_struct::operator !=( - const enum_struct& x) const -{ - return !(*this == x); -} - -size_t enum_struct::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return enum_struct_max_cdr_typesize; -} - -size_t enum_struct::getCdrSerializedSize( - const enum_struct& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - - return current_alignment - initial_alignment; -} - -void enum_struct::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - - scdr << m_index; - scdr << (uint32_t)m_enum_value; - -} - -void enum_struct::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - - dcdr >> m_index; - { - uint32_t enum_value = 0; - dcdr >> enum_value; - m_enum_value = (ColorEnum)enum_value; - } - -} - -/*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ -void enum_struct::index( - uint32_t _index) -{ - m_index = _index; -} - -/*! - * @brief This function returns the value of member index - * @return Value of member index - */ -uint32_t enum_struct::index() const -{ - return m_index; -} - -/*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ -uint32_t& enum_struct::index() -{ - return m_index; -} - -/*! - * @brief This function sets a value in member enum_value - * @param _enum_value New value for member enum_value - */ -void enum_struct::enum_value( - ColorEnum _enum_value) -{ - m_enum_value = _enum_value; -} - -/*! - * @brief This function returns the value of member enum_value - * @return Value of member enum_value - */ -ColorEnum enum_struct::enum_value() const -{ - return m_enum_value; -} - -/*! - * @brief This function returns a reference to member enum_value - * @return Reference to member enum_value - */ -ColorEnum& enum_struct::enum_value() -{ - return m_enum_value; -} - - - -size_t enum_struct::getKeyMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return enum_struct_max_key_cdr_typesize; -} - -bool enum_struct::isKeyDefined() -{ - return false; -} - -void enum_struct::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_struct.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_struct.h deleted file mode 100644 index 1c0a770d..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_struct.h +++ /dev/null @@ -1,239 +0,0 @@ -// 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 enum_struct.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifndef _FAST_DDS_GENERATED_ENUM_STRUCT_H_ -#define _FAST_DDS_GENERATED_ENUM_STRUCT_H_ - - -#include - -#include -#include -#include -#include -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(ENUM_STRUCT_SOURCE) -#define ENUM_STRUCT_DllAPI __declspec( dllexport ) -#else -#define ENUM_STRUCT_DllAPI __declspec( dllimport ) -#endif // ENUM_STRUCT_SOURCE -#else -#define ENUM_STRUCT_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define ENUM_STRUCT_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - -/*! - * @brief This class represents the enumeration ColorEnum defined by the user in the IDL file. - * @ingroup enum_struct - */ -enum ColorEnum : uint32_t -{ - RED, - GREEN, - BLUE -}; -/*! - * @brief This class represents the structure enum_struct defined by the user in the IDL file. - * @ingroup enum_struct - */ -class enum_struct -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport enum_struct(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~enum_struct(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object enum_struct that will be copied. - */ - eProsima_user_DllExport enum_struct( - const enum_struct& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object enum_struct that will be copied. - */ - eProsima_user_DllExport enum_struct( - enum_struct&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object enum_struct that will be copied. - */ - eProsima_user_DllExport enum_struct& operator =( - const enum_struct& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object enum_struct that will be copied. - */ - eProsima_user_DllExport enum_struct& operator =( - enum_struct&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x enum_struct object to compare. - */ - eProsima_user_DllExport bool operator ==( - const enum_struct& x) const; - - /*! - * @brief Comparison operator. - * @param x enum_struct object to compare. - */ - eProsima_user_DllExport bool operator !=( - const enum_struct& x) const; - - /*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ - eProsima_user_DllExport void index( - uint32_t _index); - - /*! - * @brief This function returns the value of member index - * @return Value of member index - */ - eProsima_user_DllExport uint32_t index() const; - - /*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ - eProsima_user_DllExport uint32_t& index(); - - /*! - * @brief This function sets a value in member enum_value - * @param _enum_value New value for member enum_value - */ - eProsima_user_DllExport void enum_value( - ColorEnum _enum_value); - - /*! - * @brief This function returns the value of member enum_value - * @return Value of member enum_value - */ - eProsima_user_DllExport ColorEnum enum_value() const; - - /*! - * @brief This function returns a reference to member enum_value - * @return Reference to member enum_value - */ - eProsima_user_DllExport ColorEnum& enum_value(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const enum_struct& data, - size_t current_alignment = 0); - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - /*! - * @brief This function returns the maximum serialized size of the Key of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - -private: - - uint32_t m_index; - ColorEnum m_enum_value; - -}; - -#endif // _FAST_DDS_GENERATED_ENUM_STRUCT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_structPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_structPubSubTypes.cxx deleted file mode 100644 index e93d8f5d..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_structPubSubTypes.cxx +++ /dev/null @@ -1,170 +0,0 @@ -// 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 enum_structPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#include -#include - -#include "enum_structPubSubTypes.h" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; - - -enum_structPubSubType::enum_structPubSubType() -{ - setName("enum_struct"); - auto type_size = enum_struct::getMaxCdrSerializedSize(); - type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ - m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ - m_isGetKeyDefined = enum_struct::isKeyDefined(); - size_t keyLength = enum_struct::getKeyMaxCdrSerializedSize() > 16 ? - enum_struct::getKeyMaxCdrSerializedSize() : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -enum_structPubSubType::~enum_structPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool enum_structPubSubType::serialize( - void* data, - SerializedPayload_t* payload) -{ - enum_struct* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - p_type->serialize(ser); - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length - payload->length = static_cast(ser.getSerializedDataLength()); - return true; -} - -bool enum_structPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - enum_struct* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - p_type->deserialize(deser); - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function enum_structPubSubType::getSerializedSizeProvider( - void* data) -{ - return [data]() -> uint32_t - { - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - }; -} - -void* enum_structPubSubType::createData() -{ - return reinterpret_cast(new enum_struct()); -} - -void enum_structPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool enum_structPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - enum_struct* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - enum_struct::getKeyMaxCdrSerializedSize()); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); - p_type->serializeKey(ser); - if (force_md5 || enum_struct::getKeyMaxCdrSerializedSize() > 16) - { - m_md5.init(); - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_structPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_structPubSubTypes.h deleted file mode 100644 index f85486a8..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_structPubSubTypes.h +++ /dev/null @@ -1,105 +0,0 @@ -// 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 enum_structPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#ifndef _FAST_DDS_GENERATED_ENUM_STRUCT_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_ENUM_STRUCT_PUBSUBTYPES_H_ - -#include -#include - -#include "enum_struct.h" - - -#if !defined(GEN_API_VER) || (GEN_API_VER != 1) -#error \ - Generated enum_struct is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER - - - -/*! - * @brief This class represents the TopicDataType of the type enum_struct defined by the user in the IDL file. - * @ingroup enum_struct - */ -class enum_structPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef enum_struct type; - - eProsima_user_DllExport enum_structPubSubType(); - - eProsima_user_DllExport virtual ~enum_structPubSubType() override; - - eProsima_user_DllExport virtual bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; - - eProsima_user_DllExport virtual bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport virtual std::function getSerializedSizeProvider( - void* data) override; - - eProsima_user_DllExport virtual bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport virtual void* createData() override; - - eProsima_user_DllExport virtual void deleteData( - void* data) override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - (void)memory; - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - -#endif // _FAST_DDS_GENERATED_ENUM_STRUCT_PUBSUBTYPES_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_structTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_structTypeObject.cxx deleted file mode 100644 index 109026e6..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_structTypeObject.cxx +++ /dev/null @@ -1,470 +0,0 @@ -// 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 enum_structTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { char dummy; } -#endif - -#include "enum_struct.h" -#include "enum_structTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerenum_structTypes() -{ - static std::once_flag once_flag; - std::call_once(once_flag, []() - { - TypeObjectFactory *factory = TypeObjectFactory::get_instance(); - factory->add_type_object("ColorEnum", GetColorEnumIdentifier(true), - GetColorEnumObject(true)); - factory->add_type_object("ColorEnum", GetColorEnumIdentifier(false), - GetColorEnumObject(false)); - - factory->add_type_object("enum_struct", Getenum_structIdentifier(true), - Getenum_structObject(true)); - factory->add_type_object("enum_struct", Getenum_structIdentifier(false), - Getenum_structObject(false)); - - }); -} - -const TypeIdentifier* GetColorEnumIdentifier(bool complete) -{ - const TypeIdentifier* c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("ColorEnum", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetColorEnumObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("ColorEnum", complete); -} - -const TypeObject* GetColorEnumObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("ColorEnum", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteColorEnumObject(); - } - // else - return GetMinimalColorEnumObject(); -} - -const TypeObject* GetMinimalColorEnumObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("ColorEnum", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_ENUM); - - // No flags apply - //type_object->minimal().enumerated_type().enum_flags().IS_FINAL(false); - //type_object->minimal().enumerated_type().enum_flags().IS_APPENDABLE(false); - //type_object->minimal().enumerated_type().enum_flags().IS_MUTABLE(false); - //type_object->minimal().enumerated_type().enum_flags().IS_NESTED(false); - //type_object->minimal().enumerated_type().enum_flags().IS_AUTOID_HASH(false); - - type_object->minimal().enumerated_type().header().common().bit_bound(32); // TODO fixed by IDL, isn't? - - uint32_t value = 0; - MinimalEnumeratedLiteral mel_RED; - mel_RED.common().flags().TRY_CONSTRUCT1(false); // Doesn't apply - mel_RED.common().flags().TRY_CONSTRUCT2(false); // Doesn't apply - mel_RED.common().flags().IS_EXTERNAL(false); // Doesn't apply - mel_RED.common().flags().IS_OPTIONAL(false); // Doesn't apply - mel_RED.common().flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - mel_RED.common().flags().IS_KEY(false); // Doesn't apply - mel_RED.common().flags().IS_DEFAULT(false); - mel_RED.common().value(value++); - MD5 RED_hash("RED"); - for(int i = 0; i < 4; ++i) - { - mel_RED.detail().name_hash()[i] = RED_hash.digest[i]; - } - type_object->minimal().enumerated_type().literal_seq().emplace_back(mel_RED); - - MinimalEnumeratedLiteral mel_GREEN; - mel_GREEN.common().flags().TRY_CONSTRUCT1(false); // Doesn't apply - mel_GREEN.common().flags().TRY_CONSTRUCT2(false); // Doesn't apply - mel_GREEN.common().flags().IS_EXTERNAL(false); // Doesn't apply - mel_GREEN.common().flags().IS_OPTIONAL(false); // Doesn't apply - mel_GREEN.common().flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - mel_GREEN.common().flags().IS_KEY(false); // Doesn't apply - mel_GREEN.common().flags().IS_DEFAULT(false); - mel_GREEN.common().value(value++); - MD5 GREEN_hash("GREEN"); - for(int i = 0; i < 4; ++i) - { - mel_GREEN.detail().name_hash()[i] = GREEN_hash.digest[i]; - } - type_object->minimal().enumerated_type().literal_seq().emplace_back(mel_GREEN); - - MinimalEnumeratedLiteral mel_BLUE; - mel_BLUE.common().flags().TRY_CONSTRUCT1(false); // Doesn't apply - mel_BLUE.common().flags().TRY_CONSTRUCT2(false); // Doesn't apply - mel_BLUE.common().flags().IS_EXTERNAL(false); // Doesn't apply - mel_BLUE.common().flags().IS_OPTIONAL(false); // Doesn't apply - mel_BLUE.common().flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - mel_BLUE.common().flags().IS_KEY(false); // Doesn't apply - mel_BLUE.common().flags().IS_DEFAULT(false); - mel_BLUE.common().value(value++); - MD5 BLUE_hash("BLUE"); - for(int i = 0; i < 4; ++i) - { - mel_BLUE.detail().name_hash()[i] = BLUE_hash.digest[i]; - } - type_object->minimal().enumerated_type().literal_seq().emplace_back(mel_BLUE); - - - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - SerializedPayload_t payload(static_cast( - MinimalEnumeratedType::getCdrSerializedSize(type_object->minimal().enumerated_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("ColorEnum", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("ColorEnum", false); -} - -const TypeObject* GetCompleteColorEnumObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("ColorEnum", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_ENUM); - - // No flags apply - //type_object->complete().enumerated_type().enum_flags().IS_FINAL(false); - //type_object->complete().enumerated_type().enum_flags().IS_APPENDABLE(false); - //type_object->complete().enumerated_type().enum_flags().IS_MUTABLE(false); - //type_object->complete().enumerated_type().enum_flags().IS_NESTED(false); - //type_object->complete().enumerated_type().enum_flags().IS_AUTOID_HASH(false); - - type_object->complete().enumerated_type().header().common().bit_bound(32); // TODO fixed by IDL, isn't? - type_object->complete().enumerated_type().header().detail().type_name("ColorEnum"); - - - uint32_t value = 0; - CompleteEnumeratedLiteral cel_RED; - cel_RED.common().flags().TRY_CONSTRUCT1(false); // Doesn't apply - cel_RED.common().flags().TRY_CONSTRUCT2(false); // Doesn't apply - cel_RED.common().flags().IS_EXTERNAL(false); // Doesn't apply - cel_RED.common().flags().IS_OPTIONAL(false); // Doesn't apply - cel_RED.common().flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - cel_RED.common().flags().IS_KEY(false); // Doesn't apply - cel_RED.common().flags().IS_DEFAULT(false); - cel_RED.common().value(value++); - cel_RED.detail().name("RED"); - - type_object->complete().enumerated_type().literal_seq().emplace_back(cel_RED); - - CompleteEnumeratedLiteral cel_GREEN; - cel_GREEN.common().flags().TRY_CONSTRUCT1(false); // Doesn't apply - cel_GREEN.common().flags().TRY_CONSTRUCT2(false); // Doesn't apply - cel_GREEN.common().flags().IS_EXTERNAL(false); // Doesn't apply - cel_GREEN.common().flags().IS_OPTIONAL(false); // Doesn't apply - cel_GREEN.common().flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - cel_GREEN.common().flags().IS_KEY(false); // Doesn't apply - cel_GREEN.common().flags().IS_DEFAULT(false); - cel_GREEN.common().value(value++); - cel_GREEN.detail().name("GREEN"); - - type_object->complete().enumerated_type().literal_seq().emplace_back(cel_GREEN); - - CompleteEnumeratedLiteral cel_BLUE; - cel_BLUE.common().flags().TRY_CONSTRUCT1(false); // Doesn't apply - cel_BLUE.common().flags().TRY_CONSTRUCT2(false); // Doesn't apply - cel_BLUE.common().flags().IS_EXTERNAL(false); // Doesn't apply - cel_BLUE.common().flags().IS_OPTIONAL(false); // Doesn't apply - cel_BLUE.common().flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - cel_BLUE.common().flags().IS_KEY(false); // Doesn't apply - cel_BLUE.common().flags().IS_DEFAULT(false); - cel_BLUE.common().value(value++); - cel_BLUE.detail().name("BLUE"); - - type_object->complete().enumerated_type().literal_seq().emplace_back(cel_BLUE); - - - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - SerializedPayload_t payload(static_cast( - CompleteEnumeratedType::getCdrSerializedSize(type_object->complete().enumerated_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("ColorEnum", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("ColorEnum", true); -} - -const TypeIdentifier* Getenum_structIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("enum_struct", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - Getenum_structObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("enum_struct", complete); -} - -const TypeObject* Getenum_structObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("enum_struct", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteenum_structObject(); - } - //else - return GetMinimalenum_structObject(); -} - -const TypeObject* GetMinimalenum_structObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("enum_struct", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_index; - mst_index.common().member_id(memberId++); - mst_index.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_index.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_index.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_index.common().member_flags().IS_OPTIONAL(false); - mst_index.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_index.common().member_flags().IS_KEY(false); - mst_index.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_index.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); - - MD5 index_hash("index"); - for(int i = 0; i < 4; ++i) - { - mst_index.detail().name_hash()[i] = index_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_index); - - MinimalStructMember mst_enum_value; - mst_enum_value.common().member_id(memberId++); - mst_enum_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_enum_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_enum_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_enum_value.common().member_flags().IS_OPTIONAL(false); - mst_enum_value.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_enum_value.common().member_flags().IS_KEY(false); - mst_enum_value.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_enum_value.common().member_type_id(*GetColorEnumIdentifier(false)); - MD5 enum_value_hash("enum_value"); - for(int i = 0; i < 4; ++i) - { - mst_enum_value.detail().name_hash()[i] = enum_value_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_enum_value); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - SerializedPayload_t payload(static_cast( - MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("enum_struct", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("enum_struct", false); -} - -const TypeObject* GetCompleteenum_structObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("enum_struct", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_index; - cst_index.common().member_id(memberId++); - cst_index.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_index.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_index.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_index.common().member_flags().IS_OPTIONAL(false); - cst_index.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_index.common().member_flags().IS_KEY(false); - cst_index.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_index.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); - - cst_index.detail().name("index"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_index); - - CompleteStructMember cst_enum_value; - cst_enum_value.common().member_id(memberId++); - cst_enum_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_enum_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_enum_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_enum_value.common().member_flags().IS_OPTIONAL(false); - cst_enum_value.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_enum_value.common().member_flags().IS_KEY(false); - cst_enum_value.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_enum_value.common().member_type_id(*GetColorEnumIdentifier(true)); - cst_enum_value.detail().name("enum_value"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_enum_value); - - - // Header - type_object->complete().struct_type().header().detail().type_name("enum_struct"); - // TODO inheritance - - - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - SerializedPayload_t payload(static_cast( - CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("enum_struct", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("enum_struct", true); -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_structTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_structTypeObject.h deleted file mode 100644 index ab841f64..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_structTypeObject.h +++ /dev/null @@ -1,68 +0,0 @@ -// 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 enum_structTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifndef _FAST_DDS_GENERATED_ENUM_STRUCT_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_ENUM_STRUCT_TYPE_OBJECT_H_ - - -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif -#else -#define eProsima_user_DllExport -#endif - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(enum_struct_SOURCE) -#define enum_struct_DllAPI __declspec( dllexport ) -#else -#define enum_struct_DllAPI __declspec( dllimport ) -#endif // enum_struct_SOURCE -#else -#define enum_struct_DllAPI -#endif -#else -#define enum_struct_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registerenum_structTypes(); - -eProsima_user_DllExport const TypeIdentifier* GetColorEnumIdentifier(bool complete = false); -eProsima_user_DllExport const TypeObject* GetColorEnumObject(bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalColorEnumObject(); -eProsima_user_DllExport const TypeObject* GetCompleteColorEnumObject(); - -eProsima_user_DllExport const TypeIdentifier* Getenum_structIdentifier(bool complete = false); -eProsima_user_DllExport const TypeObject* Getenum_structObject(bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalenum_structObject(); -eProsima_user_DllExport const TypeObject* GetCompleteenum_structObject(); - - -#endif // _FAST_DDS_GENERATED_ENUM_STRUCT_TYPE_OBJECT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequence.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequence.cxx deleted file mode 100644 index 7179606c..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequence.cxx +++ /dev/null @@ -1,200 +0,0 @@ -// 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 float_bounded_sequence.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "float_bounded_sequence.h" -#include "float_bounded_sequenceTypeObject.h" -#include - -#include -using namespace eprosima::fastcdr::exception; - -#include - -float_bounded_sequence::float_bounded_sequence() -{ - // m_numbers com.eprosima.idl.parser.typecode.SequenceTypeCode@3fd7a715 - - - // Just to register all known types - registerfloat_bounded_sequenceTypes(); -} - -float_bounded_sequence::~float_bounded_sequence() -{ -} - -float_bounded_sequence::float_bounded_sequence( - const float_bounded_sequence& x) -{ - m_numbers = x.m_numbers; -} - -float_bounded_sequence::float_bounded_sequence( - float_bounded_sequence&& x) noexcept -{ - m_numbers = std::move(x.m_numbers); -} - -float_bounded_sequence& float_bounded_sequence::operator =( - const float_bounded_sequence& x) -{ - - m_numbers = x.m_numbers; - - return *this; -} - -float_bounded_sequence& float_bounded_sequence::operator =( - float_bounded_sequence&& x) noexcept -{ - - m_numbers = std::move(x.m_numbers); - - return *this; -} - -bool float_bounded_sequence::operator ==( - const float_bounded_sequence& x) const -{ - - return (m_numbers == x.m_numbers); -} - -bool float_bounded_sequence::operator !=( - const float_bounded_sequence& x) const -{ - return !(*this == x); -} - -size_t float_bounded_sequence::getMaxCdrSerializedSize( - size_t current_alignment) -{ - size_t initial_alignment = current_alignment; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - current_alignment += (13 * 4) + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - - return current_alignment - initial_alignment; -} - -size_t float_bounded_sequence::getCdrSerializedSize( - const float_bounded_sequence& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - if (data.numbers().size() > 0) - { - current_alignment += (data.numbers().size() * 4) + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - } - - - - return current_alignment - initial_alignment; -} - -void float_bounded_sequence::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - - scdr << m_numbers; -} - -void float_bounded_sequence::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - - dcdr >> m_numbers;} - -/*! - * @brief This function copies the value in member numbers - * @param _numbers New value to be copied in member numbers - */ -void float_bounded_sequence::numbers( - const std::vector& _numbers) -{ - m_numbers = _numbers; -} - -/*! - * @brief This function moves the value in member numbers - * @param _numbers New value to be moved in member numbers - */ -void float_bounded_sequence::numbers( - std::vector&& _numbers) -{ - m_numbers = std::move(_numbers); -} - -/*! - * @brief This function returns a constant reference to member numbers - * @return Constant reference to member numbers - */ -const std::vector& float_bounded_sequence::numbers() const -{ - return m_numbers; -} - -/*! - * @brief This function returns a reference to member numbers - * @return Reference to member numbers - */ -std::vector& float_bounded_sequence::numbers() -{ - return m_numbers; -} - -size_t float_bounded_sequence::getKeyMaxCdrSerializedSize( - size_t current_alignment) -{ - size_t current_align = current_alignment; - - - - return current_align; -} - -bool float_bounded_sequence::isKeyDefined() -{ - return false; -} - -void float_bounded_sequence::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; - -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequence.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequence.h deleted file mode 100644 index b25178db..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequence.h +++ /dev/null @@ -1,214 +0,0 @@ -// 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 float_bounded_sequence.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifndef _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCE_H_ -#define _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCE_H_ - - -#include - -#include -#include -#include -#include -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(float_bounded_sequence_SOURCE) -#define float_bounded_sequence_DllAPI __declspec( dllexport ) -#else -#define float_bounded_sequence_DllAPI __declspec( dllimport ) -#endif // float_bounded_sequence_SOURCE -#else -#define float_bounded_sequence_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define float_bounded_sequence_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - -/*! - * @brief This class represents the structure float_bounded_sequence defined by the user in the IDL file. - * @ingroup FLOAT_BOUNDED_SEQUENCE - */ -class float_bounded_sequence -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport float_bounded_sequence(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~float_bounded_sequence(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object float_bounded_sequence that will be copied. - */ - eProsima_user_DllExport float_bounded_sequence( - const float_bounded_sequence& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object float_bounded_sequence that will be copied. - */ - eProsima_user_DllExport float_bounded_sequence( - float_bounded_sequence&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object float_bounded_sequence that will be copied. - */ - eProsima_user_DllExport float_bounded_sequence& operator =( - const float_bounded_sequence& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object float_bounded_sequence that will be copied. - */ - eProsima_user_DllExport float_bounded_sequence& operator =( - float_bounded_sequence&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x float_bounded_sequence object to compare. - */ - eProsima_user_DllExport bool operator ==( - const float_bounded_sequence& x) const; - - /*! - * @brief Comparison operator. - * @param x float_bounded_sequence object to compare. - */ - eProsima_user_DllExport bool operator !=( - const float_bounded_sequence& x) const; - - /*! - * @brief This function copies the value in member numbers - * @param _numbers New value to be copied in member numbers - */ - eProsima_user_DllExport void numbers( - const std::vector& _numbers); - - /*! - * @brief This function moves the value in member numbers - * @param _numbers New value to be moved in member numbers - */ - eProsima_user_DllExport void numbers( - std::vector&& _numbers); - - /*! - * @brief This function returns a constant reference to member numbers - * @return Constant reference to member numbers - */ - eProsima_user_DllExport const std::vector& numbers() const; - - /*! - * @brief This function returns a reference to member numbers - * @return Reference to member numbers - */ - eProsima_user_DllExport std::vector& numbers(); - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const float_bounded_sequence& data, - size_t current_alignment = 0); - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - /*! - * @brief This function returns the maximum serialized size of the Key of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - -private: - - std::vector m_numbers; -}; - -#endif // _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCE_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequencePubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequencePubSubTypes.cxx deleted file mode 100644 index e0176475..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequencePubSubTypes.cxx +++ /dev/null @@ -1,169 +0,0 @@ -// 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 float_bounded_sequencePubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#include -#include - -#include "float_bounded_sequencePubSubTypes.h" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; - -float_bounded_sequencePubSubType::float_bounded_sequencePubSubType() -{ - setName("float_bounded_sequence"); - auto type_size = float_bounded_sequence::getMaxCdrSerializedSize(); - type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ - m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ - m_isGetKeyDefined = float_bounded_sequence::isKeyDefined(); - size_t keyLength = float_bounded_sequence::getKeyMaxCdrSerializedSize() > 16 ? - float_bounded_sequence::getKeyMaxCdrSerializedSize() : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -float_bounded_sequencePubSubType::~float_bounded_sequencePubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool float_bounded_sequencePubSubType::serialize( - void* data, - SerializedPayload_t* payload) -{ - float_bounded_sequence* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - // Serialize encapsulation - ser.serialize_encapsulation(); - - try - { - // Serialize the object. - p_type->serialize(ser); - } - catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) - { - return false; - } - - // Get the serialized length - payload->length = static_cast(ser.getSerializedDataLength()); - return true; -} - -bool float_bounded_sequencePubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - //Convert DATA to pointer of your type - float_bounded_sequence* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - p_type->deserialize(deser); - } - catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) - { - return false; - } - - return true; -} - -std::function float_bounded_sequencePubSubType::getSerializedSizeProvider( - void* data) -{ - return [data]() -> uint32_t - { - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - }; -} - -void* float_bounded_sequencePubSubType::createData() -{ - return reinterpret_cast(new float_bounded_sequence()); -} - -void float_bounded_sequencePubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool float_bounded_sequencePubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - float_bounded_sequence* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - float_bounded_sequence::getKeyMaxCdrSerializedSize()); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); - p_type->serializeKey(ser); - if (force_md5 || float_bounded_sequence::getKeyMaxCdrSerializedSize() > 16) - { - m_md5.init(); - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequencePubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequencePubSubTypes.h deleted file mode 100644 index 80661b58..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequencePubSubTypes.h +++ /dev/null @@ -1,101 +0,0 @@ -// 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 float_bounded_sequencePubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#ifndef _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCE_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCE_PUBSUBTYPES_H_ - -#include -#include - -#include "float_bounded_sequence.h" - -#if !defined(GEN_API_VER) || (GEN_API_VER != 1) -#error \ - Generated float_bounded_sequence is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER - -/*! - * @brief This class represents the TopicDataType of the type float_bounded_sequence defined by the user in the IDL file. - * @ingroup FLOAT_BOUNDED_SEQUENCE - */ -class float_bounded_sequencePubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef float_bounded_sequence type; - - eProsima_user_DllExport float_bounded_sequencePubSubType(); - - eProsima_user_DllExport virtual ~float_bounded_sequencePubSubType() override; - - eProsima_user_DllExport virtual bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; - - eProsima_user_DllExport virtual bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport virtual std::function getSerializedSizeProvider( - void* data) override; - - eProsima_user_DllExport virtual bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport virtual void* createData() override; - - eProsima_user_DllExport virtual void deleteData( - void* data) override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - (void)memory; - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; -}; - -#endif // _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCE_PUBSUBTYPES_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequenceTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequenceTypeObject.cxx deleted file mode 100644 index a329d1c0..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequenceTypeObject.cxx +++ /dev/null @@ -1,215 +0,0 @@ -// 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 float_bounded_sequenceTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { char dummy; } -#endif - -#include "float_bounded_sequence.h" -#include "float_bounded_sequenceTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerfloat_bounded_sequenceTypes() -{ - TypeObjectFactory *factory = TypeObjectFactory::get_instance(); - factory->add_type_object("float_bounded_sequence", Getfloat_bounded_sequenceIdentifier(true), - Getfloat_bounded_sequenceObject(true)); - factory->add_type_object("float_bounded_sequence", Getfloat_bounded_sequenceIdentifier(false), - Getfloat_bounded_sequenceObject(false)); - -} - -const TypeIdentifier* Getfloat_bounded_sequenceIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("float_bounded_sequence", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - Getfloat_bounded_sequenceObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("float_bounded_sequence", complete); -} - -const TypeObject* Getfloat_bounded_sequenceObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("float_bounded_sequence", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompletefloat_bounded_sequenceObject(); - } - //else - return GetMinimalfloat_bounded_sequenceObject(); -} - -const TypeObject* GetMinimalfloat_bounded_sequenceObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("float_bounded_sequence", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_numbers; - mst_numbers.common().member_id(memberId++); - mst_numbers.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_numbers.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_numbers.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_numbers.common().member_flags().IS_OPTIONAL(false); - mst_numbers.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_numbers.common().member_flags().IS_KEY(false); - mst_numbers.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_numbers.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("float", 13, false)); - - - MD5 numbers_hash("numbers"); - for(int i = 0; i < 4; ++i) - { - mst_numbers.detail().name_hash()[i] = numbers_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_numbers); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - SerializedPayload_t payload(static_cast( - MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("float_bounded_sequence", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("float_bounded_sequence", false); -} - -const TypeObject* GetCompletefloat_bounded_sequenceObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("float_bounded_sequence", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_numbers; - cst_numbers.common().member_id(memberId++); - cst_numbers.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_numbers.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_numbers.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_numbers.common().member_flags().IS_OPTIONAL(false); - cst_numbers.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_numbers.common().member_flags().IS_KEY(false); - cst_numbers.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_numbers.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("float", 13, true)); - - - cst_numbers.detail().name("numbers"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_numbers); - - - // Header - type_object->complete().struct_type().header().detail().type_name("float_bounded_sequence"); - // TODO inheritance - - - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - SerializedPayload_t payload(static_cast( - CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("float_bounded_sequence", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("float_bounded_sequence", true); -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequenceTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequenceTypeObject.h deleted file mode 100644 index 65d62243..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequenceTypeObject.h +++ /dev/null @@ -1,65 +0,0 @@ -// 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 float_bounded_sequenceTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifndef _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCE_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCE_TYPE_OBJECT_H_ - - -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define eProsima_user_DllExport -#endif // if defined(_WIN32) - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(float_bounded_sequence_SOURCE) -#define float_bounded_sequence_DllAPI __declspec( dllexport ) -#else -#define float_bounded_sequence_DllAPI __declspec( dllimport ) -#endif // float_bounded_sequence_SOURCE -#else -#define float_bounded_sequence_DllAPI -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define float_bounded_sequence_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registerfloat_bounded_sequenceTypes(); - -eProsima_user_DllExport const TypeIdentifier* Getfloat_bounded_sequenceIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* Getfloat_bounded_sequenceObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalfloat_bounded_sequenceObject(); -eProsima_user_DllExport const TypeObject* GetCompletefloat_bounded_sequenceObject(); - - -#endif // _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCE_TYPE_OBJECT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_world.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_world.cxx deleted file mode 100644 index 40a12463..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_world.cxx +++ /dev/null @@ -1,239 +0,0 @@ -// 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 hello_world.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "hello_world.h" -#include "hello_worldTypeObject.h" -#include - -#include -using namespace eprosima::fastcdr::exception; - -#include - -hello_world::hello_world() -{ - // m_index com.eprosima.idl.parser.typecode.PrimitiveTypeCode@1dfe2924 - m_index = 0; - // m_message com.eprosima.idl.parser.typecode.StringTypeCode@6ebc05a6 - m_message =""; - - // Just to register all known types - registerhello_worldTypes(); -} - -hello_world::~hello_world() -{ - - -} - -hello_world::hello_world( - const hello_world& x) -{ - m_index = x.m_index; - m_message = x.m_message; -} - -hello_world::hello_world( - hello_world&& x) noexcept -{ - m_index = x.m_index; - m_message = std::move(x.m_message); -} - -hello_world& hello_world::operator =( - const hello_world& x) -{ - - m_index = x.m_index; - m_message = x.m_message; - - return *this; -} - -hello_world& hello_world::operator =( - hello_world&& x) noexcept -{ - - m_index = x.m_index; - m_message = std::move(x.m_message); - - return *this; -} - -bool hello_world::operator ==( - const hello_world& x) const -{ - - return (m_index == x.m_index && m_message == x.m_message); -} - -bool hello_world::operator !=( - const hello_world& x) const -{ - return !(*this == x); -} - -size_t hello_world::getMaxCdrSerializedSize( - size_t current_alignment) -{ - size_t initial_alignment = current_alignment; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + 255 + 1; - - - return current_alignment - initial_alignment; -} - -size_t hello_world::getCdrSerializedSize( - const hello_world& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.message().size() + 1; - - - return current_alignment - initial_alignment; -} - -void hello_world::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - - scdr << m_index; - scdr << m_message.c_str(); - -} - -void hello_world::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - - dcdr >> m_index; - dcdr >> m_message; -} - -/*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ -void hello_world::index( - uint32_t _index) -{ - m_index = _index; -} - -/*! - * @brief This function returns the value of member index - * @return Value of member index - */ -uint32_t hello_world::index() const -{ - return m_index; -} - -/*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ -uint32_t& hello_world::index() -{ - return m_index; -} - -/*! - * @brief This function copies the value in member message - * @param _message New value to be copied in member message - */ -void hello_world::message( - const std::string& _message) -{ - m_message = _message; -} - -/*! - * @brief This function moves the value in member message - * @param _message New value to be moved in member message - */ -void hello_world::message( - std::string&& _message) -{ - m_message = std::move(_message); -} - -/*! - * @brief This function returns a constant reference to member message - * @return Constant reference to member message - */ -const std::string& hello_world::message() const -{ - return m_message; -} - -/*! - * @brief This function returns a reference to member message - * @return Reference to member message - */ -std::string& hello_world::message() -{ - return m_message; -} - -size_t hello_world::getKeyMaxCdrSerializedSize( - size_t current_alignment) -{ - size_t current_align = current_alignment; - - - - - - return current_align; -} - -bool hello_world::isKeyDefined() -{ - return false; -} - -void hello_world::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; - -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_world.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_world.h deleted file mode 100644 index 678a59f0..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_world.h +++ /dev/null @@ -1,234 +0,0 @@ -// 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 hello_world.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifndef _FAST_DDS_GENERATED_HELLO_WORLD_H_ -#define _FAST_DDS_GENERATED_HELLO_WORLD_H_ - - -#include - -#include -#include -#include -#include -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(hello_world_SOURCE) -#define hello_world_DllAPI __declspec( dllexport ) -#else -#define hello_world_DllAPI __declspec( dllimport ) -#endif // hello_world_SOURCE -#else -#define hello_world_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define hello_world_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - -/*! - * @brief This class represents the structure hello_world defined by the user in the IDL file. - * @ingroup HELLO_WORLD - */ -class hello_world -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport hello_world(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~hello_world(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object hello_world that will be copied. - */ - eProsima_user_DllExport hello_world( - const hello_world& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object hello_world that will be copied. - */ - eProsima_user_DllExport hello_world( - hello_world&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object hello_world that will be copied. - */ - eProsima_user_DllExport hello_world& operator =( - const hello_world& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object hello_world that will be copied. - */ - eProsima_user_DllExport hello_world& operator =( - hello_world&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x hello_world object to compare. - */ - eProsima_user_DllExport bool operator ==( - const hello_world& x) const; - - /*! - * @brief Comparison operator. - * @param x hello_world object to compare. - */ - eProsima_user_DllExport bool operator !=( - const hello_world& x) const; - - /*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ - eProsima_user_DllExport void index( - uint32_t _index); - - /*! - * @brief This function returns the value of member index - * @return Value of member index - */ - eProsima_user_DllExport uint32_t index() const; - - /*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ - eProsima_user_DllExport uint32_t& index(); - - /*! - * @brief This function copies the value in member message - * @param _message New value to be copied in member message - */ - eProsima_user_DllExport void message( - const std::string& _message); - - /*! - * @brief This function moves the value in member message - * @param _message New value to be moved in member message - */ - eProsima_user_DllExport void message( - std::string&& _message); - - /*! - * @brief This function returns a constant reference to member message - * @return Constant reference to member message - */ - eProsima_user_DllExport const std::string& message() const; - - /*! - * @brief This function returns a reference to member message - * @return Reference to member message - */ - eProsima_user_DllExport std::string& message(); - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const hello_world& data, - size_t current_alignment = 0); - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - /*! - * @brief This function returns the maximum serialized size of the Key of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - -private: - - uint32_t m_index; - std::string m_message; -}; - -#endif // _FAST_DDS_GENERATED_HELLO_WORLD_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_worldPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_worldPubSubTypes.cxx deleted file mode 100644 index 8717497c..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_worldPubSubTypes.cxx +++ /dev/null @@ -1,169 +0,0 @@ -// 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 hello_worldPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#include -#include - -#include "hello_worldPubSubTypes.h" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; - -hello_worldPubSubType::hello_worldPubSubType() -{ - setName("hello_world"); - auto type_size = hello_world::getMaxCdrSerializedSize(); - type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ - m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ - m_isGetKeyDefined = hello_world::isKeyDefined(); - size_t keyLength = hello_world::getKeyMaxCdrSerializedSize() > 16 ? - hello_world::getKeyMaxCdrSerializedSize() : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -hello_worldPubSubType::~hello_worldPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool hello_worldPubSubType::serialize( - void* data, - SerializedPayload_t* payload) -{ - hello_world* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - // Serialize encapsulation - ser.serialize_encapsulation(); - - try - { - // Serialize the object. - p_type->serialize(ser); - } - catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) - { - return false; - } - - // Get the serialized length - payload->length = static_cast(ser.getSerializedDataLength()); - return true; -} - -bool hello_worldPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - //Convert DATA to pointer of your type - hello_world* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - p_type->deserialize(deser); - } - catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) - { - return false; - } - - return true; -} - -std::function hello_worldPubSubType::getSerializedSizeProvider( - void* data) -{ - return [data]() -> uint32_t - { - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - }; -} - -void* hello_worldPubSubType::createData() -{ - return reinterpret_cast(new hello_world()); -} - -void hello_worldPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool hello_worldPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - hello_world* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - hello_world::getKeyMaxCdrSerializedSize()); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); - p_type->serializeKey(ser); - if (force_md5 || hello_world::getKeyMaxCdrSerializedSize() > 16) - { - m_md5.init(); - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_worldPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_worldPubSubTypes.h deleted file mode 100644 index d261d555..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_worldPubSubTypes.h +++ /dev/null @@ -1,101 +0,0 @@ -// 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 hello_worldPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#ifndef _FAST_DDS_GENERATED_HELLO_WORLD_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_HELLO_WORLD_PUBSUBTYPES_H_ - -#include -#include - -#include "hello_world.h" - -#if !defined(GEN_API_VER) || (GEN_API_VER != 1) -#error \ - Generated hello_world is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER - -/*! - * @brief This class represents the TopicDataType of the type hello_world defined by the user in the IDL file. - * @ingroup HELLO_WORLD - */ -class hello_worldPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef hello_world type; - - eProsima_user_DllExport hello_worldPubSubType(); - - eProsima_user_DllExport virtual ~hello_worldPubSubType() override; - - eProsima_user_DllExport virtual bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; - - eProsima_user_DllExport virtual bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport virtual std::function getSerializedSizeProvider( - void* data) override; - - eProsima_user_DllExport virtual bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport virtual void* createData() override; - - eProsima_user_DllExport virtual void deleteData( - void* data) override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - (void)memory; - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; -}; - -#endif // _FAST_DDS_GENERATED_HELLO_WORLD_PUBSUBTYPES_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_worldTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_worldTypeObject.cxx deleted file mode 100644 index aac863c3..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_worldTypeObject.cxx +++ /dev/null @@ -1,248 +0,0 @@ -// 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 hello_worldTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { char dummy; } -#endif - -#include "hello_world.h" -#include "hello_worldTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerhello_worldTypes() -{ - TypeObjectFactory *factory = TypeObjectFactory::get_instance(); - factory->add_type_object("hello_world", Gethello_worldIdentifier(true), - Gethello_worldObject(true)); - factory->add_type_object("hello_world", Gethello_worldIdentifier(false), - Gethello_worldObject(false)); - -} - -const TypeIdentifier* Gethello_worldIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("hello_world", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - Gethello_worldObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("hello_world", complete); -} - -const TypeObject* Gethello_worldObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("hello_world", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompletehello_worldObject(); - } - //else - return GetMinimalhello_worldObject(); -} - -const TypeObject* GetMinimalhello_worldObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("hello_world", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_index; - mst_index.common().member_id(memberId++); - mst_index.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_index.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_index.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_index.common().member_flags().IS_OPTIONAL(false); - mst_index.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_index.common().member_flags().IS_KEY(false); - mst_index.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_index.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); - - MD5 index_hash("index"); - for(int i = 0; i < 4; ++i) - { - mst_index.detail().name_hash()[i] = index_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_index); - - MinimalStructMember mst_message; - mst_message.common().member_id(memberId++); - mst_message.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_message.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_message.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_message.common().member_flags().IS_OPTIONAL(false); - mst_message.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_message.common().member_flags().IS_KEY(false); - mst_message.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_message.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - - MD5 message_hash("message"); - for(int i = 0; i < 4; ++i) - { - mst_message.detail().name_hash()[i] = message_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_message); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - SerializedPayload_t payload(static_cast( - MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("hello_world", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("hello_world", false); -} - -const TypeObject* GetCompletehello_worldObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("hello_world", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_index; - cst_index.common().member_id(memberId++); - cst_index.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_index.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_index.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_index.common().member_flags().IS_OPTIONAL(false); - cst_index.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_index.common().member_flags().IS_KEY(false); - cst_index.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_index.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); - - cst_index.detail().name("index"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_index); - - CompleteStructMember cst_message; - cst_message.common().member_id(memberId++); - cst_message.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_message.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_message.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_message.common().member_flags().IS_OPTIONAL(false); - cst_message.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_message.common().member_flags().IS_KEY(false); - cst_message.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_message.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - - cst_message.detail().name("message"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_message); - - - // Header - type_object->complete().struct_type().header().detail().type_name("hello_world"); - // TODO inheritance - - - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - SerializedPayload_t payload(static_cast( - CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("hello_world", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("hello_world", true); -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_worldTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_worldTypeObject.h deleted file mode 100644 index 7774c87b..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_worldTypeObject.h +++ /dev/null @@ -1,65 +0,0 @@ -// 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 hello_worldTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifndef _FAST_DDS_GENERATED_HELLO_WORLD_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_HELLO_WORLD_TYPE_OBJECT_H_ - - -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define eProsima_user_DllExport -#endif // if defined(_WIN32) - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(hello_world_SOURCE) -#define hello_world_DllAPI __declspec( dllexport ) -#else -#define hello_world_DllAPI __declspec( dllimport ) -#endif // hello_world_SOURCE -#else -#define hello_world_DllAPI -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define hello_world_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registerhello_worldTypes(); - -eProsima_user_DllExport const TypeIdentifier* Gethello_worldIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* Gethello_worldObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalhello_worldObject(); -eProsima_user_DllExport const TypeObject* GetCompletehello_worldObject(); - - -#endif // _FAST_DDS_GENERATED_HELLO_WORLD_TYPE_OBJECT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_struct.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_struct.cxx deleted file mode 100644 index b48a5d98..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_struct.cxx +++ /dev/null @@ -1,194 +0,0 @@ -// 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 map_struct.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "map_struct.h" -#include "map_structTypeObject.h" -#include - -#include -using namespace eprosima::fastcdr::exception; - -#include - -#define map_struct_max_cdr_typesize 26401ULL; -#define map_struct_max_key_cdr_typesize 0ULL; - -map_struct::map_struct() -{ - // map m_my_map - - - // Just to register all known types - registermap_structTypes(); -} - -map_struct::~map_struct() -{ -} - -map_struct::map_struct( - const map_struct& x) -{ - m_my_map = x.m_my_map; -} - -map_struct::map_struct( - map_struct&& x) noexcept -{ - m_my_map = std::move(x.m_my_map); -} - -map_struct& map_struct::operator =( - const map_struct& x) -{ - - m_my_map = x.m_my_map; - - return *this; -} - -map_struct& map_struct::operator =( - map_struct&& x) noexcept -{ - - m_my_map = std::move(x.m_my_map); - - return *this; -} - -bool map_struct::operator ==( - const map_struct& x) const -{ - - return (m_my_map == x.m_my_map); -} - -bool map_struct::operator !=( - const map_struct& x) const -{ - return !(*this == x); -} - -size_t map_struct::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return map_struct_max_cdr_typesize; -} - -size_t map_struct::getCdrSerializedSize( - const map_struct& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - for(auto a : data.my_map()) - { - (void)a; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + a.first.size() + 1; - current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); - - } - - return current_alignment - initial_alignment; -} - -void map_struct::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - - scdr << m_my_map; -} - -void map_struct::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - - dcdr >> m_my_map;} - -/*! - * @brief This function copies the value in member my_map - * @param _my_map New value to be copied in member my_map - */ -void map_struct::my_map( - const std::map& _my_map) -{ - m_my_map = _my_map; -} - -/*! - * @brief This function moves the value in member my_map - * @param _my_map New value to be moved in member my_map - */ -void map_struct::my_map( - std::map&& _my_map) -{ - m_my_map = std::move(_my_map); -} - -/*! - * @brief This function returns a constant reference to member my_map - * @return Constant reference to member my_map - */ -const std::map& map_struct::my_map() const -{ - return m_my_map; -} - -/*! - * @brief This function returns a reference to member my_map - * @return Reference to member my_map - */ -std::map& map_struct::my_map() -{ - return m_my_map; -} - - -size_t map_struct::getKeyMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return map_struct_max_key_cdr_typesize; -} - -bool map_struct::isKeyDefined() -{ - return false; -} - -void map_struct::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_struct.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_struct.h deleted file mode 100644 index 232aea44..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_struct.h +++ /dev/null @@ -1,215 +0,0 @@ -// 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 map_struct.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifndef _FAST_DDS_GENERATED_MAP_STRUCT_H_ -#define _FAST_DDS_GENERATED_MAP_STRUCT_H_ - - -#include - -#include -#include -#include -#include -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(MAP_STRUCT_SOURCE) -#define MAP_STRUCT_DllAPI __declspec( dllexport ) -#else -#define MAP_STRUCT_DllAPI __declspec( dllimport ) -#endif // MAP_STRUCT_SOURCE -#else -#define MAP_STRUCT_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define MAP_STRUCT_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - -/*! - * @brief This class represents the structure map_struct defined by the user in the IDL file. - * @ingroup map_struct - */ -class map_struct -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport map_struct(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~map_struct(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object map_struct that will be copied. - */ - eProsima_user_DllExport map_struct( - const map_struct& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object map_struct that will be copied. - */ - eProsima_user_DllExport map_struct( - map_struct&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object map_struct that will be copied. - */ - eProsima_user_DllExport map_struct& operator =( - const map_struct& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object map_struct that will be copied. - */ - eProsima_user_DllExport map_struct& operator =( - map_struct&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x map_struct object to compare. - */ - eProsima_user_DllExport bool operator ==( - const map_struct& x) const; - - /*! - * @brief Comparison operator. - * @param x map_struct object to compare. - */ - eProsima_user_DllExport bool operator !=( - const map_struct& x) const; - - /*! - * @brief This function copies the value in member my_map - * @param _my_map New value to be copied in member my_map - */ - eProsima_user_DllExport void my_map( - const std::map& _my_map); - - /*! - * @brief This function moves the value in member my_map - * @param _my_map New value to be moved in member my_map - */ - eProsima_user_DllExport void my_map( - std::map&& _my_map); - - /*! - * @brief This function returns a constant reference to member my_map - * @return Constant reference to member my_map - */ - eProsima_user_DllExport const std::map& my_map() const; - - /*! - * @brief This function returns a reference to member my_map - * @return Reference to member my_map - */ - eProsima_user_DllExport std::map& my_map(); - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const map_struct& data, - size_t current_alignment = 0); - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - /*! - * @brief This function returns the maximum serialized size of the Key of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - -private: - - std::map m_my_map; - -}; - -#endif // _FAST_DDS_GENERATED_MAP_STRUCT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_structPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_structPubSubTypes.cxx deleted file mode 100644 index c6e6e006..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_structPubSubTypes.cxx +++ /dev/null @@ -1,169 +0,0 @@ -// 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 map_structPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#include -#include - -#include "map_structPubSubTypes.h" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; - -map_structPubSubType::map_structPubSubType() -{ - setName("map_struct"); - auto type_size = map_struct::getMaxCdrSerializedSize(); - type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ - m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ - m_isGetKeyDefined = map_struct::isKeyDefined(); - size_t keyLength = map_struct::getKeyMaxCdrSerializedSize() > 16 ? - map_struct::getKeyMaxCdrSerializedSize() : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -map_structPubSubType::~map_structPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool map_structPubSubType::serialize( - void* data, - SerializedPayload_t* payload) -{ - map_struct* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - p_type->serialize(ser); - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length - payload->length = static_cast(ser.getSerializedDataLength()); - return true; -} - -bool map_structPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - map_struct* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - p_type->deserialize(deser); - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function map_structPubSubType::getSerializedSizeProvider( - void* data) -{ - return [data]() -> uint32_t - { - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - }; -} - -void* map_structPubSubType::createData() -{ - return reinterpret_cast(new map_struct()); -} - -void map_structPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool map_structPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - map_struct* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - map_struct::getKeyMaxCdrSerializedSize()); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); - p_type->serializeKey(ser); - if (force_md5 || map_struct::getKeyMaxCdrSerializedSize() > 16) - { - m_md5.init(); - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_structPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_structPubSubTypes.h deleted file mode 100644 index 80aa0787..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_structPubSubTypes.h +++ /dev/null @@ -1,104 +0,0 @@ -// 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 map_structPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#ifndef _FAST_DDS_GENERATED_MAP_STRUCT_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_MAP_STRUCT_PUBSUBTYPES_H_ - -#include -#include - -#include "map_struct.h" - - -#if !defined(GEN_API_VER) || (GEN_API_VER != 1) -#error \ - Generated map_struct is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER - - -/*! - * @brief This class represents the TopicDataType of the type map_struct defined by the user in the IDL file. - * @ingroup map_struct - */ -class map_structPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef map_struct type; - - eProsima_user_DllExport map_structPubSubType(); - - eProsima_user_DllExport virtual ~map_structPubSubType() override; - - eProsima_user_DllExport virtual bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; - - eProsima_user_DllExport virtual bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport virtual std::function getSerializedSizeProvider( - void* data) override; - - eProsima_user_DllExport virtual bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport virtual void* createData() override; - - eProsima_user_DllExport virtual void deleteData( - void* data) override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - (void)memory; - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - -#endif // _FAST_DDS_GENERATED_MAP_STRUCT_PUBSUBTYPES_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_structTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_structTypeObject.cxx deleted file mode 100644 index 397ce137..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_structTypeObject.cxx +++ /dev/null @@ -1,220 +0,0 @@ -// 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 map_structTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { char dummy; } -#endif - -#include "map_struct.h" -#include "map_structTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registermap_structTypes() -{ - static std::once_flag once_flag; - std::call_once(once_flag, []() - { - TypeObjectFactory *factory = TypeObjectFactory::get_instance(); - factory->add_type_object("map_struct", Getmap_structIdentifier(true), - Getmap_structObject(true)); - factory->add_type_object("map_struct", Getmap_structIdentifier(false), - Getmap_structObject(false)); - - }); -} - -const TypeIdentifier* Getmap_structIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("map_struct", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - Getmap_structObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("map_struct", complete); -} - -const TypeObject* Getmap_structObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("map_struct", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompletemap_structObject(); - } - //else - return GetMinimalmap_structObject(); -} - -const TypeObject* GetMinimalmap_structObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("map_struct", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_my_map; - mst_my_map.common().member_id(memberId++); - mst_my_map.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_my_map.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_my_map.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_my_map.common().member_flags().IS_OPTIONAL(false); - mst_my_map.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_my_map.common().member_flags().IS_KEY(false); - mst_my_map.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_my_map.common().member_type_id(*TypeObjectFactory::get_instance()->get_map_identifier(TypeNamesGenerator::get_string_type_name(255, false), "bool", 100, false)); - - - MD5 my_map_hash("my_map"); - for(int i = 0; i < 4; ++i) - { - mst_my_map.detail().name_hash()[i] = my_map_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_my_map); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - SerializedPayload_t payload(static_cast( - MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("map_struct", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("map_struct", false); -} - -const TypeObject* GetCompletemap_structObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("map_struct", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_my_map; - cst_my_map.common().member_id(memberId++); - cst_my_map.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_my_map.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_my_map.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_my_map.common().member_flags().IS_OPTIONAL(false); - cst_my_map.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_my_map.common().member_flags().IS_KEY(false); - cst_my_map.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_my_map.common().member_type_id(*TypeObjectFactory::get_instance()->get_map_identifier(TypeNamesGenerator::get_string_type_name(255, false), "bool", 100, true)); - - - cst_my_map.detail().name("my_map"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_my_map); - - - // Header - type_object->complete().struct_type().header().detail().type_name("map_struct"); - // TODO inheritance - - - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - SerializedPayload_t payload(static_cast( - CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("map_struct", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("map_struct", true); -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_structTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_structTypeObject.h deleted file mode 100644 index 07559e37..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_structTypeObject.h +++ /dev/null @@ -1,63 +0,0 @@ -// 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 map_structTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifndef _FAST_DDS_GENERATED_MAP_STRUCT_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_MAP_STRUCT_TYPE_OBJECT_H_ - - -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif -#else -#define eProsima_user_DllExport -#endif - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(map_struct_SOURCE) -#define map_struct_DllAPI __declspec( dllexport ) -#else -#define map_struct_DllAPI __declspec( dllimport ) -#endif // map_struct_SOURCE -#else -#define map_struct_DllAPI -#endif -#else -#define map_struct_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registermap_structTypes(); - -eProsima_user_DllExport const TypeIdentifier* Getmap_structIdentifier(bool complete = false); -eProsima_user_DllExport const TypeObject* Getmap_structObject(bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalmap_structObject(); -eProsima_user_DllExport const TypeObject* GetCompletemap_structObject(); - - -#endif // _FAST_DDS_GENERATED_MAP_STRUCT_TYPE_OBJECT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_array.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_array.cxx deleted file mode 100644 index 6ec457f2..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_array.cxx +++ /dev/null @@ -1,197 +0,0 @@ -// 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 numeric_array.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "numeric_array.h" -#include "numeric_arrayTypeObject.h" -#include - -#include -using namespace eprosima::fastcdr::exception; - -#include - -numeric_array::numeric_array() -{ - // m_points com.eprosima.idl.parser.typecode.ArrayTypeCode@cd2dae5 - memset(&m_points, 0, (3) * 4); - - // Just to register all known types - registernumeric_arrayTypes(); -} - -numeric_array::~numeric_array() -{ -} - -numeric_array::numeric_array( - const numeric_array& x) -{ - m_points = x.m_points; -} - -numeric_array::numeric_array( - numeric_array&& x) noexcept -{ - m_points = std::move(x.m_points); -} - -numeric_array& numeric_array::operator =( - const numeric_array& x) -{ - - m_points = x.m_points; - - return *this; -} - -numeric_array& numeric_array::operator =( - numeric_array&& x) noexcept -{ - - m_points = std::move(x.m_points); - - return *this; -} - -bool numeric_array::operator ==( - const numeric_array& x) const -{ - - return (m_points == x.m_points); -} - -bool numeric_array::operator !=( - const numeric_array& x) const -{ - return !(*this == x); -} - -size_t numeric_array::getMaxCdrSerializedSize( - size_t current_alignment) -{ - size_t initial_alignment = current_alignment; - - - current_alignment += ((3) * 4) + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - return current_alignment - initial_alignment; -} - -size_t numeric_array::getCdrSerializedSize( - const numeric_array& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - - if ((3) > 0) - { - current_alignment += ((3) * 4) + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - } - - return current_alignment - initial_alignment; -} - -void numeric_array::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - - scdr << m_points; - - -} - -void numeric_array::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - - dcdr >> m_points; - -} - -/*! - * @brief This function copies the value in member points - * @param _points New value to be copied in member points - */ -void numeric_array::points( - const std::array& _points) -{ - m_points = _points; -} - -/*! - * @brief This function moves the value in member points - * @param _points New value to be moved in member points - */ -void numeric_array::points( - std::array&& _points) -{ - m_points = std::move(_points); -} - -/*! - * @brief This function returns a constant reference to member points - * @return Constant reference to member points - */ -const std::array& numeric_array::points() const -{ - return m_points; -} - -/*! - * @brief This function returns a reference to member points - * @return Reference to member points - */ -std::array& numeric_array::points() -{ - return m_points; -} - -size_t numeric_array::getKeyMaxCdrSerializedSize( - size_t current_alignment) -{ - size_t current_align = current_alignment; - - - - return current_align; -} - -bool numeric_array::isKeyDefined() -{ - return false; -} - -void numeric_array::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; - -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_array.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_array.h deleted file mode 100644 index 5d23be32..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_array.h +++ /dev/null @@ -1,214 +0,0 @@ -// 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 numeric_array.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifndef _FAST_DDS_GENERATED_NUMERIC_ARRAY_H_ -#define _FAST_DDS_GENERATED_NUMERIC_ARRAY_H_ - - -#include - -#include -#include -#include -#include -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(numeric_array_SOURCE) -#define numeric_array_DllAPI __declspec( dllexport ) -#else -#define numeric_array_DllAPI __declspec( dllimport ) -#endif // numeric_array_SOURCE -#else -#define numeric_array_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define numeric_array_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - -/*! - * @brief This class represents the structure numeric_array defined by the user in the IDL file. - * @ingroup NUMERIC_ARRAY - */ -class numeric_array -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport numeric_array(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~numeric_array(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object numeric_array that will be copied. - */ - eProsima_user_DllExport numeric_array( - const numeric_array& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object numeric_array that will be copied. - */ - eProsima_user_DllExport numeric_array( - numeric_array&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object numeric_array that will be copied. - */ - eProsima_user_DllExport numeric_array& operator =( - const numeric_array& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object numeric_array that will be copied. - */ - eProsima_user_DllExport numeric_array& operator =( - numeric_array&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x numeric_array object to compare. - */ - eProsima_user_DllExport bool operator ==( - const numeric_array& x) const; - - /*! - * @brief Comparison operator. - * @param x numeric_array object to compare. - */ - eProsima_user_DllExport bool operator !=( - const numeric_array& x) const; - - /*! - * @brief This function copies the value in member points - * @param _points New value to be copied in member points - */ - eProsima_user_DllExport void points( - const std::array& _points); - - /*! - * @brief This function moves the value in member points - * @param _points New value to be moved in member points - */ - eProsima_user_DllExport void points( - std::array&& _points); - - /*! - * @brief This function returns a constant reference to member points - * @return Constant reference to member points - */ - eProsima_user_DllExport const std::array& points() const; - - /*! - * @brief This function returns a reference to member points - * @return Reference to member points - */ - eProsima_user_DllExport std::array& points(); - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const numeric_array& data, - size_t current_alignment = 0); - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - /*! - * @brief This function returns the maximum serialized size of the Key of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - -private: - - std::array m_points; -}; - -#endif // _FAST_DDS_GENERATED_NUMERIC_ARRAY_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_arrayPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_arrayPubSubTypes.cxx deleted file mode 100644 index 1f6aa132..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_arrayPubSubTypes.cxx +++ /dev/null @@ -1,169 +0,0 @@ -// 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 numeric_arrayPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#include -#include - -#include "numeric_arrayPubSubTypes.h" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; - -numeric_arrayPubSubType::numeric_arrayPubSubType() -{ - setName("numeric_array"); - auto type_size = numeric_array::getMaxCdrSerializedSize(); - type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ - m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ - m_isGetKeyDefined = numeric_array::isKeyDefined(); - size_t keyLength = numeric_array::getKeyMaxCdrSerializedSize() > 16 ? - numeric_array::getKeyMaxCdrSerializedSize() : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -numeric_arrayPubSubType::~numeric_arrayPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool numeric_arrayPubSubType::serialize( - void* data, - SerializedPayload_t* payload) -{ - numeric_array* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - // Serialize encapsulation - ser.serialize_encapsulation(); - - try - { - // Serialize the object. - p_type->serialize(ser); - } - catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) - { - return false; - } - - // Get the serialized length - payload->length = static_cast(ser.getSerializedDataLength()); - return true; -} - -bool numeric_arrayPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - //Convert DATA to pointer of your type - numeric_array* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - p_type->deserialize(deser); - } - catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) - { - return false; - } - - return true; -} - -std::function numeric_arrayPubSubType::getSerializedSizeProvider( - void* data) -{ - return [data]() -> uint32_t - { - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - }; -} - -void* numeric_arrayPubSubType::createData() -{ - return reinterpret_cast(new numeric_array()); -} - -void numeric_arrayPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool numeric_arrayPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - numeric_array* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - numeric_array::getKeyMaxCdrSerializedSize()); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); - p_type->serializeKey(ser); - if (force_md5 || numeric_array::getKeyMaxCdrSerializedSize() > 16) - { - m_md5.init(); - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_arrayPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_arrayPubSubTypes.h deleted file mode 100644 index b975cd5e..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_arrayPubSubTypes.h +++ /dev/null @@ -1,101 +0,0 @@ -// 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 numeric_arrayPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#ifndef _FAST_DDS_GENERATED_NUMERIC_ARRAY_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_NUMERIC_ARRAY_PUBSUBTYPES_H_ - -#include -#include - -#include "numeric_array.h" - -#if !defined(GEN_API_VER) || (GEN_API_VER != 1) -#error \ - Generated numeric_array is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER - -/*! - * @brief This class represents the TopicDataType of the type numeric_array defined by the user in the IDL file. - * @ingroup NUMERIC_ARRAY - */ -class numeric_arrayPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef numeric_array type; - - eProsima_user_DllExport numeric_arrayPubSubType(); - - eProsima_user_DllExport virtual ~numeric_arrayPubSubType() override; - - eProsima_user_DllExport virtual bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; - - eProsima_user_DllExport virtual bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport virtual std::function getSerializedSizeProvider( - void* data) override; - - eProsima_user_DllExport virtual bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport virtual void* createData() override; - - eProsima_user_DllExport virtual void deleteData( - void* data) override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - new (memory) numeric_array(); - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; -}; - -#endif // _FAST_DDS_GENERATED_NUMERIC_ARRAY_PUBSUBTYPES_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_arrayTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_arrayTypeObject.cxx deleted file mode 100644 index aaab64ae..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_arrayTypeObject.cxx +++ /dev/null @@ -1,215 +0,0 @@ -// 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 numeric_arrayTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { char dummy; } -#endif - -#include "numeric_array.h" -#include "numeric_arrayTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registernumeric_arrayTypes() -{ - TypeObjectFactory *factory = TypeObjectFactory::get_instance(); - factory->add_type_object("numeric_array", Getnumeric_arrayIdentifier(true), - Getnumeric_arrayObject(true)); - factory->add_type_object("numeric_array", Getnumeric_arrayIdentifier(false), - Getnumeric_arrayObject(false)); - -} - -const TypeIdentifier* Getnumeric_arrayIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("numeric_array", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - Getnumeric_arrayObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("numeric_array", complete); -} - -const TypeObject* Getnumeric_arrayObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("numeric_array", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompletenumeric_arrayObject(); - } - //else - return GetMinimalnumeric_arrayObject(); -} - -const TypeObject* GetMinimalnumeric_arrayObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("numeric_array", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_points; - mst_points.common().member_id(memberId++); - mst_points.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_points.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_points.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_points.common().member_flags().IS_OPTIONAL(false); - mst_points.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_points.common().member_flags().IS_KEY(false); - mst_points.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_points.common().member_type_id(*TypeObjectFactory::get_instance()->get_array_identifier("int32_t", {3}, false)); - - - MD5 points_hash("points"); - for(int i = 0; i < 4; ++i) - { - mst_points.detail().name_hash()[i] = points_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_points); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - SerializedPayload_t payload(static_cast( - MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("numeric_array", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("numeric_array", false); -} - -const TypeObject* GetCompletenumeric_arrayObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("numeric_array", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_points; - cst_points.common().member_id(memberId++); - cst_points.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_points.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_points.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_points.common().member_flags().IS_OPTIONAL(false); - cst_points.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_points.common().member_flags().IS_KEY(false); - cst_points.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_points.common().member_type_id(*TypeObjectFactory::get_instance()->get_array_identifier("int32_t", {3}, true)); - - - cst_points.detail().name("points"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_points); - - - // Header - type_object->complete().struct_type().header().detail().type_name("numeric_array"); - // TODO inheritance - - - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - SerializedPayload_t payload(static_cast( - CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("numeric_array", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("numeric_array", true); -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_arrayTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_arrayTypeObject.h deleted file mode 100644 index 30c2eef2..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_arrayTypeObject.h +++ /dev/null @@ -1,65 +0,0 @@ -// 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 numeric_arrayTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifndef _FAST_DDS_GENERATED_NUMERIC_ARRAY_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_NUMERIC_ARRAY_TYPE_OBJECT_H_ - - -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define eProsima_user_DllExport -#endif // if defined(_WIN32) - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(numeric_array_SOURCE) -#define numeric_array_DllAPI __declspec( dllexport ) -#else -#define numeric_array_DllAPI __declspec( dllimport ) -#endif // numeric_array_SOURCE -#else -#define numeric_array_DllAPI -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define numeric_array_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registernumeric_arrayTypes(); - -eProsima_user_DllExport const TypeIdentifier* Getnumeric_arrayIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* Getnumeric_arrayObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalnumeric_arrayObject(); -eProsima_user_DllExport const TypeObject* GetCompletenumeric_arrayObject(); - - -#endif // _FAST_DDS_GENERATED_NUMERIC_ARRAY_TYPE_OBJECT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_struct.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_struct.cxx deleted file mode 100644 index 8531c9f8..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_struct.cxx +++ /dev/null @@ -1,642 +0,0 @@ -// 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 union_struct.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "union_struct.h" -#include "union_structTypeObject.h" -#include - -#include -using namespace eprosima::fastcdr::exception; - -#include - -#define union_struct_max_cdr_typesize 268ULL; - -#define union_struct_max_key_cdr_typesize 0ULL; - - -MyUnion::MyUnion() -{ - m__d = 1; - // octet m_octet_value - m_octet_value = 0; - // long m_long_value - m_long_value = 0; - // string m_string_value - m_string_value =""; -} - -MyUnion::~MyUnion() -{ -} - -MyUnion::MyUnion( - const MyUnion& x) -{ - m__d = x.m__d; - - switch(m__d) - { - case 1: - m_octet_value = x.m_octet_value; - break; - case 2: - m_long_value = x.m_long_value; - break; - case 3: - m_string_value = x.m_string_value; - break; - default: - break; - } -} - -MyUnion::MyUnion( - MyUnion&& x) noexcept -{ - m__d = x.m__d; - - switch(m__d) - { - case 1: - m_octet_value = x.m_octet_value; - break; - case 2: - m_long_value = x.m_long_value; - break; - case 3: - m_string_value = std::move(x.m_string_value); - break; - default: - break; - } -} - -MyUnion& MyUnion::operator =( - const MyUnion& x) -{ - m__d = x.m__d; - - switch(m__d) - { - case 1: - m_octet_value = x.m_octet_value; - break; - case 2: - m_long_value = x.m_long_value; - break; - case 3: - m_string_value = x.m_string_value; - break; - default: - break; - } - - return *this; -} - -MyUnion& MyUnion::operator =( - MyUnion&& x) noexcept -{ - m__d = x.m__d; - - switch(m__d) - { - case 1: - m_octet_value = x.m_octet_value; - break; - case 2: - m_long_value = x.m_long_value; - break; - case 3: - m_string_value = std::move(x.m_string_value); - break; - default: - break; - } - - return *this; -} - -bool MyUnion::operator ==( - const MyUnion& x) const -{ - if (m__d != x.m__d) - { - return false; - } - - switch(m__d) - { - case 1: - return (m_octet_value == x.m_octet_value); - break; - case 2: - return (m_long_value == x.m_long_value); - break; - case 3: - return (m_string_value == x.m_string_value); - break; - default: - break; - } - return false; -} - -bool MyUnion::operator !=( - const MyUnion& x) const -{ - return !(*this == x); -} - -void MyUnion::_d( - int32_t __d) -{ - bool b = false; - - switch(m__d) - { - case 1: - switch(__d) - { - case 1: - b = true; - break; - default: - break; - } - break; - case 2: - switch(__d) - { - case 2: - b = true; - break; - default: - break; - } - break; - case 3: - switch(__d) - { - case 3: - b = true; - break; - default: - break; - } - break; - } - - if(!b) - { - throw BadParamException("Discriminator doesn't correspond with the selected union member"); - } - - m__d = __d; -} - -int32_t MyUnion::_d() const -{ - return m__d; -} - -int32_t& MyUnion::_d() -{ - return m__d; -} - -void MyUnion::octet_value( - uint8_t _octet_value) -{ - m_octet_value = _octet_value; - m__d = 1; -} - -uint8_t MyUnion::octet_value() const -{ - bool b = false; - - switch(m__d) - { - case 1: - b = true; - break; - default: - break; - } - if(!b) - { - throw BadParamException("This member is not been selected"); - } - - return m_octet_value; -} - -uint8_t& MyUnion::octet_value() -{ - bool b = false; - - switch(m__d) - { - case 1: - b = true; - break; - default: - break; - } - if(!b) - { - throw BadParamException("This member is not been selected"); - } - - return m_octet_value; -} -void MyUnion::long_value( - int32_t _long_value) -{ - m_long_value = _long_value; - m__d = 2; -} - -int32_t MyUnion::long_value() const -{ - bool b = false; - - switch(m__d) - { - case 2: - b = true; - break; - default: - break; - } - if(!b) - { - throw BadParamException("This member is not been selected"); - } - - return m_long_value; -} - -int32_t& MyUnion::long_value() -{ - bool b = false; - - switch(m__d) - { - case 2: - b = true; - break; - default: - break; - } - if(!b) - { - throw BadParamException("This member is not been selected"); - } - - return m_long_value; -} -void MyUnion::string_value( - const std::string& _string_value) -{ - m_string_value = _string_value; - m__d = 3; -} - -void MyUnion::string_value( - std::string&& _string_value) -{ - m_string_value = std::move(_string_value); - m__d = 3; -} - -const std::string& MyUnion::string_value() const -{ - bool b = false; - - switch(m__d) - { - case 3: - b = true; - break; - default: - break; - } - if(!b) - { - throw BadParamException("This member is not been selected"); - } - - return m_string_value; -} - -std::string& MyUnion::string_value() -{ - bool b = false; - - switch(m__d) - { - case 3: - b = true; - break; - default: - break; - } - if(!b) - { - throw BadParamException("This member is not been selected"); - } - - return m_string_value; -} - -// TODO(Ricardo) Review -size_t MyUnion::getCdrSerializedSize( - const MyUnion& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - switch(data.m__d) - { - case 1: - current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); - - break; - case 2: - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - break; - case 3: - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.string_value().size() + 1; - break; - default: - break; - } - - return current_alignment - initial_alignment; -} - -void MyUnion::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m__d; - - switch(m__d) - { - case 1: - scdr << m_octet_value; - - break; - case 2: - scdr << m_long_value; - - break; - case 3: - scdr << m_string_value.c_str(); - - break; - default: - break; - } -} - -void MyUnion::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m__d; - - switch(m__d) - { - case 1: - dcdr >> m_octet_value; - break; - case 2: - dcdr >> m_long_value; - break; - case 3: - dcdr >> m_string_value;break; - default: - break; - } -} - - -union_struct::union_struct() -{ - // unsigned long m_index - m_index = 0; - // MyUnion m_union_value - - - // Just to register all known types - registerunion_structTypes(); -} - -union_struct::~union_struct() -{ - - -} - -union_struct::union_struct( - const union_struct& x) -{ - m_index = x.m_index; - m_union_value = x.m_union_value; -} - -union_struct::union_struct( - union_struct&& x) noexcept -{ - m_index = x.m_index; - m_union_value = std::move(x.m_union_value); -} - -union_struct& union_struct::operator =( - const union_struct& x) -{ - - m_index = x.m_index; - m_union_value = x.m_union_value; - - return *this; -} - -union_struct& union_struct::operator =( - union_struct&& x) noexcept -{ - - m_index = x.m_index; - m_union_value = std::move(x.m_union_value); - - return *this; -} - -bool union_struct::operator ==( - const union_struct& x) const -{ - - return (m_index == x.m_index && m_union_value == x.m_union_value); -} - -bool union_struct::operator !=( - const union_struct& x) const -{ - return !(*this == x); -} - -size_t union_struct::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return union_struct_max_cdr_typesize; -} - -size_t union_struct::getCdrSerializedSize( - const union_struct& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - current_alignment += MyUnion::getCdrSerializedSize(data.union_value(), current_alignment); - - return current_alignment - initial_alignment; -} - -void union_struct::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - - scdr << m_index; - scdr << m_union_value; - -} - -void union_struct::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - - dcdr >> m_index; - dcdr >> m_union_value; -} - -/*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ -void union_struct::index( - uint32_t _index) -{ - m_index = _index; -} - -/*! - * @brief This function returns the value of member index - * @return Value of member index - */ -uint32_t union_struct::index() const -{ - return m_index; -} - -/*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ -uint32_t& union_struct::index() -{ - return m_index; -} - -/*! - * @brief This function copies the value in member union_value - * @param _union_value New value to be copied in member union_value - */ -void union_struct::union_value( - const MyUnion& _union_value) -{ - m_union_value = _union_value; -} - -/*! - * @brief This function moves the value in member union_value - * @param _union_value New value to be moved in member union_value - */ -void union_struct::union_value( - MyUnion&& _union_value) -{ - m_union_value = std::move(_union_value); -} - -/*! - * @brief This function returns a constant reference to member union_value - * @return Constant reference to member union_value - */ -const MyUnion& union_struct::union_value() const -{ - return m_union_value; -} - -/*! - * @brief This function returns a reference to member union_value - * @return Reference to member union_value - */ -MyUnion& union_struct::union_value() -{ - return m_union_value; -} - - -size_t union_struct::getKeyMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return union_struct_max_key_cdr_typesize; -} - -bool union_struct::isKeyDefined() -{ - return false; -} - -void union_struct::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_struct.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_struct.h deleted file mode 100644 index 26739ce2..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_struct.h +++ /dev/null @@ -1,421 +0,0 @@ -// 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 union_struct.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifndef _FAST_DDS_GENERATED_UNION_STRUCT_H_ -#define _FAST_DDS_GENERATED_UNION_STRUCT_H_ - - -#include - -#include -#include -#include -#include -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(UNION_STRUCT_SOURCE) -#define UNION_STRUCT_DllAPI __declspec( dllexport ) -#else -#define UNION_STRUCT_DllAPI __declspec( dllimport ) -#endif // UNION_STRUCT_SOURCE -#else -#define UNION_STRUCT_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define UNION_STRUCT_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - -/*! - * @brief This class represents the union MyUnion defined by the user in the IDL file. - * @ingroup union_struct - */ -class MyUnion -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport MyUnion(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~MyUnion(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object MyUnion that will be copied. - */ - eProsima_user_DllExport MyUnion( - const MyUnion& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object MyUnion that will be copied. - */ - eProsima_user_DllExport MyUnion( - MyUnion&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object MyUnion that will be copied. - */ - eProsima_user_DllExport MyUnion& operator =( - const MyUnion& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object MyUnion that will be copied. - */ - eProsima_user_DllExport MyUnion& operator =( - MyUnion&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x MyUnion object to compare. - */ - eProsima_user_DllExport bool operator ==( - const MyUnion& x) const; - - /*! - * @brief Comparison operator. - * @param x MyUnion object to compare. - */ - eProsima_user_DllExport bool operator !=( - const MyUnion& x) const; - - /*! - * @brief This function sets the discriminator value. - * @param __d New value for the discriminator. - * @exception eprosima::fastcdr::BadParamException This exception is thrown if the new value doesn't correspond to the selected union member. - */ - eProsima_user_DllExport void _d( - int32_t __d); - - /*! - * @brief This function returns the value of the discriminator. - * @return Value of the discriminator - */ - eProsima_user_DllExport int32_t _d() const; - - /*! - * @brief This function returns a reference to the discriminator. - * @return Reference to the discriminator. - */ - eProsima_user_DllExport int32_t& _d(); - - /*! - * @brief This function sets a value in member octet_value - * @param _octet_value New value for member octet_value - */ - eProsima_user_DllExport void octet_value( - uint8_t _octet_value); - - /*! - * @brief This function returns the value of member octet_value - * @return Value of member octet_value - * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection. - */ - eProsima_user_DllExport uint8_t octet_value() const; - - /*! - * @brief This function returns a reference to member octet_value - * @return Reference to member octet_value - * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection. - */ - eProsima_user_DllExport uint8_t& octet_value(); - - /*! - * @brief This function sets a value in member long_value - * @param _long_value New value for member long_value - */ - eProsima_user_DllExport void long_value( - int32_t _long_value); - - /*! - * @brief This function returns the value of member long_value - * @return Value of member long_value - * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection. - */ - eProsima_user_DllExport int32_t long_value() const; - - /*! - * @brief This function returns a reference to member long_value - * @return Reference to member long_value - * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection. - */ - eProsima_user_DllExport int32_t& long_value(); - - /*! - * @brief This function copies the value in member string_value - * @param _string_value New value to be copied in member string_value - */ - eProsima_user_DllExport void string_value( - const std::string& _string_value); - - /*! - * @brief This function moves the value in member string_value - * @param _string_value New value to be moved in member string_value - */ - eProsima_user_DllExport void string_value( - std::string&& _string_value); - - /*! - * @brief This function returns a constant reference to member string_value - * @return Constant reference to member string_value - * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection. - */ - eProsima_user_DllExport const std::string& string_value() const; - - /*! - * @brief This function returns a reference to member string_value - * @return Reference to member string_value - * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection. - */ - eProsima_user_DllExport std::string& string_value(); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const MyUnion& data, - size_t current_alignment = 0); - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - -private: - - int32_t m__d; - - uint8_t m_octet_value; - int32_t m_long_value; - std::string m_string_value; -}; -/*! - * @brief This class represents the structure union_struct defined by the user in the IDL file. - * @ingroup union_struct - */ -class union_struct -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport union_struct(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~union_struct(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object union_struct that will be copied. - */ - eProsima_user_DllExport union_struct( - const union_struct& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object union_struct that will be copied. - */ - eProsima_user_DllExport union_struct( - union_struct&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object union_struct that will be copied. - */ - eProsima_user_DllExport union_struct& operator =( - const union_struct& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object union_struct that will be copied. - */ - eProsima_user_DllExport union_struct& operator =( - union_struct&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x union_struct object to compare. - */ - eProsima_user_DllExport bool operator ==( - const union_struct& x) const; - - /*! - * @brief Comparison operator. - * @param x union_struct object to compare. - */ - eProsima_user_DllExport bool operator !=( - const union_struct& x) const; - - /*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ - eProsima_user_DllExport void index( - uint32_t _index); - - /*! - * @brief This function returns the value of member index - * @return Value of member index - */ - eProsima_user_DllExport uint32_t index() const; - - /*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ - eProsima_user_DllExport uint32_t& index(); - - /*! - * @brief This function copies the value in member union_value - * @param _union_value New value to be copied in member union_value - */ - eProsima_user_DllExport void union_value( - const MyUnion& _union_value); - - /*! - * @brief This function moves the value in member union_value - * @param _union_value New value to be moved in member union_value - */ - eProsima_user_DllExport void union_value( - MyUnion&& _union_value); - - /*! - * @brief This function returns a constant reference to member union_value - * @return Constant reference to member union_value - */ - eProsima_user_DllExport const MyUnion& union_value() const; - - /*! - * @brief This function returns a reference to member union_value - * @return Reference to member union_value - */ - eProsima_user_DllExport MyUnion& union_value(); - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const union_struct& data, - size_t current_alignment = 0); - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - /*! - * @brief This function returns the maximum serialized size of the Key of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - -private: - - uint32_t m_index; - MyUnion m_union_value; - -}; - -#endif // _FAST_DDS_GENERATED_UNION_STRUCT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structPubSubTypes.cxx deleted file mode 100644 index c1812023..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structPubSubTypes.cxx +++ /dev/null @@ -1,170 +0,0 @@ -// 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 union_structPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#include -#include - -#include "union_structPubSubTypes.h" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; - - -union_structPubSubType::union_structPubSubType() -{ - setName("union_struct"); - auto type_size = union_struct::getMaxCdrSerializedSize(); - type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ - m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ - m_isGetKeyDefined = union_struct::isKeyDefined(); - size_t keyLength = union_struct::getKeyMaxCdrSerializedSize() > 16 ? - union_struct::getKeyMaxCdrSerializedSize() : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -union_structPubSubType::~union_structPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool union_structPubSubType::serialize( - void* data, - SerializedPayload_t* payload) -{ - union_struct* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - p_type->serialize(ser); - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length - payload->length = static_cast(ser.getSerializedDataLength()); - return true; -} - -bool union_structPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - union_struct* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - p_type->deserialize(deser); - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function union_structPubSubType::getSerializedSizeProvider( - void* data) -{ - return [data]() -> uint32_t - { - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - }; -} - -void* union_structPubSubType::createData() -{ - return reinterpret_cast(new union_struct()); -} - -void union_structPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool union_structPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - union_struct* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - union_struct::getKeyMaxCdrSerializedSize()); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); - p_type->serializeKey(ser); - if (force_md5 || union_struct::getKeyMaxCdrSerializedSize() > 16) - { - m_md5.init(); - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structPubSubTypes.h deleted file mode 100644 index 4e92f498..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structPubSubTypes.h +++ /dev/null @@ -1,105 +0,0 @@ -// 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 union_structPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#ifndef _FAST_DDS_GENERATED_UNION_STRUCT_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_UNION_STRUCT_PUBSUBTYPES_H_ - -#include -#include - -#include "union_struct.h" - - -#if !defined(GEN_API_VER) || (GEN_API_VER != 1) -#error \ - Generated union_struct is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER - - - -/*! - * @brief This class represents the TopicDataType of the type union_struct defined by the user in the IDL file. - * @ingroup union_struct - */ -class union_structPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef union_struct type; - - eProsima_user_DllExport union_structPubSubType(); - - eProsima_user_DllExport virtual ~union_structPubSubType() override; - - eProsima_user_DllExport virtual bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; - - eProsima_user_DllExport virtual bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport virtual std::function getSerializedSizeProvider( - void* data) override; - - eProsima_user_DllExport virtual bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport virtual void* createData() override; - - eProsima_user_DllExport virtual void deleteData( - void* data) override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - (void)memory; - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - -#endif // _FAST_DDS_GENERATED_UNION_STRUCT_PUBSUBTYPES_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structTypeObject.cxx deleted file mode 100644 index 8796c646..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structTypeObject.cxx +++ /dev/null @@ -1,512 +0,0 @@ -// 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 union_structTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { char dummy; } -#endif - -#include "union_struct.h" -#include "union_structTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerunion_structTypes() -{ - static std::once_flag once_flag; - std::call_once(once_flag, []() - { - TypeObjectFactory *factory = TypeObjectFactory::get_instance(); - factory->add_type_object("MyUnion", GetMyUnionIdentifier(true), - GetMyUnionObject(true)); - factory->add_type_object("MyUnion", GetMyUnionIdentifier(false), - GetMyUnionObject(false)); - - factory->add_type_object("union_struct", Getunion_structIdentifier(true), - Getunion_structObject(true)); - factory->add_type_object("union_struct", Getunion_structIdentifier(false), - Getunion_structObject(false)); - - }); -} - -const TypeIdentifier* GetMyUnionIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("MyUnion", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetMyUnionObject(complete); - return TypeObjectFactory::get_instance()->get_type_identifier("MyUnion", complete); -} - -const TypeObject* GetMyUnionObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MyUnion", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteMyUnionObject(); - } - // else - return GetMinimalMyUnionObject(); -} - -const TypeObject* GetMinimalMyUnionObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MyUnion", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_UNION); - - type_object->minimal().union_type().union_flags().IS_FINAL(false); - type_object->minimal().union_type().union_flags().IS_APPENDABLE(false); - type_object->minimal().union_type().union_flags().IS_MUTABLE(false); - type_object->minimal().union_type().union_flags().IS_NESTED(false); - type_object->minimal().union_type().union_flags().IS_AUTOID_HASH(false); // Unsupported - - type_object->minimal().union_type().discriminator().common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - type_object->minimal().union_type().discriminator().common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - type_object->minimal().union_type().discriminator().common().member_flags().IS_EXTERNAL(false); // Doesn't apply - type_object->minimal().union_type().discriminator().common().member_flags().IS_OPTIONAL(false); // Doesn't apply - type_object->minimal().union_type().discriminator().common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - type_object->minimal().union_type().discriminator().common().member_flags().IS_KEY(false); // Unsupported - type_object->minimal().union_type().discriminator().common().member_flags().IS_DEFAULT(false); // Doesn't apply - - type_object->minimal().union_type().discriminator().common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - - MemberId memberId = 0; - MinimalUnionMember mst_octet_value; - mst_octet_value.common().member_id(memberId++); - mst_octet_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_octet_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_octet_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_octet_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply - mst_octet_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - mst_octet_value.common().member_flags().IS_KEY(false); // Doesn't apply - mst_octet_value.common().member_flags().IS_DEFAULT(false); - mst_octet_value.common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint8_t", false)); - - mst_octet_value.common().label_seq().emplace_back(1); - MD5 octet_value_hash("octet_value"); - for(int i = 0; i < 4; ++i) - { - mst_octet_value.detail().name_hash()[i] = octet_value_hash.digest[i]; - } - type_object->minimal().union_type().member_seq().emplace_back(mst_octet_value); - - MinimalUnionMember mst_long_value; - mst_long_value.common().member_id(memberId++); - mst_long_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_long_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_long_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_long_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply - mst_long_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - mst_long_value.common().member_flags().IS_KEY(false); // Doesn't apply - mst_long_value.common().member_flags().IS_DEFAULT(false); - mst_long_value.common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - - mst_long_value.common().label_seq().emplace_back(2); - MD5 long_value_hash("long_value"); - for(int i = 0; i < 4; ++i) - { - mst_long_value.detail().name_hash()[i] = long_value_hash.digest[i]; - } - type_object->minimal().union_type().member_seq().emplace_back(mst_long_value); - - MinimalUnionMember mst_string_value; - mst_string_value.common().member_id(memberId++); - mst_string_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_string_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_string_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_string_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply - mst_string_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - mst_string_value.common().member_flags().IS_KEY(false); // Doesn't apply - mst_string_value.common().member_flags().IS_DEFAULT(false); - mst_string_value.common().type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - - mst_string_value.common().label_seq().emplace_back(3); - MD5 string_value_hash("string_value"); - for(int i = 0; i < 4; ++i) - { - mst_string_value.detail().name_hash()[i] = string_value_hash.digest[i]; - } - type_object->minimal().union_type().member_seq().emplace_back(mst_string_value); - - - // Header - //type_object->minimal().union_type().header().detail()... // Empty - - TypeIdentifier* identifier = new TypeIdentifier(); - identifier->_d(EK_MINIMAL); - - SerializedPayload_t payload(static_cast( - MinimalUnionType::getCdrSerializedSize(type_object->minimal().union_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier->equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("MyUnion", identifier, type_object); - delete type_object; - delete identifier; - return TypeObjectFactory::get_instance()->get_type_object("MyUnion", false); -} - -const TypeObject* GetCompleteMyUnionObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MyUnion", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_UNION); - - type_object->complete().union_type().union_flags().IS_FINAL(false); - type_object->complete().union_type().union_flags().IS_APPENDABLE(false); - type_object->complete().union_type().union_flags().IS_MUTABLE(false); - type_object->complete().union_type().union_flags().IS_NESTED(false); - type_object->complete().union_type().union_flags().IS_AUTOID_HASH(false); // Unsupported - - type_object->complete().union_type().discriminator().common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - type_object->complete().union_type().discriminator().common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - type_object->complete().union_type().discriminator().common().member_flags().IS_EXTERNAL(false); // Doesn't apply - type_object->complete().union_type().discriminator().common().member_flags().IS_OPTIONAL(false); // Doesn't apply - type_object->complete().union_type().discriminator().common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - type_object->complete().union_type().discriminator().common().member_flags().IS_KEY(false); // Unsupported - type_object->complete().union_type().discriminator().common().member_flags().IS_DEFAULT(false); // Doesn't apply - - type_object->complete().union_type().discriminator().common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - - - MemberId memberId = 0; - CompleteUnionMember cst_octet_value; - cst_octet_value.common().member_id(memberId++); - cst_octet_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_octet_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_octet_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_octet_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply - cst_octet_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - cst_octet_value.common().member_flags().IS_KEY(false); // Doesn't apply - cst_octet_value.common().member_flags().IS_DEFAULT(false); - cst_octet_value.common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint8_t", false)); - cst_octet_value.common().label_seq().emplace_back(1); - - cst_octet_value.detail().name("octet_value"); - - type_object->complete().union_type().member_seq().emplace_back(cst_octet_value); - - CompleteUnionMember cst_long_value; - cst_long_value.common().member_id(memberId++); - cst_long_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_long_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_long_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_long_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply - cst_long_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - cst_long_value.common().member_flags().IS_KEY(false); // Doesn't apply - cst_long_value.common().member_flags().IS_DEFAULT(false); - cst_long_value.common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - cst_long_value.common().label_seq().emplace_back(2); - - cst_long_value.detail().name("long_value"); - - type_object->complete().union_type().member_seq().emplace_back(cst_long_value); - - CompleteUnionMember cst_string_value; - cst_string_value.common().member_id(memberId++); - cst_string_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_string_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_string_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_string_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply - cst_string_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - cst_string_value.common().member_flags().IS_KEY(false); // Doesn't apply - cst_string_value.common().member_flags().IS_DEFAULT(false); - cst_string_value.common().type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - cst_string_value.common().label_seq().emplace_back(3); - - cst_string_value.detail().name("string_value"); - - type_object->complete().union_type().member_seq().emplace_back(cst_string_value); - - - // Header - type_object->complete().union_type().header().detail().type_name("MyUnion"); - - - TypeIdentifier* identifier = new TypeIdentifier(); - identifier->_d(EK_COMPLETE); - - SerializedPayload_t payload(static_cast( - CompleteUnionType::getCdrSerializedSize(type_object->complete().union_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier->equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("MyUnion", identifier, type_object); - delete type_object; - delete identifier; - return TypeObjectFactory::get_instance()->get_type_object("MyUnion", true); -} - -const TypeIdentifier* Getunion_structIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("union_struct", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - Getunion_structObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("union_struct", complete); -} - -const TypeObject* Getunion_structObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("union_struct", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteunion_structObject(); - } - //else - return GetMinimalunion_structObject(); -} - -const TypeObject* GetMinimalunion_structObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("union_struct", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_index; - mst_index.common().member_id(memberId++); - mst_index.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_index.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_index.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_index.common().member_flags().IS_OPTIONAL(false); - mst_index.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_index.common().member_flags().IS_KEY(false); - mst_index.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_index.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); - - MD5 index_hash("index"); - for(int i = 0; i < 4; ++i) - { - mst_index.detail().name_hash()[i] = index_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_index); - - MinimalStructMember mst_union_value; - mst_union_value.common().member_id(memberId++); - mst_union_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_union_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_union_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_union_value.common().member_flags().IS_OPTIONAL(false); - mst_union_value.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_union_value.common().member_flags().IS_KEY(false); - mst_union_value.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_union_value.common().member_type_id(*GetMyUnionIdentifier(false)); - MD5 union_value_hash("union_value"); - for(int i = 0; i < 4; ++i) - { - mst_union_value.detail().name_hash()[i] = union_value_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_union_value); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - SerializedPayload_t payload(static_cast( - MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("union_struct", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("union_struct", false); -} - -const TypeObject* GetCompleteunion_structObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("union_struct", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_index; - cst_index.common().member_id(memberId++); - cst_index.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_index.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_index.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_index.common().member_flags().IS_OPTIONAL(false); - cst_index.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_index.common().member_flags().IS_KEY(false); - cst_index.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_index.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); - - cst_index.detail().name("index"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_index); - - CompleteStructMember cst_union_value; - cst_union_value.common().member_id(memberId++); - cst_union_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_union_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_union_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_union_value.common().member_flags().IS_OPTIONAL(false); - cst_union_value.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_union_value.common().member_flags().IS_KEY(false); - cst_union_value.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_union_value.common().member_type_id(*GetMyUnionIdentifier(true)); - cst_union_value.detail().name("union_value"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_union_value); - - - // Header - type_object->complete().struct_type().header().detail().type_name("union_struct"); - // TODO inheritance - - - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - SerializedPayload_t payload(static_cast( - CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("union_struct", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("union_struct", true); -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structTypeObject.h deleted file mode 100644 index f341bb35..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structTypeObject.h +++ /dev/null @@ -1,68 +0,0 @@ -// 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 union_structTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifndef _FAST_DDS_GENERATED_UNION_STRUCT_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_UNION_STRUCT_TYPE_OBJECT_H_ - - -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif -#else -#define eProsima_user_DllExport -#endif - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(union_struct_SOURCE) -#define union_struct_DllAPI __declspec( dllexport ) -#else -#define union_struct_DllAPI __declspec( dllimport ) -#endif // union_struct_SOURCE -#else -#define union_struct_DllAPI -#endif -#else -#define union_struct_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registerunion_structTypes(); - -eProsima_user_DllExport const TypeIdentifier* GetMyUnionIdentifier(bool complete = false); -eProsima_user_DllExport const TypeObject* GetMyUnionObject(bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalMyUnionObject(); -eProsima_user_DllExport const TypeObject* GetCompleteMyUnionObject(); - -eProsima_user_DllExport const TypeIdentifier* Getunion_structIdentifier(bool complete = false); -eProsima_user_DllExport const TypeObject* Getunion_structObject(bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalunion_structObject(); -eProsima_user_DllExport const TypeObject* GetCompleteunion_structObject(); - - -#endif // _FAST_DDS_GENERATED_UNION_STRUCT_TYPE_OBJECT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/all_types.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/all_types.hpp deleted file mode 100644 index 65fa0566..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/all_types.hpp +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright 2022 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_types.hpp - */ - -/* - * USEFUL COMMAND - * - * for TYPE in hello_world numeric_array char_sequence basic_struct basic_array_struct float_bounded_sequence arrays_and_sequences complex_nested_arrays; do ${FASTDDSGEN_WS}/scripts/fastddsgen -replace -d ${WS}/src/recorder/ddsrecorder/test/unittest/dynamic_types/types/type_objects/ -typeobject -cs ${WS}/src/recorder/ddsrecorder/test/unittest/dynamic_types/types/idls/${TYPE}.idl; done - */ - -#pragma once - -#include -#include -#include - -#include -#include -#include - -#include "type_objects/hello_worldTypeObject.h" -#include "type_objects/numeric_arrayTypeObject.h" -#include "type_objects/char_sequenceTypeObject.h" -#include "type_objects/basic_structTypeObject.h" -#include "type_objects/basic_array_structTypeObject.h" -#include "type_objects/float_bounded_sequenceTypeObject.h" -#include "type_objects/arrays_and_sequencesTypeObject.h" -#include "type_objects/complex_nested_arraysTypeObject.h" -#include "type_objects/enum_structTypeObject.h" -#include "type_objects/union_structTypeObject.h" -#include "type_objects/map_structTypeObject.h" - -namespace test { - -ENUMERATION_BUILDER( - SupportedType, - hello_world, - numeric_array, - char_sequence, - basic_struct, - basic_array_struct, - float_bounded_sequence, - arrays_and_sequences, - complex_nested_arrays, - enum_struct, - union_struct, // NOTE: default case currently not supported in dynamic types - map_struct - ); - -eprosima::fastrtps::types::DynamicType_ptr get_dynamic_type( - SupportedType type) -{ - registerhello_worldTypes(); - registernumeric_arrayTypes(); - registerchar_sequenceTypes(); - registerbasic_structTypes(); - registerbasic_array_structTypes(); - registerfloat_bounded_sequenceTypes(); - registerarrays_and_sequencesTypes(); - registercomplex_nested_arraysTypes(); - registerenum_structTypes(); - registerunion_structTypes(); - registermap_structTypes(); - - auto type_name = to_string(type); - - auto type_obj_factory = eprosima::fastrtps::types::TypeObjectFactory::get_instance(); - auto type_id = type_obj_factory->get_type_identifier(type_name, true); - if (type_id == nullptr) - { - throw eprosima::utils::InconsistencyException("Not Type Id"); - } - - auto type_obj = type_obj_factory->get_type_object(type_id); - if (type_obj == nullptr) - { - throw eprosima::utils::InconsistencyException("Not Type Object"); - } - - return type_obj_factory->build_dynamic_type(type_name, type_id, type_obj); -} - -} /* namespace test */ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/arrays_and_sequences.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/arrays_and_sequences.idl deleted file mode 100644 index 5d9f9819..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/arrays_and_sequences.idl +++ /dev/null @@ -1,12 +0,0 @@ -struct AnInternalObject -{ - float x; - boolean positive; -}; - -struct arrays_and_sequences -{ - sequence unlimited_vector; - sequence limited_vector; - AnInternalObject limited_array[10]; -}; diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/basic_array_struct.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/basic_array_struct.idl deleted file mode 100644 index b81e5956..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/basic_array_struct.idl +++ /dev/null @@ -1,11 +0,0 @@ -struct TheOtherObjectInArray -{ - long some_num; - boolean positive; -}; - -struct basic_array_struct -{ - unsigned long index; - TheOtherObjectInArray sub_structs[5]; -}; diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/basic_struct.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/basic_struct.idl deleted file mode 100644 index da2ea1bb..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/basic_struct.idl +++ /dev/null @@ -1,9 +0,0 @@ -struct TheOtherObject -{ - long some_num; -}; - -struct basic_struct -{ - TheOtherObject sub_struct; -}; diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/char_sequence.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/char_sequence.idl deleted file mode 100644 index 0abf7dd8..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/char_sequence.idl +++ /dev/null @@ -1,4 +0,0 @@ -struct char_sequence -{ - sequence chars; -}; diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/complex_nested_arrays.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/complex_nested_arrays.idl deleted file mode 100644 index b4eca21b..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/complex_nested_arrays.idl +++ /dev/null @@ -1,23 +0,0 @@ -struct ThirdLevelElement -{ - double x; - double y; -}; - -struct SecondLevelElement -{ - ThirdLevelElement an_element_alone; - sequence a_limited_other_value; -}; - -struct FirstLevelElement -{ - string useless_name; - sequence sub; - ThirdLevelElement an_element_alone; -}; - -struct complex_nested_arrays -{ - FirstLevelElement array_of_elements[3]; -}; diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/enum_struct.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/enum_struct.idl deleted file mode 100644 index c40eae6e..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/enum_struct.idl +++ /dev/null @@ -1,12 +0,0 @@ -enum ColorEnum -{ - RED, - GREEN, - BLUE -}; - -struct enum_struct -{ - unsigned long index; - ColorEnum enum_value; -}; diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/float_bounded_sequence.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/float_bounded_sequence.idl deleted file mode 100644 index b297df86..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/float_bounded_sequence.idl +++ /dev/null @@ -1,4 +0,0 @@ -struct float_bounded_sequence -{ - sequence numbers; -}; diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/hello_world.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/hello_world.idl deleted file mode 100644 index d82036d8..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/hello_world.idl +++ /dev/null @@ -1,5 +0,0 @@ -struct hello_world -{ - unsigned long index; - string message; -}; diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/map_struct.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/map_struct.idl deleted file mode 100644 index d4d19acb..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/map_struct.idl +++ /dev/null @@ -1,4 +0,0 @@ -struct map_struct -{ - map my_map; -}; diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/numeric_array.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/numeric_array.idl deleted file mode 100644 index 814abd59..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/numeric_array.idl +++ /dev/null @@ -1,4 +0,0 @@ -struct numeric_array -{ - long points[3]; -}; diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/union_struct.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/union_struct.idl deleted file mode 100644 index 3967f961..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/union_struct.idl +++ /dev/null @@ -1,15 +0,0 @@ -union MyUnion switch (long) -{ - case 1: - octet octet_value; - case 2: - long long_value; - case 3: - string string_value; -}; - -struct union_struct -{ - unsigned long index; - MyUnion union_value; -}; diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/arrays_and_sequences.msg b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/arrays_and_sequences.msg deleted file mode 100644 index 1942bc58..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/arrays_and_sequences.msg +++ /dev/null @@ -1,7 +0,0 @@ -AnInternalObject[] unlimited_vector -AnInternalObject[<=10] limited_vector -AnInternalObject[10] limited_array -================================================================================ -MSG: fastdds/AnInternalObject -float32 x -bool positive diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/basic_array_struct.msg b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/basic_array_struct.msg deleted file mode 100644 index a012398a..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/basic_array_struct.msg +++ /dev/null @@ -1,6 +0,0 @@ -uint32 index -TheOtherObjectInArray[5] sub_structs -================================================================================ -MSG: fastdds/TheOtherObjectInArray -int32 some_num -bool positive diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/basic_struct.msg b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/basic_struct.msg deleted file mode 100644 index eb9814cb..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/basic_struct.msg +++ /dev/null @@ -1,4 +0,0 @@ -TheOtherObject sub_struct -================================================================================ -MSG: fastdds/TheOtherObject -int32 some_num diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/char_sequence.msg b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/char_sequence.msg deleted file mode 100644 index bf4b2456..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/char_sequence.msg +++ /dev/null @@ -1 +0,0 @@ -int8[] chars diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/complex_nested_arrays.msg b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/complex_nested_arrays.msg deleted file mode 100644 index 5eebc2f4..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/complex_nested_arrays.msg +++ /dev/null @@ -1,14 +0,0 @@ -FirstLevelElement[3] array_of_elements -================================================================================ -MSG: fastdds/ThirdLevelElement -float64 x -float64 y -================================================================================ -MSG: fastdds/SecondLevelElement -ThirdLevelElement an_element_alone -ThirdLevelElement[<=1] a_limited_other_value -================================================================================ -MSG: fastdds/FirstLevelElement -string useless_name -SecondLevelElement[] sub -ThirdLevelElement an_element_alone diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/float_bounded_sequence.msg b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/float_bounded_sequence.msg deleted file mode 100644 index 77503c2e..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/float_bounded_sequence.msg +++ /dev/null @@ -1 +0,0 @@ -float32[<=13] numbers diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/hello_world.msg b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/hello_world.msg deleted file mode 100644 index 63e3fbcb..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/hello_world.msg +++ /dev/null @@ -1,2 +0,0 @@ -uint32 index -string message diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/numeric_array.msg b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/numeric_array.msg deleted file mode 100644 index d391c85d..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/numeric_array.msg +++ /dev/null @@ -1 +0,0 @@ -int32[3] points diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequences.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequences.cxx deleted file mode 100644 index 096ae93e..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequences.cxx +++ /dev/null @@ -1,341 +0,0 @@ -// 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 arrays_and_sequences.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "arrays_and_sequences.h" - -#if FASTCDR_VERSION_MAJOR > 1 - -#include "arrays_and_sequencesTypeObject.h" - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - - - - -AnInternalObject::AnInternalObject() -{ - // Just to register all known types - registerarrays_and_sequencesTypes(); -} - -AnInternalObject::~AnInternalObject() -{ -} - -AnInternalObject::AnInternalObject( - const AnInternalObject& x) -{ - m_x = x.m_x; - m_positive = x.m_positive; -} - -AnInternalObject::AnInternalObject( - AnInternalObject&& x) noexcept -{ - m_x = x.m_x; - m_positive = x.m_positive; -} - -AnInternalObject& AnInternalObject::operator =( - const AnInternalObject& x) -{ - - m_x = x.m_x; - m_positive = x.m_positive; - return *this; -} - -AnInternalObject& AnInternalObject::operator =( - AnInternalObject&& x) noexcept -{ - - m_x = x.m_x; - m_positive = x.m_positive; - return *this; -} - -bool AnInternalObject::operator ==( - const AnInternalObject& x) const -{ - return (m_x == x.m_x && - m_positive == x.m_positive); -} - -bool AnInternalObject::operator !=( - const AnInternalObject& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function sets a value in member x - * @param _x New value for member x - */ -void AnInternalObject::x( - float _x) -{ - m_x = _x; -} - -/*! - * @brief This function returns the value of member x - * @return Value of member x - */ -float AnInternalObject::x() const -{ - return m_x; -} - -/*! - * @brief This function returns a reference to member x - * @return Reference to member x - */ -float& AnInternalObject::x() -{ - return m_x; -} - - -/*! - * @brief This function sets a value in member positive - * @param _positive New value for member positive - */ -void AnInternalObject::positive( - bool _positive) -{ - m_positive = _positive; -} - -/*! - * @brief This function returns the value of member positive - * @return Value of member positive - */ -bool AnInternalObject::positive() const -{ - return m_positive; -} - -/*! - * @brief This function returns a reference to member positive - * @return Reference to member positive - */ -bool& AnInternalObject::positive() -{ - return m_positive; -} - - - - -arrays_and_sequences::arrays_and_sequences() -{ - // Just to register all known types - registerarrays_and_sequencesTypes(); -} - -arrays_and_sequences::~arrays_and_sequences() -{ -} - -arrays_and_sequences::arrays_and_sequences( - const arrays_and_sequences& x) -{ - m_unlimited_vector = x.m_unlimited_vector; - m_limited_vector = x.m_limited_vector; - m_limited_array = x.m_limited_array; -} - -arrays_and_sequences::arrays_and_sequences( - arrays_and_sequences&& x) noexcept -{ - m_unlimited_vector = std::move(x.m_unlimited_vector); - m_limited_vector = std::move(x.m_limited_vector); - m_limited_array = std::move(x.m_limited_array); -} - -arrays_and_sequences& arrays_and_sequences::operator =( - const arrays_and_sequences& x) -{ - - m_unlimited_vector = x.m_unlimited_vector; - m_limited_vector = x.m_limited_vector; - m_limited_array = x.m_limited_array; - return *this; -} - -arrays_and_sequences& arrays_and_sequences::operator =( - arrays_and_sequences&& x) noexcept -{ - - m_unlimited_vector = std::move(x.m_unlimited_vector); - m_limited_vector = std::move(x.m_limited_vector); - m_limited_array = std::move(x.m_limited_array); - return *this; -} - -bool arrays_and_sequences::operator ==( - const arrays_and_sequences& x) const -{ - return (m_unlimited_vector == x.m_unlimited_vector && - m_limited_vector == x.m_limited_vector && - m_limited_array == x.m_limited_array); -} - -bool arrays_and_sequences::operator !=( - const arrays_and_sequences& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function copies the value in member unlimited_vector - * @param _unlimited_vector New value to be copied in member unlimited_vector - */ -void arrays_and_sequences::unlimited_vector( - const std::vector& _unlimited_vector) -{ - m_unlimited_vector = _unlimited_vector; -} - -/*! - * @brief This function moves the value in member unlimited_vector - * @param _unlimited_vector New value to be moved in member unlimited_vector - */ -void arrays_and_sequences::unlimited_vector( - std::vector&& _unlimited_vector) -{ - m_unlimited_vector = std::move(_unlimited_vector); -} - -/*! - * @brief This function returns a constant reference to member unlimited_vector - * @return Constant reference to member unlimited_vector - */ -const std::vector& arrays_and_sequences::unlimited_vector() const -{ - return m_unlimited_vector; -} - -/*! - * @brief This function returns a reference to member unlimited_vector - * @return Reference to member unlimited_vector - */ -std::vector& arrays_and_sequences::unlimited_vector() -{ - return m_unlimited_vector; -} - - -/*! - * @brief This function copies the value in member limited_vector - * @param _limited_vector New value to be copied in member limited_vector - */ -void arrays_and_sequences::limited_vector( - const std::vector& _limited_vector) -{ - m_limited_vector = _limited_vector; -} - -/*! - * @brief This function moves the value in member limited_vector - * @param _limited_vector New value to be moved in member limited_vector - */ -void arrays_and_sequences::limited_vector( - std::vector&& _limited_vector) -{ - m_limited_vector = std::move(_limited_vector); -} - -/*! - * @brief This function returns a constant reference to member limited_vector - * @return Constant reference to member limited_vector - */ -const std::vector& arrays_and_sequences::limited_vector() const -{ - return m_limited_vector; -} - -/*! - * @brief This function returns a reference to member limited_vector - * @return Reference to member limited_vector - */ -std::vector& arrays_and_sequences::limited_vector() -{ - return m_limited_vector; -} - - -/*! - * @brief This function copies the value in member limited_array - * @param _limited_array New value to be copied in member limited_array - */ -void arrays_and_sequences::limited_array( - const std::array& _limited_array) -{ - m_limited_array = _limited_array; -} - -/*! - * @brief This function moves the value in member limited_array - * @param _limited_array New value to be moved in member limited_array - */ -void arrays_and_sequences::limited_array( - std::array&& _limited_array) -{ - m_limited_array = std::move(_limited_array); -} - -/*! - * @brief This function returns a constant reference to member limited_array - * @return Constant reference to member limited_array - */ -const std::array& arrays_and_sequences::limited_array() const -{ - return m_limited_array; -} - -/*! - * @brief This function returns a reference to member limited_array - * @return Reference to member limited_array - */ -std::array& arrays_and_sequences::limited_array() -{ - return m_limited_array; -} - - -// Include auxiliary functions like for serializing/deserializing. -#include "arrays_and_sequencesCdrAux.ipp" - -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesPubSubTypes.cxx deleted file mode 100644 index c79cb323..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesPubSubTypes.cxx +++ /dev/null @@ -1,411 +0,0 @@ -// 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 arrays_and_sequencesPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#include - -#include "arrays_and_sequencesPubSubTypes.h" -#include "arrays_and_sequencesCdrAux.hpp" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; -using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - - - -AnInternalObjectPubSubType::AnInternalObjectPubSubType() -{ - setName("AnInternalObject"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AnInternalObject::getMaxCdrSerializedSize()); -#else - AnInternalObject_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AnInternalObject_max_key_cdr_typesize > 16 ? AnInternalObject_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -AnInternalObjectPubSubType::~AnInternalObjectPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool AnInternalObjectPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - AnInternalObject* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool AnInternalObjectPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - AnInternalObject* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function AnInternalObjectPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AnInternalObjectPubSubType::createData() -{ - return reinterpret_cast(new AnInternalObject()); -} - -void AnInternalObjectPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool AnInternalObjectPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - AnInternalObject* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - AnInternalObject_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || AnInternalObject_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - - - -arrays_and_sequencesPubSubType::arrays_and_sequencesPubSubType() -{ - setName("arrays_and_sequences"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(arrays_and_sequences::getMaxCdrSerializedSize()); -#else - arrays_and_sequences_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = arrays_and_sequences_max_key_cdr_typesize > 16 ? arrays_and_sequences_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -arrays_and_sequencesPubSubType::~arrays_and_sequencesPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool arrays_and_sequencesPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - arrays_and_sequences* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool arrays_and_sequencesPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - arrays_and_sequences* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function arrays_and_sequencesPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* arrays_and_sequencesPubSubType::createData() -{ - return reinterpret_cast(new arrays_and_sequences()); -} - -void arrays_and_sequencesPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool arrays_and_sequencesPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - arrays_and_sequences* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - arrays_and_sequences_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || arrays_and_sequences_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesTypeObject.cxx deleted file mode 100644 index 4022a550..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesTypeObject.cxx +++ /dev/null @@ -1,512 +0,0 @@ -// 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 arrays_and_sequencesTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { char dummy; } -#endif - -#include "arrays_and_sequences.h" -#include "arrays_and_sequencesTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerarrays_and_sequencesTypes() -{ - static std::once_flag once_flag; - std::call_once(once_flag, []() - { - TypeObjectFactory *factory = TypeObjectFactory::get_instance(); - factory->add_type_object("AnInternalObject", GetAnInternalObjectIdentifier(true), - GetAnInternalObjectObject(true)); - factory->add_type_object("AnInternalObject", GetAnInternalObjectIdentifier(false), - GetAnInternalObjectObject(false)); - - - factory->add_type_object("arrays_and_sequences", Getarrays_and_sequencesIdentifier(true), - Getarrays_and_sequencesObject(true)); - factory->add_type_object("arrays_and_sequences", Getarrays_and_sequencesIdentifier(false), - Getarrays_and_sequencesObject(false)); - - }); -} - - - -const TypeIdentifier* GetAnInternalObjectIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("AnInternalObject", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetAnInternalObjectObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("AnInternalObject", complete); -} - -const TypeObject* GetAnInternalObjectObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("AnInternalObject", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteAnInternalObjectObject(); - } - //else - return GetMinimalAnInternalObjectObject(); -} - -const TypeObject* GetMinimalAnInternalObjectObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("AnInternalObject", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_x; - mst_x.common().member_id(memberId++); - mst_x.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_x.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_x.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_x.common().member_flags().IS_OPTIONAL(false); - mst_x.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_x.common().member_flags().IS_KEY(false); - mst_x.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_x.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("float", false)); - - - MD5 x_hash("x"); - for(int i = 0; i < 4; ++i) - { - mst_x.detail().name_hash()[i] = x_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_x); - - MinimalStructMember mst_positive; - mst_positive.common().member_id(memberId++); - mst_positive.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_positive.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_positive.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_positive.common().member_flags().IS_OPTIONAL(false); - mst_positive.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_positive.common().member_flags().IS_KEY(false); - mst_positive.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_positive.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - - MD5 positive_hash("positive"); - for(int i = 0; i < 4; ++i) - { - mst_positive.detail().name_hash()[i] = positive_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_positive); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("AnInternalObject", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("AnInternalObject", false); -} - -const TypeObject* GetCompleteAnInternalObjectObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("AnInternalObject", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_x; - cst_x.common().member_id(memberId++); - cst_x.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_x.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_x.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_x.common().member_flags().IS_OPTIONAL(false); - cst_x.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_x.common().member_flags().IS_KEY(false); - cst_x.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_x.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("float", false)); - - - cst_x.detail().name("x"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_x); - - CompleteStructMember cst_positive; - cst_positive.common().member_id(memberId++); - cst_positive.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_positive.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_positive.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_positive.common().member_flags().IS_OPTIONAL(false); - cst_positive.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_positive.common().member_flags().IS_KEY(false); - cst_positive.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_positive.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - - cst_positive.detail().name("positive"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_positive); - - - // Header - type_object->complete().struct_type().header().detail().type_name("AnInternalObject"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("AnInternalObject", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("AnInternalObject", true); -} - - - -const TypeIdentifier* Getarrays_and_sequencesIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("arrays_and_sequences", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - Getarrays_and_sequencesObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("arrays_and_sequences", complete); -} - -const TypeObject* Getarrays_and_sequencesObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("arrays_and_sequences", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompletearrays_and_sequencesObject(); - } - //else - return GetMinimalarrays_and_sequencesObject(); -} - -const TypeObject* GetMinimalarrays_and_sequencesObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("arrays_and_sequences", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_unlimited_vector; - mst_unlimited_vector.common().member_id(memberId++); - mst_unlimited_vector.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_unlimited_vector.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_unlimited_vector.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_unlimited_vector.common().member_flags().IS_OPTIONAL(false); - mst_unlimited_vector.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_unlimited_vector.common().member_flags().IS_KEY(false); - mst_unlimited_vector.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_unlimited_vector.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("AnInternalObject", 0, false)); - - MD5 unlimited_vector_hash("unlimited_vector"); - for(int i = 0; i < 4; ++i) - { - mst_unlimited_vector.detail().name_hash()[i] = unlimited_vector_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_unlimited_vector); - - MinimalStructMember mst_limited_vector; - mst_limited_vector.common().member_id(memberId++); - mst_limited_vector.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_limited_vector.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_limited_vector.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_limited_vector.common().member_flags().IS_OPTIONAL(false); - mst_limited_vector.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_limited_vector.common().member_flags().IS_KEY(false); - mst_limited_vector.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_limited_vector.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("AnInternalObject", 10, false)); - - MD5 limited_vector_hash("limited_vector"); - for(int i = 0; i < 4; ++i) - { - mst_limited_vector.detail().name_hash()[i] = limited_vector_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_limited_vector); - - MinimalStructMember mst_limited_array; - mst_limited_array.common().member_id(memberId++); - mst_limited_array.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_limited_array.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_limited_array.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_limited_array.common().member_flags().IS_OPTIONAL(false); - mst_limited_array.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_limited_array.common().member_flags().IS_KEY(false); - mst_limited_array.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_limited_array.common().member_type_id(*TypeObjectFactory::get_instance()->get_array_identifier("AnInternalObject", {10}, false)); - - MD5 limited_array_hash("limited_array"); - for(int i = 0; i < 4; ++i) - { - mst_limited_array.detail().name_hash()[i] = limited_array_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_limited_array); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("arrays_and_sequences", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("arrays_and_sequences", false); -} - -const TypeObject* GetCompletearrays_and_sequencesObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("arrays_and_sequences", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_unlimited_vector; - cst_unlimited_vector.common().member_id(memberId++); - cst_unlimited_vector.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_unlimited_vector.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_unlimited_vector.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_unlimited_vector.common().member_flags().IS_OPTIONAL(false); - cst_unlimited_vector.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_unlimited_vector.common().member_flags().IS_KEY(false); - cst_unlimited_vector.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_unlimited_vector.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("AnInternalObject", 0, true)); - - cst_unlimited_vector.detail().name("unlimited_vector"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_unlimited_vector); - - CompleteStructMember cst_limited_vector; - cst_limited_vector.common().member_id(memberId++); - cst_limited_vector.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_limited_vector.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_limited_vector.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_limited_vector.common().member_flags().IS_OPTIONAL(false); - cst_limited_vector.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_limited_vector.common().member_flags().IS_KEY(false); - cst_limited_vector.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_limited_vector.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("AnInternalObject", 10, true)); - - cst_limited_vector.detail().name("limited_vector"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_limited_vector); - - CompleteStructMember cst_limited_array; - cst_limited_array.common().member_id(memberId++); - cst_limited_array.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_limited_array.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_limited_array.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_limited_array.common().member_flags().IS_OPTIONAL(false); - cst_limited_array.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_limited_array.common().member_flags().IS_KEY(false); - cst_limited_array.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_limited_array.common().member_type_id(*TypeObjectFactory::get_instance()->get_array_identifier("AnInternalObject", {10}, true)); - - cst_limited_array.detail().name("limited_array"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_limited_array); - - - // Header - type_object->complete().struct_type().header().detail().type_name("arrays_and_sequences"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("arrays_and_sequences", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("arrays_and_sequences", true); -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesTypeObject.h deleted file mode 100644 index e0e979ef..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesTypeObject.h +++ /dev/null @@ -1,72 +0,0 @@ -// 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 arrays_and_sequencesTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_TYPE_OBJECT_H_ - - -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif -#else -#define eProsima_user_DllExport -#endif - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(arrays_and_sequences_SOURCE) -#define arrays_and_sequences_DllAPI __declspec( dllexport ) -#else -#define arrays_and_sequences_DllAPI __declspec( dllimport ) -#endif // arrays_and_sequences_SOURCE -#else -#define arrays_and_sequences_DllAPI -#endif -#else -#define arrays_and_sequences_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registerarrays_and_sequencesTypes(); - - - -eProsima_user_DllExport const TypeIdentifier* GetAnInternalObjectIdentifier(bool complete = false); -eProsima_user_DllExport const TypeObject* GetAnInternalObjectObject(bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalAnInternalObjectObject(); -eProsima_user_DllExport const TypeObject* GetCompleteAnInternalObjectObject(); - - - -eProsima_user_DllExport const TypeIdentifier* Getarrays_and_sequencesIdentifier(bool complete = false); -eProsima_user_DllExport const TypeObject* Getarrays_and_sequencesObject(bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalarrays_and_sequencesObject(); -eProsima_user_DllExport const TypeObject* GetCompletearrays_and_sequencesObject(); - - -#endif // _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_TYPE_OBJECT_H_ \ No newline at end of file diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesv1.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesv1.cxx deleted file mode 100644 index 7171511b..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesv1.cxx +++ /dev/null @@ -1,575 +0,0 @@ -// 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 arrays_and_sequences.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "arrays_and_sequences.h" - -#if FASTCDR_VERSION_MAJOR == 1 - -#include "arrays_and_sequencesTypeObject.h" - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - -namespace helper { namespace internal { - -enum class Size { - UInt8, - UInt16, - UInt32, - UInt64, -}; - -constexpr Size get_size(int s) { - return (s <= 8 ) ? Size::UInt8: - (s <= 16) ? Size::UInt16: - (s <= 32) ? Size::UInt32: Size::UInt64; -} - -template -struct FindTypeH; - -template<> -struct FindTypeH { - using type = std::uint8_t; -}; - -template<> -struct FindTypeH { - using type = std::uint16_t; -}; - -template<> -struct FindTypeH { - using type = std::uint32_t; -}; - -template<> -struct FindTypeH { - using type = std::uint64_t; -}; -} - -template -struct FindType { - using type = typename internal::FindTypeH::type; -}; -} - -#define arrays_and_sequences_max_cdr_typesize 261ULL; -#define AnInternalObject_max_cdr_typesize 9ULL; - - - - -AnInternalObject::AnInternalObject() -{ - // float m_x - m_x = 0.0; - // boolean m_positive - m_positive = false; - - // Just to register all known types - registerarrays_and_sequencesTypes(); -} - -AnInternalObject::~AnInternalObject() -{ -} - -AnInternalObject::AnInternalObject( - const AnInternalObject& x) -{ - m_x = x.m_x; - - - m_positive = x.m_positive; - -} - -AnInternalObject::AnInternalObject( - AnInternalObject&& x) noexcept -{ - m_x = x.m_x; - - - m_positive = x.m_positive; - -} - -AnInternalObject& AnInternalObject::operator =( - const AnInternalObject& x) -{ - m_x = x.m_x; - - - m_positive = x.m_positive; - - return *this; -} - -AnInternalObject& AnInternalObject::operator =( - AnInternalObject&& x) noexcept -{ - m_x = x.m_x; - - - m_positive = x.m_positive; - - return *this; -} - -bool AnInternalObject::operator ==( - const AnInternalObject& x) const -{ - return (m_x == x.m_x && - m_positive == x.m_positive); -} - -bool AnInternalObject::operator !=( - const AnInternalObject& x) const -{ - return !(*this == x); -} - -size_t AnInternalObject::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return AnInternalObject_max_cdr_typesize; -} - -size_t AnInternalObject::getCdrSerializedSize( - const AnInternalObject& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); - - - return current_alignment - initial_alignment; -} - - -void AnInternalObject::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_x; - - scdr << m_positive; - -} - -void AnInternalObject::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_x; - - - - dcdr >> m_positive; - - -} - - -bool AnInternalObject::isKeyDefined() -{ - return false; -} - -void AnInternalObject::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function sets a value in member x - * @param _x New value for member x - */ -void AnInternalObject::x( - float _x) -{ - m_x = _x; -} - -/*! - * @brief This function returns the value of member x - * @return Value of member x - */ -float AnInternalObject::x() const -{ - return m_x; -} - -/*! - * @brief This function returns a reference to member x - * @return Reference to member x - */ -float& AnInternalObject::x() -{ - return m_x; -} - - -/*! - * @brief This function sets a value in member positive - * @param _positive New value for member positive - */ -void AnInternalObject::positive( - bool _positive) -{ - m_positive = _positive; -} - -/*! - * @brief This function returns the value of member positive - * @return Value of member positive - */ -bool AnInternalObject::positive() const -{ - return m_positive; -} - -/*! - * @brief This function returns a reference to member positive - * @return Reference to member positive - */ -bool& AnInternalObject::positive() -{ - return m_positive; -} - - - - - -arrays_and_sequences::arrays_and_sequences() -{ - // sequence m_unlimited_vector - - // sequence m_limited_vector - - // AnInternalObject m_limited_array - - - // Just to register all known types - registerarrays_and_sequencesTypes(); -} - -arrays_and_sequences::~arrays_and_sequences() -{ -} - -arrays_and_sequences::arrays_and_sequences( - const arrays_and_sequences& x) -{ - m_unlimited_vector = x.m_unlimited_vector; - - - m_limited_vector = x.m_limited_vector; - - - m_limited_array = x.m_limited_array; - -} - -arrays_and_sequences::arrays_and_sequences( - arrays_and_sequences&& x) noexcept -{ - m_unlimited_vector = std::move(x.m_unlimited_vector); - - - m_limited_vector = std::move(x.m_limited_vector); - - - m_limited_array = std::move(x.m_limited_array); - -} - -arrays_and_sequences& arrays_and_sequences::operator =( - const arrays_and_sequences& x) -{ - m_unlimited_vector = x.m_unlimited_vector; - - - m_limited_vector = x.m_limited_vector; - - - m_limited_array = x.m_limited_array; - - return *this; -} - -arrays_and_sequences& arrays_and_sequences::operator =( - arrays_and_sequences&& x) noexcept -{ - m_unlimited_vector = std::move(x.m_unlimited_vector); - - - m_limited_vector = std::move(x.m_limited_vector); - - - m_limited_array = std::move(x.m_limited_array); - - return *this; -} - -bool arrays_and_sequences::operator ==( - const arrays_and_sequences& x) const -{ - return (m_unlimited_vector == x.m_unlimited_vector && - m_limited_vector == x.m_limited_vector && - m_limited_array == x.m_limited_array); -} - -bool arrays_and_sequences::operator !=( - const arrays_and_sequences& x) const -{ - return !(*this == x); -} - -size_t arrays_and_sequences::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return arrays_and_sequences_max_cdr_typesize; -} - -size_t arrays_and_sequences::getCdrSerializedSize( - const arrays_and_sequences& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - for(size_t a = 0; a < data.unlimited_vector().size(); ++a) - { - current_alignment += AnInternalObject::getCdrSerializedSize(data.unlimited_vector().at(a), current_alignment); - } - - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - for(size_t a = 0; a < data.limited_vector().size(); ++a) - { - current_alignment += AnInternalObject::getCdrSerializedSize(data.limited_vector().at(a), current_alignment); - } - - - - - for(size_t a = 0; a < data.limited_array().size(); ++a) - { - current_alignment += AnInternalObject::getCdrSerializedSize(data.limited_array().at(a), current_alignment); - - } - - - - return current_alignment - initial_alignment; -} - - -void arrays_and_sequences::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_unlimited_vector; - - - scdr << m_limited_vector; - - - scdr << m_limited_array; - - -} - -void arrays_and_sequences::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_unlimited_vector; - - - - dcdr >> m_limited_vector; - - - - dcdr >> m_limited_array; - - -} - - -bool arrays_and_sequences::isKeyDefined() -{ - return false; -} - -void arrays_and_sequences::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function copies the value in member unlimited_vector - * @param _unlimited_vector New value to be copied in member unlimited_vector - */ -void arrays_and_sequences::unlimited_vector( - const std::vector& _unlimited_vector) -{ - m_unlimited_vector = _unlimited_vector; -} - -/*! - * @brief This function moves the value in member unlimited_vector - * @param _unlimited_vector New value to be moved in member unlimited_vector - */ -void arrays_and_sequences::unlimited_vector( - std::vector&& _unlimited_vector) -{ - m_unlimited_vector = std::move(_unlimited_vector); -} - -/*! - * @brief This function returns a constant reference to member unlimited_vector - * @return Constant reference to member unlimited_vector - */ -const std::vector& arrays_and_sequences::unlimited_vector() const -{ - return m_unlimited_vector; -} - -/*! - * @brief This function returns a reference to member unlimited_vector - * @return Reference to member unlimited_vector - */ -std::vector& arrays_and_sequences::unlimited_vector() -{ - return m_unlimited_vector; -} - - -/*! - * @brief This function copies the value in member limited_vector - * @param _limited_vector New value to be copied in member limited_vector - */ -void arrays_and_sequences::limited_vector( - const std::vector& _limited_vector) -{ - m_limited_vector = _limited_vector; -} - -/*! - * @brief This function moves the value in member limited_vector - * @param _limited_vector New value to be moved in member limited_vector - */ -void arrays_and_sequences::limited_vector( - std::vector&& _limited_vector) -{ - m_limited_vector = std::move(_limited_vector); -} - -/*! - * @brief This function returns a constant reference to member limited_vector - * @return Constant reference to member limited_vector - */ -const std::vector& arrays_and_sequences::limited_vector() const -{ - return m_limited_vector; -} - -/*! - * @brief This function returns a reference to member limited_vector - * @return Reference to member limited_vector - */ -std::vector& arrays_and_sequences::limited_vector() -{ - return m_limited_vector; -} - - -/*! - * @brief This function copies the value in member limited_array - * @param _limited_array New value to be copied in member limited_array - */ -void arrays_and_sequences::limited_array( - const std::array& _limited_array) -{ - m_limited_array = _limited_array; -} - -/*! - * @brief This function moves the value in member limited_array - * @param _limited_array New value to be moved in member limited_array - */ -void arrays_and_sequences::limited_array( - std::array&& _limited_array) -{ - m_limited_array = std::move(_limited_array); -} - -/*! - * @brief This function returns a constant reference to member limited_array - * @return Constant reference to member limited_array - */ -const std::array& arrays_and_sequences::limited_array() const -{ - return m_limited_array; -} - -/*! - * @brief This function returns a reference to member limited_array - * @return Reference to member limited_array - */ -std::array& arrays_and_sequences::limited_array() -{ - return m_limited_array; -} - - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesv1.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesv1.h deleted file mode 100644 index 69c73768..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesv1.h +++ /dev/null @@ -1,438 +0,0 @@ -// 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 arrays_and_sequences.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#include - -#if FASTCDR_VERSION_MAJOR == 1 - -#ifndef _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_H_ -#define _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_H_ - - -#include - -#include -#include -#include -#include -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(ARRAYS_AND_SEQUENCES_SOURCE) -#define ARRAYS_AND_SEQUENCES_DllAPI __declspec( dllexport ) -#else -#define ARRAYS_AND_SEQUENCES_DllAPI __declspec( dllimport ) -#endif // ARRAYS_AND_SEQUENCES_SOURCE -#else -#define ARRAYS_AND_SEQUENCES_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define ARRAYS_AND_SEQUENCES_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - - - - -/*! - * @brief This class represents the structure AnInternalObject defined by the user in the IDL file. - * @ingroup arrays_and_sequences - */ -class AnInternalObject -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport AnInternalObject(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~AnInternalObject(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object AnInternalObject that will be copied. - */ - eProsima_user_DllExport AnInternalObject( - const AnInternalObject& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object AnInternalObject that will be copied. - */ - eProsima_user_DllExport AnInternalObject( - AnInternalObject&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object AnInternalObject that will be copied. - */ - eProsima_user_DllExport AnInternalObject& operator =( - const AnInternalObject& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object AnInternalObject that will be copied. - */ - eProsima_user_DllExport AnInternalObject& operator =( - AnInternalObject&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x AnInternalObject object to compare. - */ - eProsima_user_DllExport bool operator ==( - const AnInternalObject& x) const; - - /*! - * @brief Comparison operator. - * @param x AnInternalObject object to compare. - */ - eProsima_user_DllExport bool operator !=( - const AnInternalObject& x) const; - - /*! - * @brief This function sets a value in member x - * @param _x New value for member x - */ - eProsima_user_DllExport void x( - float _x); - - /*! - * @brief This function returns the value of member x - * @return Value of member x - */ - eProsima_user_DllExport float x() const; - - /*! - * @brief This function returns a reference to member x - * @return Reference to member x - */ - eProsima_user_DllExport float& x(); - - - /*! - * @brief This function sets a value in member positive - * @param _positive New value for member positive - */ - eProsima_user_DllExport void positive( - bool _positive); - - /*! - * @brief This function returns the value of member positive - * @return Value of member positive - */ - eProsima_user_DllExport bool positive() const; - - /*! - * @brief This function returns a reference to member positive - * @return Reference to member positive - */ - eProsima_user_DllExport bool& positive(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const AnInternalObject& data, - size_t current_alignment = 0); - - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - - -private: - - float m_x; - bool m_positive; - -}; - - - -/*! - * @brief This class represents the structure arrays_and_sequences defined by the user in the IDL file. - * @ingroup arrays_and_sequences - */ -class arrays_and_sequences -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport arrays_and_sequences(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~arrays_and_sequences(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object arrays_and_sequences that will be copied. - */ - eProsima_user_DllExport arrays_and_sequences( - const arrays_and_sequences& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object arrays_and_sequences that will be copied. - */ - eProsima_user_DllExport arrays_and_sequences( - arrays_and_sequences&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object arrays_and_sequences that will be copied. - */ - eProsima_user_DllExport arrays_and_sequences& operator =( - const arrays_and_sequences& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object arrays_and_sequences that will be copied. - */ - eProsima_user_DllExport arrays_and_sequences& operator =( - arrays_and_sequences&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x arrays_and_sequences object to compare. - */ - eProsima_user_DllExport bool operator ==( - const arrays_and_sequences& x) const; - - /*! - * @brief Comparison operator. - * @param x arrays_and_sequences object to compare. - */ - eProsima_user_DllExport bool operator !=( - const arrays_and_sequences& x) const; - - /*! - * @brief This function copies the value in member unlimited_vector - * @param _unlimited_vector New value to be copied in member unlimited_vector - */ - eProsima_user_DllExport void unlimited_vector( - const std::vector& _unlimited_vector); - - /*! - * @brief This function moves the value in member unlimited_vector - * @param _unlimited_vector New value to be moved in member unlimited_vector - */ - eProsima_user_DllExport void unlimited_vector( - std::vector&& _unlimited_vector); - - /*! - * @brief This function returns a constant reference to member unlimited_vector - * @return Constant reference to member unlimited_vector - */ - eProsima_user_DllExport const std::vector& unlimited_vector() const; - - /*! - * @brief This function returns a reference to member unlimited_vector - * @return Reference to member unlimited_vector - */ - eProsima_user_DllExport std::vector& unlimited_vector(); - - - /*! - * @brief This function copies the value in member limited_vector - * @param _limited_vector New value to be copied in member limited_vector - */ - eProsima_user_DllExport void limited_vector( - const std::vector& _limited_vector); - - /*! - * @brief This function moves the value in member limited_vector - * @param _limited_vector New value to be moved in member limited_vector - */ - eProsima_user_DllExport void limited_vector( - std::vector&& _limited_vector); - - /*! - * @brief This function returns a constant reference to member limited_vector - * @return Constant reference to member limited_vector - */ - eProsima_user_DllExport const std::vector& limited_vector() const; - - /*! - * @brief This function returns a reference to member limited_vector - * @return Reference to member limited_vector - */ - eProsima_user_DllExport std::vector& limited_vector(); - - - /*! - * @brief This function copies the value in member limited_array - * @param _limited_array New value to be copied in member limited_array - */ - eProsima_user_DllExport void limited_array( - const std::array& _limited_array); - - /*! - * @brief This function moves the value in member limited_array - * @param _limited_array New value to be moved in member limited_array - */ - eProsima_user_DllExport void limited_array( - std::array&& _limited_array); - - /*! - * @brief This function returns a constant reference to member limited_array - * @return Constant reference to member limited_array - */ - eProsima_user_DllExport const std::array& limited_array() const; - - /*! - * @brief This function returns a reference to member limited_array - * @return Reference to member limited_array - */ - eProsima_user_DllExport std::array& limited_array(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const arrays_and_sequences& data, - size_t current_alignment = 0); - - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - - -private: - - std::vector m_unlimited_vector; - std::vector m_limited_vector; - std::array m_limited_array; - -}; - - -#endif // _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_H_ - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_struct.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_struct.cxx deleted file mode 100644 index fdd5905b..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_struct.cxx +++ /dev/null @@ -1,287 +0,0 @@ -// 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 basic_array_struct.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "basic_array_struct.h" - -#if FASTCDR_VERSION_MAJOR > 1 - -#include "basic_array_structTypeObject.h" - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - - - - -TheOtherObjectInArray::TheOtherObjectInArray() -{ - // Just to register all known types - registerbasic_array_structTypes(); -} - -TheOtherObjectInArray::~TheOtherObjectInArray() -{ -} - -TheOtherObjectInArray::TheOtherObjectInArray( - const TheOtherObjectInArray& x) -{ - m_some_num = x.m_some_num; - m_positive = x.m_positive; -} - -TheOtherObjectInArray::TheOtherObjectInArray( - TheOtherObjectInArray&& x) noexcept -{ - m_some_num = x.m_some_num; - m_positive = x.m_positive; -} - -TheOtherObjectInArray& TheOtherObjectInArray::operator =( - const TheOtherObjectInArray& x) -{ - - m_some_num = x.m_some_num; - m_positive = x.m_positive; - return *this; -} - -TheOtherObjectInArray& TheOtherObjectInArray::operator =( - TheOtherObjectInArray&& x) noexcept -{ - - m_some_num = x.m_some_num; - m_positive = x.m_positive; - return *this; -} - -bool TheOtherObjectInArray::operator ==( - const TheOtherObjectInArray& x) const -{ - return (m_some_num == x.m_some_num && - m_positive == x.m_positive); -} - -bool TheOtherObjectInArray::operator !=( - const TheOtherObjectInArray& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function sets a value in member some_num - * @param _some_num New value for member some_num - */ -void TheOtherObjectInArray::some_num( - int32_t _some_num) -{ - m_some_num = _some_num; -} - -/*! - * @brief This function returns the value of member some_num - * @return Value of member some_num - */ -int32_t TheOtherObjectInArray::some_num() const -{ - return m_some_num; -} - -/*! - * @brief This function returns a reference to member some_num - * @return Reference to member some_num - */ -int32_t& TheOtherObjectInArray::some_num() -{ - return m_some_num; -} - - -/*! - * @brief This function sets a value in member positive - * @param _positive New value for member positive - */ -void TheOtherObjectInArray::positive( - bool _positive) -{ - m_positive = _positive; -} - -/*! - * @brief This function returns the value of member positive - * @return Value of member positive - */ -bool TheOtherObjectInArray::positive() const -{ - return m_positive; -} - -/*! - * @brief This function returns a reference to member positive - * @return Reference to member positive - */ -bool& TheOtherObjectInArray::positive() -{ - return m_positive; -} - - - - -basic_array_struct::basic_array_struct() -{ - // Just to register all known types - registerbasic_array_structTypes(); -} - -basic_array_struct::~basic_array_struct() -{ -} - -basic_array_struct::basic_array_struct( - const basic_array_struct& x) -{ - m_index = x.m_index; - m_sub_structs = x.m_sub_structs; -} - -basic_array_struct::basic_array_struct( - basic_array_struct&& x) noexcept -{ - m_index = x.m_index; - m_sub_structs = std::move(x.m_sub_structs); -} - -basic_array_struct& basic_array_struct::operator =( - const basic_array_struct& x) -{ - - m_index = x.m_index; - m_sub_structs = x.m_sub_structs; - return *this; -} - -basic_array_struct& basic_array_struct::operator =( - basic_array_struct&& x) noexcept -{ - - m_index = x.m_index; - m_sub_structs = std::move(x.m_sub_structs); - return *this; -} - -bool basic_array_struct::operator ==( - const basic_array_struct& x) const -{ - return (m_index == x.m_index && - m_sub_structs == x.m_sub_structs); -} - -bool basic_array_struct::operator !=( - const basic_array_struct& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ -void basic_array_struct::index( - uint32_t _index) -{ - m_index = _index; -} - -/*! - * @brief This function returns the value of member index - * @return Value of member index - */ -uint32_t basic_array_struct::index() const -{ - return m_index; -} - -/*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ -uint32_t& basic_array_struct::index() -{ - return m_index; -} - - -/*! - * @brief This function copies the value in member sub_structs - * @param _sub_structs New value to be copied in member sub_structs - */ -void basic_array_struct::sub_structs( - const std::array& _sub_structs) -{ - m_sub_structs = _sub_structs; -} - -/*! - * @brief This function moves the value in member sub_structs - * @param _sub_structs New value to be moved in member sub_structs - */ -void basic_array_struct::sub_structs( - std::array&& _sub_structs) -{ - m_sub_structs = std::move(_sub_structs); -} - -/*! - * @brief This function returns a constant reference to member sub_structs - * @return Constant reference to member sub_structs - */ -const std::array& basic_array_struct::sub_structs() const -{ - return m_sub_structs; -} - -/*! - * @brief This function returns a reference to member sub_structs - * @return Reference to member sub_structs - */ -std::array& basic_array_struct::sub_structs() -{ - return m_sub_structs; -} - - -// Include auxiliary functions like for serializing/deserializing. -#include "basic_array_structCdrAux.ipp" - -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structPubSubTypes.cxx deleted file mode 100644 index dae8639b..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structPubSubTypes.cxx +++ /dev/null @@ -1,411 +0,0 @@ -// 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 basic_array_structPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#include - -#include "basic_array_structPubSubTypes.h" -#include "basic_array_structCdrAux.hpp" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; -using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - - - -TheOtherObjectInArrayPubSubType::TheOtherObjectInArrayPubSubType() -{ - setName("TheOtherObjectInArray"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(TheOtherObjectInArray::getMaxCdrSerializedSize()); -#else - TheOtherObjectInArray_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = TheOtherObjectInArray_max_key_cdr_typesize > 16 ? TheOtherObjectInArray_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -TheOtherObjectInArrayPubSubType::~TheOtherObjectInArrayPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool TheOtherObjectInArrayPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - TheOtherObjectInArray* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool TheOtherObjectInArrayPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - TheOtherObjectInArray* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function TheOtherObjectInArrayPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* TheOtherObjectInArrayPubSubType::createData() -{ - return reinterpret_cast(new TheOtherObjectInArray()); -} - -void TheOtherObjectInArrayPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool TheOtherObjectInArrayPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - TheOtherObjectInArray* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - TheOtherObjectInArray_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || TheOtherObjectInArray_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - - - -basic_array_structPubSubType::basic_array_structPubSubType() -{ - setName("basic_array_struct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(basic_array_struct::getMaxCdrSerializedSize()); -#else - basic_array_struct_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = basic_array_struct_max_key_cdr_typesize > 16 ? basic_array_struct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -basic_array_structPubSubType::~basic_array_structPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool basic_array_structPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - basic_array_struct* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool basic_array_structPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - basic_array_struct* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function basic_array_structPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* basic_array_structPubSubType::createData() -{ - return reinterpret_cast(new basic_array_struct()); -} - -void basic_array_structPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool basic_array_structPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - basic_array_struct* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - basic_array_struct_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || basic_array_struct_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structTypeObject.cxx deleted file mode 100644 index 24fbff30..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structTypeObject.cxx +++ /dev/null @@ -1,481 +0,0 @@ -// 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 basic_array_structTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { char dummy; } -#endif - -#include "basic_array_struct.h" -#include "basic_array_structTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerbasic_array_structTypes() -{ - static std::once_flag once_flag; - std::call_once(once_flag, []() - { - TypeObjectFactory *factory = TypeObjectFactory::get_instance(); - factory->add_type_object("TheOtherObjectInArray", GetTheOtherObjectInArrayIdentifier(true), - GetTheOtherObjectInArrayObject(true)); - factory->add_type_object("TheOtherObjectInArray", GetTheOtherObjectInArrayIdentifier(false), - GetTheOtherObjectInArrayObject(false)); - - - factory->add_type_object("basic_array_struct", Getbasic_array_structIdentifier(true), - Getbasic_array_structObject(true)); - factory->add_type_object("basic_array_struct", Getbasic_array_structIdentifier(false), - Getbasic_array_structObject(false)); - - }); -} - - - -const TypeIdentifier* GetTheOtherObjectInArrayIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("TheOtherObjectInArray", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetTheOtherObjectInArrayObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("TheOtherObjectInArray", complete); -} - -const TypeObject* GetTheOtherObjectInArrayObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("TheOtherObjectInArray", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteTheOtherObjectInArrayObject(); - } - //else - return GetMinimalTheOtherObjectInArrayObject(); -} - -const TypeObject* GetMinimalTheOtherObjectInArrayObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("TheOtherObjectInArray", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_some_num; - mst_some_num.common().member_id(memberId++); - mst_some_num.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_some_num.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_some_num.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_some_num.common().member_flags().IS_OPTIONAL(false); - mst_some_num.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_some_num.common().member_flags().IS_KEY(false); - mst_some_num.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_some_num.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - - - MD5 some_num_hash("some_num"); - for(int i = 0; i < 4; ++i) - { - mst_some_num.detail().name_hash()[i] = some_num_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_some_num); - - MinimalStructMember mst_positive; - mst_positive.common().member_id(memberId++); - mst_positive.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_positive.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_positive.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_positive.common().member_flags().IS_OPTIONAL(false); - mst_positive.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_positive.common().member_flags().IS_KEY(false); - mst_positive.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_positive.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - - MD5 positive_hash("positive"); - for(int i = 0; i < 4; ++i) - { - mst_positive.detail().name_hash()[i] = positive_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_positive); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("TheOtherObjectInArray", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("TheOtherObjectInArray", false); -} - -const TypeObject* GetCompleteTheOtherObjectInArrayObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("TheOtherObjectInArray", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_some_num; - cst_some_num.common().member_id(memberId++); - cst_some_num.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_some_num.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_some_num.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_some_num.common().member_flags().IS_OPTIONAL(false); - cst_some_num.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_some_num.common().member_flags().IS_KEY(false); - cst_some_num.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_some_num.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - - - cst_some_num.detail().name("some_num"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_some_num); - - CompleteStructMember cst_positive; - cst_positive.common().member_id(memberId++); - cst_positive.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_positive.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_positive.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_positive.common().member_flags().IS_OPTIONAL(false); - cst_positive.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_positive.common().member_flags().IS_KEY(false); - cst_positive.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_positive.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - - cst_positive.detail().name("positive"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_positive); - - - // Header - type_object->complete().struct_type().header().detail().type_name("TheOtherObjectInArray"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("TheOtherObjectInArray", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("TheOtherObjectInArray", true); -} - - - -const TypeIdentifier* Getbasic_array_structIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("basic_array_struct", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - Getbasic_array_structObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("basic_array_struct", complete); -} - -const TypeObject* Getbasic_array_structObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("basic_array_struct", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompletebasic_array_structObject(); - } - //else - return GetMinimalbasic_array_structObject(); -} - -const TypeObject* GetMinimalbasic_array_structObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("basic_array_struct", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_index; - mst_index.common().member_id(memberId++); - mst_index.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_index.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_index.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_index.common().member_flags().IS_OPTIONAL(false); - mst_index.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_index.common().member_flags().IS_KEY(false); - mst_index.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_index.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); - - - MD5 index_hash("index"); - for(int i = 0; i < 4; ++i) - { - mst_index.detail().name_hash()[i] = index_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_index); - - MinimalStructMember mst_sub_structs; - mst_sub_structs.common().member_id(memberId++); - mst_sub_structs.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_sub_structs.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_sub_structs.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_sub_structs.common().member_flags().IS_OPTIONAL(false); - mst_sub_structs.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_sub_structs.common().member_flags().IS_KEY(false); - mst_sub_structs.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_sub_structs.common().member_type_id(*TypeObjectFactory::get_instance()->get_array_identifier("TheOtherObjectInArray", {5}, false)); - - MD5 sub_structs_hash("sub_structs"); - for(int i = 0; i < 4; ++i) - { - mst_sub_structs.detail().name_hash()[i] = sub_structs_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_sub_structs); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("basic_array_struct", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("basic_array_struct", false); -} - -const TypeObject* GetCompletebasic_array_structObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("basic_array_struct", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_index; - cst_index.common().member_id(memberId++); - cst_index.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_index.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_index.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_index.common().member_flags().IS_OPTIONAL(false); - cst_index.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_index.common().member_flags().IS_KEY(false); - cst_index.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_index.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); - - - cst_index.detail().name("index"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_index); - - CompleteStructMember cst_sub_structs; - cst_sub_structs.common().member_id(memberId++); - cst_sub_structs.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_sub_structs.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_sub_structs.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_sub_structs.common().member_flags().IS_OPTIONAL(false); - cst_sub_structs.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_sub_structs.common().member_flags().IS_KEY(false); - cst_sub_structs.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_sub_structs.common().member_type_id(*TypeObjectFactory::get_instance()->get_array_identifier("TheOtherObjectInArray", {5}, true)); - - cst_sub_structs.detail().name("sub_structs"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_sub_structs); - - - // Header - type_object->complete().struct_type().header().detail().type_name("basic_array_struct"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("basic_array_struct", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("basic_array_struct", true); -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structTypeObject.h deleted file mode 100644 index 56633c05..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structTypeObject.h +++ /dev/null @@ -1,72 +0,0 @@ -// 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 basic_array_structTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCT_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCT_TYPE_OBJECT_H_ - - -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif -#else -#define eProsima_user_DllExport -#endif - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(basic_array_struct_SOURCE) -#define basic_array_struct_DllAPI __declspec( dllexport ) -#else -#define basic_array_struct_DllAPI __declspec( dllimport ) -#endif // basic_array_struct_SOURCE -#else -#define basic_array_struct_DllAPI -#endif -#else -#define basic_array_struct_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registerbasic_array_structTypes(); - - - -eProsima_user_DllExport const TypeIdentifier* GetTheOtherObjectInArrayIdentifier(bool complete = false); -eProsima_user_DllExport const TypeObject* GetTheOtherObjectInArrayObject(bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalTheOtherObjectInArrayObject(); -eProsima_user_DllExport const TypeObject* GetCompleteTheOtherObjectInArrayObject(); - - - -eProsima_user_DllExport const TypeIdentifier* Getbasic_array_structIdentifier(bool complete = false); -eProsima_user_DllExport const TypeObject* Getbasic_array_structObject(bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalbasic_array_structObject(); -eProsima_user_DllExport const TypeObject* GetCompletebasic_array_structObject(); - - -#endif // _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCT_TYPE_OBJECT_H_ \ No newline at end of file diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structv1.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structv1.cxx deleted file mode 100644 index 89ebbf93..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structv1.cxx +++ /dev/null @@ -1,486 +0,0 @@ -// 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 basic_array_struct.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "basic_array_struct.h" - -#if FASTCDR_VERSION_MAJOR == 1 - -#include "basic_array_structTypeObject.h" - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - -namespace helper { namespace internal { - -enum class Size { - UInt8, - UInt16, - UInt32, - UInt64, -}; - -constexpr Size get_size(int s) { - return (s <= 8 ) ? Size::UInt8: - (s <= 16) ? Size::UInt16: - (s <= 32) ? Size::UInt32: Size::UInt64; -} - -template -struct FindTypeH; - -template<> -struct FindTypeH { - using type = std::uint8_t; -}; - -template<> -struct FindTypeH { - using type = std::uint16_t; -}; - -template<> -struct FindTypeH { - using type = std::uint32_t; -}; - -template<> -struct FindTypeH { - using type = std::uint64_t; -}; -} - -template -struct FindType { - using type = typename internal::FindTypeH::type; -}; -} - -#define basic_array_struct_max_cdr_typesize 69ULL; -#define TheOtherObjectInArray_max_cdr_typesize 9ULL; - - - - -TheOtherObjectInArray::TheOtherObjectInArray() -{ - // long m_some_num - m_some_num = 0; - // boolean m_positive - m_positive = false; - - // Just to register all known types - registerbasic_array_structTypes(); -} - -TheOtherObjectInArray::~TheOtherObjectInArray() -{ -} - -TheOtherObjectInArray::TheOtherObjectInArray( - const TheOtherObjectInArray& x) -{ - m_some_num = x.m_some_num; - - - m_positive = x.m_positive; - -} - -TheOtherObjectInArray::TheOtherObjectInArray( - TheOtherObjectInArray&& x) noexcept -{ - m_some_num = x.m_some_num; - - - m_positive = x.m_positive; - -} - -TheOtherObjectInArray& TheOtherObjectInArray::operator =( - const TheOtherObjectInArray& x) -{ - m_some_num = x.m_some_num; - - - m_positive = x.m_positive; - - return *this; -} - -TheOtherObjectInArray& TheOtherObjectInArray::operator =( - TheOtherObjectInArray&& x) noexcept -{ - m_some_num = x.m_some_num; - - - m_positive = x.m_positive; - - return *this; -} - -bool TheOtherObjectInArray::operator ==( - const TheOtherObjectInArray& x) const -{ - return (m_some_num == x.m_some_num && - m_positive == x.m_positive); -} - -bool TheOtherObjectInArray::operator !=( - const TheOtherObjectInArray& x) const -{ - return !(*this == x); -} - -size_t TheOtherObjectInArray::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return TheOtherObjectInArray_max_cdr_typesize; -} - -size_t TheOtherObjectInArray::getCdrSerializedSize( - const TheOtherObjectInArray& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); - - - return current_alignment - initial_alignment; -} - - -void TheOtherObjectInArray::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_some_num; - - scdr << m_positive; - -} - -void TheOtherObjectInArray::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_some_num; - - - - dcdr >> m_positive; - - -} - - -bool TheOtherObjectInArray::isKeyDefined() -{ - return false; -} - -void TheOtherObjectInArray::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function sets a value in member some_num - * @param _some_num New value for member some_num - */ -void TheOtherObjectInArray::some_num( - int32_t _some_num) -{ - m_some_num = _some_num; -} - -/*! - * @brief This function returns the value of member some_num - * @return Value of member some_num - */ -int32_t TheOtherObjectInArray::some_num() const -{ - return m_some_num; -} - -/*! - * @brief This function returns a reference to member some_num - * @return Reference to member some_num - */ -int32_t& TheOtherObjectInArray::some_num() -{ - return m_some_num; -} - - -/*! - * @brief This function sets a value in member positive - * @param _positive New value for member positive - */ -void TheOtherObjectInArray::positive( - bool _positive) -{ - m_positive = _positive; -} - -/*! - * @brief This function returns the value of member positive - * @return Value of member positive - */ -bool TheOtherObjectInArray::positive() const -{ - return m_positive; -} - -/*! - * @brief This function returns a reference to member positive - * @return Reference to member positive - */ -bool& TheOtherObjectInArray::positive() -{ - return m_positive; -} - - - - - -basic_array_struct::basic_array_struct() -{ - // unsigned long m_index - m_index = 0; - // TheOtherObjectInArray m_sub_structs - - - // Just to register all known types - registerbasic_array_structTypes(); -} - -basic_array_struct::~basic_array_struct() -{ -} - -basic_array_struct::basic_array_struct( - const basic_array_struct& x) -{ - m_index = x.m_index; - - - m_sub_structs = x.m_sub_structs; - -} - -basic_array_struct::basic_array_struct( - basic_array_struct&& x) noexcept -{ - m_index = x.m_index; - - - m_sub_structs = std::move(x.m_sub_structs); - -} - -basic_array_struct& basic_array_struct::operator =( - const basic_array_struct& x) -{ - m_index = x.m_index; - - - m_sub_structs = x.m_sub_structs; - - return *this; -} - -basic_array_struct& basic_array_struct::operator =( - basic_array_struct&& x) noexcept -{ - m_index = x.m_index; - - - m_sub_structs = std::move(x.m_sub_structs); - - return *this; -} - -bool basic_array_struct::operator ==( - const basic_array_struct& x) const -{ - return (m_index == x.m_index && - m_sub_structs == x.m_sub_structs); -} - -bool basic_array_struct::operator !=( - const basic_array_struct& x) const -{ - return !(*this == x); -} - -size_t basic_array_struct::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return basic_array_struct_max_cdr_typesize; -} - -size_t basic_array_struct::getCdrSerializedSize( - const basic_array_struct& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - - for(size_t a = 0; a < data.sub_structs().size(); ++a) - { - current_alignment += TheOtherObjectInArray::getCdrSerializedSize(data.sub_structs().at(a), current_alignment); - - } - - - - return current_alignment - initial_alignment; -} - - -void basic_array_struct::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_index; - - scdr << m_sub_structs; - - -} - -void basic_array_struct::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_index; - - - - dcdr >> m_sub_structs; - - -} - - -bool basic_array_struct::isKeyDefined() -{ - return false; -} - -void basic_array_struct::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ -void basic_array_struct::index( - uint32_t _index) -{ - m_index = _index; -} - -/*! - * @brief This function returns the value of member index - * @return Value of member index - */ -uint32_t basic_array_struct::index() const -{ - return m_index; -} - -/*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ -uint32_t& basic_array_struct::index() -{ - return m_index; -} - - -/*! - * @brief This function copies the value in member sub_structs - * @param _sub_structs New value to be copied in member sub_structs - */ -void basic_array_struct::sub_structs( - const std::array& _sub_structs) -{ - m_sub_structs = _sub_structs; -} - -/*! - * @brief This function moves the value in member sub_structs - * @param _sub_structs New value to be moved in member sub_structs - */ -void basic_array_struct::sub_structs( - std::array&& _sub_structs) -{ - m_sub_structs = std::move(_sub_structs); -} - -/*! - * @brief This function returns a constant reference to member sub_structs - * @return Constant reference to member sub_structs - */ -const std::array& basic_array_struct::sub_structs() const -{ - return m_sub_structs; -} - -/*! - * @brief This function returns a reference to member sub_structs - * @return Reference to member sub_structs - */ -std::array& basic_array_struct::sub_structs() -{ - return m_sub_structs; -} - - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structv1.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structv1.h deleted file mode 100644 index 58c0a213..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structv1.h +++ /dev/null @@ -1,403 +0,0 @@ -// 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 basic_array_struct.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#include - -#if FASTCDR_VERSION_MAJOR == 1 - -#ifndef _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCT_H_ -#define _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCT_H_ - - -#include - -#include -#include -#include -#include -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(BASIC_ARRAY_STRUCT_SOURCE) -#define BASIC_ARRAY_STRUCT_DllAPI __declspec( dllexport ) -#else -#define BASIC_ARRAY_STRUCT_DllAPI __declspec( dllimport ) -#endif // BASIC_ARRAY_STRUCT_SOURCE -#else -#define BASIC_ARRAY_STRUCT_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define BASIC_ARRAY_STRUCT_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - - - - -/*! - * @brief This class represents the structure TheOtherObjectInArray defined by the user in the IDL file. - * @ingroup basic_array_struct - */ -class TheOtherObjectInArray -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport TheOtherObjectInArray(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~TheOtherObjectInArray(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object TheOtherObjectInArray that will be copied. - */ - eProsima_user_DllExport TheOtherObjectInArray( - const TheOtherObjectInArray& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object TheOtherObjectInArray that will be copied. - */ - eProsima_user_DllExport TheOtherObjectInArray( - TheOtherObjectInArray&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object TheOtherObjectInArray that will be copied. - */ - eProsima_user_DllExport TheOtherObjectInArray& operator =( - const TheOtherObjectInArray& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object TheOtherObjectInArray that will be copied. - */ - eProsima_user_DllExport TheOtherObjectInArray& operator =( - TheOtherObjectInArray&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x TheOtherObjectInArray object to compare. - */ - eProsima_user_DllExport bool operator ==( - const TheOtherObjectInArray& x) const; - - /*! - * @brief Comparison operator. - * @param x TheOtherObjectInArray object to compare. - */ - eProsima_user_DllExport bool operator !=( - const TheOtherObjectInArray& x) const; - - /*! - * @brief This function sets a value in member some_num - * @param _some_num New value for member some_num - */ - eProsima_user_DllExport void some_num( - int32_t _some_num); - - /*! - * @brief This function returns the value of member some_num - * @return Value of member some_num - */ - eProsima_user_DllExport int32_t some_num() const; - - /*! - * @brief This function returns a reference to member some_num - * @return Reference to member some_num - */ - eProsima_user_DllExport int32_t& some_num(); - - - /*! - * @brief This function sets a value in member positive - * @param _positive New value for member positive - */ - eProsima_user_DllExport void positive( - bool _positive); - - /*! - * @brief This function returns the value of member positive - * @return Value of member positive - */ - eProsima_user_DllExport bool positive() const; - - /*! - * @brief This function returns a reference to member positive - * @return Reference to member positive - */ - eProsima_user_DllExport bool& positive(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const TheOtherObjectInArray& data, - size_t current_alignment = 0); - - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - - -private: - - int32_t m_some_num; - bool m_positive; - -}; - - - -/*! - * @brief This class represents the structure basic_array_struct defined by the user in the IDL file. - * @ingroup basic_array_struct - */ -class basic_array_struct -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport basic_array_struct(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~basic_array_struct(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object basic_array_struct that will be copied. - */ - eProsima_user_DllExport basic_array_struct( - const basic_array_struct& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object basic_array_struct that will be copied. - */ - eProsima_user_DllExport basic_array_struct( - basic_array_struct&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object basic_array_struct that will be copied. - */ - eProsima_user_DllExport basic_array_struct& operator =( - const basic_array_struct& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object basic_array_struct that will be copied. - */ - eProsima_user_DllExport basic_array_struct& operator =( - basic_array_struct&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x basic_array_struct object to compare. - */ - eProsima_user_DllExport bool operator ==( - const basic_array_struct& x) const; - - /*! - * @brief Comparison operator. - * @param x basic_array_struct object to compare. - */ - eProsima_user_DllExport bool operator !=( - const basic_array_struct& x) const; - - /*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ - eProsima_user_DllExport void index( - uint32_t _index); - - /*! - * @brief This function returns the value of member index - * @return Value of member index - */ - eProsima_user_DllExport uint32_t index() const; - - /*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ - eProsima_user_DllExport uint32_t& index(); - - - /*! - * @brief This function copies the value in member sub_structs - * @param _sub_structs New value to be copied in member sub_structs - */ - eProsima_user_DllExport void sub_structs( - const std::array& _sub_structs); - - /*! - * @brief This function moves the value in member sub_structs - * @param _sub_structs New value to be moved in member sub_structs - */ - eProsima_user_DllExport void sub_structs( - std::array&& _sub_structs); - - /*! - * @brief This function returns a constant reference to member sub_structs - * @return Constant reference to member sub_structs - */ - eProsima_user_DllExport const std::array& sub_structs() const; - - /*! - * @brief This function returns a reference to member sub_structs - * @return Reference to member sub_structs - */ - eProsima_user_DllExport std::array& sub_structs(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const basic_array_struct& data, - size_t current_alignment = 0); - - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - - -private: - - uint32_t m_index; - std::array m_sub_structs; - -}; - - -#endif // _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCT_H_ - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_struct.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_struct.cxx deleted file mode 100644 index e97c666d..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_struct.cxx +++ /dev/null @@ -1,219 +0,0 @@ -// 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 basic_struct.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "basic_struct.h" - -#if FASTCDR_VERSION_MAJOR > 1 - -#include "basic_structTypeObject.h" - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - - - - -TheOtherObject::TheOtherObject() -{ - // Just to register all known types - registerbasic_structTypes(); -} - -TheOtherObject::~TheOtherObject() -{ -} - -TheOtherObject::TheOtherObject( - const TheOtherObject& x) -{ - m_some_num = x.m_some_num; -} - -TheOtherObject::TheOtherObject( - TheOtherObject&& x) noexcept -{ - m_some_num = x.m_some_num; -} - -TheOtherObject& TheOtherObject::operator =( - const TheOtherObject& x) -{ - - m_some_num = x.m_some_num; - return *this; -} - -TheOtherObject& TheOtherObject::operator =( - TheOtherObject&& x) noexcept -{ - - m_some_num = x.m_some_num; - return *this; -} - -bool TheOtherObject::operator ==( - const TheOtherObject& x) const -{ - return (m_some_num == x.m_some_num); -} - -bool TheOtherObject::operator !=( - const TheOtherObject& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function sets a value in member some_num - * @param _some_num New value for member some_num - */ -void TheOtherObject::some_num( - int32_t _some_num) -{ - m_some_num = _some_num; -} - -/*! - * @brief This function returns the value of member some_num - * @return Value of member some_num - */ -int32_t TheOtherObject::some_num() const -{ - return m_some_num; -} - -/*! - * @brief This function returns a reference to member some_num - * @return Reference to member some_num - */ -int32_t& TheOtherObject::some_num() -{ - return m_some_num; -} - - - - -basic_struct::basic_struct() -{ - // Just to register all known types - registerbasic_structTypes(); -} - -basic_struct::~basic_struct() -{ -} - -basic_struct::basic_struct( - const basic_struct& x) -{ - m_sub_struct = x.m_sub_struct; -} - -basic_struct::basic_struct( - basic_struct&& x) noexcept -{ - m_sub_struct = std::move(x.m_sub_struct); -} - -basic_struct& basic_struct::operator =( - const basic_struct& x) -{ - - m_sub_struct = x.m_sub_struct; - return *this; -} - -basic_struct& basic_struct::operator =( - basic_struct&& x) noexcept -{ - - m_sub_struct = std::move(x.m_sub_struct); - return *this; -} - -bool basic_struct::operator ==( - const basic_struct& x) const -{ - return (m_sub_struct == x.m_sub_struct); -} - -bool basic_struct::operator !=( - const basic_struct& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function copies the value in member sub_struct - * @param _sub_struct New value to be copied in member sub_struct - */ -void basic_struct::sub_struct( - const TheOtherObject& _sub_struct) -{ - m_sub_struct = _sub_struct; -} - -/*! - * @brief This function moves the value in member sub_struct - * @param _sub_struct New value to be moved in member sub_struct - */ -void basic_struct::sub_struct( - TheOtherObject&& _sub_struct) -{ - m_sub_struct = std::move(_sub_struct); -} - -/*! - * @brief This function returns a constant reference to member sub_struct - * @return Constant reference to member sub_struct - */ -const TheOtherObject& basic_struct::sub_struct() const -{ - return m_sub_struct; -} - -/*! - * @brief This function returns a reference to member sub_struct - * @return Reference to member sub_struct - */ -TheOtherObject& basic_struct::sub_struct() -{ - return m_sub_struct; -} - - -// Include auxiliary functions like for serializing/deserializing. -#include "basic_structCdrAux.ipp" - -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structPubSubTypes.cxx deleted file mode 100644 index 8ada3884..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structPubSubTypes.cxx +++ /dev/null @@ -1,411 +0,0 @@ -// 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 basic_structPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#include - -#include "basic_structPubSubTypes.h" -#include "basic_structCdrAux.hpp" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; -using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - - - -TheOtherObjectPubSubType::TheOtherObjectPubSubType() -{ - setName("TheOtherObject"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(TheOtherObject::getMaxCdrSerializedSize()); -#else - TheOtherObject_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = TheOtherObject_max_key_cdr_typesize > 16 ? TheOtherObject_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -TheOtherObjectPubSubType::~TheOtherObjectPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool TheOtherObjectPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - TheOtherObject* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool TheOtherObjectPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - TheOtherObject* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function TheOtherObjectPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* TheOtherObjectPubSubType::createData() -{ - return reinterpret_cast(new TheOtherObject()); -} - -void TheOtherObjectPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool TheOtherObjectPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - TheOtherObject* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - TheOtherObject_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || TheOtherObject_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - - - -basic_structPubSubType::basic_structPubSubType() -{ - setName("basic_struct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(basic_struct::getMaxCdrSerializedSize()); -#else - basic_struct_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = basic_struct_max_key_cdr_typesize > 16 ? basic_struct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -basic_structPubSubType::~basic_structPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool basic_structPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - basic_struct* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool basic_structPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - basic_struct* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function basic_structPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* basic_structPubSubType::createData() -{ - return reinterpret_cast(new basic_struct()); -} - -void basic_structPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool basic_structPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - basic_struct* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - basic_struct_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || basic_struct_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structTypeObject.cxx deleted file mode 100644 index f2c48c12..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structTypeObject.cxx +++ /dev/null @@ -1,411 +0,0 @@ -// 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 basic_structTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { char dummy; } -#endif - -#include "basic_struct.h" -#include "basic_structTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerbasic_structTypes() -{ - static std::once_flag once_flag; - std::call_once(once_flag, []() - { - TypeObjectFactory *factory = TypeObjectFactory::get_instance(); - factory->add_type_object("TheOtherObject", GetTheOtherObjectIdentifier(true), - GetTheOtherObjectObject(true)); - factory->add_type_object("TheOtherObject", GetTheOtherObjectIdentifier(false), - GetTheOtherObjectObject(false)); - - - factory->add_type_object("basic_struct", Getbasic_structIdentifier(true), - Getbasic_structObject(true)); - factory->add_type_object("basic_struct", Getbasic_structIdentifier(false), - Getbasic_structObject(false)); - - }); -} - - - -const TypeIdentifier* GetTheOtherObjectIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("TheOtherObject", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetTheOtherObjectObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("TheOtherObject", complete); -} - -const TypeObject* GetTheOtherObjectObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("TheOtherObject", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteTheOtherObjectObject(); - } - //else - return GetMinimalTheOtherObjectObject(); -} - -const TypeObject* GetMinimalTheOtherObjectObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("TheOtherObject", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_some_num; - mst_some_num.common().member_id(memberId++); - mst_some_num.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_some_num.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_some_num.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_some_num.common().member_flags().IS_OPTIONAL(false); - mst_some_num.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_some_num.common().member_flags().IS_KEY(false); - mst_some_num.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_some_num.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - - - MD5 some_num_hash("some_num"); - for(int i = 0; i < 4; ++i) - { - mst_some_num.detail().name_hash()[i] = some_num_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_some_num); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("TheOtherObject", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("TheOtherObject", false); -} - -const TypeObject* GetCompleteTheOtherObjectObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("TheOtherObject", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_some_num; - cst_some_num.common().member_id(memberId++); - cst_some_num.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_some_num.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_some_num.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_some_num.common().member_flags().IS_OPTIONAL(false); - cst_some_num.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_some_num.common().member_flags().IS_KEY(false); - cst_some_num.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_some_num.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - - - cst_some_num.detail().name("some_num"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_some_num); - - - // Header - type_object->complete().struct_type().header().detail().type_name("TheOtherObject"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("TheOtherObject", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("TheOtherObject", true); -} - - - -const TypeIdentifier* Getbasic_structIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("basic_struct", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - Getbasic_structObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("basic_struct", complete); -} - -const TypeObject* Getbasic_structObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("basic_struct", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompletebasic_structObject(); - } - //else - return GetMinimalbasic_structObject(); -} - -const TypeObject* GetMinimalbasic_structObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("basic_struct", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_sub_struct; - mst_sub_struct.common().member_id(memberId++); - mst_sub_struct.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_sub_struct.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_sub_struct.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_sub_struct.common().member_flags().IS_OPTIONAL(false); - mst_sub_struct.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_sub_struct.common().member_flags().IS_KEY(false); - mst_sub_struct.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_sub_struct.common().member_type_id(*GetTheOtherObjectIdentifier(false)); - - MD5 sub_struct_hash("sub_struct"); - for(int i = 0; i < 4; ++i) - { - mst_sub_struct.detail().name_hash()[i] = sub_struct_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_sub_struct); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("basic_struct", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("basic_struct", false); -} - -const TypeObject* GetCompletebasic_structObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("basic_struct", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_sub_struct; - cst_sub_struct.common().member_id(memberId++); - cst_sub_struct.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_sub_struct.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_sub_struct.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_sub_struct.common().member_flags().IS_OPTIONAL(false); - cst_sub_struct.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_sub_struct.common().member_flags().IS_KEY(false); - cst_sub_struct.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_sub_struct.common().member_type_id(*GetTheOtherObjectIdentifier(true)); - - cst_sub_struct.detail().name("sub_struct"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_sub_struct); - - - // Header - type_object->complete().struct_type().header().detail().type_name("basic_struct"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("basic_struct", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("basic_struct", true); -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structTypeObject.h deleted file mode 100644 index 670cb315..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structTypeObject.h +++ /dev/null @@ -1,72 +0,0 @@ -// 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 basic_structTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_BASIC_STRUCT_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_BASIC_STRUCT_TYPE_OBJECT_H_ - - -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif -#else -#define eProsima_user_DllExport -#endif - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(basic_struct_SOURCE) -#define basic_struct_DllAPI __declspec( dllexport ) -#else -#define basic_struct_DllAPI __declspec( dllimport ) -#endif // basic_struct_SOURCE -#else -#define basic_struct_DllAPI -#endif -#else -#define basic_struct_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registerbasic_structTypes(); - - - -eProsima_user_DllExport const TypeIdentifier* GetTheOtherObjectIdentifier(bool complete = false); -eProsima_user_DllExport const TypeObject* GetTheOtherObjectObject(bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalTheOtherObjectObject(); -eProsima_user_DllExport const TypeObject* GetCompleteTheOtherObjectObject(); - - - -eProsima_user_DllExport const TypeIdentifier* Getbasic_structIdentifier(bool complete = false); -eProsima_user_DllExport const TypeObject* Getbasic_structObject(bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalbasic_structObject(); -eProsima_user_DllExport const TypeObject* GetCompletebasic_structObject(); - - -#endif // _FAST_DDS_GENERATED_BASIC_STRUCT_TYPE_OBJECT_H_ \ No newline at end of file diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structv1.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structv1.cxx deleted file mode 100644 index a485ca50..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structv1.cxx +++ /dev/null @@ -1,373 +0,0 @@ -// 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 basic_struct.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "basic_struct.h" - -#if FASTCDR_VERSION_MAJOR == 1 - -#include "basic_structTypeObject.h" - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - -namespace helper { namespace internal { - -enum class Size { - UInt8, - UInt16, - UInt32, - UInt64, -}; - -constexpr Size get_size(int s) { - return (s <= 8 ) ? Size::UInt8: - (s <= 16) ? Size::UInt16: - (s <= 32) ? Size::UInt32: Size::UInt64; -} - -template -struct FindTypeH; - -template<> -struct FindTypeH { - using type = std::uint8_t; -}; - -template<> -struct FindTypeH { - using type = std::uint16_t; -}; - -template<> -struct FindTypeH { - using type = std::uint32_t; -}; - -template<> -struct FindTypeH { - using type = std::uint64_t; -}; -} - -template -struct FindType { - using type = typename internal::FindTypeH::type; -}; -} - -#define basic_struct_max_cdr_typesize 12ULL; -#define TheOtherObject_max_cdr_typesize 8ULL; - - - - -TheOtherObject::TheOtherObject() -{ - // long m_some_num - m_some_num = 0; - - // Just to register all known types - registerbasic_structTypes(); -} - -TheOtherObject::~TheOtherObject() -{ -} - -TheOtherObject::TheOtherObject( - const TheOtherObject& x) -{ - m_some_num = x.m_some_num; - -} - -TheOtherObject::TheOtherObject( - TheOtherObject&& x) noexcept -{ - m_some_num = x.m_some_num; - -} - -TheOtherObject& TheOtherObject::operator =( - const TheOtherObject& x) -{ - m_some_num = x.m_some_num; - - return *this; -} - -TheOtherObject& TheOtherObject::operator =( - TheOtherObject&& x) noexcept -{ - m_some_num = x.m_some_num; - - return *this; -} - -bool TheOtherObject::operator ==( - const TheOtherObject& x) const -{ - return (m_some_num == x.m_some_num); -} - -bool TheOtherObject::operator !=( - const TheOtherObject& x) const -{ - return !(*this == x); -} - -size_t TheOtherObject::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return TheOtherObject_max_cdr_typesize; -} - -size_t TheOtherObject::getCdrSerializedSize( - const TheOtherObject& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - return current_alignment - initial_alignment; -} - - -void TheOtherObject::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_some_num; - -} - -void TheOtherObject::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_some_num; - - -} - - -bool TheOtherObject::isKeyDefined() -{ - return false; -} - -void TheOtherObject::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function sets a value in member some_num - * @param _some_num New value for member some_num - */ -void TheOtherObject::some_num( - int32_t _some_num) -{ - m_some_num = _some_num; -} - -/*! - * @brief This function returns the value of member some_num - * @return Value of member some_num - */ -int32_t TheOtherObject::some_num() const -{ - return m_some_num; -} - -/*! - * @brief This function returns a reference to member some_num - * @return Reference to member some_num - */ -int32_t& TheOtherObject::some_num() -{ - return m_some_num; -} - - - - - -basic_struct::basic_struct() -{ - // TheOtherObject m_sub_struct - - - // Just to register all known types - registerbasic_structTypes(); -} - -basic_struct::~basic_struct() -{ -} - -basic_struct::basic_struct( - const basic_struct& x) -{ - m_sub_struct = x.m_sub_struct; - -} - -basic_struct::basic_struct( - basic_struct&& x) noexcept -{ - m_sub_struct = std::move(x.m_sub_struct); - -} - -basic_struct& basic_struct::operator =( - const basic_struct& x) -{ - m_sub_struct = x.m_sub_struct; - - return *this; -} - -basic_struct& basic_struct::operator =( - basic_struct&& x) noexcept -{ - m_sub_struct = std::move(x.m_sub_struct); - - return *this; -} - -bool basic_struct::operator ==( - const basic_struct& x) const -{ - return (m_sub_struct == x.m_sub_struct); -} - -bool basic_struct::operator !=( - const basic_struct& x) const -{ - return !(*this == x); -} - -size_t basic_struct::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return basic_struct_max_cdr_typesize; -} - -size_t basic_struct::getCdrSerializedSize( - const basic_struct& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += TheOtherObject::getCdrSerializedSize(data.sub_struct(), current_alignment); - - - return current_alignment - initial_alignment; -} - - -void basic_struct::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_sub_struct; - -} - -void basic_struct::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_sub_struct; - - -} - - -bool basic_struct::isKeyDefined() -{ - return false; -} - -void basic_struct::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function copies the value in member sub_struct - * @param _sub_struct New value to be copied in member sub_struct - */ -void basic_struct::sub_struct( - const TheOtherObject& _sub_struct) -{ - m_sub_struct = _sub_struct; -} - -/*! - * @brief This function moves the value in member sub_struct - * @param _sub_struct New value to be moved in member sub_struct - */ -void basic_struct::sub_struct( - TheOtherObject&& _sub_struct) -{ - m_sub_struct = std::move(_sub_struct); -} - -/*! - * @brief This function returns a constant reference to member sub_struct - * @return Constant reference to member sub_struct - */ -const TheOtherObject& basic_struct::sub_struct() const -{ - return m_sub_struct; -} - -/*! - * @brief This function returns a reference to member sub_struct - * @return Reference to member sub_struct - */ -TheOtherObject& basic_struct::sub_struct() -{ - return m_sub_struct; -} - - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structv1.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structv1.h deleted file mode 100644 index 2e1540cd..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structv1.h +++ /dev/null @@ -1,361 +0,0 @@ -// 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 basic_struct.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#include - -#if FASTCDR_VERSION_MAJOR == 1 - -#ifndef _FAST_DDS_GENERATED_BASIC_STRUCT_H_ -#define _FAST_DDS_GENERATED_BASIC_STRUCT_H_ - - -#include - -#include -#include -#include -#include -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(BASIC_STRUCT_SOURCE) -#define BASIC_STRUCT_DllAPI __declspec( dllexport ) -#else -#define BASIC_STRUCT_DllAPI __declspec( dllimport ) -#endif // BASIC_STRUCT_SOURCE -#else -#define BASIC_STRUCT_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define BASIC_STRUCT_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - - - - -/*! - * @brief This class represents the structure TheOtherObject defined by the user in the IDL file. - * @ingroup basic_struct - */ -class TheOtherObject -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport TheOtherObject(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~TheOtherObject(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object TheOtherObject that will be copied. - */ - eProsima_user_DllExport TheOtherObject( - const TheOtherObject& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object TheOtherObject that will be copied. - */ - eProsima_user_DllExport TheOtherObject( - TheOtherObject&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object TheOtherObject that will be copied. - */ - eProsima_user_DllExport TheOtherObject& operator =( - const TheOtherObject& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object TheOtherObject that will be copied. - */ - eProsima_user_DllExport TheOtherObject& operator =( - TheOtherObject&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x TheOtherObject object to compare. - */ - eProsima_user_DllExport bool operator ==( - const TheOtherObject& x) const; - - /*! - * @brief Comparison operator. - * @param x TheOtherObject object to compare. - */ - eProsima_user_DllExport bool operator !=( - const TheOtherObject& x) const; - - /*! - * @brief This function sets a value in member some_num - * @param _some_num New value for member some_num - */ - eProsima_user_DllExport void some_num( - int32_t _some_num); - - /*! - * @brief This function returns the value of member some_num - * @return Value of member some_num - */ - eProsima_user_DllExport int32_t some_num() const; - - /*! - * @brief This function returns a reference to member some_num - * @return Reference to member some_num - */ - eProsima_user_DllExport int32_t& some_num(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const TheOtherObject& data, - size_t current_alignment = 0); - - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - - -private: - - int32_t m_some_num; - -}; - - - -/*! - * @brief This class represents the structure basic_struct defined by the user in the IDL file. - * @ingroup basic_struct - */ -class basic_struct -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport basic_struct(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~basic_struct(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object basic_struct that will be copied. - */ - eProsima_user_DllExport basic_struct( - const basic_struct& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object basic_struct that will be copied. - */ - eProsima_user_DllExport basic_struct( - basic_struct&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object basic_struct that will be copied. - */ - eProsima_user_DllExport basic_struct& operator =( - const basic_struct& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object basic_struct that will be copied. - */ - eProsima_user_DllExport basic_struct& operator =( - basic_struct&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x basic_struct object to compare. - */ - eProsima_user_DllExport bool operator ==( - const basic_struct& x) const; - - /*! - * @brief Comparison operator. - * @param x basic_struct object to compare. - */ - eProsima_user_DllExport bool operator !=( - const basic_struct& x) const; - - /*! - * @brief This function copies the value in member sub_struct - * @param _sub_struct New value to be copied in member sub_struct - */ - eProsima_user_DllExport void sub_struct( - const TheOtherObject& _sub_struct); - - /*! - * @brief This function moves the value in member sub_struct - * @param _sub_struct New value to be moved in member sub_struct - */ - eProsima_user_DllExport void sub_struct( - TheOtherObject&& _sub_struct); - - /*! - * @brief This function returns a constant reference to member sub_struct - * @return Constant reference to member sub_struct - */ - eProsima_user_DllExport const TheOtherObject& sub_struct() const; - - /*! - * @brief This function returns a reference to member sub_struct - * @return Reference to member sub_struct - */ - eProsima_user_DllExport TheOtherObject& sub_struct(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const basic_struct& data, - size_t current_alignment = 0); - - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - - -private: - - TheOtherObject m_sub_struct; - -}; - - -#endif // _FAST_DDS_GENERATED_BASIC_STRUCT_H_ - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequence.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequence.cxx deleted file mode 100644 index 807a8835..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequence.cxx +++ /dev/null @@ -1,140 +0,0 @@ -// 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 char_sequence.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "char_sequence.h" - -#if FASTCDR_VERSION_MAJOR > 1 - -#include "char_sequenceTypeObject.h" - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - - - - - - -char_sequence::char_sequence() -{ - // Just to register all known types - registerchar_sequenceTypes(); -} - -char_sequence::~char_sequence() -{ -} - -char_sequence::char_sequence( - const char_sequence& x) -{ - m_chars = x.m_chars; -} - -char_sequence::char_sequence( - char_sequence&& x) noexcept -{ - m_chars = std::move(x.m_chars); -} - -char_sequence& char_sequence::operator =( - const char_sequence& x) -{ - - m_chars = x.m_chars; - return *this; -} - -char_sequence& char_sequence::operator =( - char_sequence&& x) noexcept -{ - - m_chars = std::move(x.m_chars); - return *this; -} - -bool char_sequence::operator ==( - const char_sequence& x) const -{ - return (m_chars == x.m_chars); -} - -bool char_sequence::operator !=( - const char_sequence& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function copies the value in member chars - * @param _chars New value to be copied in member chars - */ -void char_sequence::chars( - const std::vector& _chars) -{ - m_chars = _chars; -} - -/*! - * @brief This function moves the value in member chars - * @param _chars New value to be moved in member chars - */ -void char_sequence::chars( - std::vector&& _chars) -{ - m_chars = std::move(_chars); -} - -/*! - * @brief This function returns a constant reference to member chars - * @return Constant reference to member chars - */ -const std::vector& char_sequence::chars() const -{ - return m_chars; -} - -/*! - * @brief This function returns a reference to member chars - * @return Reference to member chars - */ -std::vector& char_sequence::chars() -{ - return m_chars; -} - - -// Include auxiliary functions like for serializing/deserializing. -#include "char_sequenceCdrAux.ipp" - -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequenceTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequenceTypeObject.cxx deleted file mode 100644 index 77600c44..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequenceTypeObject.cxx +++ /dev/null @@ -1,230 +0,0 @@ -// 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 char_sequenceTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { char dummy; } -#endif - -#include "char_sequence.h" -#include "char_sequenceTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerchar_sequenceTypes() -{ - static std::once_flag once_flag; - std::call_once(once_flag, []() - { - TypeObjectFactory *factory = TypeObjectFactory::get_instance(); - factory->add_type_object("char_sequence", Getchar_sequenceIdentifier(true), - Getchar_sequenceObject(true)); - factory->add_type_object("char_sequence", Getchar_sequenceIdentifier(false), - Getchar_sequenceObject(false)); - - }); -} - - - - - -const TypeIdentifier* Getchar_sequenceIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("char_sequence", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - Getchar_sequenceObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("char_sequence", complete); -} - -const TypeObject* Getchar_sequenceObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("char_sequence", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompletechar_sequenceObject(); - } - //else - return GetMinimalchar_sequenceObject(); -} - -const TypeObject* GetMinimalchar_sequenceObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("char_sequence", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_chars; - mst_chars.common().member_id(memberId++); - mst_chars.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_chars.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_chars.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_chars.common().member_flags().IS_OPTIONAL(false); - mst_chars.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_chars.common().member_flags().IS_KEY(false); - mst_chars.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_chars.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("char", 0, false)); - - MD5 chars_hash("chars"); - for(int i = 0; i < 4; ++i) - { - mst_chars.detail().name_hash()[i] = chars_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_chars); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("char_sequence", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("char_sequence", false); -} - -const TypeObject* GetCompletechar_sequenceObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("char_sequence", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_chars; - cst_chars.common().member_id(memberId++); - cst_chars.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_chars.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_chars.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_chars.common().member_flags().IS_OPTIONAL(false); - cst_chars.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_chars.common().member_flags().IS_KEY(false); - cst_chars.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_chars.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("char", 0, true)); - - cst_chars.detail().name("chars"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_chars); - - - // Header - type_object->complete().struct_type().header().detail().type_name("char_sequence"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("char_sequence", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("char_sequence", true); -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequenceTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequenceTypeObject.h deleted file mode 100644 index 4bcf2209..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequenceTypeObject.h +++ /dev/null @@ -1,67 +0,0 @@ -// 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 char_sequenceTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_CHAR_SEQUENCE_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_CHAR_SEQUENCE_TYPE_OBJECT_H_ - - -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif -#else -#define eProsima_user_DllExport -#endif - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(char_sequence_SOURCE) -#define char_sequence_DllAPI __declspec( dllexport ) -#else -#define char_sequence_DllAPI __declspec( dllimport ) -#endif // char_sequence_SOURCE -#else -#define char_sequence_DllAPI -#endif -#else -#define char_sequence_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registerchar_sequenceTypes(); - - - - - -eProsima_user_DllExport const TypeIdentifier* Getchar_sequenceIdentifier(bool complete = false); -eProsima_user_DllExport const TypeObject* Getchar_sequenceObject(bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalchar_sequenceObject(); -eProsima_user_DllExport const TypeObject* GetCompletechar_sequenceObject(); - - -#endif // _FAST_DDS_GENERATED_CHAR_SEQUENCE_TYPE_OBJECT_H_ \ No newline at end of file diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequencev1.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequencev1.cxx deleted file mode 100644 index dde0c072..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequencev1.cxx +++ /dev/null @@ -1,247 +0,0 @@ -// 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 char_sequence.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "char_sequence.h" - -#if FASTCDR_VERSION_MAJOR == 1 - -#include "char_sequenceTypeObject.h" - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - -namespace helper { namespace internal { - -enum class Size { - UInt8, - UInt16, - UInt32, - UInt64, -}; - -constexpr Size get_size(int s) { - return (s <= 8 ) ? Size::UInt8: - (s <= 16) ? Size::UInt16: - (s <= 32) ? Size::UInt32: Size::UInt64; -} - -template -struct FindTypeH; - -template<> -struct FindTypeH { - using type = std::uint8_t; -}; - -template<> -struct FindTypeH { - using type = std::uint16_t; -}; - -template<> -struct FindTypeH { - using type = std::uint32_t; -}; - -template<> -struct FindTypeH { - using type = std::uint64_t; -}; -} - -template -struct FindType { - using type = typename internal::FindTypeH::type; -}; -} - -#define char_sequence_max_cdr_typesize 8ULL; - - - - - - -char_sequence::char_sequence() -{ - // sequence m_chars - - - // Just to register all known types - registerchar_sequenceTypes(); -} - -char_sequence::~char_sequence() -{ -} - -char_sequence::char_sequence( - const char_sequence& x) -{ - m_chars = x.m_chars; - -} - -char_sequence::char_sequence( - char_sequence&& x) noexcept -{ - m_chars = std::move(x.m_chars); - -} - -char_sequence& char_sequence::operator =( - const char_sequence& x) -{ - m_chars = x.m_chars; - - return *this; -} - -char_sequence& char_sequence::operator =( - char_sequence&& x) noexcept -{ - m_chars = std::move(x.m_chars); - - return *this; -} - -bool char_sequence::operator ==( - const char_sequence& x) const -{ - return (m_chars == x.m_chars); -} - -bool char_sequence::operator !=( - const char_sequence& x) const -{ - return !(*this == x); -} - -size_t char_sequence::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return char_sequence_max_cdr_typesize; -} - -size_t char_sequence::getCdrSerializedSize( - const char_sequence& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - if (data.chars().size() > 0) - { - current_alignment += (data.chars().size() * 1) + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); - } - - - - - return current_alignment - initial_alignment; -} - - -void char_sequence::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_chars; - - -} - -void char_sequence::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_chars; - - -} - - -bool char_sequence::isKeyDefined() -{ - return false; -} - -void char_sequence::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function copies the value in member chars - * @param _chars New value to be copied in member chars - */ -void char_sequence::chars( - const std::vector& _chars) -{ - m_chars = _chars; -} - -/*! - * @brief This function moves the value in member chars - * @param _chars New value to be moved in member chars - */ -void char_sequence::chars( - std::vector&& _chars) -{ - m_chars = std::move(_chars); -} - -/*! - * @brief This function returns a constant reference to member chars - * @return Constant reference to member chars - */ -const std::vector& char_sequence::chars() const -{ - return m_chars; -} - -/*! - * @brief This function returns a reference to member chars - * @return Reference to member chars - */ -std::vector& char_sequence::chars() -{ - return m_chars; -} - - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequencev1.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequencev1.h deleted file mode 100644 index d091c583..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequencev1.h +++ /dev/null @@ -1,224 +0,0 @@ -// 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 char_sequence.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#include - -#if FASTCDR_VERSION_MAJOR == 1 - -#ifndef _FAST_DDS_GENERATED_CHAR_SEQUENCE_H_ -#define _FAST_DDS_GENERATED_CHAR_SEQUENCE_H_ - - -#include - -#include -#include -#include -#include -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(CHAR_SEQUENCE_SOURCE) -#define CHAR_SEQUENCE_DllAPI __declspec( dllexport ) -#else -#define CHAR_SEQUENCE_DllAPI __declspec( dllimport ) -#endif // CHAR_SEQUENCE_SOURCE -#else -#define CHAR_SEQUENCE_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define CHAR_SEQUENCE_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - - - - - - -/*! - * @brief This class represents the structure char_sequence defined by the user in the IDL file. - * @ingroup char_sequence - */ -class char_sequence -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport char_sequence(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~char_sequence(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object char_sequence that will be copied. - */ - eProsima_user_DllExport char_sequence( - const char_sequence& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object char_sequence that will be copied. - */ - eProsima_user_DllExport char_sequence( - char_sequence&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object char_sequence that will be copied. - */ - eProsima_user_DllExport char_sequence& operator =( - const char_sequence& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object char_sequence that will be copied. - */ - eProsima_user_DllExport char_sequence& operator =( - char_sequence&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x char_sequence object to compare. - */ - eProsima_user_DllExport bool operator ==( - const char_sequence& x) const; - - /*! - * @brief Comparison operator. - * @param x char_sequence object to compare. - */ - eProsima_user_DllExport bool operator !=( - const char_sequence& x) const; - - /*! - * @brief This function copies the value in member chars - * @param _chars New value to be copied in member chars - */ - eProsima_user_DllExport void chars( - const std::vector& _chars); - - /*! - * @brief This function moves the value in member chars - * @param _chars New value to be moved in member chars - */ - eProsima_user_DllExport void chars( - std::vector&& _chars); - - /*! - * @brief This function returns a constant reference to member chars - * @return Constant reference to member chars - */ - eProsima_user_DllExport const std::vector& chars() const; - - /*! - * @brief This function returns a reference to member chars - * @return Reference to member chars - */ - eProsima_user_DllExport std::vector& chars(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const char_sequence& data, - size_t current_alignment = 0); - - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - - -private: - - std::vector m_chars; - -}; - - -#endif // _FAST_DDS_GENERATED_CHAR_SEQUENCE_H_ - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arrays.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arrays.cxx deleted file mode 100644 index 278d065a..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arrays.cxx +++ /dev/null @@ -1,569 +0,0 @@ -// 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 complex_nested_arrays.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "complex_nested_arrays.h" - -#if FASTCDR_VERSION_MAJOR > 1 - -#include "complex_nested_arraysTypeObject.h" - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - - - - -ThirdLevelElement::ThirdLevelElement() -{ - // Just to register all known types - registercomplex_nested_arraysTypes(); -} - -ThirdLevelElement::~ThirdLevelElement() -{ -} - -ThirdLevelElement::ThirdLevelElement( - const ThirdLevelElement& x) -{ - m_x = x.m_x; - m_y = x.m_y; -} - -ThirdLevelElement::ThirdLevelElement( - ThirdLevelElement&& x) noexcept -{ - m_x = x.m_x; - m_y = x.m_y; -} - -ThirdLevelElement& ThirdLevelElement::operator =( - const ThirdLevelElement& x) -{ - - m_x = x.m_x; - m_y = x.m_y; - return *this; -} - -ThirdLevelElement& ThirdLevelElement::operator =( - ThirdLevelElement&& x) noexcept -{ - - m_x = x.m_x; - m_y = x.m_y; - return *this; -} - -bool ThirdLevelElement::operator ==( - const ThirdLevelElement& x) const -{ - return (m_x == x.m_x && - m_y == x.m_y); -} - -bool ThirdLevelElement::operator !=( - const ThirdLevelElement& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function sets a value in member x - * @param _x New value for member x - */ -void ThirdLevelElement::x( - double _x) -{ - m_x = _x; -} - -/*! - * @brief This function returns the value of member x - * @return Value of member x - */ -double ThirdLevelElement::x() const -{ - return m_x; -} - -/*! - * @brief This function returns a reference to member x - * @return Reference to member x - */ -double& ThirdLevelElement::x() -{ - return m_x; -} - - -/*! - * @brief This function sets a value in member y - * @param _y New value for member y - */ -void ThirdLevelElement::y( - double _y) -{ - m_y = _y; -} - -/*! - * @brief This function returns the value of member y - * @return Value of member y - */ -double ThirdLevelElement::y() const -{ - return m_y; -} - -/*! - * @brief This function returns a reference to member y - * @return Reference to member y - */ -double& ThirdLevelElement::y() -{ - return m_y; -} - - - - - - -SecondLevelElement::SecondLevelElement() -{ - // Just to register all known types - registercomplex_nested_arraysTypes(); -} - -SecondLevelElement::~SecondLevelElement() -{ -} - -SecondLevelElement::SecondLevelElement( - const SecondLevelElement& x) -{ - m_an_element_alone = x.m_an_element_alone; - m_a_limited_other_value = x.m_a_limited_other_value; -} - -SecondLevelElement::SecondLevelElement( - SecondLevelElement&& x) noexcept -{ - m_an_element_alone = std::move(x.m_an_element_alone); - m_a_limited_other_value = std::move(x.m_a_limited_other_value); -} - -SecondLevelElement& SecondLevelElement::operator =( - const SecondLevelElement& x) -{ - - m_an_element_alone = x.m_an_element_alone; - m_a_limited_other_value = x.m_a_limited_other_value; - return *this; -} - -SecondLevelElement& SecondLevelElement::operator =( - SecondLevelElement&& x) noexcept -{ - - m_an_element_alone = std::move(x.m_an_element_alone); - m_a_limited_other_value = std::move(x.m_a_limited_other_value); - return *this; -} - -bool SecondLevelElement::operator ==( - const SecondLevelElement& x) const -{ - return (m_an_element_alone == x.m_an_element_alone && - m_a_limited_other_value == x.m_a_limited_other_value); -} - -bool SecondLevelElement::operator !=( - const SecondLevelElement& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function copies the value in member an_element_alone - * @param _an_element_alone New value to be copied in member an_element_alone - */ -void SecondLevelElement::an_element_alone( - const ThirdLevelElement& _an_element_alone) -{ - m_an_element_alone = _an_element_alone; -} - -/*! - * @brief This function moves the value in member an_element_alone - * @param _an_element_alone New value to be moved in member an_element_alone - */ -void SecondLevelElement::an_element_alone( - ThirdLevelElement&& _an_element_alone) -{ - m_an_element_alone = std::move(_an_element_alone); -} - -/*! - * @brief This function returns a constant reference to member an_element_alone - * @return Constant reference to member an_element_alone - */ -const ThirdLevelElement& SecondLevelElement::an_element_alone() const -{ - return m_an_element_alone; -} - -/*! - * @brief This function returns a reference to member an_element_alone - * @return Reference to member an_element_alone - */ -ThirdLevelElement& SecondLevelElement::an_element_alone() -{ - return m_an_element_alone; -} - - -/*! - * @brief This function copies the value in member a_limited_other_value - * @param _a_limited_other_value New value to be copied in member a_limited_other_value - */ -void SecondLevelElement::a_limited_other_value( - const std::vector& _a_limited_other_value) -{ - m_a_limited_other_value = _a_limited_other_value; -} - -/*! - * @brief This function moves the value in member a_limited_other_value - * @param _a_limited_other_value New value to be moved in member a_limited_other_value - */ -void SecondLevelElement::a_limited_other_value( - std::vector&& _a_limited_other_value) -{ - m_a_limited_other_value = std::move(_a_limited_other_value); -} - -/*! - * @brief This function returns a constant reference to member a_limited_other_value - * @return Constant reference to member a_limited_other_value - */ -const std::vector& SecondLevelElement::a_limited_other_value() const -{ - return m_a_limited_other_value; -} - -/*! - * @brief This function returns a reference to member a_limited_other_value - * @return Reference to member a_limited_other_value - */ -std::vector& SecondLevelElement::a_limited_other_value() -{ - return m_a_limited_other_value; -} - - - - -FirstLevelElement::FirstLevelElement() -{ - // Just to register all known types - registercomplex_nested_arraysTypes(); -} - -FirstLevelElement::~FirstLevelElement() -{ -} - -FirstLevelElement::FirstLevelElement( - const FirstLevelElement& x) -{ - m_useless_name = x.m_useless_name; - m_sub = x.m_sub; - m_an_element_alone = x.m_an_element_alone; -} - -FirstLevelElement::FirstLevelElement( - FirstLevelElement&& x) noexcept -{ - m_useless_name = std::move(x.m_useless_name); - m_sub = std::move(x.m_sub); - m_an_element_alone = std::move(x.m_an_element_alone); -} - -FirstLevelElement& FirstLevelElement::operator =( - const FirstLevelElement& x) -{ - - m_useless_name = x.m_useless_name; - m_sub = x.m_sub; - m_an_element_alone = x.m_an_element_alone; - return *this; -} - -FirstLevelElement& FirstLevelElement::operator =( - FirstLevelElement&& x) noexcept -{ - - m_useless_name = std::move(x.m_useless_name); - m_sub = std::move(x.m_sub); - m_an_element_alone = std::move(x.m_an_element_alone); - return *this; -} - -bool FirstLevelElement::operator ==( - const FirstLevelElement& x) const -{ - return (m_useless_name == x.m_useless_name && - m_sub == x.m_sub && - m_an_element_alone == x.m_an_element_alone); -} - -bool FirstLevelElement::operator !=( - const FirstLevelElement& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function copies the value in member useless_name - * @param _useless_name New value to be copied in member useless_name - */ -void FirstLevelElement::useless_name( - const std::string& _useless_name) -{ - m_useless_name = _useless_name; -} - -/*! - * @brief This function moves the value in member useless_name - * @param _useless_name New value to be moved in member useless_name - */ -void FirstLevelElement::useless_name( - std::string&& _useless_name) -{ - m_useless_name = std::move(_useless_name); -} - -/*! - * @brief This function returns a constant reference to member useless_name - * @return Constant reference to member useless_name - */ -const std::string& FirstLevelElement::useless_name() const -{ - return m_useless_name; -} - -/*! - * @brief This function returns a reference to member useless_name - * @return Reference to member useless_name - */ -std::string& FirstLevelElement::useless_name() -{ - return m_useless_name; -} - - -/*! - * @brief This function copies the value in member sub - * @param _sub New value to be copied in member sub - */ -void FirstLevelElement::sub( - const std::vector& _sub) -{ - m_sub = _sub; -} - -/*! - * @brief This function moves the value in member sub - * @param _sub New value to be moved in member sub - */ -void FirstLevelElement::sub( - std::vector&& _sub) -{ - m_sub = std::move(_sub); -} - -/*! - * @brief This function returns a constant reference to member sub - * @return Constant reference to member sub - */ -const std::vector& FirstLevelElement::sub() const -{ - return m_sub; -} - -/*! - * @brief This function returns a reference to member sub - * @return Reference to member sub - */ -std::vector& FirstLevelElement::sub() -{ - return m_sub; -} - - -/*! - * @brief This function copies the value in member an_element_alone - * @param _an_element_alone New value to be copied in member an_element_alone - */ -void FirstLevelElement::an_element_alone( - const ThirdLevelElement& _an_element_alone) -{ - m_an_element_alone = _an_element_alone; -} - -/*! - * @brief This function moves the value in member an_element_alone - * @param _an_element_alone New value to be moved in member an_element_alone - */ -void FirstLevelElement::an_element_alone( - ThirdLevelElement&& _an_element_alone) -{ - m_an_element_alone = std::move(_an_element_alone); -} - -/*! - * @brief This function returns a constant reference to member an_element_alone - * @return Constant reference to member an_element_alone - */ -const ThirdLevelElement& FirstLevelElement::an_element_alone() const -{ - return m_an_element_alone; -} - -/*! - * @brief This function returns a reference to member an_element_alone - * @return Reference to member an_element_alone - */ -ThirdLevelElement& FirstLevelElement::an_element_alone() -{ - return m_an_element_alone; -} - - - - -complex_nested_arrays::complex_nested_arrays() -{ - // Just to register all known types - registercomplex_nested_arraysTypes(); -} - -complex_nested_arrays::~complex_nested_arrays() -{ -} - -complex_nested_arrays::complex_nested_arrays( - const complex_nested_arrays& x) -{ - m_array_of_elements = x.m_array_of_elements; -} - -complex_nested_arrays::complex_nested_arrays( - complex_nested_arrays&& x) noexcept -{ - m_array_of_elements = std::move(x.m_array_of_elements); -} - -complex_nested_arrays& complex_nested_arrays::operator =( - const complex_nested_arrays& x) -{ - - m_array_of_elements = x.m_array_of_elements; - return *this; -} - -complex_nested_arrays& complex_nested_arrays::operator =( - complex_nested_arrays&& x) noexcept -{ - - m_array_of_elements = std::move(x.m_array_of_elements); - return *this; -} - -bool complex_nested_arrays::operator ==( - const complex_nested_arrays& x) const -{ - return (m_array_of_elements == x.m_array_of_elements); -} - -bool complex_nested_arrays::operator !=( - const complex_nested_arrays& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function copies the value in member array_of_elements - * @param _array_of_elements New value to be copied in member array_of_elements - */ -void complex_nested_arrays::array_of_elements( - const std::array& _array_of_elements) -{ - m_array_of_elements = _array_of_elements; -} - -/*! - * @brief This function moves the value in member array_of_elements - * @param _array_of_elements New value to be moved in member array_of_elements - */ -void complex_nested_arrays::array_of_elements( - std::array&& _array_of_elements) -{ - m_array_of_elements = std::move(_array_of_elements); -} - -/*! - * @brief This function returns a constant reference to member array_of_elements - * @return Constant reference to member array_of_elements - */ -const std::array& complex_nested_arrays::array_of_elements() const -{ - return m_array_of_elements; -} - -/*! - * @brief This function returns a reference to member array_of_elements - * @return Reference to member array_of_elements - */ -std::array& complex_nested_arrays::array_of_elements() -{ - return m_array_of_elements; -} - - -// Include auxiliary functions like for serializing/deserializing. -#include "complex_nested_arraysCdrAux.ipp" - -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysPubSubTypes.cxx deleted file mode 100644 index 9b559a33..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysPubSubTypes.cxx +++ /dev/null @@ -1,793 +0,0 @@ -// 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 complex_nested_arraysPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#include - -#include "complex_nested_arraysPubSubTypes.h" -#include "complex_nested_arraysCdrAux.hpp" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; -using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - - - -ThirdLevelElementPubSubType::ThirdLevelElementPubSubType() -{ - setName("ThirdLevelElement"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ThirdLevelElement::getMaxCdrSerializedSize()); -#else - ThirdLevelElement_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ThirdLevelElement_max_key_cdr_typesize > 16 ? ThirdLevelElement_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -ThirdLevelElementPubSubType::~ThirdLevelElementPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool ThirdLevelElementPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - ThirdLevelElement* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool ThirdLevelElementPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - ThirdLevelElement* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function ThirdLevelElementPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ThirdLevelElementPubSubType::createData() -{ - return reinterpret_cast(new ThirdLevelElement()); -} - -void ThirdLevelElementPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool ThirdLevelElementPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - ThirdLevelElement* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - ThirdLevelElement_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || ThirdLevelElement_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - - - - - -SecondLevelElementPubSubType::SecondLevelElementPubSubType() -{ - setName("SecondLevelElement"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(SecondLevelElement::getMaxCdrSerializedSize()); -#else - SecondLevelElement_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = SecondLevelElement_max_key_cdr_typesize > 16 ? SecondLevelElement_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -SecondLevelElementPubSubType::~SecondLevelElementPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool SecondLevelElementPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - SecondLevelElement* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool SecondLevelElementPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - SecondLevelElement* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function SecondLevelElementPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* SecondLevelElementPubSubType::createData() -{ - return reinterpret_cast(new SecondLevelElement()); -} - -void SecondLevelElementPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool SecondLevelElementPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - SecondLevelElement* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - SecondLevelElement_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || SecondLevelElement_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - - - -FirstLevelElementPubSubType::FirstLevelElementPubSubType() -{ - setName("FirstLevelElement"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(FirstLevelElement::getMaxCdrSerializedSize()); -#else - FirstLevelElement_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = FirstLevelElement_max_key_cdr_typesize > 16 ? FirstLevelElement_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -FirstLevelElementPubSubType::~FirstLevelElementPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool FirstLevelElementPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - FirstLevelElement* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool FirstLevelElementPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - FirstLevelElement* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function FirstLevelElementPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* FirstLevelElementPubSubType::createData() -{ - return reinterpret_cast(new FirstLevelElement()); -} - -void FirstLevelElementPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool FirstLevelElementPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - FirstLevelElement* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - FirstLevelElement_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || FirstLevelElement_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - - - -complex_nested_arraysPubSubType::complex_nested_arraysPubSubType() -{ - setName("complex_nested_arrays"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(complex_nested_arrays::getMaxCdrSerializedSize()); -#else - complex_nested_arrays_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = complex_nested_arrays_max_key_cdr_typesize > 16 ? complex_nested_arrays_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -complex_nested_arraysPubSubType::~complex_nested_arraysPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool complex_nested_arraysPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - complex_nested_arrays* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool complex_nested_arraysPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - complex_nested_arrays* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function complex_nested_arraysPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* complex_nested_arraysPubSubType::createData() -{ - return reinterpret_cast(new complex_nested_arrays()); -} - -void complex_nested_arraysPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool complex_nested_arraysPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - complex_nested_arrays* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - complex_nested_arrays_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || complex_nested_arrays_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysTypeObject.cxx deleted file mode 100644 index c26317f6..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysTypeObject.cxx +++ /dev/null @@ -1,909 +0,0 @@ -// 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 complex_nested_arraysTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { char dummy; } -#endif - -#include "complex_nested_arrays.h" -#include "complex_nested_arraysTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registercomplex_nested_arraysTypes() -{ - static std::once_flag once_flag; - std::call_once(once_flag, []() - { - TypeObjectFactory *factory = TypeObjectFactory::get_instance(); - factory->add_type_object("ThirdLevelElement", GetThirdLevelElementIdentifier(true), - GetThirdLevelElementObject(true)); - factory->add_type_object("ThirdLevelElement", GetThirdLevelElementIdentifier(false), - GetThirdLevelElementObject(false)); - - - factory->add_type_object("SecondLevelElement", GetSecondLevelElementIdentifier(true), - GetSecondLevelElementObject(true)); - factory->add_type_object("SecondLevelElement", GetSecondLevelElementIdentifier(false), - GetSecondLevelElementObject(false)); - - - factory->add_type_object("FirstLevelElement", GetFirstLevelElementIdentifier(true), - GetFirstLevelElementObject(true)); - factory->add_type_object("FirstLevelElement", GetFirstLevelElementIdentifier(false), - GetFirstLevelElementObject(false)); - - - factory->add_type_object("complex_nested_arrays", Getcomplex_nested_arraysIdentifier(true), - Getcomplex_nested_arraysObject(true)); - factory->add_type_object("complex_nested_arrays", Getcomplex_nested_arraysIdentifier(false), - Getcomplex_nested_arraysObject(false)); - - }); -} - - - -const TypeIdentifier* GetThirdLevelElementIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("ThirdLevelElement", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetThirdLevelElementObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("ThirdLevelElement", complete); -} - -const TypeObject* GetThirdLevelElementObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("ThirdLevelElement", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteThirdLevelElementObject(); - } - //else - return GetMinimalThirdLevelElementObject(); -} - -const TypeObject* GetMinimalThirdLevelElementObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("ThirdLevelElement", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_x; - mst_x.common().member_id(memberId++); - mst_x.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_x.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_x.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_x.common().member_flags().IS_OPTIONAL(false); - mst_x.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_x.common().member_flags().IS_KEY(false); - mst_x.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_x.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("double", false)); - - - MD5 x_hash("x"); - for(int i = 0; i < 4; ++i) - { - mst_x.detail().name_hash()[i] = x_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_x); - - MinimalStructMember mst_y; - mst_y.common().member_id(memberId++); - mst_y.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_y.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_y.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_y.common().member_flags().IS_OPTIONAL(false); - mst_y.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_y.common().member_flags().IS_KEY(false); - mst_y.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_y.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("double", false)); - - - MD5 y_hash("y"); - for(int i = 0; i < 4; ++i) - { - mst_y.detail().name_hash()[i] = y_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_y); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("ThirdLevelElement", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("ThirdLevelElement", false); -} - -const TypeObject* GetCompleteThirdLevelElementObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("ThirdLevelElement", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_x; - cst_x.common().member_id(memberId++); - cst_x.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_x.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_x.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_x.common().member_flags().IS_OPTIONAL(false); - cst_x.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_x.common().member_flags().IS_KEY(false); - cst_x.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_x.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("double", false)); - - - cst_x.detail().name("x"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_x); - - CompleteStructMember cst_y; - cst_y.common().member_id(memberId++); - cst_y.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_y.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_y.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_y.common().member_flags().IS_OPTIONAL(false); - cst_y.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_y.common().member_flags().IS_KEY(false); - cst_y.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_y.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("double", false)); - - - cst_y.detail().name("y"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_y); - - - // Header - type_object->complete().struct_type().header().detail().type_name("ThirdLevelElement"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("ThirdLevelElement", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("ThirdLevelElement", true); -} - - - - - -const TypeIdentifier* GetSecondLevelElementIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("SecondLevelElement", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetSecondLevelElementObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("SecondLevelElement", complete); -} - -const TypeObject* GetSecondLevelElementObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("SecondLevelElement", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteSecondLevelElementObject(); - } - //else - return GetMinimalSecondLevelElementObject(); -} - -const TypeObject* GetMinimalSecondLevelElementObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("SecondLevelElement", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_an_element_alone; - mst_an_element_alone.common().member_id(memberId++); - mst_an_element_alone.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_an_element_alone.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_an_element_alone.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_an_element_alone.common().member_flags().IS_OPTIONAL(false); - mst_an_element_alone.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_an_element_alone.common().member_flags().IS_KEY(false); - mst_an_element_alone.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_an_element_alone.common().member_type_id(*GetThirdLevelElementIdentifier(false)); - - MD5 an_element_alone_hash("an_element_alone"); - for(int i = 0; i < 4; ++i) - { - mst_an_element_alone.detail().name_hash()[i] = an_element_alone_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_an_element_alone); - - MinimalStructMember mst_a_limited_other_value; - mst_a_limited_other_value.common().member_id(memberId++); - mst_a_limited_other_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_a_limited_other_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_a_limited_other_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_a_limited_other_value.common().member_flags().IS_OPTIONAL(false); - mst_a_limited_other_value.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_a_limited_other_value.common().member_flags().IS_KEY(false); - mst_a_limited_other_value.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_a_limited_other_value.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("ThirdLevelElement", 1, false)); - - MD5 a_limited_other_value_hash("a_limited_other_value"); - for(int i = 0; i < 4; ++i) - { - mst_a_limited_other_value.detail().name_hash()[i] = a_limited_other_value_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_a_limited_other_value); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("SecondLevelElement", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("SecondLevelElement", false); -} - -const TypeObject* GetCompleteSecondLevelElementObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("SecondLevelElement", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_an_element_alone; - cst_an_element_alone.common().member_id(memberId++); - cst_an_element_alone.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_an_element_alone.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_an_element_alone.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_an_element_alone.common().member_flags().IS_OPTIONAL(false); - cst_an_element_alone.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_an_element_alone.common().member_flags().IS_KEY(false); - cst_an_element_alone.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_an_element_alone.common().member_type_id(*GetThirdLevelElementIdentifier(true)); - - cst_an_element_alone.detail().name("an_element_alone"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_an_element_alone); - - CompleteStructMember cst_a_limited_other_value; - cst_a_limited_other_value.common().member_id(memberId++); - cst_a_limited_other_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_a_limited_other_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_a_limited_other_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_a_limited_other_value.common().member_flags().IS_OPTIONAL(false); - cst_a_limited_other_value.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_a_limited_other_value.common().member_flags().IS_KEY(false); - cst_a_limited_other_value.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_a_limited_other_value.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("ThirdLevelElement", 1, true)); - - cst_a_limited_other_value.detail().name("a_limited_other_value"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_a_limited_other_value); - - - // Header - type_object->complete().struct_type().header().detail().type_name("SecondLevelElement"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("SecondLevelElement", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("SecondLevelElement", true); -} - - - -const TypeIdentifier* GetFirstLevelElementIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("FirstLevelElement", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetFirstLevelElementObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("FirstLevelElement", complete); -} - -const TypeObject* GetFirstLevelElementObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("FirstLevelElement", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteFirstLevelElementObject(); - } - //else - return GetMinimalFirstLevelElementObject(); -} - -const TypeObject* GetMinimalFirstLevelElementObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("FirstLevelElement", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_useless_name; - mst_useless_name.common().member_id(memberId++); - mst_useless_name.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_useless_name.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_useless_name.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_useless_name.common().member_flags().IS_OPTIONAL(false); - mst_useless_name.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_useless_name.common().member_flags().IS_KEY(false); - mst_useless_name.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_useless_name.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - MD5 useless_name_hash("useless_name"); - for(int i = 0; i < 4; ++i) - { - mst_useless_name.detail().name_hash()[i] = useless_name_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_useless_name); - - MinimalStructMember mst_sub; - mst_sub.common().member_id(memberId++); - mst_sub.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_sub.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_sub.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_sub.common().member_flags().IS_OPTIONAL(false); - mst_sub.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_sub.common().member_flags().IS_KEY(false); - mst_sub.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_sub.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("SecondLevelElement", 0, false)); - - MD5 sub_hash("sub"); - for(int i = 0; i < 4; ++i) - { - mst_sub.detail().name_hash()[i] = sub_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_sub); - - MinimalStructMember mst_an_element_alone; - mst_an_element_alone.common().member_id(memberId++); - mst_an_element_alone.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_an_element_alone.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_an_element_alone.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_an_element_alone.common().member_flags().IS_OPTIONAL(false); - mst_an_element_alone.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_an_element_alone.common().member_flags().IS_KEY(false); - mst_an_element_alone.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_an_element_alone.common().member_type_id(*GetThirdLevelElementIdentifier(false)); - - MD5 an_element_alone_hash("an_element_alone"); - for(int i = 0; i < 4; ++i) - { - mst_an_element_alone.detail().name_hash()[i] = an_element_alone_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_an_element_alone); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("FirstLevelElement", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("FirstLevelElement", false); -} - -const TypeObject* GetCompleteFirstLevelElementObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("FirstLevelElement", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_useless_name; - cst_useless_name.common().member_id(memberId++); - cst_useless_name.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_useless_name.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_useless_name.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_useless_name.common().member_flags().IS_OPTIONAL(false); - cst_useless_name.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_useless_name.common().member_flags().IS_KEY(false); - cst_useless_name.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_useless_name.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - cst_useless_name.detail().name("useless_name"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_useless_name); - - CompleteStructMember cst_sub; - cst_sub.common().member_id(memberId++); - cst_sub.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_sub.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_sub.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_sub.common().member_flags().IS_OPTIONAL(false); - cst_sub.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_sub.common().member_flags().IS_KEY(false); - cst_sub.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_sub.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("SecondLevelElement", 0, true)); - - cst_sub.detail().name("sub"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_sub); - - CompleteStructMember cst_an_element_alone; - cst_an_element_alone.common().member_id(memberId++); - cst_an_element_alone.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_an_element_alone.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_an_element_alone.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_an_element_alone.common().member_flags().IS_OPTIONAL(false); - cst_an_element_alone.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_an_element_alone.common().member_flags().IS_KEY(false); - cst_an_element_alone.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_an_element_alone.common().member_type_id(*GetThirdLevelElementIdentifier(true)); - - cst_an_element_alone.detail().name("an_element_alone"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_an_element_alone); - - - // Header - type_object->complete().struct_type().header().detail().type_name("FirstLevelElement"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("FirstLevelElement", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("FirstLevelElement", true); -} - - - -const TypeIdentifier* Getcomplex_nested_arraysIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("complex_nested_arrays", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - Getcomplex_nested_arraysObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("complex_nested_arrays", complete); -} - -const TypeObject* Getcomplex_nested_arraysObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("complex_nested_arrays", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompletecomplex_nested_arraysObject(); - } - //else - return GetMinimalcomplex_nested_arraysObject(); -} - -const TypeObject* GetMinimalcomplex_nested_arraysObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("complex_nested_arrays", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_array_of_elements; - mst_array_of_elements.common().member_id(memberId++); - mst_array_of_elements.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_array_of_elements.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_array_of_elements.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_array_of_elements.common().member_flags().IS_OPTIONAL(false); - mst_array_of_elements.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_array_of_elements.common().member_flags().IS_KEY(false); - mst_array_of_elements.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_array_of_elements.common().member_type_id(*TypeObjectFactory::get_instance()->get_array_identifier("FirstLevelElement", {3}, false)); - - MD5 array_of_elements_hash("array_of_elements"); - for(int i = 0; i < 4; ++i) - { - mst_array_of_elements.detail().name_hash()[i] = array_of_elements_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_array_of_elements); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("complex_nested_arrays", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("complex_nested_arrays", false); -} - -const TypeObject* GetCompletecomplex_nested_arraysObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("complex_nested_arrays", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_array_of_elements; - cst_array_of_elements.common().member_id(memberId++); - cst_array_of_elements.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_array_of_elements.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_array_of_elements.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_array_of_elements.common().member_flags().IS_OPTIONAL(false); - cst_array_of_elements.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_array_of_elements.common().member_flags().IS_KEY(false); - cst_array_of_elements.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_array_of_elements.common().member_type_id(*TypeObjectFactory::get_instance()->get_array_identifier("FirstLevelElement", {3}, true)); - - cst_array_of_elements.detail().name("array_of_elements"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_array_of_elements); - - - // Header - type_object->complete().struct_type().header().detail().type_name("complex_nested_arrays"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("complex_nested_arrays", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("complex_nested_arrays", true); -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysTypeObject.h deleted file mode 100644 index 96d8e29e..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysTypeObject.h +++ /dev/null @@ -1,88 +0,0 @@ -// 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 complex_nested_arraysTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYS_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYS_TYPE_OBJECT_H_ - - -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif -#else -#define eProsima_user_DllExport -#endif - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(complex_nested_arrays_SOURCE) -#define complex_nested_arrays_DllAPI __declspec( dllexport ) -#else -#define complex_nested_arrays_DllAPI __declspec( dllimport ) -#endif // complex_nested_arrays_SOURCE -#else -#define complex_nested_arrays_DllAPI -#endif -#else -#define complex_nested_arrays_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registercomplex_nested_arraysTypes(); - - - -eProsima_user_DllExport const TypeIdentifier* GetThirdLevelElementIdentifier(bool complete = false); -eProsima_user_DllExport const TypeObject* GetThirdLevelElementObject(bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalThirdLevelElementObject(); -eProsima_user_DllExport const TypeObject* GetCompleteThirdLevelElementObject(); - - - - - -eProsima_user_DllExport const TypeIdentifier* GetSecondLevelElementIdentifier(bool complete = false); -eProsima_user_DllExport const TypeObject* GetSecondLevelElementObject(bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalSecondLevelElementObject(); -eProsima_user_DllExport const TypeObject* GetCompleteSecondLevelElementObject(); - - - -eProsima_user_DllExport const TypeIdentifier* GetFirstLevelElementIdentifier(bool complete = false); -eProsima_user_DllExport const TypeObject* GetFirstLevelElementObject(bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalFirstLevelElementObject(); -eProsima_user_DllExport const TypeObject* GetCompleteFirstLevelElementObject(); - - - -eProsima_user_DllExport const TypeIdentifier* Getcomplex_nested_arraysIdentifier(bool complete = false); -eProsima_user_DllExport const TypeObject* Getcomplex_nested_arraysObject(bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalcomplex_nested_arraysObject(); -eProsima_user_DllExport const TypeObject* GetCompletecomplex_nested_arraysObject(); - - -#endif // _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYS_TYPE_OBJECT_H_ \ No newline at end of file diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysv1.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysv1.cxx deleted file mode 100644 index afac5ea1..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysv1.cxx +++ /dev/null @@ -1,932 +0,0 @@ -// 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 complex_nested_arrays.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "complex_nested_arrays.h" - -#if FASTCDR_VERSION_MAJOR == 1 - -#include "complex_nested_arraysTypeObject.h" - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - -namespace helper { namespace internal { - -enum class Size { - UInt8, - UInt16, - UInt32, - UInt64, -}; - -constexpr Size get_size(int s) { - return (s <= 8 ) ? Size::UInt8: - (s <= 16) ? Size::UInt16: - (s <= 32) ? Size::UInt32: Size::UInt64; -} - -template -struct FindTypeH; - -template<> -struct FindTypeH { - using type = std::uint8_t; -}; - -template<> -struct FindTypeH { - using type = std::uint16_t; -}; - -template<> -struct FindTypeH { - using type = std::uint32_t; -}; - -template<> -struct FindTypeH { - using type = std::uint64_t; -}; -} - -template -struct FindType { - using type = typename internal::FindTypeH::type; -}; -} - -#define FirstLevelElement_max_cdr_typesize 296ULL; -#define ThirdLevelElement_max_cdr_typesize 24ULL; -#define SecondLevelElement_max_cdr_typesize 56ULL; -#define complex_nested_arrays_max_cdr_typesize 896ULL; - - - - -ThirdLevelElement::ThirdLevelElement() -{ - // double m_x - m_x = 0.0; - // double m_y - m_y = 0.0; - - // Just to register all known types - registercomplex_nested_arraysTypes(); -} - -ThirdLevelElement::~ThirdLevelElement() -{ -} - -ThirdLevelElement::ThirdLevelElement( - const ThirdLevelElement& x) -{ - m_x = x.m_x; - - - m_y = x.m_y; - -} - -ThirdLevelElement::ThirdLevelElement( - ThirdLevelElement&& x) noexcept -{ - m_x = x.m_x; - - - m_y = x.m_y; - -} - -ThirdLevelElement& ThirdLevelElement::operator =( - const ThirdLevelElement& x) -{ - m_x = x.m_x; - - - m_y = x.m_y; - - return *this; -} - -ThirdLevelElement& ThirdLevelElement::operator =( - ThirdLevelElement&& x) noexcept -{ - m_x = x.m_x; - - - m_y = x.m_y; - - return *this; -} - -bool ThirdLevelElement::operator ==( - const ThirdLevelElement& x) const -{ - return (m_x == x.m_x && - m_y == x.m_y); -} - -bool ThirdLevelElement::operator !=( - const ThirdLevelElement& x) const -{ - return !(*this == x); -} - -size_t ThirdLevelElement::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return ThirdLevelElement_max_cdr_typesize; -} - -size_t ThirdLevelElement::getCdrSerializedSize( - const ThirdLevelElement& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 8 + eprosima::fastcdr::Cdr::alignment(current_alignment, 8); - - - current_alignment += 8 + eprosima::fastcdr::Cdr::alignment(current_alignment, 8); - - - return current_alignment - initial_alignment; -} - - -void ThirdLevelElement::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_x; - - scdr << m_y; - -} - -void ThirdLevelElement::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_x; - - - - dcdr >> m_y; - - -} - - -bool ThirdLevelElement::isKeyDefined() -{ - return false; -} - -void ThirdLevelElement::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function sets a value in member x - * @param _x New value for member x - */ -void ThirdLevelElement::x( - double _x) -{ - m_x = _x; -} - -/*! - * @brief This function returns the value of member x - * @return Value of member x - */ -double ThirdLevelElement::x() const -{ - return m_x; -} - -/*! - * @brief This function returns a reference to member x - * @return Reference to member x - */ -double& ThirdLevelElement::x() -{ - return m_x; -} - - -/*! - * @brief This function sets a value in member y - * @param _y New value for member y - */ -void ThirdLevelElement::y( - double _y) -{ - m_y = _y; -} - -/*! - * @brief This function returns the value of member y - * @return Value of member y - */ -double ThirdLevelElement::y() const -{ - return m_y; -} - -/*! - * @brief This function returns a reference to member y - * @return Reference to member y - */ -double& ThirdLevelElement::y() -{ - return m_y; -} - - - - - - - -SecondLevelElement::SecondLevelElement() -{ - // ThirdLevelElement m_an_element_alone - - // sequence m_a_limited_other_value - - - // Just to register all known types - registercomplex_nested_arraysTypes(); -} - -SecondLevelElement::~SecondLevelElement() -{ -} - -SecondLevelElement::SecondLevelElement( - const SecondLevelElement& x) -{ - m_an_element_alone = x.m_an_element_alone; - - - m_a_limited_other_value = x.m_a_limited_other_value; - -} - -SecondLevelElement::SecondLevelElement( - SecondLevelElement&& x) noexcept -{ - m_an_element_alone = std::move(x.m_an_element_alone); - - - m_a_limited_other_value = std::move(x.m_a_limited_other_value); - -} - -SecondLevelElement& SecondLevelElement::operator =( - const SecondLevelElement& x) -{ - m_an_element_alone = x.m_an_element_alone; - - - m_a_limited_other_value = x.m_a_limited_other_value; - - return *this; -} - -SecondLevelElement& SecondLevelElement::operator =( - SecondLevelElement&& x) noexcept -{ - m_an_element_alone = std::move(x.m_an_element_alone); - - - m_a_limited_other_value = std::move(x.m_a_limited_other_value); - - return *this; -} - -bool SecondLevelElement::operator ==( - const SecondLevelElement& x) const -{ - return (m_an_element_alone == x.m_an_element_alone && - m_a_limited_other_value == x.m_a_limited_other_value); -} - -bool SecondLevelElement::operator !=( - const SecondLevelElement& x) const -{ - return !(*this == x); -} - -size_t SecondLevelElement::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return SecondLevelElement_max_cdr_typesize; -} - -size_t SecondLevelElement::getCdrSerializedSize( - const SecondLevelElement& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += ThirdLevelElement::getCdrSerializedSize(data.an_element_alone(), current_alignment); - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - for(size_t a = 0; a < data.a_limited_other_value().size(); ++a) - { - current_alignment += ThirdLevelElement::getCdrSerializedSize(data.a_limited_other_value().at(a), current_alignment); - } - - - - return current_alignment - initial_alignment; -} - - -void SecondLevelElement::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_an_element_alone; - - scdr << m_a_limited_other_value; - - -} - -void SecondLevelElement::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_an_element_alone; - - - - dcdr >> m_a_limited_other_value; - - -} - - -bool SecondLevelElement::isKeyDefined() -{ - return false; -} - -void SecondLevelElement::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function copies the value in member an_element_alone - * @param _an_element_alone New value to be copied in member an_element_alone - */ -void SecondLevelElement::an_element_alone( - const ThirdLevelElement& _an_element_alone) -{ - m_an_element_alone = _an_element_alone; -} - -/*! - * @brief This function moves the value in member an_element_alone - * @param _an_element_alone New value to be moved in member an_element_alone - */ -void SecondLevelElement::an_element_alone( - ThirdLevelElement&& _an_element_alone) -{ - m_an_element_alone = std::move(_an_element_alone); -} - -/*! - * @brief This function returns a constant reference to member an_element_alone - * @return Constant reference to member an_element_alone - */ -const ThirdLevelElement& SecondLevelElement::an_element_alone() const -{ - return m_an_element_alone; -} - -/*! - * @brief This function returns a reference to member an_element_alone - * @return Reference to member an_element_alone - */ -ThirdLevelElement& SecondLevelElement::an_element_alone() -{ - return m_an_element_alone; -} - - -/*! - * @brief This function copies the value in member a_limited_other_value - * @param _a_limited_other_value New value to be copied in member a_limited_other_value - */ -void SecondLevelElement::a_limited_other_value( - const std::vector& _a_limited_other_value) -{ - m_a_limited_other_value = _a_limited_other_value; -} - -/*! - * @brief This function moves the value in member a_limited_other_value - * @param _a_limited_other_value New value to be moved in member a_limited_other_value - */ -void SecondLevelElement::a_limited_other_value( - std::vector&& _a_limited_other_value) -{ - m_a_limited_other_value = std::move(_a_limited_other_value); -} - -/*! - * @brief This function returns a constant reference to member a_limited_other_value - * @return Constant reference to member a_limited_other_value - */ -const std::vector& SecondLevelElement::a_limited_other_value() const -{ - return m_a_limited_other_value; -} - -/*! - * @brief This function returns a reference to member a_limited_other_value - * @return Reference to member a_limited_other_value - */ -std::vector& SecondLevelElement::a_limited_other_value() -{ - return m_a_limited_other_value; -} - - - - - -FirstLevelElement::FirstLevelElement() -{ - // /type_d() m_useless_name - - // sequence m_sub - - // ThirdLevelElement m_an_element_alone - - - // Just to register all known types - registercomplex_nested_arraysTypes(); -} - -FirstLevelElement::~FirstLevelElement() -{ -} - -FirstLevelElement::FirstLevelElement( - const FirstLevelElement& x) -{ - m_useless_name = x.m_useless_name; - - - m_sub = x.m_sub; - - - m_an_element_alone = x.m_an_element_alone; - -} - -FirstLevelElement::FirstLevelElement( - FirstLevelElement&& x) noexcept -{ - m_useless_name = std::move(x.m_useless_name); - - - m_sub = std::move(x.m_sub); - - - m_an_element_alone = std::move(x.m_an_element_alone); - -} - -FirstLevelElement& FirstLevelElement::operator =( - const FirstLevelElement& x) -{ - m_useless_name = x.m_useless_name; - - - m_sub = x.m_sub; - - - m_an_element_alone = x.m_an_element_alone; - - return *this; -} - -FirstLevelElement& FirstLevelElement::operator =( - FirstLevelElement&& x) noexcept -{ - m_useless_name = std::move(x.m_useless_name); - - - m_sub = std::move(x.m_sub); - - - m_an_element_alone = std::move(x.m_an_element_alone); - - return *this; -} - -bool FirstLevelElement::operator ==( - const FirstLevelElement& x) const -{ - return (m_useless_name == x.m_useless_name && - m_sub == x.m_sub && - m_an_element_alone == x.m_an_element_alone); -} - -bool FirstLevelElement::operator !=( - const FirstLevelElement& x) const -{ - return !(*this == x); -} - -size_t FirstLevelElement::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return FirstLevelElement_max_cdr_typesize; -} - -size_t FirstLevelElement::getCdrSerializedSize( - const FirstLevelElement& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.useless_name().size() + 1; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - for(size_t a = 0; a < data.sub().size(); ++a) - { - current_alignment += SecondLevelElement::getCdrSerializedSize(data.sub().at(a), current_alignment); - } - - - - current_alignment += ThirdLevelElement::getCdrSerializedSize(data.an_element_alone(), current_alignment); - - - return current_alignment - initial_alignment; -} - - -void FirstLevelElement::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_useless_name.c_str(); - - scdr << m_sub; - - - scdr << m_an_element_alone; - -} - -void FirstLevelElement::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_useless_name; - - - - dcdr >> m_sub; - - - - dcdr >> m_an_element_alone; - - -} - - -bool FirstLevelElement::isKeyDefined() -{ - return false; -} - -void FirstLevelElement::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function copies the value in member useless_name - * @param _useless_name New value to be copied in member useless_name - */ -void FirstLevelElement::useless_name( - const std::string& _useless_name) -{ - m_useless_name = _useless_name; -} - -/*! - * @brief This function moves the value in member useless_name - * @param _useless_name New value to be moved in member useless_name - */ -void FirstLevelElement::useless_name( - std::string&& _useless_name) -{ - m_useless_name = std::move(_useless_name); -} - -/*! - * @brief This function returns a constant reference to member useless_name - * @return Constant reference to member useless_name - */ -const std::string& FirstLevelElement::useless_name() const -{ - return m_useless_name; -} - -/*! - * @brief This function returns a reference to member useless_name - * @return Reference to member useless_name - */ -std::string& FirstLevelElement::useless_name() -{ - return m_useless_name; -} - - -/*! - * @brief This function copies the value in member sub - * @param _sub New value to be copied in member sub - */ -void FirstLevelElement::sub( - const std::vector& _sub) -{ - m_sub = _sub; -} - -/*! - * @brief This function moves the value in member sub - * @param _sub New value to be moved in member sub - */ -void FirstLevelElement::sub( - std::vector&& _sub) -{ - m_sub = std::move(_sub); -} - -/*! - * @brief This function returns a constant reference to member sub - * @return Constant reference to member sub - */ -const std::vector& FirstLevelElement::sub() const -{ - return m_sub; -} - -/*! - * @brief This function returns a reference to member sub - * @return Reference to member sub - */ -std::vector& FirstLevelElement::sub() -{ - return m_sub; -} - - -/*! - * @brief This function copies the value in member an_element_alone - * @param _an_element_alone New value to be copied in member an_element_alone - */ -void FirstLevelElement::an_element_alone( - const ThirdLevelElement& _an_element_alone) -{ - m_an_element_alone = _an_element_alone; -} - -/*! - * @brief This function moves the value in member an_element_alone - * @param _an_element_alone New value to be moved in member an_element_alone - */ -void FirstLevelElement::an_element_alone( - ThirdLevelElement&& _an_element_alone) -{ - m_an_element_alone = std::move(_an_element_alone); -} - -/*! - * @brief This function returns a constant reference to member an_element_alone - * @return Constant reference to member an_element_alone - */ -const ThirdLevelElement& FirstLevelElement::an_element_alone() const -{ - return m_an_element_alone; -} - -/*! - * @brief This function returns a reference to member an_element_alone - * @return Reference to member an_element_alone - */ -ThirdLevelElement& FirstLevelElement::an_element_alone() -{ - return m_an_element_alone; -} - - - - - -complex_nested_arrays::complex_nested_arrays() -{ - // FirstLevelElement m_array_of_elements - - - // Just to register all known types - registercomplex_nested_arraysTypes(); -} - -complex_nested_arrays::~complex_nested_arrays() -{ -} - -complex_nested_arrays::complex_nested_arrays( - const complex_nested_arrays& x) -{ - m_array_of_elements = x.m_array_of_elements; - -} - -complex_nested_arrays::complex_nested_arrays( - complex_nested_arrays&& x) noexcept -{ - m_array_of_elements = std::move(x.m_array_of_elements); - -} - -complex_nested_arrays& complex_nested_arrays::operator =( - const complex_nested_arrays& x) -{ - m_array_of_elements = x.m_array_of_elements; - - return *this; -} - -complex_nested_arrays& complex_nested_arrays::operator =( - complex_nested_arrays&& x) noexcept -{ - m_array_of_elements = std::move(x.m_array_of_elements); - - return *this; -} - -bool complex_nested_arrays::operator ==( - const complex_nested_arrays& x) const -{ - return (m_array_of_elements == x.m_array_of_elements); -} - -bool complex_nested_arrays::operator !=( - const complex_nested_arrays& x) const -{ - return !(*this == x); -} - -size_t complex_nested_arrays::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return complex_nested_arrays_max_cdr_typesize; -} - -size_t complex_nested_arrays::getCdrSerializedSize( - const complex_nested_arrays& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - - for(size_t a = 0; a < data.array_of_elements().size(); ++a) - { - current_alignment += FirstLevelElement::getCdrSerializedSize(data.array_of_elements().at(a), current_alignment); - - } - - - - return current_alignment - initial_alignment; -} - - -void complex_nested_arrays::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_array_of_elements; - - -} - -void complex_nested_arrays::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_array_of_elements; - - -} - - -bool complex_nested_arrays::isKeyDefined() -{ - return false; -} - -void complex_nested_arrays::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function copies the value in member array_of_elements - * @param _array_of_elements New value to be copied in member array_of_elements - */ -void complex_nested_arrays::array_of_elements( - const std::array& _array_of_elements) -{ - m_array_of_elements = _array_of_elements; -} - -/*! - * @brief This function moves the value in member array_of_elements - * @param _array_of_elements New value to be moved in member array_of_elements - */ -void complex_nested_arrays::array_of_elements( - std::array&& _array_of_elements) -{ - m_array_of_elements = std::move(_array_of_elements); -} - -/*! - * @brief This function returns a constant reference to member array_of_elements - * @return Constant reference to member array_of_elements - */ -const std::array& complex_nested_arrays::array_of_elements() const -{ - return m_array_of_elements; -} - -/*! - * @brief This function returns a reference to member array_of_elements - * @return Reference to member array_of_elements - */ -std::array& complex_nested_arrays::array_of_elements() -{ - return m_array_of_elements; -} - - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysv1.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysv1.h deleted file mode 100644 index 66b88bbe..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysv1.h +++ /dev/null @@ -1,760 +0,0 @@ -// 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 complex_nested_arrays.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#include - -#if FASTCDR_VERSION_MAJOR == 1 - -#ifndef _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYS_H_ -#define _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYS_H_ - - -#include - -#include -#include -#include -#include -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(COMPLEX_NESTED_ARRAYS_SOURCE) -#define COMPLEX_NESTED_ARRAYS_DllAPI __declspec( dllexport ) -#else -#define COMPLEX_NESTED_ARRAYS_DllAPI __declspec( dllimport ) -#endif // COMPLEX_NESTED_ARRAYS_SOURCE -#else -#define COMPLEX_NESTED_ARRAYS_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define COMPLEX_NESTED_ARRAYS_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - - - - -/*! - * @brief This class represents the structure ThirdLevelElement defined by the user in the IDL file. - * @ingroup complex_nested_arrays - */ -class ThirdLevelElement -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport ThirdLevelElement(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~ThirdLevelElement(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object ThirdLevelElement that will be copied. - */ - eProsima_user_DllExport ThirdLevelElement( - const ThirdLevelElement& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object ThirdLevelElement that will be copied. - */ - eProsima_user_DllExport ThirdLevelElement( - ThirdLevelElement&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object ThirdLevelElement that will be copied. - */ - eProsima_user_DllExport ThirdLevelElement& operator =( - const ThirdLevelElement& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object ThirdLevelElement that will be copied. - */ - eProsima_user_DllExport ThirdLevelElement& operator =( - ThirdLevelElement&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x ThirdLevelElement object to compare. - */ - eProsima_user_DllExport bool operator ==( - const ThirdLevelElement& x) const; - - /*! - * @brief Comparison operator. - * @param x ThirdLevelElement object to compare. - */ - eProsima_user_DllExport bool operator !=( - const ThirdLevelElement& x) const; - - /*! - * @brief This function sets a value in member x - * @param _x New value for member x - */ - eProsima_user_DllExport void x( - double _x); - - /*! - * @brief This function returns the value of member x - * @return Value of member x - */ - eProsima_user_DllExport double x() const; - - /*! - * @brief This function returns a reference to member x - * @return Reference to member x - */ - eProsima_user_DllExport double& x(); - - - /*! - * @brief This function sets a value in member y - * @param _y New value for member y - */ - eProsima_user_DllExport void y( - double _y); - - /*! - * @brief This function returns the value of member y - * @return Value of member y - */ - eProsima_user_DllExport double y() const; - - /*! - * @brief This function returns a reference to member y - * @return Reference to member y - */ - eProsima_user_DllExport double& y(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const ThirdLevelElement& data, - size_t current_alignment = 0); - - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - - -private: - - double m_x; - double m_y; - -}; - - - - - -/*! - * @brief This class represents the structure SecondLevelElement defined by the user in the IDL file. - * @ingroup complex_nested_arrays - */ -class SecondLevelElement -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport SecondLevelElement(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~SecondLevelElement(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object SecondLevelElement that will be copied. - */ - eProsima_user_DllExport SecondLevelElement( - const SecondLevelElement& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object SecondLevelElement that will be copied. - */ - eProsima_user_DllExport SecondLevelElement( - SecondLevelElement&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object SecondLevelElement that will be copied. - */ - eProsima_user_DllExport SecondLevelElement& operator =( - const SecondLevelElement& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object SecondLevelElement that will be copied. - */ - eProsima_user_DllExport SecondLevelElement& operator =( - SecondLevelElement&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x SecondLevelElement object to compare. - */ - eProsima_user_DllExport bool operator ==( - const SecondLevelElement& x) const; - - /*! - * @brief Comparison operator. - * @param x SecondLevelElement object to compare. - */ - eProsima_user_DllExport bool operator !=( - const SecondLevelElement& x) const; - - /*! - * @brief This function copies the value in member an_element_alone - * @param _an_element_alone New value to be copied in member an_element_alone - */ - eProsima_user_DllExport void an_element_alone( - const ThirdLevelElement& _an_element_alone); - - /*! - * @brief This function moves the value in member an_element_alone - * @param _an_element_alone New value to be moved in member an_element_alone - */ - eProsima_user_DllExport void an_element_alone( - ThirdLevelElement&& _an_element_alone); - - /*! - * @brief This function returns a constant reference to member an_element_alone - * @return Constant reference to member an_element_alone - */ - eProsima_user_DllExport const ThirdLevelElement& an_element_alone() const; - - /*! - * @brief This function returns a reference to member an_element_alone - * @return Reference to member an_element_alone - */ - eProsima_user_DllExport ThirdLevelElement& an_element_alone(); - - - /*! - * @brief This function copies the value in member a_limited_other_value - * @param _a_limited_other_value New value to be copied in member a_limited_other_value - */ - eProsima_user_DllExport void a_limited_other_value( - const std::vector& _a_limited_other_value); - - /*! - * @brief This function moves the value in member a_limited_other_value - * @param _a_limited_other_value New value to be moved in member a_limited_other_value - */ - eProsima_user_DllExport void a_limited_other_value( - std::vector&& _a_limited_other_value); - - /*! - * @brief This function returns a constant reference to member a_limited_other_value - * @return Constant reference to member a_limited_other_value - */ - eProsima_user_DllExport const std::vector& a_limited_other_value() const; - - /*! - * @brief This function returns a reference to member a_limited_other_value - * @return Reference to member a_limited_other_value - */ - eProsima_user_DllExport std::vector& a_limited_other_value(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const SecondLevelElement& data, - size_t current_alignment = 0); - - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - - -private: - - ThirdLevelElement m_an_element_alone; - std::vector m_a_limited_other_value; - -}; - - - -/*! - * @brief This class represents the structure FirstLevelElement defined by the user in the IDL file. - * @ingroup complex_nested_arrays - */ -class FirstLevelElement -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport FirstLevelElement(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~FirstLevelElement(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object FirstLevelElement that will be copied. - */ - eProsima_user_DllExport FirstLevelElement( - const FirstLevelElement& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object FirstLevelElement that will be copied. - */ - eProsima_user_DllExport FirstLevelElement( - FirstLevelElement&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object FirstLevelElement that will be copied. - */ - eProsima_user_DllExport FirstLevelElement& operator =( - const FirstLevelElement& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object FirstLevelElement that will be copied. - */ - eProsima_user_DllExport FirstLevelElement& operator =( - FirstLevelElement&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x FirstLevelElement object to compare. - */ - eProsima_user_DllExport bool operator ==( - const FirstLevelElement& x) const; - - /*! - * @brief Comparison operator. - * @param x FirstLevelElement object to compare. - */ - eProsima_user_DllExport bool operator !=( - const FirstLevelElement& x) const; - - /*! - * @brief This function copies the value in member useless_name - * @param _useless_name New value to be copied in member useless_name - */ - eProsima_user_DllExport void useless_name( - const std::string& _useless_name); - - /*! - * @brief This function moves the value in member useless_name - * @param _useless_name New value to be moved in member useless_name - */ - eProsima_user_DllExport void useless_name( - std::string&& _useless_name); - - /*! - * @brief This function returns a constant reference to member useless_name - * @return Constant reference to member useless_name - */ - eProsima_user_DllExport const std::string& useless_name() const; - - /*! - * @brief This function returns a reference to member useless_name - * @return Reference to member useless_name - */ - eProsima_user_DllExport std::string& useless_name(); - - - /*! - * @brief This function copies the value in member sub - * @param _sub New value to be copied in member sub - */ - eProsima_user_DllExport void sub( - const std::vector& _sub); - - /*! - * @brief This function moves the value in member sub - * @param _sub New value to be moved in member sub - */ - eProsima_user_DllExport void sub( - std::vector&& _sub); - - /*! - * @brief This function returns a constant reference to member sub - * @return Constant reference to member sub - */ - eProsima_user_DllExport const std::vector& sub() const; - - /*! - * @brief This function returns a reference to member sub - * @return Reference to member sub - */ - eProsima_user_DllExport std::vector& sub(); - - - /*! - * @brief This function copies the value in member an_element_alone - * @param _an_element_alone New value to be copied in member an_element_alone - */ - eProsima_user_DllExport void an_element_alone( - const ThirdLevelElement& _an_element_alone); - - /*! - * @brief This function moves the value in member an_element_alone - * @param _an_element_alone New value to be moved in member an_element_alone - */ - eProsima_user_DllExport void an_element_alone( - ThirdLevelElement&& _an_element_alone); - - /*! - * @brief This function returns a constant reference to member an_element_alone - * @return Constant reference to member an_element_alone - */ - eProsima_user_DllExport const ThirdLevelElement& an_element_alone() const; - - /*! - * @brief This function returns a reference to member an_element_alone - * @return Reference to member an_element_alone - */ - eProsima_user_DllExport ThirdLevelElement& an_element_alone(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const FirstLevelElement& data, - size_t current_alignment = 0); - - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - - -private: - - std::string m_useless_name; - std::vector m_sub; - ThirdLevelElement m_an_element_alone; - -}; - - - -/*! - * @brief This class represents the structure complex_nested_arrays defined by the user in the IDL file. - * @ingroup complex_nested_arrays - */ -class complex_nested_arrays -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport complex_nested_arrays(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~complex_nested_arrays(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object complex_nested_arrays that will be copied. - */ - eProsima_user_DllExport complex_nested_arrays( - const complex_nested_arrays& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object complex_nested_arrays that will be copied. - */ - eProsima_user_DllExport complex_nested_arrays( - complex_nested_arrays&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object complex_nested_arrays that will be copied. - */ - eProsima_user_DllExport complex_nested_arrays& operator =( - const complex_nested_arrays& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object complex_nested_arrays that will be copied. - */ - eProsima_user_DllExport complex_nested_arrays& operator =( - complex_nested_arrays&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x complex_nested_arrays object to compare. - */ - eProsima_user_DllExport bool operator ==( - const complex_nested_arrays& x) const; - - /*! - * @brief Comparison operator. - * @param x complex_nested_arrays object to compare. - */ - eProsima_user_DllExport bool operator !=( - const complex_nested_arrays& x) const; - - /*! - * @brief This function copies the value in member array_of_elements - * @param _array_of_elements New value to be copied in member array_of_elements - */ - eProsima_user_DllExport void array_of_elements( - const std::array& _array_of_elements); - - /*! - * @brief This function moves the value in member array_of_elements - * @param _array_of_elements New value to be moved in member array_of_elements - */ - eProsima_user_DllExport void array_of_elements( - std::array&& _array_of_elements); - - /*! - * @brief This function returns a constant reference to member array_of_elements - * @return Constant reference to member array_of_elements - */ - eProsima_user_DllExport const std::array& array_of_elements() const; - - /*! - * @brief This function returns a reference to member array_of_elements - * @return Reference to member array_of_elements - */ - eProsima_user_DllExport std::array& array_of_elements(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const complex_nested_arrays& data, - size_t current_alignment = 0); - - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - - -private: - - std::array m_array_of_elements; - -}; - - -#endif // _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYS_H_ - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_struct.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_struct.cxx deleted file mode 100644 index a9f384fe..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_struct.cxx +++ /dev/null @@ -1,162 +0,0 @@ -// 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 enum_struct.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "enum_struct.h" - -#if FASTCDR_VERSION_MAJOR > 1 - -#include "enum_structTypeObject.h" - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - - - - -enum_struct::enum_struct() -{ - // Just to register all known types - registerenum_structTypes(); -} - -enum_struct::~enum_struct() -{ -} - -enum_struct::enum_struct( - const enum_struct& x) -{ - m_index = x.m_index; - m_enum_value = x.m_enum_value; -} - -enum_struct::enum_struct( - enum_struct&& x) noexcept -{ - m_index = x.m_index; - m_enum_value = x.m_enum_value; -} - -enum_struct& enum_struct::operator =( - const enum_struct& x) -{ - - m_index = x.m_index; - m_enum_value = x.m_enum_value; - return *this; -} - -enum_struct& enum_struct::operator =( - enum_struct&& x) noexcept -{ - - m_index = x.m_index; - m_enum_value = x.m_enum_value; - return *this; -} - -bool enum_struct::operator ==( - const enum_struct& x) const -{ - return (m_index == x.m_index && - m_enum_value == x.m_enum_value); -} - -bool enum_struct::operator !=( - const enum_struct& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ -void enum_struct::index( - uint32_t _index) -{ - m_index = _index; -} - -/*! - * @brief This function returns the value of member index - * @return Value of member index - */ -uint32_t enum_struct::index() const -{ - return m_index; -} - -/*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ -uint32_t& enum_struct::index() -{ - return m_index; -} - - -/*! - * @brief This function sets a value in member enum_value - * @param _enum_value New value for member enum_value - */ -void enum_struct::enum_value( - ColorEnum _enum_value) -{ - m_enum_value = _enum_value; -} - -/*! - * @brief This function returns the value of member enum_value - * @return Value of member enum_value - */ -ColorEnum enum_struct::enum_value() const -{ - return m_enum_value; -} - -/*! - * @brief This function returns a reference to member enum_value - * @return Reference to member enum_value - */ -ColorEnum& enum_struct::enum_value() -{ - return m_enum_value; -} - - -// Include auxiliary functions like for serializing/deserializing. -#include "enum_structCdrAux.ipp" - -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_struct.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_struct.h deleted file mode 100644 index e90272ea..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_struct.h +++ /dev/null @@ -1,198 +0,0 @@ -// 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 enum_struct.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#include -#include "enum_structv1.h" - -#if FASTCDR_VERSION_MAJOR > 1 - -#ifndef _FAST_DDS_GENERATED_ENUM_STRUCT_H_ -#define _FAST_DDS_GENERATED_ENUM_STRUCT_H_ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - - - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(ENUM_STRUCT_SOURCE) -#define ENUM_STRUCT_DllAPI __declspec( dllexport ) -#else -#define ENUM_STRUCT_DllAPI __declspec( dllimport ) -#endif // ENUM_STRUCT_SOURCE -#else -#define ENUM_STRUCT_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define ENUM_STRUCT_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -class CdrSizeCalculator; -} // namespace fastcdr -} // namespace eprosima - - - -/*! - * @brief This class represents the enumeration ColorEnum defined by the user in the IDL file. - * @ingroup enum_struct - */ -enum ColorEnum : uint32_t -{ - RED, - GREEN, - BLUE -}; - - -/*! - * @brief This class represents the structure enum_struct defined by the user in the IDL file. - * @ingroup enum_struct - */ -class enum_struct -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport enum_struct(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~enum_struct(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object enum_struct that will be copied. - */ - eProsima_user_DllExport enum_struct( - const enum_struct& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object enum_struct that will be copied. - */ - eProsima_user_DllExport enum_struct( - enum_struct&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object enum_struct that will be copied. - */ - eProsima_user_DllExport enum_struct& operator =( - const enum_struct& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object enum_struct that will be copied. - */ - eProsima_user_DllExport enum_struct& operator =( - enum_struct&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x enum_struct object to compare. - */ - eProsima_user_DllExport bool operator ==( - const enum_struct& x) const; - - /*! - * @brief Comparison operator. - * @param x enum_struct object to compare. - */ - eProsima_user_DllExport bool operator !=( - const enum_struct& x) const; - - /*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ - eProsima_user_DllExport void index( - uint32_t _index); - - /*! - * @brief This function returns the value of member index - * @return Value of member index - */ - eProsima_user_DllExport uint32_t index() const; - - /*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ - eProsima_user_DllExport uint32_t& index(); - - - /*! - * @brief This function sets a value in member enum_value - * @param _enum_value New value for member enum_value - */ - eProsima_user_DllExport void enum_value( - ColorEnum _enum_value); - - /*! - * @brief This function returns the value of member enum_value - * @return Value of member enum_value - */ - eProsima_user_DllExport ColorEnum enum_value() const; - - /*! - * @brief This function returns a reference to member enum_value - * @return Reference to member enum_value - */ - eProsima_user_DllExport ColorEnum& enum_value(); - -private: - - uint32_t m_index{0}; - ColorEnum m_enum_value{::RED}; - -}; - -#endif // _FAST_DDS_GENERATED_ENUM_STRUCT_H_ - - - -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structCdrAux.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structCdrAux.hpp deleted file mode 100644 index 5f7c61b4..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structCdrAux.hpp +++ /dev/null @@ -1,49 +0,0 @@ -// 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 enum_structCdrAux.hpp - * This source file contains some definitions of CDR related functions. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_ENUM_STRUCTCDRAUX_HPP_ -#define _FAST_DDS_GENERATED_ENUM_STRUCTCDRAUX_HPP_ - -#include "enum_struct.h" - -constexpr uint32_t enum_struct_max_cdr_typesize {12UL}; -constexpr uint32_t enum_struct_max_key_cdr_typesize {0UL}; - - - -namespace eprosima { -namespace fastcdr { - -class Cdr; -class CdrSizeCalculator; - - - -eProsima_user_DllExport void serialize_key( - eprosima::fastcdr::Cdr& scdr, - const enum_struct& data); - - -} // namespace fastcdr -} // namespace eprosima - -#endif // _FAST_DDS_GENERATED_ENUM_STRUCTCDRAUX_HPP_ - diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structCdrAux.ipp b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structCdrAux.ipp deleted file mode 100644 index 8528ff4e..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structCdrAux.ipp +++ /dev/null @@ -1,128 +0,0 @@ -// 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 enum_structCdrAux.ipp - * This source file contains some declarations of CDR related functions. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_ENUM_STRUCTCDRAUX_IPP_ -#define _FAST_DDS_GENERATED_ENUM_STRUCTCDRAUX_IPP_ - -#include "enum_structCdrAux.hpp" - -#include -#include - - -#include -using namespace eprosima::fastcdr::exception; - -namespace eprosima { -namespace fastcdr { - - - -template<> -eProsima_user_DllExport size_t calculate_serialized_size( - eprosima::fastcdr::CdrSizeCalculator& calculator, - const enum_struct& data, - size_t& current_alignment) -{ - static_cast(data); - - eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); - size_t calculated_size {calculator.begin_calculate_type_serialized_size( - eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, - current_alignment)}; - - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.index(), current_alignment); - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), - data.enum_value(), current_alignment); - - - calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); - - return calculated_size; -} - -template<> -eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& scdr, - const enum_struct& data) -{ - eprosima::fastcdr::Cdr::state current_state(scdr); - scdr.begin_serialize_type(current_state, - eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR); - - scdr - << eprosima::fastcdr::MemberId(0) << data.index() - << eprosima::fastcdr::MemberId(1) << data.enum_value() -; - scdr.end_serialize_type(current_state); -} - -template<> -eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr, - enum_struct& data) -{ - cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, - [&data](eprosima::fastcdr::Cdr& dcdr, const eprosima::fastcdr::MemberId& mid) -> bool - { - bool ret_value = true; - switch (mid.id) - { - case 0: - dcdr >> data.index(); - break; - - case 1: - dcdr >> data.enum_value(); - break; - - default: - ret_value = false; - break; - } - return ret_value; - }); -} - -void serialize_key( - eprosima::fastcdr::Cdr& scdr, - const enum_struct& data) -{ - static_cast(scdr); - static_cast(data); -} - - - -} // namespace fastcdr -} // namespace eprosima - -#endif // _FAST_DDS_GENERATED_ENUM_STRUCTCDRAUX_IPP_ - diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structPubSubTypes.cxx deleted file mode 100644 index 10f62bac..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structPubSubTypes.cxx +++ /dev/null @@ -1,221 +0,0 @@ -// 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 enum_structPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#include - -#include "enum_structPubSubTypes.h" -#include "enum_structCdrAux.hpp" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; -using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - - - -enum_structPubSubType::enum_structPubSubType() -{ - setName("enum_struct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(enum_struct::getMaxCdrSerializedSize()); -#else - enum_struct_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = enum_struct_max_key_cdr_typesize > 16 ? enum_struct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -enum_structPubSubType::~enum_structPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool enum_structPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - enum_struct* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool enum_structPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - enum_struct* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function enum_structPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* enum_structPubSubType::createData() -{ - return reinterpret_cast(new enum_struct()); -} - -void enum_structPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool enum_structPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - enum_struct* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - enum_struct_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || enum_struct_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structPubSubTypes.h deleted file mode 100644 index 73e83613..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structPubSubTypes.h +++ /dev/null @@ -1,132 +0,0 @@ -// 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 enum_structPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#ifndef _FAST_DDS_GENERATED_ENUM_STRUCT_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_ENUM_STRUCT_PUBSUBTYPES_H_ - -#include -#include -#include -#include -#include - -#include "enum_struct.h" - - -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) -#error \ - Generated enum_struct is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER - - - - -/*! - * @brief This class represents the TopicDataType of the type enum_struct defined by the user in the IDL file. - * @ingroup enum_struct - */ -class enum_structPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef enum_struct type; - - eProsima_user_DllExport enum_structPubSubType(); - - eProsima_user_DllExport ~enum_structPubSubType() override; - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport void* createData() override; - - eProsima_user_DllExport void deleteData( - void* data) override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } - - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - static_cast(memory); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - -#endif // _FAST_DDS_GENERATED_ENUM_STRUCT_PUBSUBTYPES_H_ - diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structTypeObject.cxx deleted file mode 100644 index 6ad9350d..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structTypeObject.cxx +++ /dev/null @@ -1,496 +0,0 @@ -// 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 enum_structTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { char dummy; } -#endif - -#include "enum_struct.h" -#include "enum_structTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerenum_structTypes() -{ - static std::once_flag once_flag; - std::call_once(once_flag, []() - { - TypeObjectFactory *factory = TypeObjectFactory::get_instance(); - factory->add_type_object("ColorEnum", GetColorEnumIdentifier(true), - GetColorEnumObject(true)); - factory->add_type_object("ColorEnum", GetColorEnumIdentifier(false), - GetColorEnumObject(false)); - - - factory->add_type_object("enum_struct", Getenum_structIdentifier(true), - Getenum_structObject(true)); - factory->add_type_object("enum_struct", Getenum_structIdentifier(false), - Getenum_structObject(false)); - - }); -} - -const TypeIdentifier* GetColorEnumIdentifier(bool complete) -{ - const TypeIdentifier* c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("ColorEnum", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetColorEnumObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("ColorEnum", complete); -} - -const TypeObject* GetColorEnumObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("ColorEnum", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteColorEnumObject(); - } - // else - return GetMinimalColorEnumObject(); -} - -const TypeObject* GetMinimalColorEnumObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("ColorEnum", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_ENUM); - - // No flags apply - //type_object->minimal().enumerated_type().enum_flags().IS_FINAL(false); - //type_object->minimal().enumerated_type().enum_flags().IS_APPENDABLE(false); - //type_object->minimal().enumerated_type().enum_flags().IS_MUTABLE(false); - //type_object->minimal().enumerated_type().enum_flags().IS_NESTED(false); - //type_object->minimal().enumerated_type().enum_flags().IS_AUTOID_HASH(false); - - type_object->minimal().enumerated_type().header().common().bit_bound(32); // TODO fixed by IDL, isn't? - - uint32_t value = 0; - MinimalEnumeratedLiteral mel_RED; - mel_RED.common().flags().TRY_CONSTRUCT1(false); // Doesn't apply - mel_RED.common().flags().TRY_CONSTRUCT2(false); // Doesn't apply - mel_RED.common().flags().IS_EXTERNAL(false); // Doesn't apply - mel_RED.common().flags().IS_OPTIONAL(false); // Doesn't apply - mel_RED.common().flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - mel_RED.common().flags().IS_KEY(false); // Doesn't apply - mel_RED.common().flags().IS_DEFAULT(false); - mel_RED.common().value(value++); - MD5 RED_hash("RED"); - for(int i = 0; i < 4; ++i) - { - mel_RED.detail().name_hash()[i] = RED_hash.digest[i]; - } - type_object->minimal().enumerated_type().literal_seq().emplace_back(mel_RED); - - MinimalEnumeratedLiteral mel_GREEN; - mel_GREEN.common().flags().TRY_CONSTRUCT1(false); // Doesn't apply - mel_GREEN.common().flags().TRY_CONSTRUCT2(false); // Doesn't apply - mel_GREEN.common().flags().IS_EXTERNAL(false); // Doesn't apply - mel_GREEN.common().flags().IS_OPTIONAL(false); // Doesn't apply - mel_GREEN.common().flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - mel_GREEN.common().flags().IS_KEY(false); // Doesn't apply - mel_GREEN.common().flags().IS_DEFAULT(false); - mel_GREEN.common().value(value++); - MD5 GREEN_hash("GREEN"); - for(int i = 0; i < 4; ++i) - { - mel_GREEN.detail().name_hash()[i] = GREEN_hash.digest[i]; - } - type_object->minimal().enumerated_type().literal_seq().emplace_back(mel_GREEN); - - MinimalEnumeratedLiteral mel_BLUE; - mel_BLUE.common().flags().TRY_CONSTRUCT1(false); // Doesn't apply - mel_BLUE.common().flags().TRY_CONSTRUCT2(false); // Doesn't apply - mel_BLUE.common().flags().IS_EXTERNAL(false); // Doesn't apply - mel_BLUE.common().flags().IS_OPTIONAL(false); // Doesn't apply - mel_BLUE.common().flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - mel_BLUE.common().flags().IS_KEY(false); // Doesn't apply - mel_BLUE.common().flags().IS_DEFAULT(false); - mel_BLUE.common().value(value++); - MD5 BLUE_hash("BLUE"); - for(int i = 0; i < 4; ++i) - { - mel_BLUE.detail().name_hash()[i] = BLUE_hash.digest[i]; - } - type_object->minimal().enumerated_type().literal_seq().emplace_back(mel_BLUE); - - - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().enumerated_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("ColorEnum", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("ColorEnum", false); -} - -const TypeObject* GetCompleteColorEnumObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("ColorEnum", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_ENUM); - - // No flags apply - //type_object->complete().enumerated_type().enum_flags().IS_FINAL(false); - //type_object->complete().enumerated_type().enum_flags().IS_APPENDABLE(false); - //type_object->complete().enumerated_type().enum_flags().IS_MUTABLE(false); - //type_object->complete().enumerated_type().enum_flags().IS_NESTED(false); - //type_object->complete().enumerated_type().enum_flags().IS_AUTOID_HASH(false); - - type_object->complete().enumerated_type().header().common().bit_bound(32); // TODO fixed by IDL, isn't? - type_object->complete().enumerated_type().header().detail().type_name("ColorEnum"); - - uint32_t value = 0; - CompleteEnumeratedLiteral cel_RED; - cel_RED.common().flags().TRY_CONSTRUCT1(false); // Doesn't apply - cel_RED.common().flags().TRY_CONSTRUCT2(false); // Doesn't apply - cel_RED.common().flags().IS_EXTERNAL(false); // Doesn't apply - cel_RED.common().flags().IS_OPTIONAL(false); // Doesn't apply - cel_RED.common().flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - cel_RED.common().flags().IS_KEY(false); // Doesn't apply - cel_RED.common().flags().IS_DEFAULT(false); - cel_RED.common().value(value++); - cel_RED.detail().name("RED"); - - type_object->complete().enumerated_type().literal_seq().emplace_back(cel_RED); - - CompleteEnumeratedLiteral cel_GREEN; - cel_GREEN.common().flags().TRY_CONSTRUCT1(false); // Doesn't apply - cel_GREEN.common().flags().TRY_CONSTRUCT2(false); // Doesn't apply - cel_GREEN.common().flags().IS_EXTERNAL(false); // Doesn't apply - cel_GREEN.common().flags().IS_OPTIONAL(false); // Doesn't apply - cel_GREEN.common().flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - cel_GREEN.common().flags().IS_KEY(false); // Doesn't apply - cel_GREEN.common().flags().IS_DEFAULT(false); - cel_GREEN.common().value(value++); - cel_GREEN.detail().name("GREEN"); - - type_object->complete().enumerated_type().literal_seq().emplace_back(cel_GREEN); - - CompleteEnumeratedLiteral cel_BLUE; - cel_BLUE.common().flags().TRY_CONSTRUCT1(false); // Doesn't apply - cel_BLUE.common().flags().TRY_CONSTRUCT2(false); // Doesn't apply - cel_BLUE.common().flags().IS_EXTERNAL(false); // Doesn't apply - cel_BLUE.common().flags().IS_OPTIONAL(false); // Doesn't apply - cel_BLUE.common().flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - cel_BLUE.common().flags().IS_KEY(false); // Doesn't apply - cel_BLUE.common().flags().IS_DEFAULT(false); - cel_BLUE.common().value(value++); - cel_BLUE.detail().name("BLUE"); - - type_object->complete().enumerated_type().literal_seq().emplace_back(cel_BLUE); - - - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().enumerated_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("ColorEnum", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("ColorEnum", true); -} - - - -const TypeIdentifier* Getenum_structIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("enum_struct", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - Getenum_structObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("enum_struct", complete); -} - -const TypeObject* Getenum_structObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("enum_struct", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteenum_structObject(); - } - //else - return GetMinimalenum_structObject(); -} - -const TypeObject* GetMinimalenum_structObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("enum_struct", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_index; - mst_index.common().member_id(memberId++); - mst_index.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_index.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_index.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_index.common().member_flags().IS_OPTIONAL(false); - mst_index.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_index.common().member_flags().IS_KEY(false); - mst_index.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_index.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); - - - MD5 index_hash("index"); - for(int i = 0; i < 4; ++i) - { - mst_index.detail().name_hash()[i] = index_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_index); - - MinimalStructMember mst_enum_value; - mst_enum_value.common().member_id(memberId++); - mst_enum_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_enum_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_enum_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_enum_value.common().member_flags().IS_OPTIONAL(false); - mst_enum_value.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_enum_value.common().member_flags().IS_KEY(false); - mst_enum_value.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_enum_value.common().member_type_id(*GetColorEnumIdentifier(false)); - - MD5 enum_value_hash("enum_value"); - for(int i = 0; i < 4; ++i) - { - mst_enum_value.detail().name_hash()[i] = enum_value_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_enum_value); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("enum_struct", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("enum_struct", false); -} - -const TypeObject* GetCompleteenum_structObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("enum_struct", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_index; - cst_index.common().member_id(memberId++); - cst_index.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_index.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_index.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_index.common().member_flags().IS_OPTIONAL(false); - cst_index.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_index.common().member_flags().IS_KEY(false); - cst_index.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_index.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); - - - cst_index.detail().name("index"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_index); - - CompleteStructMember cst_enum_value; - cst_enum_value.common().member_id(memberId++); - cst_enum_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_enum_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_enum_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_enum_value.common().member_flags().IS_OPTIONAL(false); - cst_enum_value.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_enum_value.common().member_flags().IS_KEY(false); - cst_enum_value.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_enum_value.common().member_type_id(*GetColorEnumIdentifier(true)); - - cst_enum_value.detail().name("enum_value"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_enum_value); - - - // Header - type_object->complete().struct_type().header().detail().type_name("enum_struct"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("enum_struct", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("enum_struct", true); -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structTypeObject.h deleted file mode 100644 index 795c5d96..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structTypeObject.h +++ /dev/null @@ -1,70 +0,0 @@ -// 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 enum_structTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_ENUM_STRUCT_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_ENUM_STRUCT_TYPE_OBJECT_H_ - - -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif -#else -#define eProsima_user_DllExport -#endif - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(enum_struct_SOURCE) -#define enum_struct_DllAPI __declspec( dllexport ) -#else -#define enum_struct_DllAPI __declspec( dllimport ) -#endif // enum_struct_SOURCE -#else -#define enum_struct_DllAPI -#endif -#else -#define enum_struct_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registerenum_structTypes(); - -eProsima_user_DllExport const TypeIdentifier* GetColorEnumIdentifier(bool complete = false); -eProsima_user_DllExport const TypeObject* GetColorEnumObject(bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalColorEnumObject(); -eProsima_user_DllExport const TypeObject* GetCompleteColorEnumObject(); - - - -eProsima_user_DllExport const TypeIdentifier* Getenum_structIdentifier(bool complete = false); -eProsima_user_DllExport const TypeObject* Getenum_structObject(bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalenum_structObject(); -eProsima_user_DllExport const TypeObject* GetCompleteenum_structObject(); - - -#endif // _FAST_DDS_GENERATED_ENUM_STRUCT_TYPE_OBJECT_H_ \ No newline at end of file diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structv1.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structv1.cxx deleted file mode 100644 index 835121d4..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structv1.cxx +++ /dev/null @@ -1,285 +0,0 @@ -// 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 enum_struct.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "enum_struct.h" - -#if FASTCDR_VERSION_MAJOR == 1 - -#include "enum_structTypeObject.h" - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - -namespace helper { namespace internal { - -enum class Size { - UInt8, - UInt16, - UInt32, - UInt64, -}; - -constexpr Size get_size(int s) { - return (s <= 8 ) ? Size::UInt8: - (s <= 16) ? Size::UInt16: - (s <= 32) ? Size::UInt32: Size::UInt64; -} - -template -struct FindTypeH; - -template<> -struct FindTypeH { - using type = std::uint8_t; -}; - -template<> -struct FindTypeH { - using type = std::uint16_t; -}; - -template<> -struct FindTypeH { - using type = std::uint32_t; -}; - -template<> -struct FindTypeH { - using type = std::uint64_t; -}; -} - -template -struct FindType { - using type = typename internal::FindTypeH::type; -}; -} - -#define enum_struct_max_cdr_typesize 12ULL; - - - - - -enum_struct::enum_struct() -{ - // unsigned long m_index - m_index = 0; - // ColorEnum m_enum_value - m_enum_value = ::RED; - - // Just to register all known types - registerenum_structTypes(); -} - -enum_struct::~enum_struct() -{ -} - -enum_struct::enum_struct( - const enum_struct& x) -{ - m_index = x.m_index; - - - m_enum_value = x.m_enum_value; - -} - -enum_struct::enum_struct( - enum_struct&& x) noexcept -{ - m_index = x.m_index; - - - m_enum_value = x.m_enum_value; - -} - -enum_struct& enum_struct::operator =( - const enum_struct& x) -{ - m_index = x.m_index; - - - m_enum_value = x.m_enum_value; - - return *this; -} - -enum_struct& enum_struct::operator =( - enum_struct&& x) noexcept -{ - m_index = x.m_index; - - - m_enum_value = x.m_enum_value; - - return *this; -} - -bool enum_struct::operator ==( - const enum_struct& x) const -{ - return (m_index == x.m_index && - m_enum_value == x.m_enum_value); -} - -bool enum_struct::operator !=( - const enum_struct& x) const -{ - return !(*this == x); -} - -size_t enum_struct::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return enum_struct_max_cdr_typesize; -} - -size_t enum_struct::getCdrSerializedSize( - const enum_struct& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - return current_alignment - initial_alignment; -} - - -void enum_struct::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_index; - - scdr << (uint32_t)m_enum_value; - -} - -void enum_struct::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_index; - - - - { - uint32_t enum_value = 0; - dcdr >> enum_value; - m_enum_value = (ColorEnum)enum_value; - } - - -} - - -bool enum_struct::isKeyDefined() -{ - return false; -} - -void enum_struct::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ -void enum_struct::index( - uint32_t _index) -{ - m_index = _index; -} - -/*! - * @brief This function returns the value of member index - * @return Value of member index - */ -uint32_t enum_struct::index() const -{ - return m_index; -} - -/*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ -uint32_t& enum_struct::index() -{ - return m_index; -} - - -/*! - * @brief This function sets a value in member enum_value - * @param _enum_value New value for member enum_value - */ -void enum_struct::enum_value( - ColorEnum _enum_value) -{ - m_enum_value = _enum_value; -} - -/*! - * @brief This function returns the value of member enum_value - * @return Value of member enum_value - */ -ColorEnum enum_struct::enum_value() const -{ - return m_enum_value; -} - -/*! - * @brief This function returns a reference to member enum_value - * @return Reference to member enum_value - */ -ColorEnum& enum_struct::enum_value() -{ - return m_enum_value; -} - - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structv1.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structv1.h deleted file mode 100644 index 646f7876..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structv1.h +++ /dev/null @@ -1,246 +0,0 @@ -// 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 enum_struct.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#include - -#if FASTCDR_VERSION_MAJOR == 1 - -#ifndef _FAST_DDS_GENERATED_ENUM_STRUCT_H_ -#define _FAST_DDS_GENERATED_ENUM_STRUCT_H_ - - -#include - -#include -#include -#include -#include -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(ENUM_STRUCT_SOURCE) -#define ENUM_STRUCT_DllAPI __declspec( dllexport ) -#else -#define ENUM_STRUCT_DllAPI __declspec( dllimport ) -#endif // ENUM_STRUCT_SOURCE -#else -#define ENUM_STRUCT_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define ENUM_STRUCT_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - - -/*! - * @brief This class represents the enumeration ColorEnum defined by the user in the IDL file. - * @ingroup enum_struct - */ -enum ColorEnum : uint32_t -{ - RED, - GREEN, - BLUE -}; - - -/*! - * @brief This class represents the structure enum_struct defined by the user in the IDL file. - * @ingroup enum_struct - */ -class enum_struct -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport enum_struct(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~enum_struct(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object enum_struct that will be copied. - */ - eProsima_user_DllExport enum_struct( - const enum_struct& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object enum_struct that will be copied. - */ - eProsima_user_DllExport enum_struct( - enum_struct&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object enum_struct that will be copied. - */ - eProsima_user_DllExport enum_struct& operator =( - const enum_struct& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object enum_struct that will be copied. - */ - eProsima_user_DllExport enum_struct& operator =( - enum_struct&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x enum_struct object to compare. - */ - eProsima_user_DllExport bool operator ==( - const enum_struct& x) const; - - /*! - * @brief Comparison operator. - * @param x enum_struct object to compare. - */ - eProsima_user_DllExport bool operator !=( - const enum_struct& x) const; - - /*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ - eProsima_user_DllExport void index( - uint32_t _index); - - /*! - * @brief This function returns the value of member index - * @return Value of member index - */ - eProsima_user_DllExport uint32_t index() const; - - /*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ - eProsima_user_DllExport uint32_t& index(); - - - /*! - * @brief This function sets a value in member enum_value - * @param _enum_value New value for member enum_value - */ - eProsima_user_DllExport void enum_value( - ColorEnum _enum_value); - - /*! - * @brief This function returns the value of member enum_value - * @return Value of member enum_value - */ - eProsima_user_DllExport ColorEnum enum_value() const; - - /*! - * @brief This function returns a reference to member enum_value - * @return Reference to member enum_value - */ - eProsima_user_DllExport ColorEnum& enum_value(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const enum_struct& data, - size_t current_alignment = 0); - - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - - -private: - - uint32_t m_index; - ColorEnum m_enum_value; - -}; - - -#endif // _FAST_DDS_GENERATED_ENUM_STRUCT_H_ - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequence.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequence.cxx deleted file mode 100644 index d4a503d2..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequence.cxx +++ /dev/null @@ -1,140 +0,0 @@ -// 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 float_bounded_sequence.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "float_bounded_sequence.h" - -#if FASTCDR_VERSION_MAJOR > 1 - -#include "float_bounded_sequenceTypeObject.h" - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - - - - - - -float_bounded_sequence::float_bounded_sequence() -{ - // Just to register all known types - registerfloat_bounded_sequenceTypes(); -} - -float_bounded_sequence::~float_bounded_sequence() -{ -} - -float_bounded_sequence::float_bounded_sequence( - const float_bounded_sequence& x) -{ - m_numbers = x.m_numbers; -} - -float_bounded_sequence::float_bounded_sequence( - float_bounded_sequence&& x) noexcept -{ - m_numbers = std::move(x.m_numbers); -} - -float_bounded_sequence& float_bounded_sequence::operator =( - const float_bounded_sequence& x) -{ - - m_numbers = x.m_numbers; - return *this; -} - -float_bounded_sequence& float_bounded_sequence::operator =( - float_bounded_sequence&& x) noexcept -{ - - m_numbers = std::move(x.m_numbers); - return *this; -} - -bool float_bounded_sequence::operator ==( - const float_bounded_sequence& x) const -{ - return (m_numbers == x.m_numbers); -} - -bool float_bounded_sequence::operator !=( - const float_bounded_sequence& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function copies the value in member numbers - * @param _numbers New value to be copied in member numbers - */ -void float_bounded_sequence::numbers( - const std::vector& _numbers) -{ - m_numbers = _numbers; -} - -/*! - * @brief This function moves the value in member numbers - * @param _numbers New value to be moved in member numbers - */ -void float_bounded_sequence::numbers( - std::vector&& _numbers) -{ - m_numbers = std::move(_numbers); -} - -/*! - * @brief This function returns a constant reference to member numbers - * @return Constant reference to member numbers - */ -const std::vector& float_bounded_sequence::numbers() const -{ - return m_numbers; -} - -/*! - * @brief This function returns a reference to member numbers - * @return Reference to member numbers - */ -std::vector& float_bounded_sequence::numbers() -{ - return m_numbers; -} - - -// Include auxiliary functions like for serializing/deserializing. -#include "float_bounded_sequenceCdrAux.ipp" - -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequenceTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequenceTypeObject.cxx deleted file mode 100644 index ad7d52d9..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequenceTypeObject.cxx +++ /dev/null @@ -1,230 +0,0 @@ -// 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 float_bounded_sequenceTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { char dummy; } -#endif - -#include "float_bounded_sequence.h" -#include "float_bounded_sequenceTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerfloat_bounded_sequenceTypes() -{ - static std::once_flag once_flag; - std::call_once(once_flag, []() - { - TypeObjectFactory *factory = TypeObjectFactory::get_instance(); - factory->add_type_object("float_bounded_sequence", Getfloat_bounded_sequenceIdentifier(true), - Getfloat_bounded_sequenceObject(true)); - factory->add_type_object("float_bounded_sequence", Getfloat_bounded_sequenceIdentifier(false), - Getfloat_bounded_sequenceObject(false)); - - }); -} - - - - - -const TypeIdentifier* Getfloat_bounded_sequenceIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("float_bounded_sequence", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - Getfloat_bounded_sequenceObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("float_bounded_sequence", complete); -} - -const TypeObject* Getfloat_bounded_sequenceObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("float_bounded_sequence", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompletefloat_bounded_sequenceObject(); - } - //else - return GetMinimalfloat_bounded_sequenceObject(); -} - -const TypeObject* GetMinimalfloat_bounded_sequenceObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("float_bounded_sequence", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_numbers; - mst_numbers.common().member_id(memberId++); - mst_numbers.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_numbers.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_numbers.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_numbers.common().member_flags().IS_OPTIONAL(false); - mst_numbers.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_numbers.common().member_flags().IS_KEY(false); - mst_numbers.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_numbers.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("float", 13, false)); - - MD5 numbers_hash("numbers"); - for(int i = 0; i < 4; ++i) - { - mst_numbers.detail().name_hash()[i] = numbers_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_numbers); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("float_bounded_sequence", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("float_bounded_sequence", false); -} - -const TypeObject* GetCompletefloat_bounded_sequenceObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("float_bounded_sequence", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_numbers; - cst_numbers.common().member_id(memberId++); - cst_numbers.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_numbers.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_numbers.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_numbers.common().member_flags().IS_OPTIONAL(false); - cst_numbers.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_numbers.common().member_flags().IS_KEY(false); - cst_numbers.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_numbers.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("float", 13, true)); - - cst_numbers.detail().name("numbers"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_numbers); - - - // Header - type_object->complete().struct_type().header().detail().type_name("float_bounded_sequence"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("float_bounded_sequence", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("float_bounded_sequence", true); -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequenceTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequenceTypeObject.h deleted file mode 100644 index ebd7c318..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequenceTypeObject.h +++ /dev/null @@ -1,67 +0,0 @@ -// 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 float_bounded_sequenceTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCE_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCE_TYPE_OBJECT_H_ - - -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif -#else -#define eProsima_user_DllExport -#endif - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(float_bounded_sequence_SOURCE) -#define float_bounded_sequence_DllAPI __declspec( dllexport ) -#else -#define float_bounded_sequence_DllAPI __declspec( dllimport ) -#endif // float_bounded_sequence_SOURCE -#else -#define float_bounded_sequence_DllAPI -#endif -#else -#define float_bounded_sequence_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registerfloat_bounded_sequenceTypes(); - - - - - -eProsima_user_DllExport const TypeIdentifier* Getfloat_bounded_sequenceIdentifier(bool complete = false); -eProsima_user_DllExport const TypeObject* Getfloat_bounded_sequenceObject(bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalfloat_bounded_sequenceObject(); -eProsima_user_DllExport const TypeObject* GetCompletefloat_bounded_sequenceObject(); - - -#endif // _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCE_TYPE_OBJECT_H_ \ No newline at end of file diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequencev1.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequencev1.cxx deleted file mode 100644 index aacdac49..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequencev1.cxx +++ /dev/null @@ -1,247 +0,0 @@ -// 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 float_bounded_sequence.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "float_bounded_sequence.h" - -#if FASTCDR_VERSION_MAJOR == 1 - -#include "float_bounded_sequenceTypeObject.h" - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - -namespace helper { namespace internal { - -enum class Size { - UInt8, - UInt16, - UInt32, - UInt64, -}; - -constexpr Size get_size(int s) { - return (s <= 8 ) ? Size::UInt8: - (s <= 16) ? Size::UInt16: - (s <= 32) ? Size::UInt32: Size::UInt64; -} - -template -struct FindTypeH; - -template<> -struct FindTypeH { - using type = std::uint8_t; -}; - -template<> -struct FindTypeH { - using type = std::uint16_t; -}; - -template<> -struct FindTypeH { - using type = std::uint32_t; -}; - -template<> -struct FindTypeH { - using type = std::uint64_t; -}; -} - -template -struct FindType { - using type = typename internal::FindTypeH::type; -}; -} - -#define float_bounded_sequence_max_cdr_typesize 60ULL; - - - - - - -float_bounded_sequence::float_bounded_sequence() -{ - // sequence m_numbers - - - // Just to register all known types - registerfloat_bounded_sequenceTypes(); -} - -float_bounded_sequence::~float_bounded_sequence() -{ -} - -float_bounded_sequence::float_bounded_sequence( - const float_bounded_sequence& x) -{ - m_numbers = x.m_numbers; - -} - -float_bounded_sequence::float_bounded_sequence( - float_bounded_sequence&& x) noexcept -{ - m_numbers = std::move(x.m_numbers); - -} - -float_bounded_sequence& float_bounded_sequence::operator =( - const float_bounded_sequence& x) -{ - m_numbers = x.m_numbers; - - return *this; -} - -float_bounded_sequence& float_bounded_sequence::operator =( - float_bounded_sequence&& x) noexcept -{ - m_numbers = std::move(x.m_numbers); - - return *this; -} - -bool float_bounded_sequence::operator ==( - const float_bounded_sequence& x) const -{ - return (m_numbers == x.m_numbers); -} - -bool float_bounded_sequence::operator !=( - const float_bounded_sequence& x) const -{ - return !(*this == x); -} - -size_t float_bounded_sequence::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return float_bounded_sequence_max_cdr_typesize; -} - -size_t float_bounded_sequence::getCdrSerializedSize( - const float_bounded_sequence& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - if (data.numbers().size() > 0) - { - current_alignment += (data.numbers().size() * 4) + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - } - - - - - return current_alignment - initial_alignment; -} - - -void float_bounded_sequence::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_numbers; - - -} - -void float_bounded_sequence::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_numbers; - - -} - - -bool float_bounded_sequence::isKeyDefined() -{ - return false; -} - -void float_bounded_sequence::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function copies the value in member numbers - * @param _numbers New value to be copied in member numbers - */ -void float_bounded_sequence::numbers( - const std::vector& _numbers) -{ - m_numbers = _numbers; -} - -/*! - * @brief This function moves the value in member numbers - * @param _numbers New value to be moved in member numbers - */ -void float_bounded_sequence::numbers( - std::vector&& _numbers) -{ - m_numbers = std::move(_numbers); -} - -/*! - * @brief This function returns a constant reference to member numbers - * @return Constant reference to member numbers - */ -const std::vector& float_bounded_sequence::numbers() const -{ - return m_numbers; -} - -/*! - * @brief This function returns a reference to member numbers - * @return Reference to member numbers - */ -std::vector& float_bounded_sequence::numbers() -{ - return m_numbers; -} - - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequencev1.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequencev1.h deleted file mode 100644 index b5abe95c..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequencev1.h +++ /dev/null @@ -1,224 +0,0 @@ -// 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 float_bounded_sequence.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#include - -#if FASTCDR_VERSION_MAJOR == 1 - -#ifndef _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCE_H_ -#define _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCE_H_ - - -#include - -#include -#include -#include -#include -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(FLOAT_BOUNDED_SEQUENCE_SOURCE) -#define FLOAT_BOUNDED_SEQUENCE_DllAPI __declspec( dllexport ) -#else -#define FLOAT_BOUNDED_SEQUENCE_DllAPI __declspec( dllimport ) -#endif // FLOAT_BOUNDED_SEQUENCE_SOURCE -#else -#define FLOAT_BOUNDED_SEQUENCE_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define FLOAT_BOUNDED_SEQUENCE_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - - - - - - -/*! - * @brief This class represents the structure float_bounded_sequence defined by the user in the IDL file. - * @ingroup float_bounded_sequence - */ -class float_bounded_sequence -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport float_bounded_sequence(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~float_bounded_sequence(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object float_bounded_sequence that will be copied. - */ - eProsima_user_DllExport float_bounded_sequence( - const float_bounded_sequence& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object float_bounded_sequence that will be copied. - */ - eProsima_user_DllExport float_bounded_sequence( - float_bounded_sequence&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object float_bounded_sequence that will be copied. - */ - eProsima_user_DllExport float_bounded_sequence& operator =( - const float_bounded_sequence& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object float_bounded_sequence that will be copied. - */ - eProsima_user_DllExport float_bounded_sequence& operator =( - float_bounded_sequence&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x float_bounded_sequence object to compare. - */ - eProsima_user_DllExport bool operator ==( - const float_bounded_sequence& x) const; - - /*! - * @brief Comparison operator. - * @param x float_bounded_sequence object to compare. - */ - eProsima_user_DllExport bool operator !=( - const float_bounded_sequence& x) const; - - /*! - * @brief This function copies the value in member numbers - * @param _numbers New value to be copied in member numbers - */ - eProsima_user_DllExport void numbers( - const std::vector& _numbers); - - /*! - * @brief This function moves the value in member numbers - * @param _numbers New value to be moved in member numbers - */ - eProsima_user_DllExport void numbers( - std::vector&& _numbers); - - /*! - * @brief This function returns a constant reference to member numbers - * @return Constant reference to member numbers - */ - eProsima_user_DllExport const std::vector& numbers() const; - - /*! - * @brief This function returns a reference to member numbers - * @return Reference to member numbers - */ - eProsima_user_DllExport std::vector& numbers(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const float_bounded_sequence& data, - size_t current_alignment = 0); - - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - - -private: - - std::vector m_numbers; - -}; - - -#endif // _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCE_H_ - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_world.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_world.cxx deleted file mode 100644 index 2ee1dd79..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_world.cxx +++ /dev/null @@ -1,172 +0,0 @@ -// 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 hello_world.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "hello_world.h" - -#if FASTCDR_VERSION_MAJOR > 1 - -#include "hello_worldTypeObject.h" - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - - - - -hello_world::hello_world() -{ - // Just to register all known types - registerhello_worldTypes(); -} - -hello_world::~hello_world() -{ -} - -hello_world::hello_world( - const hello_world& x) -{ - m_index = x.m_index; - m_message = x.m_message; -} - -hello_world::hello_world( - hello_world&& x) noexcept -{ - m_index = x.m_index; - m_message = std::move(x.m_message); -} - -hello_world& hello_world::operator =( - const hello_world& x) -{ - - m_index = x.m_index; - m_message = x.m_message; - return *this; -} - -hello_world& hello_world::operator =( - hello_world&& x) noexcept -{ - - m_index = x.m_index; - m_message = std::move(x.m_message); - return *this; -} - -bool hello_world::operator ==( - const hello_world& x) const -{ - return (m_index == x.m_index && - m_message == x.m_message); -} - -bool hello_world::operator !=( - const hello_world& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ -void hello_world::index( - uint32_t _index) -{ - m_index = _index; -} - -/*! - * @brief This function returns the value of member index - * @return Value of member index - */ -uint32_t hello_world::index() const -{ - return m_index; -} - -/*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ -uint32_t& hello_world::index() -{ - return m_index; -} - - -/*! - * @brief This function copies the value in member message - * @param _message New value to be copied in member message - */ -void hello_world::message( - const std::string& _message) -{ - m_message = _message; -} - -/*! - * @brief This function moves the value in member message - * @param _message New value to be moved in member message - */ -void hello_world::message( - std::string&& _message) -{ - m_message = std::move(_message); -} - -/*! - * @brief This function returns a constant reference to member message - * @return Constant reference to member message - */ -const std::string& hello_world::message() const -{ - return m_message; -} - -/*! - * @brief This function returns a reference to member message - * @return Reference to member message - */ -std::string& hello_world::message() -{ - return m_message; -} - - -// Include auxiliary functions like for serializing/deserializing. -#include "hello_worldCdrAux.ipp" - -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldTypeObject.cxx deleted file mode 100644 index d6ece315..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldTypeObject.cxx +++ /dev/null @@ -1,263 +0,0 @@ -// 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 hello_worldTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { char dummy; } -#endif - -#include "hello_world.h" -#include "hello_worldTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerhello_worldTypes() -{ - static std::once_flag once_flag; - std::call_once(once_flag, []() - { - TypeObjectFactory *factory = TypeObjectFactory::get_instance(); - factory->add_type_object("hello_world", Gethello_worldIdentifier(true), - Gethello_worldObject(true)); - factory->add_type_object("hello_world", Gethello_worldIdentifier(false), - Gethello_worldObject(false)); - - }); -} - - - -const TypeIdentifier* Gethello_worldIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("hello_world", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - Gethello_worldObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("hello_world", complete); -} - -const TypeObject* Gethello_worldObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("hello_world", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompletehello_worldObject(); - } - //else - return GetMinimalhello_worldObject(); -} - -const TypeObject* GetMinimalhello_worldObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("hello_world", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_index; - mst_index.common().member_id(memberId++); - mst_index.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_index.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_index.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_index.common().member_flags().IS_OPTIONAL(false); - mst_index.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_index.common().member_flags().IS_KEY(false); - mst_index.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_index.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); - - - MD5 index_hash("index"); - for(int i = 0; i < 4; ++i) - { - mst_index.detail().name_hash()[i] = index_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_index); - - MinimalStructMember mst_message; - mst_message.common().member_id(memberId++); - mst_message.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_message.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_message.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_message.common().member_flags().IS_OPTIONAL(false); - mst_message.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_message.common().member_flags().IS_KEY(false); - mst_message.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_message.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - MD5 message_hash("message"); - for(int i = 0; i < 4; ++i) - { - mst_message.detail().name_hash()[i] = message_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_message); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("hello_world", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("hello_world", false); -} - -const TypeObject* GetCompletehello_worldObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("hello_world", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_index; - cst_index.common().member_id(memberId++); - cst_index.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_index.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_index.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_index.common().member_flags().IS_OPTIONAL(false); - cst_index.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_index.common().member_flags().IS_KEY(false); - cst_index.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_index.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); - - - cst_index.detail().name("index"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_index); - - CompleteStructMember cst_message; - cst_message.common().member_id(memberId++); - cst_message.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_message.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_message.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_message.common().member_flags().IS_OPTIONAL(false); - cst_message.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_message.common().member_flags().IS_KEY(false); - cst_message.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_message.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - cst_message.detail().name("message"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_message); - - - // Header - type_object->complete().struct_type().header().detail().type_name("hello_world"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("hello_world", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("hello_world", true); -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldTypeObject.h deleted file mode 100644 index 6e3ff21a..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldTypeObject.h +++ /dev/null @@ -1,65 +0,0 @@ -// 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 hello_worldTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_HELLO_WORLD_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_HELLO_WORLD_TYPE_OBJECT_H_ - - -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif -#else -#define eProsima_user_DllExport -#endif - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(hello_world_SOURCE) -#define hello_world_DllAPI __declspec( dllexport ) -#else -#define hello_world_DllAPI __declspec( dllimport ) -#endif // hello_world_SOURCE -#else -#define hello_world_DllAPI -#endif -#else -#define hello_world_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registerhello_worldTypes(); - - - -eProsima_user_DllExport const TypeIdentifier* Gethello_worldIdentifier(bool complete = false); -eProsima_user_DllExport const TypeObject* Gethello_worldObject(bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalhello_worldObject(); -eProsima_user_DllExport const TypeObject* GetCompletehello_worldObject(); - - -#endif // _FAST_DDS_GENERATED_HELLO_WORLD_TYPE_OBJECT_H_ \ No newline at end of file diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldv1.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldv1.cxx deleted file mode 100644 index 245df98d..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldv1.cxx +++ /dev/null @@ -1,290 +0,0 @@ -// 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 hello_world.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "hello_world.h" - -#if FASTCDR_VERSION_MAJOR == 1 - -#include "hello_worldTypeObject.h" - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - -namespace helper { namespace internal { - -enum class Size { - UInt8, - UInt16, - UInt32, - UInt64, -}; - -constexpr Size get_size(int s) { - return (s <= 8 ) ? Size::UInt8: - (s <= 16) ? Size::UInt16: - (s <= 32) ? Size::UInt32: Size::UInt64; -} - -template -struct FindTypeH; - -template<> -struct FindTypeH { - using type = std::uint8_t; -}; - -template<> -struct FindTypeH { - using type = std::uint16_t; -}; - -template<> -struct FindTypeH { - using type = std::uint32_t; -}; - -template<> -struct FindTypeH { - using type = std::uint64_t; -}; -} - -template -struct FindType { - using type = typename internal::FindTypeH::type; -}; -} - -#define hello_world_max_cdr_typesize 268ULL; - - - - -hello_world::hello_world() -{ - // unsigned long m_index - m_index = 0; - // /type_d() m_message - - - // Just to register all known types - registerhello_worldTypes(); -} - -hello_world::~hello_world() -{ -} - -hello_world::hello_world( - const hello_world& x) -{ - m_index = x.m_index; - - - m_message = x.m_message; - -} - -hello_world::hello_world( - hello_world&& x) noexcept -{ - m_index = x.m_index; - - - m_message = std::move(x.m_message); - -} - -hello_world& hello_world::operator =( - const hello_world& x) -{ - m_index = x.m_index; - - - m_message = x.m_message; - - return *this; -} - -hello_world& hello_world::operator =( - hello_world&& x) noexcept -{ - m_index = x.m_index; - - - m_message = std::move(x.m_message); - - return *this; -} - -bool hello_world::operator ==( - const hello_world& x) const -{ - return (m_index == x.m_index && - m_message == x.m_message); -} - -bool hello_world::operator !=( - const hello_world& x) const -{ - return !(*this == x); -} - -size_t hello_world::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return hello_world_max_cdr_typesize; -} - -size_t hello_world::getCdrSerializedSize( - const hello_world& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.message().size() + 1; - - - return current_alignment - initial_alignment; -} - - -void hello_world::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_index; - - scdr << m_message.c_str(); - -} - -void hello_world::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_index; - - - - dcdr >> m_message; - - -} - - -bool hello_world::isKeyDefined() -{ - return false; -} - -void hello_world::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ -void hello_world::index( - uint32_t _index) -{ - m_index = _index; -} - -/*! - * @brief This function returns the value of member index - * @return Value of member index - */ -uint32_t hello_world::index() const -{ - return m_index; -} - -/*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ -uint32_t& hello_world::index() -{ - return m_index; -} - - -/*! - * @brief This function copies the value in member message - * @param _message New value to be copied in member message - */ -void hello_world::message( - const std::string& _message) -{ - m_message = _message; -} - -/*! - * @brief This function moves the value in member message - * @param _message New value to be moved in member message - */ -void hello_world::message( - std::string&& _message) -{ - m_message = std::move(_message); -} - -/*! - * @brief This function returns a constant reference to member message - * @return Constant reference to member message - */ -const std::string& hello_world::message() const -{ - return m_message; -} - -/*! - * @brief This function returns a reference to member message - * @return Reference to member message - */ -std::string& hello_world::message() -{ - return m_message; -} - - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldv1.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldv1.h deleted file mode 100644 index 66250281..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldv1.h +++ /dev/null @@ -1,243 +0,0 @@ -// 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 hello_world.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#include - -#if FASTCDR_VERSION_MAJOR == 1 - -#ifndef _FAST_DDS_GENERATED_HELLO_WORLD_H_ -#define _FAST_DDS_GENERATED_HELLO_WORLD_H_ - - -#include - -#include -#include -#include -#include -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(HELLO_WORLD_SOURCE) -#define HELLO_WORLD_DllAPI __declspec( dllexport ) -#else -#define HELLO_WORLD_DllAPI __declspec( dllimport ) -#endif // HELLO_WORLD_SOURCE -#else -#define HELLO_WORLD_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define HELLO_WORLD_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - - - - -/*! - * @brief This class represents the structure hello_world defined by the user in the IDL file. - * @ingroup hello_world - */ -class hello_world -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport hello_world(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~hello_world(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object hello_world that will be copied. - */ - eProsima_user_DllExport hello_world( - const hello_world& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object hello_world that will be copied. - */ - eProsima_user_DllExport hello_world( - hello_world&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object hello_world that will be copied. - */ - eProsima_user_DllExport hello_world& operator =( - const hello_world& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object hello_world that will be copied. - */ - eProsima_user_DllExport hello_world& operator =( - hello_world&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x hello_world object to compare. - */ - eProsima_user_DllExport bool operator ==( - const hello_world& x) const; - - /*! - * @brief Comparison operator. - * @param x hello_world object to compare. - */ - eProsima_user_DllExport bool operator !=( - const hello_world& x) const; - - /*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ - eProsima_user_DllExport void index( - uint32_t _index); - - /*! - * @brief This function returns the value of member index - * @return Value of member index - */ - eProsima_user_DllExport uint32_t index() const; - - /*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ - eProsima_user_DllExport uint32_t& index(); - - - /*! - * @brief This function copies the value in member message - * @param _message New value to be copied in member message - */ - eProsima_user_DllExport void message( - const std::string& _message); - - /*! - * @brief This function moves the value in member message - * @param _message New value to be moved in member message - */ - eProsima_user_DllExport void message( - std::string&& _message); - - /*! - * @brief This function returns a constant reference to member message - * @return Constant reference to member message - */ - eProsima_user_DllExport const std::string& message() const; - - /*! - * @brief This function returns a reference to member message - * @return Reference to member message - */ - eProsima_user_DllExport std::string& message(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const hello_world& data, - size_t current_alignment = 0); - - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - - -private: - - uint32_t m_index; - std::string m_message; - -}; - - -#endif // _FAST_DDS_GENERATED_HELLO_WORLD_H_ - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_struct.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_struct.cxx deleted file mode 100644 index a76192c3..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_struct.cxx +++ /dev/null @@ -1,140 +0,0 @@ -// 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 map_struct.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "map_struct.h" - -#if FASTCDR_VERSION_MAJOR > 1 - -#include "map_structTypeObject.h" - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - - - - - - -map_struct::map_struct() -{ - // Just to register all known types - registermap_structTypes(); -} - -map_struct::~map_struct() -{ -} - -map_struct::map_struct( - const map_struct& x) -{ - m_my_map = x.m_my_map; -} - -map_struct::map_struct( - map_struct&& x) noexcept -{ - m_my_map = std::move(x.m_my_map); -} - -map_struct& map_struct::operator =( - const map_struct& x) -{ - - m_my_map = x.m_my_map; - return *this; -} - -map_struct& map_struct::operator =( - map_struct&& x) noexcept -{ - - m_my_map = std::move(x.m_my_map); - return *this; -} - -bool map_struct::operator ==( - const map_struct& x) const -{ - return (m_my_map == x.m_my_map); -} - -bool map_struct::operator !=( - const map_struct& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function copies the value in member my_map - * @param _my_map New value to be copied in member my_map - */ -void map_struct::my_map( - const std::map& _my_map) -{ - m_my_map = _my_map; -} - -/*! - * @brief This function moves the value in member my_map - * @param _my_map New value to be moved in member my_map - */ -void map_struct::my_map( - std::map&& _my_map) -{ - m_my_map = std::move(_my_map); -} - -/*! - * @brief This function returns a constant reference to member my_map - * @return Constant reference to member my_map - */ -const std::map& map_struct::my_map() const -{ - return m_my_map; -} - -/*! - * @brief This function returns a reference to member my_map - * @return Reference to member my_map - */ -std::map& map_struct::my_map() -{ - return m_my_map; -} - - -// Include auxiliary functions like for serializing/deserializing. -#include "map_structCdrAux.ipp" - -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_struct.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_struct.h deleted file mode 100644 index 56466950..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_struct.h +++ /dev/null @@ -1,176 +0,0 @@ -// 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 map_struct.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#include -#include "map_structv1.h" - -#if FASTCDR_VERSION_MAJOR > 1 - -#ifndef _FAST_DDS_GENERATED_MAP_STRUCT_H_ -#define _FAST_DDS_GENERATED_MAP_STRUCT_H_ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - - - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(MAP_STRUCT_SOURCE) -#define MAP_STRUCT_DllAPI __declspec( dllexport ) -#else -#define MAP_STRUCT_DllAPI __declspec( dllimport ) -#endif // MAP_STRUCT_SOURCE -#else -#define MAP_STRUCT_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define MAP_STRUCT_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -class CdrSizeCalculator; -} // namespace fastcdr -} // namespace eprosima - - - - - - - -/*! - * @brief This class represents the structure map_struct defined by the user in the IDL file. - * @ingroup map_struct - */ -class map_struct -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport map_struct(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~map_struct(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object map_struct that will be copied. - */ - eProsima_user_DllExport map_struct( - const map_struct& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object map_struct that will be copied. - */ - eProsima_user_DllExport map_struct( - map_struct&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object map_struct that will be copied. - */ - eProsima_user_DllExport map_struct& operator =( - const map_struct& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object map_struct that will be copied. - */ - eProsima_user_DllExport map_struct& operator =( - map_struct&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x map_struct object to compare. - */ - eProsima_user_DllExport bool operator ==( - const map_struct& x) const; - - /*! - * @brief Comparison operator. - * @param x map_struct object to compare. - */ - eProsima_user_DllExport bool operator !=( - const map_struct& x) const; - - /*! - * @brief This function copies the value in member my_map - * @param _my_map New value to be copied in member my_map - */ - eProsima_user_DllExport void my_map( - const std::map& _my_map); - - /*! - * @brief This function moves the value in member my_map - * @param _my_map New value to be moved in member my_map - */ - eProsima_user_DllExport void my_map( - std::map&& _my_map); - - /*! - * @brief This function returns a constant reference to member my_map - * @return Constant reference to member my_map - */ - eProsima_user_DllExport const std::map& my_map() const; - - /*! - * @brief This function returns a reference to member my_map - * @return Reference to member my_map - */ - eProsima_user_DllExport std::map& my_map(); - -private: - - std::map m_my_map; - -}; - -#endif // _FAST_DDS_GENERATED_MAP_STRUCT_H_ - - - -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structCdrAux.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structCdrAux.hpp deleted file mode 100644 index 54604acc..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structCdrAux.hpp +++ /dev/null @@ -1,50 +0,0 @@ -// 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 map_structCdrAux.hpp - * This source file contains some definitions of CDR related functions. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_MAP_STRUCTCDRAUX_HPP_ -#define _FAST_DDS_GENERATED_MAP_STRUCTCDRAUX_HPP_ - -#include "map_struct.h" - -constexpr uint32_t map_struct_max_cdr_typesize {26405UL}; -constexpr uint32_t map_struct_max_key_cdr_typesize {0UL}; - - -namespace eprosima { -namespace fastcdr { - -class Cdr; -class CdrSizeCalculator; - - - - - -eProsima_user_DllExport void serialize_key( - eprosima::fastcdr::Cdr& scdr, - const map_struct& data); - - -} // namespace fastcdr -} // namespace eprosima - -#endif // _FAST_DDS_GENERATED_MAP_STRUCTCDRAUX_HPP_ - diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structCdrAux.ipp b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structCdrAux.ipp deleted file mode 100644 index c8c4e2a9..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structCdrAux.ipp +++ /dev/null @@ -1,122 +0,0 @@ -// 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 map_structCdrAux.ipp - * This source file contains some declarations of CDR related functions. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_MAP_STRUCTCDRAUX_IPP_ -#define _FAST_DDS_GENERATED_MAP_STRUCTCDRAUX_IPP_ - -#include "map_structCdrAux.hpp" - -#include -#include - - -#include -using namespace eprosima::fastcdr::exception; - -namespace eprosima { -namespace fastcdr { - - - - - -template<> -eProsima_user_DllExport size_t calculate_serialized_size( - eprosima::fastcdr::CdrSizeCalculator& calculator, - const map_struct& data, - size_t& current_alignment) -{ - static_cast(data); - - eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); - size_t calculated_size {calculator.begin_calculate_type_serialized_size( - eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, - current_alignment)}; - - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.my_map(), current_alignment); - - - calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); - - return calculated_size; -} - -template<> -eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& scdr, - const map_struct& data) -{ - eprosima::fastcdr::Cdr::state current_state(scdr); - scdr.begin_serialize_type(current_state, - eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR); - - scdr - << eprosima::fastcdr::MemberId(0) << data.my_map() -; - scdr.end_serialize_type(current_state); -} - -template<> -eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr, - map_struct& data) -{ - cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, - [&data](eprosima::fastcdr::Cdr& dcdr, const eprosima::fastcdr::MemberId& mid) -> bool - { - bool ret_value = true; - switch (mid.id) - { - case 0: - dcdr >> data.my_map(); - break; - - default: - ret_value = false; - break; - } - return ret_value; - }); -} - -void serialize_key( - eprosima::fastcdr::Cdr& scdr, - const map_struct& data) -{ - static_cast(scdr); - static_cast(data); -} - - - -} // namespace fastcdr -} // namespace eprosima - -#endif // _FAST_DDS_GENERATED_MAP_STRUCTCDRAUX_IPP_ - diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structPubSubTypes.cxx deleted file mode 100644 index c6912f0c..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structPubSubTypes.cxx +++ /dev/null @@ -1,223 +0,0 @@ -// 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 map_structPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#include - -#include "map_structPubSubTypes.h" -#include "map_structCdrAux.hpp" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; -using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - - - - - -map_structPubSubType::map_structPubSubType() -{ - setName("map_struct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(map_struct::getMaxCdrSerializedSize()); -#else - map_struct_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = map_struct_max_key_cdr_typesize > 16 ? map_struct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -map_structPubSubType::~map_structPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool map_structPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - map_struct* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool map_structPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - map_struct* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function map_structPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* map_structPubSubType::createData() -{ - return reinterpret_cast(new map_struct()); -} - -void map_structPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool map_structPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - map_struct* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - map_struct_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || map_struct_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} - diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structPubSubTypes.h deleted file mode 100644 index 9ce0fd50..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structPubSubTypes.h +++ /dev/null @@ -1,134 +0,0 @@ -// 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 map_structPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#ifndef _FAST_DDS_GENERATED_MAP_STRUCT_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_MAP_STRUCT_PUBSUBTYPES_H_ - -#include -#include -#include -#include -#include - -#include "map_struct.h" - - -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) -#error \ - Generated map_struct is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER - - - - - - -/*! - * @brief This class represents the TopicDataType of the type map_struct defined by the user in the IDL file. - * @ingroup map_struct - */ -class map_structPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef map_struct type; - - eProsima_user_DllExport map_structPubSubType(); - - eProsima_user_DllExport ~map_structPubSubType() override; - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport void* createData() override; - - eProsima_user_DllExport void deleteData( - void* data) override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } - - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - static_cast(memory); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - -#endif // _FAST_DDS_GENERATED_MAP_STRUCT_PUBSUBTYPES_H_ - diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structTypeObject.cxx deleted file mode 100644 index 8c1761f7..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structTypeObject.cxx +++ /dev/null @@ -1,230 +0,0 @@ -// 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 map_structTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { char dummy; } -#endif - -#include "map_struct.h" -#include "map_structTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registermap_structTypes() -{ - static std::once_flag once_flag; - std::call_once(once_flag, []() - { - TypeObjectFactory *factory = TypeObjectFactory::get_instance(); - factory->add_type_object("map_struct", Getmap_structIdentifier(true), - Getmap_structObject(true)); - factory->add_type_object("map_struct", Getmap_structIdentifier(false), - Getmap_structObject(false)); - - }); -} - - - - - -const TypeIdentifier* Getmap_structIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("map_struct", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - Getmap_structObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("map_struct", complete); -} - -const TypeObject* Getmap_structObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("map_struct", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompletemap_structObject(); - } - //else - return GetMinimalmap_structObject(); -} - -const TypeObject* GetMinimalmap_structObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("map_struct", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_my_map; - mst_my_map.common().member_id(memberId++); - mst_my_map.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_my_map.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_my_map.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_my_map.common().member_flags().IS_OPTIONAL(false); - mst_my_map.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_my_map.common().member_flags().IS_KEY(false); - mst_my_map.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_my_map.common().member_type_id(*TypeObjectFactory::get_instance()->get_map_identifier(TypeNamesGenerator::get_string_type_name(255, false), "bool", 100, false)); - - MD5 my_map_hash("my_map"); - for(int i = 0; i < 4; ++i) - { - mst_my_map.detail().name_hash()[i] = my_map_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_my_map); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("map_struct", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("map_struct", false); -} - -const TypeObject* GetCompletemap_structObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("map_struct", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_my_map; - cst_my_map.common().member_id(memberId++); - cst_my_map.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_my_map.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_my_map.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_my_map.common().member_flags().IS_OPTIONAL(false); - cst_my_map.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_my_map.common().member_flags().IS_KEY(false); - cst_my_map.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_my_map.common().member_type_id(*TypeObjectFactory::get_instance()->get_map_identifier(TypeNamesGenerator::get_string_type_name(255, false), "bool", 100, true)); - - cst_my_map.detail().name("my_map"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_my_map); - - - // Header - type_object->complete().struct_type().header().detail().type_name("map_struct"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("map_struct", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("map_struct", true); -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structTypeObject.h deleted file mode 100644 index b36c5102..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structTypeObject.h +++ /dev/null @@ -1,67 +0,0 @@ -// 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 map_structTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_MAP_STRUCT_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_MAP_STRUCT_TYPE_OBJECT_H_ - - -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif -#else -#define eProsima_user_DllExport -#endif - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(map_struct_SOURCE) -#define map_struct_DllAPI __declspec( dllexport ) -#else -#define map_struct_DllAPI __declspec( dllimport ) -#endif // map_struct_SOURCE -#else -#define map_struct_DllAPI -#endif -#else -#define map_struct_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registermap_structTypes(); - - - - - -eProsima_user_DllExport const TypeIdentifier* Getmap_structIdentifier(bool complete = false); -eProsima_user_DllExport const TypeObject* Getmap_structObject(bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalmap_structObject(); -eProsima_user_DllExport const TypeObject* GetCompletemap_structObject(); - - -#endif // _FAST_DDS_GENERATED_MAP_STRUCT_TYPE_OBJECT_H_ \ No newline at end of file diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structv1.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structv1.cxx deleted file mode 100644 index cc73fa45..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structv1.cxx +++ /dev/null @@ -1,268 +0,0 @@ -// 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 map_struct.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "map_struct.h" - -#if FASTCDR_VERSION_MAJOR == 1 - -#include "map_structTypeObject.h" - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - -namespace helper { namespace internal { - -enum class Size { - UInt8, - UInt16, - UInt32, - UInt64, -}; - -constexpr Size get_size(int s) { - return (s <= 8 ) ? Size::UInt8: - (s <= 16) ? Size::UInt16: - (s <= 32) ? Size::UInt32: Size::UInt64; -} - -template -struct FindTypeH; - -template<> -struct FindTypeH { - using type = std::uint8_t; -}; - -template<> -struct FindTypeH { - using type = std::uint16_t; -}; - -template<> -struct FindTypeH { - using type = std::uint32_t; -}; - -template<> -struct FindTypeH { - using type = std::uint64_t; -}; -} - -template -struct FindType { - using type = typename internal::FindTypeH::type; -}; -} - -#define map_struct_max_cdr_typesize 26405ULL; - - - - - - -map_struct::map_struct() -{ - // map m_my_map - - - // Just to register all known types - registermap_structTypes(); -} - -map_struct::~map_struct() -{ -} - -map_struct::map_struct( - const map_struct& x) -{ - m_my_map = x.m_my_map; - -} - -map_struct::map_struct( - map_struct&& x) noexcept -{ - m_my_map = std::move(x.m_my_map); - -} - -map_struct& map_struct::operator =( - const map_struct& x) -{ - m_my_map = x.m_my_map; - - return *this; -} - -map_struct& map_struct::operator =( - map_struct&& x) noexcept -{ - m_my_map = std::move(x.m_my_map); - - return *this; -} - -bool map_struct::operator ==( - const map_struct& x) const -{ - return (m_my_map == x.m_my_map); -} - -bool map_struct::operator !=( - const map_struct& x) const -{ - return !(*this == x); -} - -size_t map_struct::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return map_struct_max_cdr_typesize; -} - -size_t map_struct::getCdrSerializedSize( - const map_struct& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - for(auto a : data.my_map()) - { - (void)a; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + a.first.size() + 1; - - current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); - - } - - - return current_alignment - initial_alignment; -} - - -void map_struct::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << static_cast(m_my_map.size()); - for (const auto& pair : m_my_map) - { - scdr << pair.first.c_str(); - scdr << pair.second; - } - -} - -void map_struct::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - - uint32_t seq_length = 0; - dcdr >> seq_length; - m_my_map.clear(); - for (uint32_t i = 0; i < seq_length; ++i) - { - std::string key; - dcdr >> key; - - - bool value; - dcdr >> value; - m_my_map[key.c_str()] = value; - - } - - -} - - -bool map_struct::isKeyDefined() -{ - return false; -} - -void map_struct::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function copies the value in member my_map - * @param _my_map New value to be copied in member my_map - */ -void map_struct::my_map( - const std::map& _my_map) -{ - m_my_map = _my_map; -} - -/*! - * @brief This function moves the value in member my_map - * @param _my_map New value to be moved in member my_map - */ -void map_struct::my_map( - std::map&& _my_map) -{ - m_my_map = std::move(_my_map); -} - -/*! - * @brief This function returns a constant reference to member my_map - * @return Constant reference to member my_map - */ -const std::map& map_struct::my_map() const -{ - return m_my_map; -} - -/*! - * @brief This function returns a reference to member my_map - * @return Reference to member my_map - */ -std::map& map_struct::my_map() -{ - return m_my_map; -} - - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structv1.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structv1.h deleted file mode 100644 index 4ed18689..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structv1.h +++ /dev/null @@ -1,224 +0,0 @@ -// 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 map_struct.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#include - -#if FASTCDR_VERSION_MAJOR == 1 - -#ifndef _FAST_DDS_GENERATED_MAP_STRUCT_H_ -#define _FAST_DDS_GENERATED_MAP_STRUCT_H_ - - -#include - -#include -#include -#include -#include -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(MAP_STRUCT_SOURCE) -#define MAP_STRUCT_DllAPI __declspec( dllexport ) -#else -#define MAP_STRUCT_DllAPI __declspec( dllimport ) -#endif // MAP_STRUCT_SOURCE -#else -#define MAP_STRUCT_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define MAP_STRUCT_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - - - - - - -/*! - * @brief This class represents the structure map_struct defined by the user in the IDL file. - * @ingroup map_struct - */ -class map_struct -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport map_struct(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~map_struct(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object map_struct that will be copied. - */ - eProsima_user_DllExport map_struct( - const map_struct& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object map_struct that will be copied. - */ - eProsima_user_DllExport map_struct( - map_struct&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object map_struct that will be copied. - */ - eProsima_user_DllExport map_struct& operator =( - const map_struct& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object map_struct that will be copied. - */ - eProsima_user_DllExport map_struct& operator =( - map_struct&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x map_struct object to compare. - */ - eProsima_user_DllExport bool operator ==( - const map_struct& x) const; - - /*! - * @brief Comparison operator. - * @param x map_struct object to compare. - */ - eProsima_user_DllExport bool operator !=( - const map_struct& x) const; - - /*! - * @brief This function copies the value in member my_map - * @param _my_map New value to be copied in member my_map - */ - eProsima_user_DllExport void my_map( - const std::map& _my_map); - - /*! - * @brief This function moves the value in member my_map - * @param _my_map New value to be moved in member my_map - */ - eProsima_user_DllExport void my_map( - std::map&& _my_map); - - /*! - * @brief This function returns a constant reference to member my_map - * @return Constant reference to member my_map - */ - eProsima_user_DllExport const std::map& my_map() const; - - /*! - * @brief This function returns a reference to member my_map - * @return Reference to member my_map - */ - eProsima_user_DllExport std::map& my_map(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const map_struct& data, - size_t current_alignment = 0); - - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - - -private: - - std::map m_my_map; - -}; - - -#endif // _FAST_DDS_GENERATED_MAP_STRUCT_H_ - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_array.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_array.cxx deleted file mode 100644 index 06dba498..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_array.cxx +++ /dev/null @@ -1,138 +0,0 @@ -// 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 numeric_array.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "numeric_array.h" - -#if FASTCDR_VERSION_MAJOR > 1 - -#include "numeric_arrayTypeObject.h" - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - - - - -numeric_array::numeric_array() -{ - // Just to register all known types - registernumeric_arrayTypes(); -} - -numeric_array::~numeric_array() -{ -} - -numeric_array::numeric_array( - const numeric_array& x) -{ - m_points = x.m_points; -} - -numeric_array::numeric_array( - numeric_array&& x) noexcept -{ - m_points = std::move(x.m_points); -} - -numeric_array& numeric_array::operator =( - const numeric_array& x) -{ - - m_points = x.m_points; - return *this; -} - -numeric_array& numeric_array::operator =( - numeric_array&& x) noexcept -{ - - m_points = std::move(x.m_points); - return *this; -} - -bool numeric_array::operator ==( - const numeric_array& x) const -{ - return (m_points == x.m_points); -} - -bool numeric_array::operator !=( - const numeric_array& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function copies the value in member points - * @param _points New value to be copied in member points - */ -void numeric_array::points( - const std::array& _points) -{ - m_points = _points; -} - -/*! - * @brief This function moves the value in member points - * @param _points New value to be moved in member points - */ -void numeric_array::points( - std::array&& _points) -{ - m_points = std::move(_points); -} - -/*! - * @brief This function returns a constant reference to member points - * @return Constant reference to member points - */ -const std::array& numeric_array::points() const -{ - return m_points; -} - -/*! - * @brief This function returns a reference to member points - * @return Reference to member points - */ -std::array& numeric_array::points() -{ - return m_points; -} - - -// Include auxiliary functions like for serializing/deserializing. -#include "numeric_arrayCdrAux.ipp" - -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayTypeObject.cxx deleted file mode 100644 index ee725383..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayTypeObject.cxx +++ /dev/null @@ -1,228 +0,0 @@ -// 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 numeric_arrayTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { char dummy; } -#endif - -#include "numeric_array.h" -#include "numeric_arrayTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registernumeric_arrayTypes() -{ - static std::once_flag once_flag; - std::call_once(once_flag, []() - { - TypeObjectFactory *factory = TypeObjectFactory::get_instance(); - factory->add_type_object("numeric_array", Getnumeric_arrayIdentifier(true), - Getnumeric_arrayObject(true)); - factory->add_type_object("numeric_array", Getnumeric_arrayIdentifier(false), - Getnumeric_arrayObject(false)); - - }); -} - - - -const TypeIdentifier* Getnumeric_arrayIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("numeric_array", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - Getnumeric_arrayObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("numeric_array", complete); -} - -const TypeObject* Getnumeric_arrayObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("numeric_array", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompletenumeric_arrayObject(); - } - //else - return GetMinimalnumeric_arrayObject(); -} - -const TypeObject* GetMinimalnumeric_arrayObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("numeric_array", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_points; - mst_points.common().member_id(memberId++); - mst_points.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_points.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_points.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_points.common().member_flags().IS_OPTIONAL(false); - mst_points.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_points.common().member_flags().IS_KEY(false); - mst_points.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_points.common().member_type_id(*TypeObjectFactory::get_instance()->get_array_identifier("int32_t", {3}, false)); - - MD5 points_hash("points"); - for(int i = 0; i < 4; ++i) - { - mst_points.detail().name_hash()[i] = points_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_points); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("numeric_array", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("numeric_array", false); -} - -const TypeObject* GetCompletenumeric_arrayObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("numeric_array", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_points; - cst_points.common().member_id(memberId++); - cst_points.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_points.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_points.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_points.common().member_flags().IS_OPTIONAL(false); - cst_points.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_points.common().member_flags().IS_KEY(false); - cst_points.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_points.common().member_type_id(*TypeObjectFactory::get_instance()->get_array_identifier("int32_t", {3}, true)); - - cst_points.detail().name("points"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_points); - - - // Header - type_object->complete().struct_type().header().detail().type_name("numeric_array"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("numeric_array", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("numeric_array", true); -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayTypeObject.h deleted file mode 100644 index 55a4b992..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayTypeObject.h +++ /dev/null @@ -1,65 +0,0 @@ -// 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 numeric_arrayTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_NUMERIC_ARRAY_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_NUMERIC_ARRAY_TYPE_OBJECT_H_ - - -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif -#else -#define eProsima_user_DllExport -#endif - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(numeric_array_SOURCE) -#define numeric_array_DllAPI __declspec( dllexport ) -#else -#define numeric_array_DllAPI __declspec( dllimport ) -#endif // numeric_array_SOURCE -#else -#define numeric_array_DllAPI -#endif -#else -#define numeric_array_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registernumeric_arrayTypes(); - - - -eProsima_user_DllExport const TypeIdentifier* Getnumeric_arrayIdentifier(bool complete = false); -eProsima_user_DllExport const TypeObject* Getnumeric_arrayObject(bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalnumeric_arrayObject(); -eProsima_user_DllExport const TypeObject* GetCompletenumeric_arrayObject(); - - -#endif // _FAST_DDS_GENERATED_NUMERIC_ARRAY_TYPE_OBJECT_H_ \ No newline at end of file diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayv1.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayv1.cxx deleted file mode 100644 index 28ba3802..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayv1.cxx +++ /dev/null @@ -1,239 +0,0 @@ -// 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 numeric_array.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "numeric_array.h" - -#if FASTCDR_VERSION_MAJOR == 1 - -#include "numeric_arrayTypeObject.h" - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - -namespace helper { namespace internal { - -enum class Size { - UInt8, - UInt16, - UInt32, - UInt64, -}; - -constexpr Size get_size(int s) { - return (s <= 8 ) ? Size::UInt8: - (s <= 16) ? Size::UInt16: - (s <= 32) ? Size::UInt32: Size::UInt64; -} - -template -struct FindTypeH; - -template<> -struct FindTypeH { - using type = std::uint8_t; -}; - -template<> -struct FindTypeH { - using type = std::uint16_t; -}; - -template<> -struct FindTypeH { - using type = std::uint32_t; -}; - -template<> -struct FindTypeH { - using type = std::uint64_t; -}; -} - -template -struct FindType { - using type = typename internal::FindTypeH::type; -}; -} - -#define numeric_array_max_cdr_typesize 16ULL; - - - - -numeric_array::numeric_array() -{ - // long m_points - memset(&m_points, 0, ((3)) * 4); - - // Just to register all known types - registernumeric_arrayTypes(); -} - -numeric_array::~numeric_array() -{ -} - -numeric_array::numeric_array( - const numeric_array& x) -{ - m_points = x.m_points; - -} - -numeric_array::numeric_array( - numeric_array&& x) noexcept -{ - m_points = std::move(x.m_points); - -} - -numeric_array& numeric_array::operator =( - const numeric_array& x) -{ - m_points = x.m_points; - - return *this; -} - -numeric_array& numeric_array::operator =( - numeric_array&& x) noexcept -{ - m_points = std::move(x.m_points); - - return *this; -} - -bool numeric_array::operator ==( - const numeric_array& x) const -{ - return (m_points == x.m_points); -} - -bool numeric_array::operator !=( - const numeric_array& x) const -{ - return !(*this == x); -} - -size_t numeric_array::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return numeric_array_max_cdr_typesize; -} - -size_t numeric_array::getCdrSerializedSize( - const numeric_array& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += (((3)) * 4) + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - - return current_alignment - initial_alignment; -} - - -void numeric_array::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_points; - - -} - -void numeric_array::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_points; - - -} - - -bool numeric_array::isKeyDefined() -{ - return false; -} - -void numeric_array::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function copies the value in member points - * @param _points New value to be copied in member points - */ -void numeric_array::points( - const std::array& _points) -{ - m_points = _points; -} - -/*! - * @brief This function moves the value in member points - * @param _points New value to be moved in member points - */ -void numeric_array::points( - std::array&& _points) -{ - m_points = std::move(_points); -} - -/*! - * @brief This function returns a constant reference to member points - * @return Constant reference to member points - */ -const std::array& numeric_array::points() const -{ - return m_points; -} - -/*! - * @brief This function returns a reference to member points - * @return Reference to member points - */ -std::array& numeric_array::points() -{ - return m_points; -} - - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayv1.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayv1.h deleted file mode 100644 index 794e52ee..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayv1.h +++ /dev/null @@ -1,222 +0,0 @@ -// 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 numeric_array.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#include - -#if FASTCDR_VERSION_MAJOR == 1 - -#ifndef _FAST_DDS_GENERATED_NUMERIC_ARRAY_H_ -#define _FAST_DDS_GENERATED_NUMERIC_ARRAY_H_ - - -#include - -#include -#include -#include -#include -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(NUMERIC_ARRAY_SOURCE) -#define NUMERIC_ARRAY_DllAPI __declspec( dllexport ) -#else -#define NUMERIC_ARRAY_DllAPI __declspec( dllimport ) -#endif // NUMERIC_ARRAY_SOURCE -#else -#define NUMERIC_ARRAY_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define NUMERIC_ARRAY_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - - - - -/*! - * @brief This class represents the structure numeric_array defined by the user in the IDL file. - * @ingroup numeric_array - */ -class numeric_array -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport numeric_array(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~numeric_array(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object numeric_array that will be copied. - */ - eProsima_user_DllExport numeric_array( - const numeric_array& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object numeric_array that will be copied. - */ - eProsima_user_DllExport numeric_array( - numeric_array&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object numeric_array that will be copied. - */ - eProsima_user_DllExport numeric_array& operator =( - const numeric_array& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object numeric_array that will be copied. - */ - eProsima_user_DllExport numeric_array& operator =( - numeric_array&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x numeric_array object to compare. - */ - eProsima_user_DllExport bool operator ==( - const numeric_array& x) const; - - /*! - * @brief Comparison operator. - * @param x numeric_array object to compare. - */ - eProsima_user_DllExport bool operator !=( - const numeric_array& x) const; - - /*! - * @brief This function copies the value in member points - * @param _points New value to be copied in member points - */ - eProsima_user_DllExport void points( - const std::array& _points); - - /*! - * @brief This function moves the value in member points - * @param _points New value to be moved in member points - */ - eProsima_user_DllExport void points( - std::array&& _points); - - /*! - * @brief This function returns a constant reference to member points - * @return Constant reference to member points - */ - eProsima_user_DllExport const std::array& points() const; - - /*! - * @brief This function returns a reference to member points - * @return Reference to member points - */ - eProsima_user_DllExport std::array& points(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const numeric_array& data, - size_t current_alignment = 0); - - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - - -private: - - std::array m_points; - -}; - - -#endif // _FAST_DDS_GENERATED_NUMERIC_ARRAY_H_ - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_struct.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_struct.cxx deleted file mode 100644 index 0bf67dac..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_struct.cxx +++ /dev/null @@ -1,554 +0,0 @@ -// 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 union_struct.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "union_struct.h" - -#if FASTCDR_VERSION_MAJOR > 1 - -#include "union_structTypeObject.h" - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - - - - -MyUnion::MyUnion() -{ - m__d = 1; -} - -MyUnion::~MyUnion() -{ -} - -MyUnion::MyUnion( - const MyUnion& x) -{ - m__d = x.m__d; - - switch (m__d) - { - case 1: - m_octet_value = x.m_octet_value; - break; - - - case 2: - m_long_value = x.m_long_value; - break; - - - case 3: - m_string_value = x.m_string_value; - break; - - default: - break; - } -} - -MyUnion::MyUnion( - MyUnion&& x) noexcept -{ - m__d = x.m__d; - - switch (m__d) - { - case 1: - m_octet_value = x.m_octet_value; - break; - - - case 2: - m_long_value = x.m_long_value; - break; - - - case 3: - m_string_value = std::move(x.m_string_value); - - break; - - default: - break; - } -} - -MyUnion& MyUnion::operator =( - const MyUnion& x) -{ - m__d = x.m__d; - - switch (m__d) - { - case 1: - m_octet_value = x.m_octet_value; - break; - - - case 2: - m_long_value = x.m_long_value; - break; - - - case 3: - m_string_value = x.m_string_value; - break; - - default: - break; - } - - return *this; -} - -MyUnion& MyUnion::operator =( - MyUnion&& x) noexcept -{ - m__d = x.m__d; - - switch (m__d) - { - case 1: - m_octet_value = x.m_octet_value; - break; - - - case 2: - m_long_value = x.m_long_value; - break; - - - case 3: - m_string_value = std::move(x.m_string_value); - - break; - - default: - break; - } - - return *this; -} - -bool MyUnion::operator ==( - const MyUnion& x) const -{ - if (m__d != x.m__d) - { - return false; - } - - switch (m__d) - { - case 1: - return (m_octet_value == x.m_octet_value); - break; - - - case 2: - return (m_long_value == x.m_long_value); - break; - - - case 3: - return (m_string_value == x.m_string_value); - break; - - default: - break; - } - return false; -} - -bool MyUnion::operator !=( - const MyUnion& x) const -{ - return !(*this == x); -} - -void MyUnion::_d( - int32_t __d) -{ - bool b = false; - - switch (m__d) - { - case 1: - switch (__d) - { - case 1: - b = true; - break; - default: - break; - } - break; - - - case 2: - switch (__d) - { - case 2: - b = true; - break; - default: - break; - } - break; - - - case 3: - switch (__d) - { - case 3: - b = true; - break; - default: - break; - } - break; - - default: - break; - } - - if (!b) - { - throw BadParamException("Discriminator doesn't correspond with the selected union member"); - } - - m__d = __d; -} - -int32_t MyUnion::_d() const -{ - return m__d; -} - -int32_t& MyUnion::_d() -{ - return m__d; -} - -void MyUnion::octet_value( - uint8_t _octet_value) -{ - m_octet_value = _octet_value; - m__d = 1; - -} - -uint8_t MyUnion::octet_value() const -{ - bool b = false; - - switch (m__d) - { - case 1: - b = true; - break; - default: - break; - } - - if (!b) - { - throw BadParamException("This member has not been selected"); - } - - return m_octet_value; -} - -uint8_t& MyUnion::octet_value() -{ - bool b = false; - - switch (m__d) - { - case 1: - b = true; - break; - default: - break; - } - - if (!b) - { - throw BadParamException("This member has not been selected"); - } - - return m_octet_value; -} - - -void MyUnion::long_value( - int32_t _long_value) -{ - m_long_value = _long_value; - m__d = 2; - -} - -int32_t MyUnion::long_value() const -{ - bool b = false; - - switch (m__d) - { - case 2: - b = true; - break; - default: - break; - } - - if (!b) - { - throw BadParamException("This member has not been selected"); - } - - return m_long_value; -} - -int32_t& MyUnion::long_value() -{ - bool b = false; - - switch (m__d) - { - case 2: - b = true; - break; - default: - break; - } - - if (!b) - { - throw BadParamException("This member has not been selected"); - } - - return m_long_value; -} - - -void MyUnion::string_value( - const std::string& _string_value) -{ - m_string_value = _string_value; - m__d = 3; - -} - -void MyUnion::string_value( - std::string&& _string_value) -{ - m_string_value = std::move(_string_value); - m__d = 3; - -} - -const std::string& MyUnion::string_value() const -{ - bool b = false; - - switch (m__d) - { - case 3: - b = true; - break; - default: - break; - } - - if (!b) - { - throw BadParamException("This member has not been selected"); - } - - return m_string_value; -} - -std::string& MyUnion::string_value() -{ - bool b = false; - - switch (m__d) - { - case 3: - b = true; - break; - default: - break; - } - - if (!b) - { - throw BadParamException("This member has not been selected"); - } - - return m_string_value; -} - - - - -union_struct::union_struct() -{ - // Just to register all known types - registerunion_structTypes(); -} - -union_struct::~union_struct() -{ -} - -union_struct::union_struct( - const union_struct& x) -{ - m_index = x.m_index; - m_union_value = x.m_union_value; -} - -union_struct::union_struct( - union_struct&& x) noexcept -{ - m_index = x.m_index; - m_union_value = std::move(x.m_union_value); -} - -union_struct& union_struct::operator =( - const union_struct& x) -{ - - m_index = x.m_index; - m_union_value = x.m_union_value; - return *this; -} - -union_struct& union_struct::operator =( - union_struct&& x) noexcept -{ - - m_index = x.m_index; - m_union_value = std::move(x.m_union_value); - return *this; -} - -bool union_struct::operator ==( - const union_struct& x) const -{ - return (m_index == x.m_index && - m_union_value == x.m_union_value); -} - -bool union_struct::operator !=( - const union_struct& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ -void union_struct::index( - uint32_t _index) -{ - m_index = _index; -} - -/*! - * @brief This function returns the value of member index - * @return Value of member index - */ -uint32_t union_struct::index() const -{ - return m_index; -} - -/*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ -uint32_t& union_struct::index() -{ - return m_index; -} - - -/*! - * @brief This function copies the value in member union_value - * @param _union_value New value to be copied in member union_value - */ -void union_struct::union_value( - const MyUnion& _union_value) -{ - m_union_value = _union_value; -} - -/*! - * @brief This function moves the value in member union_value - * @param _union_value New value to be moved in member union_value - */ -void union_struct::union_value( - MyUnion&& _union_value) -{ - m_union_value = std::move(_union_value); -} - -/*! - * @brief This function returns a constant reference to member union_value - * @return Constant reference to member union_value - */ -const MyUnion& union_struct::union_value() const -{ - return m_union_value; -} - -/*! - * @brief This function returns a reference to member union_value - * @return Reference to member union_value - */ -MyUnion& union_struct::union_value() -{ - return m_union_value; -} - - -// Include auxiliary functions like for serializing/deserializing. -#include "union_structCdrAux.ipp" - -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_struct.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_struct.h deleted file mode 100644 index 96b58855..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_struct.h +++ /dev/null @@ -1,357 +0,0 @@ -// 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 union_struct.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#include -#include "union_structv1.h" - -#if FASTCDR_VERSION_MAJOR > 1 - -#ifndef _FAST_DDS_GENERATED_UNION_STRUCT_H_ -#define _FAST_DDS_GENERATED_UNION_STRUCT_H_ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - - - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(UNION_STRUCT_SOURCE) -#define UNION_STRUCT_DllAPI __declspec( dllexport ) -#else -#define UNION_STRUCT_DllAPI __declspec( dllimport ) -#endif // UNION_STRUCT_SOURCE -#else -#define UNION_STRUCT_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define UNION_STRUCT_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -class CdrSizeCalculator; -} // namespace fastcdr -} // namespace eprosima - - - - - -/*! - * @brief This class represents the union MyUnion defined by the user in the IDL file. - * @ingroup union_struct - */ -class MyUnion -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport MyUnion(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~MyUnion(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object MyUnion that will be copied. - */ - eProsima_user_DllExport MyUnion( - const MyUnion& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object MyUnion that will be copied. - */ - eProsima_user_DllExport MyUnion( - MyUnion&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object MyUnion that will be copied. - */ - eProsima_user_DllExport MyUnion& operator =( - const MyUnion& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object MyUnion that will be copied. - */ - eProsima_user_DllExport MyUnion& operator =( - MyUnion&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x MyUnion object to compare. - */ - eProsima_user_DllExport bool operator ==( - const MyUnion& x) const; - - /*! - * @brief Comparison operator. - * @param x MyUnion object to compare. - */ - eProsima_user_DllExport bool operator !=( - const MyUnion& x) const; - - /*! - * @brief This function sets the discriminator value. - * @param __d New value for the discriminator. - * @exception eprosima::fastcdr::BadParamException This exception is thrown if the new value doesn't correspond to the selected union member. - */ - eProsima_user_DllExport void _d( - int32_t __d); - - /*! - * @brief This function returns the value of the discriminator. - * @return Value of the discriminator - */ - eProsima_user_DllExport int32_t _d() const; - - /*! - * @brief This function returns a reference to the discriminator. - * @return Reference to the discriminator. - */ - eProsima_user_DllExport int32_t& _d(); - - /*! - * @brief This function sets a value in member octet_value - * @param _octet_value New value for member octet_value - */ - eProsima_user_DllExport void octet_value( - uint8_t _octet_value); - - /*! - * @brief This function returns the value of member octet_value - * @return Value of member octet_value - * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection. - */ - eProsima_user_DllExport uint8_t octet_value() const; - - /*! - * @brief This function returns a reference to member octet_value - * @return Reference to member octet_value - * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection. - */ - eProsima_user_DllExport uint8_t& octet_value(); - - - /*! - * @brief This function sets a value in member long_value - * @param _long_value New value for member long_value - */ - eProsima_user_DllExport void long_value( - int32_t _long_value); - - /*! - * @brief This function returns the value of member long_value - * @return Value of member long_value - * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection. - */ - eProsima_user_DllExport int32_t long_value() const; - - /*! - * @brief This function returns a reference to member long_value - * @return Reference to member long_value - * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection. - */ - eProsima_user_DllExport int32_t& long_value(); - - - /*! - * @brief This function copies the value in member string_value - * @param _string_value New value to be copied in member string_value - */ - eProsima_user_DllExport void string_value( - const std::string& _string_value); - - /*! - * @brief This function moves the value in member string_value - * @param _string_value New value to be moved in member string_value - */ - eProsima_user_DllExport void string_value( - std::string&& _string_value); - - /*! - * @brief This function returns a constant reference to member string_value - * @return Constant reference to member string_value - * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection. - */ - eProsima_user_DllExport const std::string& string_value() const; - - /*! - * @brief This function returns a reference to member string_value - * @return Reference to member string_value - * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection. - */ - eProsima_user_DllExport std::string& string_value(); - -private: - - int32_t m__d; - - uint8_t m_octet_value{0}; - int32_t m_long_value{0}; - std::string m_string_value; -}; - - -/*! - * @brief This class represents the structure union_struct defined by the user in the IDL file. - * @ingroup union_struct - */ -class union_struct -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport union_struct(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~union_struct(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object union_struct that will be copied. - */ - eProsima_user_DllExport union_struct( - const union_struct& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object union_struct that will be copied. - */ - eProsima_user_DllExport union_struct( - union_struct&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object union_struct that will be copied. - */ - eProsima_user_DllExport union_struct& operator =( - const union_struct& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object union_struct that will be copied. - */ - eProsima_user_DllExport union_struct& operator =( - union_struct&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x union_struct object to compare. - */ - eProsima_user_DllExport bool operator ==( - const union_struct& x) const; - - /*! - * @brief Comparison operator. - * @param x union_struct object to compare. - */ - eProsima_user_DllExport bool operator !=( - const union_struct& x) const; - - /*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ - eProsima_user_DllExport void index( - uint32_t _index); - - /*! - * @brief This function returns the value of member index - * @return Value of member index - */ - eProsima_user_DllExport uint32_t index() const; - - /*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ - eProsima_user_DllExport uint32_t& index(); - - - /*! - * @brief This function copies the value in member union_value - * @param _union_value New value to be copied in member union_value - */ - eProsima_user_DllExport void union_value( - const MyUnion& _union_value); - - /*! - * @brief This function moves the value in member union_value - * @param _union_value New value to be moved in member union_value - */ - eProsima_user_DllExport void union_value( - MyUnion&& _union_value); - - /*! - * @brief This function returns a constant reference to member union_value - * @return Constant reference to member union_value - */ - eProsima_user_DllExport const MyUnion& union_value() const; - - /*! - * @brief This function returns a reference to member union_value - * @return Reference to member union_value - */ - eProsima_user_DllExport MyUnion& union_value(); - -private: - - uint32_t m_index{0}; - MyUnion m_union_value; - -}; - -#endif // _FAST_DDS_GENERATED_UNION_STRUCT_H_ - - - -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structCdrAux.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structCdrAux.hpp deleted file mode 100644 index 16d39d64..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structCdrAux.hpp +++ /dev/null @@ -1,53 +0,0 @@ -// 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 union_structCdrAux.hpp - * This source file contains some definitions of CDR related functions. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_UNION_STRUCTCDRAUX_HPP_ -#define _FAST_DDS_GENERATED_UNION_STRUCTCDRAUX_HPP_ - -#include "union_struct.h" - -constexpr uint32_t union_struct_max_cdr_typesize {276UL}; -constexpr uint32_t union_struct_max_key_cdr_typesize {0UL}; - - - -namespace eprosima { -namespace fastcdr { - -class Cdr; -class CdrSizeCalculator; - - - - - - - -eProsima_user_DllExport void serialize_key( - eprosima::fastcdr::Cdr& scdr, - const union_struct& data); - - -} // namespace fastcdr -} // namespace eprosima - -#endif // _FAST_DDS_GENERATED_UNION_STRUCTCDRAUX_HPP_ - diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structCdrAux.ipp b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structCdrAux.ipp deleted file mode 100644 index e5c87d0b..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structCdrAux.ipp +++ /dev/null @@ -1,250 +0,0 @@ -// 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 union_structCdrAux.ipp - * This source file contains some declarations of CDR related functions. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_UNION_STRUCTCDRAUX_IPP_ -#define _FAST_DDS_GENERATED_UNION_STRUCTCDRAUX_IPP_ - -#include "union_structCdrAux.hpp" - -#include -#include - - -#include -using namespace eprosima::fastcdr::exception; - -namespace eprosima { -namespace fastcdr { - - - -template<> -eProsima_user_DllExport size_t calculate_serialized_size( - eprosima::fastcdr::CdrSizeCalculator& calculator, - const MyUnion& data, - size_t& current_alignment) -{ - static_cast(data); - - eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); - size_t calculated_size {calculator.begin_calculate_type_serialized_size( - eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, - current_alignment)}; - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), data._d(), - current_alignment); - - switch (data._d()) - { - case 1: - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.octet_value(), current_alignment); - break; - - case 2: - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), - data.long_value(), current_alignment); - break; - - case 3: - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(2), - data.string_value(), current_alignment); - break; - - default: - break; - } - - calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); - - return calculated_size; -} - - -template<> -eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& scdr, - const MyUnion& data) -{ - eprosima::fastcdr::Cdr::state current_state(scdr); - scdr.begin_serialize_type(current_state, - eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR); - - scdr << eprosima::fastcdr::MemberId(0) << data._d(); - - switch (data._d()) - { - case 1: - scdr << eprosima::fastcdr::MemberId(0) << data.octet_value(); - break; - - case 2: - scdr << eprosima::fastcdr::MemberId(1) << data.long_value(); - break; - - case 3: - scdr << eprosima::fastcdr::MemberId(2) << data.string_value(); - break; - - default: - break; - } - - scdr.end_serialize_type(current_state); -} - -template<> -eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr, - MyUnion& data) -{ - cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, - [&data](eprosima::fastcdr::Cdr& dcdr, const eprosima::fastcdr::MemberId& mid) -> bool - { - bool ret_value = true; - switch (mid.id) - { - case 0: - dcdr >> data._d(); - break; - default: - switch (data._d()) - { - case 1: - dcdr >> data.octet_value(); - break; - - case 2: - dcdr >> data.long_value(); - break; - - case 3: - dcdr >> data.string_value(); - break; - - default: - break; - } - ret_value = false; - break; - } - return ret_value; - }); -} - - - -template<> -eProsima_user_DllExport size_t calculate_serialized_size( - eprosima::fastcdr::CdrSizeCalculator& calculator, - const union_struct& data, - size_t& current_alignment) -{ - static_cast(data); - - eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); - size_t calculated_size {calculator.begin_calculate_type_serialized_size( - eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, - current_alignment)}; - - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.index(), current_alignment); - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), - data.union_value(), current_alignment); - - - calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); - - return calculated_size; -} - -template<> -eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& scdr, - const union_struct& data) -{ - eprosima::fastcdr::Cdr::state current_state(scdr); - scdr.begin_serialize_type(current_state, - eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR); - - scdr - << eprosima::fastcdr::MemberId(0) << data.index() - << eprosima::fastcdr::MemberId(1) << data.union_value() -; - scdr.end_serialize_type(current_state); -} - -template<> -eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr, - union_struct& data) -{ - cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, - [&data](eprosima::fastcdr::Cdr& dcdr, const eprosima::fastcdr::MemberId& mid) -> bool - { - bool ret_value = true; - switch (mid.id) - { - case 0: - dcdr >> data.index(); - break; - - case 1: - dcdr >> data.union_value(); - break; - - default: - ret_value = false; - break; - } - return ret_value; - }); -} - -void serialize_key( - eprosima::fastcdr::Cdr& scdr, - const union_struct& data) -{ - static_cast(scdr); - static_cast(data); -} - - - -} // namespace fastcdr -} // namespace eprosima - -#endif // _FAST_DDS_GENERATED_UNION_STRUCTCDRAUX_IPP_ - diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structPubSubTypes.cxx deleted file mode 100644 index 35732fdd..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structPubSubTypes.cxx +++ /dev/null @@ -1,224 +0,0 @@ -// 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 union_structPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#include - -#include "union_structPubSubTypes.h" -#include "union_structCdrAux.hpp" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; -using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - - - - - - - -union_structPubSubType::union_structPubSubType() -{ - setName("union_struct"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(union_struct::getMaxCdrSerializedSize()); -#else - union_struct_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = union_struct_max_key_cdr_typesize > 16 ? union_struct_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -union_structPubSubType::~union_structPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool union_structPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - union_struct* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool union_structPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - union_struct* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function union_structPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* union_structPubSubType::createData() -{ - return reinterpret_cast(new union_struct()); -} - -void union_structPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool union_structPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - union_struct* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - union_struct_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || union_struct_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structPubSubTypes.h deleted file mode 100644 index ca9f95d0..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structPubSubTypes.h +++ /dev/null @@ -1,135 +0,0 @@ -// 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 union_structPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#ifndef _FAST_DDS_GENERATED_UNION_STRUCT_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_UNION_STRUCT_PUBSUBTYPES_H_ - -#include -#include -#include -#include -#include - -#include "union_struct.h" - - -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) -#error \ - Generated union_struct is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER - - - - - - - - -/*! - * @brief This class represents the TopicDataType of the type union_struct defined by the user in the IDL file. - * @ingroup union_struct - */ -class union_structPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef union_struct type; - - eProsima_user_DllExport union_structPubSubType(); - - eProsima_user_DllExport ~union_structPubSubType() override; - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport void* createData() override; - - eProsima_user_DllExport void deleteData( - void* data) override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } - - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - static_cast(memory); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - -#endif // _FAST_DDS_GENERATED_UNION_STRUCT_PUBSUBTYPES_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structTypeObject.cxx deleted file mode 100644 index b4834bfb..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structTypeObject.cxx +++ /dev/null @@ -1,547 +0,0 @@ -// 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 union_structTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { char dummy; } -#endif - -#include "union_struct.h" -#include "union_structTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerunion_structTypes() -{ - static std::once_flag once_flag; - std::call_once(once_flag, []() - { - TypeObjectFactory *factory = TypeObjectFactory::get_instance(); - factory->add_type_object("MyUnion", GetMyUnionIdentifier(true), - GetMyUnionObject(true)); - factory->add_type_object("MyUnion", GetMyUnionIdentifier(false), - GetMyUnionObject(false)); - - - factory->add_type_object("union_struct", Getunion_structIdentifier(true), - Getunion_structObject(true)); - factory->add_type_object("union_struct", Getunion_structIdentifier(false), - Getunion_structObject(false)); - - }); -} - - - -const TypeIdentifier* GetMyUnionIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("MyUnion", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetMyUnionObject(complete); - return TypeObjectFactory::get_instance()->get_type_identifier("MyUnion", complete); -} - -const TypeObject* GetMyUnionObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MyUnion", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteMyUnionObject(); - } - // else - return GetMinimalMyUnionObject(); -} - -const TypeObject* GetMinimalMyUnionObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MyUnion", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_UNION); - - type_object->minimal().union_type().union_flags().IS_FINAL(false); - type_object->minimal().union_type().union_flags().IS_APPENDABLE(false); - type_object->minimal().union_type().union_flags().IS_MUTABLE(false); - type_object->minimal().union_type().union_flags().IS_NESTED(false); - type_object->minimal().union_type().union_flags().IS_AUTOID_HASH(false); // Unsupported - - type_object->minimal().union_type().discriminator().common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - type_object->minimal().union_type().discriminator().common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - type_object->minimal().union_type().discriminator().common().member_flags().IS_EXTERNAL(false); // Doesn't apply - type_object->minimal().union_type().discriminator().common().member_flags().IS_OPTIONAL(false); // Doesn't apply - type_object->minimal().union_type().discriminator().common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - type_object->minimal().union_type().discriminator().common().member_flags().IS_KEY(false); // Unsupported - type_object->minimal().union_type().discriminator().common().member_flags().IS_DEFAULT(false); // Doesn't apply - - type_object->minimal().union_type().discriminator().common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - - MemberId memberId = 0; - MinimalUnionMember mst_octet_value; - mst_octet_value.common().member_id(memberId++); - mst_octet_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_octet_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_octet_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_octet_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply - mst_octet_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - mst_octet_value.common().member_flags().IS_KEY(false); // Doesn't apply - mst_octet_value.common().member_flags().IS_DEFAULT(false); - mst_octet_value.common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint8_t", false)); - - - mst_octet_value.common().label_seq().emplace_back(1); - - MD5 octet_value_hash("octet_value"); - for(int i = 0; i < 4; ++i) - { - mst_octet_value.detail().name_hash()[i] = octet_value_hash.digest[i]; - } - type_object->minimal().union_type().member_seq().emplace_back(mst_octet_value); - - MinimalUnionMember mst_long_value; - mst_long_value.common().member_id(memberId++); - mst_long_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_long_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_long_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_long_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply - mst_long_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - mst_long_value.common().member_flags().IS_KEY(false); // Doesn't apply - mst_long_value.common().member_flags().IS_DEFAULT(false); - mst_long_value.common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - - - mst_long_value.common().label_seq().emplace_back(2); - - MD5 long_value_hash("long_value"); - for(int i = 0; i < 4; ++i) - { - mst_long_value.detail().name_hash()[i] = long_value_hash.digest[i]; - } - type_object->minimal().union_type().member_seq().emplace_back(mst_long_value); - - MinimalUnionMember mst_string_value; - mst_string_value.common().member_id(memberId++); - mst_string_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_string_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_string_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_string_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply - mst_string_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - mst_string_value.common().member_flags().IS_KEY(false); // Doesn't apply - mst_string_value.common().member_flags().IS_DEFAULT(false); - mst_string_value.common().type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - mst_string_value.common().label_seq().emplace_back(3); - - MD5 string_value_hash("string_value"); - for(int i = 0; i < 4; ++i) - { - mst_string_value.detail().name_hash()[i] = string_value_hash.digest[i]; - } - type_object->minimal().union_type().member_seq().emplace_back(mst_string_value); - - - // Header - //type_object->minimal().union_type().header().detail()... // Empty - - TypeIdentifier* identifier = new TypeIdentifier(); - identifier->_d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().union_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier->equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("MyUnion", identifier, type_object); - delete type_object; - delete identifier; - return TypeObjectFactory::get_instance()->get_type_object("MyUnion", false); -} - -const TypeObject* GetCompleteMyUnionObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MyUnion", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_UNION); - - type_object->complete().union_type().union_flags().IS_FINAL(false); - type_object->complete().union_type().union_flags().IS_APPENDABLE(false); - type_object->complete().union_type().union_flags().IS_MUTABLE(false); - type_object->complete().union_type().union_flags().IS_NESTED(false); - type_object->complete().union_type().union_flags().IS_AUTOID_HASH(false); // Unsupported - - type_object->complete().union_type().discriminator().common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - type_object->complete().union_type().discriminator().common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - type_object->complete().union_type().discriminator().common().member_flags().IS_EXTERNAL(false); // Doesn't apply - type_object->complete().union_type().discriminator().common().member_flags().IS_OPTIONAL(false); // Doesn't apply - type_object->complete().union_type().discriminator().common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - type_object->complete().union_type().discriminator().common().member_flags().IS_KEY(false); // Unsupported - type_object->complete().union_type().discriminator().common().member_flags().IS_DEFAULT(false); // Doesn't apply - - type_object->complete().union_type().discriminator().common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - - MemberId memberId = 0; - CompleteUnionMember cst_octet_value; - cst_octet_value.common().member_id(memberId++); - cst_octet_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_octet_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_octet_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_octet_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply - cst_octet_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - cst_octet_value.common().member_flags().IS_KEY(false); // Doesn't apply - cst_octet_value.common().member_flags().IS_DEFAULT(false); - cst_octet_value.common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint8_t", false)); - - cst_octet_value.common().label_seq().emplace_back(1); - - - cst_octet_value.detail().name("octet_value"); - - type_object->complete().union_type().member_seq().emplace_back(cst_octet_value); - - CompleteUnionMember cst_long_value; - cst_long_value.common().member_id(memberId++); - cst_long_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_long_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_long_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_long_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply - cst_long_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - cst_long_value.common().member_flags().IS_KEY(false); // Doesn't apply - cst_long_value.common().member_flags().IS_DEFAULT(false); - cst_long_value.common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - - cst_long_value.common().label_seq().emplace_back(2); - - - cst_long_value.detail().name("long_value"); - - type_object->complete().union_type().member_seq().emplace_back(cst_long_value); - - CompleteUnionMember cst_string_value; - cst_string_value.common().member_id(memberId++); - cst_string_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_string_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_string_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_string_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply - cst_string_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - cst_string_value.common().member_flags().IS_KEY(false); // Doesn't apply - cst_string_value.common().member_flags().IS_DEFAULT(false); - cst_string_value.common().type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - cst_string_value.common().label_seq().emplace_back(3); - - - cst_string_value.detail().name("string_value"); - - type_object->complete().union_type().member_seq().emplace_back(cst_string_value); - - - // Header - type_object->complete().union_type().header().detail().type_name("MyUnion"); - - TypeIdentifier* identifier = new TypeIdentifier(); - identifier->_d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().union_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier->equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("MyUnion", identifier, type_object); - delete type_object; - delete identifier; - return TypeObjectFactory::get_instance()->get_type_object("MyUnion", true); -} - - - -const TypeIdentifier* Getunion_structIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("union_struct", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - Getunion_structObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("union_struct", complete); -} - -const TypeObject* Getunion_structObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("union_struct", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteunion_structObject(); - } - //else - return GetMinimalunion_structObject(); -} - -const TypeObject* GetMinimalunion_structObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("union_struct", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_index; - mst_index.common().member_id(memberId++); - mst_index.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_index.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_index.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_index.common().member_flags().IS_OPTIONAL(false); - mst_index.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_index.common().member_flags().IS_KEY(false); - mst_index.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_index.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); - - - MD5 index_hash("index"); - for(int i = 0; i < 4; ++i) - { - mst_index.detail().name_hash()[i] = index_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_index); - - MinimalStructMember mst_union_value; - mst_union_value.common().member_id(memberId++); - mst_union_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_union_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_union_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_union_value.common().member_flags().IS_OPTIONAL(false); - mst_union_value.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_union_value.common().member_flags().IS_KEY(false); - mst_union_value.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_union_value.common().member_type_id(*GetMyUnionIdentifier(false)); - - MD5 union_value_hash("union_value"); - for(int i = 0; i < 4; ++i) - { - mst_union_value.detail().name_hash()[i] = union_value_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_union_value); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("union_struct", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("union_struct", false); -} - -const TypeObject* GetCompleteunion_structObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("union_struct", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_index; - cst_index.common().member_id(memberId++); - cst_index.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_index.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_index.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_index.common().member_flags().IS_OPTIONAL(false); - cst_index.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_index.common().member_flags().IS_KEY(false); - cst_index.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_index.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); - - - cst_index.detail().name("index"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_index); - - CompleteStructMember cst_union_value; - cst_union_value.common().member_id(memberId++); - cst_union_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_union_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_union_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_union_value.common().member_flags().IS_OPTIONAL(false); - cst_union_value.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_union_value.common().member_flags().IS_KEY(false); - cst_union_value.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_union_value.common().member_type_id(*GetMyUnionIdentifier(true)); - - cst_union_value.detail().name("union_value"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_union_value); - - - // Header - type_object->complete().struct_type().header().detail().type_name("union_struct"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("union_struct", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("union_struct", true); -} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structTypeObject.h deleted file mode 100644 index 069b41a1..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structTypeObject.h +++ /dev/null @@ -1,72 +0,0 @@ -// 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 union_structTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_UNION_STRUCT_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_UNION_STRUCT_TYPE_OBJECT_H_ - - -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif -#else -#define eProsima_user_DllExport -#endif - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(union_struct_SOURCE) -#define union_struct_DllAPI __declspec( dllexport ) -#else -#define union_struct_DllAPI __declspec( dllimport ) -#endif // union_struct_SOURCE -#else -#define union_struct_DllAPI -#endif -#else -#define union_struct_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registerunion_structTypes(); - - - -eProsima_user_DllExport const TypeIdentifier* GetMyUnionIdentifier(bool complete = false); -eProsima_user_DllExport const TypeObject* GetMyUnionObject(bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalMyUnionObject(); -eProsima_user_DllExport const TypeObject* GetCompleteMyUnionObject(); - - - -eProsima_user_DllExport const TypeIdentifier* Getunion_structIdentifier(bool complete = false); -eProsima_user_DllExport const TypeObject* Getunion_structObject(bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalunion_structObject(); -eProsima_user_DllExport const TypeObject* GetCompleteunion_structObject(); - - -#endif // _FAST_DDS_GENERATED_UNION_STRUCT_TYPE_OBJECT_H_ \ No newline at end of file diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structv1.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structv1.cxx deleted file mode 100644 index 06b92f82..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structv1.cxx +++ /dev/null @@ -1,780 +0,0 @@ -// 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 union_struct.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "union_struct.h" - -#if FASTCDR_VERSION_MAJOR == 1 - -#include "union_structTypeObject.h" - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - -namespace helper { namespace internal { - -enum class Size { - UInt8, - UInt16, - UInt32, - UInt64, -}; - -constexpr Size get_size(int s) { - return (s <= 8 ) ? Size::UInt8: - (s <= 16) ? Size::UInt16: - (s <= 32) ? Size::UInt32: Size::UInt64; -} - -template -struct FindTypeH; - -template<> -struct FindTypeH { - using type = std::uint8_t; -}; - -template<> -struct FindTypeH { - using type = std::uint16_t; -}; - -template<> -struct FindTypeH { - using type = std::uint32_t; -}; - -template<> -struct FindTypeH { - using type = std::uint64_t; -}; -} - -template -struct FindType { - using type = typename internal::FindTypeH::type; -}; -} - -#define union_struct_max_cdr_typesize 276ULL; - - - - - -MyUnion::MyUnion() -{ - m__d = 1; - // octet m_octet_value - m_octet_value = 0; - // long m_long_value - m_long_value = 0; - // /type_d() m_string_value - -} - -MyUnion::~MyUnion() -{ -} - -MyUnion::MyUnion( - const MyUnion& x) -{ - m__d = x.m__d; - - switch(m__d) - { - case 1: - m_octet_value = x.m_octet_value; - break; - - - case 2: - m_long_value = x.m_long_value; - break; - - - case 3: - m_string_value = x.m_string_value; - break; - - default: - break; - } -} - -MyUnion::MyUnion( - MyUnion&& x) noexcept -{ - m__d = x.m__d; - - switch(m__d) - { - case 1: - m_octet_value = x.m_octet_value; - break; - - - case 2: - m_long_value = x.m_long_value; - break; - - - case 3: - m_string_value = std::move(x.m_string_value); - - break; - - default: - break; - } -} - -MyUnion& MyUnion::operator =( - const MyUnion& x) -{ - m__d = x.m__d; - - switch(m__d) - { - case 1: - m_octet_value = x.m_octet_value; - break; - - - case 2: - m_long_value = x.m_long_value; - break; - - - case 3: - m_string_value = x.m_string_value; - break; - - default: - break; - } - - return *this; -} - -MyUnion& MyUnion::operator =( - MyUnion&& x) noexcept -{ - m__d = x.m__d; - - switch(m__d) - { - case 1: - m_octet_value = x.m_octet_value; - break; - - - case 2: - m_long_value = x.m_long_value; - break; - - - case 3: - m_string_value = std::move(x.m_string_value); - - break; - - default: - break; - } - - return *this; -} - -bool MyUnion::operator ==( - const MyUnion& x) const -{ - if (m__d != x.m__d) - { - return false; - } - - switch(m__d) - { - case 1: - return (m_octet_value == x.m_octet_value); - break; - - - case 2: - return (m_long_value == x.m_long_value); - break; - - - case 3: - return (m_string_value == x.m_string_value); - break; - - default: - break; - } - return false; -} - -bool MyUnion::operator !=( - const MyUnion& x) const -{ - return !(*this == x); -} - -void MyUnion::_d( - int32_t __d) -{ - bool b = false; - - switch(m__d) - { - case 1: - switch(__d) - { - case 1: - b = true; - break; - default: - break; - } - break; - - - case 2: - switch(__d) - { - case 2: - b = true; - break; - default: - break; - } - break; - - - case 3: - switch(__d) - { - case 3: - b = true; - break; - default: - break; - } - break; - - } - - if(!b) - { - throw BadParamException("Discriminator doesn't correspond with the selected union member"); - } - - m__d = __d; -} - -int32_t MyUnion::_d() const -{ - return m__d; -} - -int32_t& MyUnion::_d() -{ - return m__d; -} - -void MyUnion::octet_value( - uint8_t _octet_value) -{ - m_octet_value = _octet_value; - m__d = 1; - -} - -uint8_t MyUnion::octet_value() const -{ - bool b = false; - - switch(m__d) - { - case 1: - b = true; - break; - default: - break; - } - - if(!b) - { - throw BadParamException("This member has not been selected"); - } - - return m_octet_value; -} - -uint8_t& MyUnion::octet_value() -{ - bool b = false; - - switch(m__d) - { - case 1: - b = true; - break; - default: - break; - } - - if(!b) - { - throw BadParamException("This member has not been selected"); - } - - return m_octet_value; -} - - -void MyUnion::long_value( - int32_t _long_value) -{ - m_long_value = _long_value; - m__d = 2; - -} - -int32_t MyUnion::long_value() const -{ - bool b = false; - - switch(m__d) - { - case 2: - b = true; - break; - default: - break; - } - - if(!b) - { - throw BadParamException("This member has not been selected"); - } - - return m_long_value; -} - -int32_t& MyUnion::long_value() -{ - bool b = false; - - switch(m__d) - { - case 2: - b = true; - break; - default: - break; - } - - if(!b) - { - throw BadParamException("This member has not been selected"); - } - - return m_long_value; -} - - -void MyUnion::string_value( - const std::string& _string_value) -{ - m_string_value = _string_value; - m__d = 3; - -} - -void MyUnion::string_value( - std::string&& _string_value) -{ - m_string_value = std::move(_string_value); - m__d = 3; - -} - -const std::string& MyUnion::string_value() const -{ - bool b = false; - - switch(m__d) - { - case 3: - b = true; - break; - default: - break; - } - - if(!b) - { - throw BadParamException("This member has not been selected"); - } - - return m_string_value; -} - -std::string& MyUnion::string_value() -{ - bool b = false; - - switch(m__d) - { - case 3: - b = true; - break; - default: - break; - } - - if(!b) - { - throw BadParamException("This member has not been selected"); - } - - return m_string_value; -} - - -// TODO(Ricardo) Review -size_t MyUnion::getCdrSerializedSize( - const MyUnion& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - - switch(data.m__d) - { - case 1: - current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); - - break; - - - case 2: - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - break; - - - case 3: - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.string_value().size() + 1; - - break; - - default: - break; - } - - return current_alignment - initial_alignment; -} - - -void MyUnion::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m__d; - - switch(m__d) - { - case 1: - scdr << m_octet_value; - - break; - - - case 2: - scdr << m_long_value; - - break; - - - case 3: - scdr << m_string_value.c_str(); - - break; - - default: - break; - } -} - -void MyUnion::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m__d; - - - switch(m__d) - { - case 1: - dcdr >> m_octet_value; - - - break; - - - case 2: - dcdr >> m_long_value; - - - break; - - - case 3: - dcdr >> m_string_value; - - - break; - - default: - break; - } -} - - - - - -union_struct::union_struct() -{ - // unsigned long m_index - m_index = 0; - // MyUnion m_union_value - - - // Just to register all known types - registerunion_structTypes(); -} - -union_struct::~union_struct() -{ -} - -union_struct::union_struct( - const union_struct& x) -{ - m_index = x.m_index; - - - m_union_value = x.m_union_value; - -} - -union_struct::union_struct( - union_struct&& x) noexcept -{ - m_index = x.m_index; - - - m_union_value = std::move(x.m_union_value); - -} - -union_struct& union_struct::operator =( - const union_struct& x) -{ - m_index = x.m_index; - - - m_union_value = x.m_union_value; - - return *this; -} - -union_struct& union_struct::operator =( - union_struct&& x) noexcept -{ - m_index = x.m_index; - - - m_union_value = std::move(x.m_union_value); - - return *this; -} - -bool union_struct::operator ==( - const union_struct& x) const -{ - return (m_index == x.m_index && - m_union_value == x.m_union_value); -} - -bool union_struct::operator !=( - const union_struct& x) const -{ - return !(*this == x); -} - -size_t union_struct::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return union_struct_max_cdr_typesize; -} - -size_t union_struct::getCdrSerializedSize( - const union_struct& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - current_alignment += MyUnion::getCdrSerializedSize(data.union_value(), current_alignment); - - - return current_alignment - initial_alignment; -} - - -void union_struct::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_index; - - scdr << m_union_value; - -} - -void union_struct::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_index; - - - - dcdr >> m_union_value; - - -} - - -bool union_struct::isKeyDefined() -{ - return false; -} - -void union_struct::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ -void union_struct::index( - uint32_t _index) -{ - m_index = _index; -} - -/*! - * @brief This function returns the value of member index - * @return Value of member index - */ -uint32_t union_struct::index() const -{ - return m_index; -} - -/*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ -uint32_t& union_struct::index() -{ - return m_index; -} - - -/*! - * @brief This function copies the value in member union_value - * @param _union_value New value to be copied in member union_value - */ -void union_struct::union_value( - const MyUnion& _union_value) -{ - m_union_value = _union_value; -} - -/*! - * @brief This function moves the value in member union_value - * @param _union_value New value to be moved in member union_value - */ -void union_struct::union_value( - MyUnion&& _union_value) -{ - m_union_value = std::move(_union_value); -} - -/*! - * @brief This function returns a constant reference to member union_value - * @return Constant reference to member union_value - */ -const MyUnion& union_struct::union_value() const -{ - return m_union_value; -} - -/*! - * @brief This function returns a reference to member union_value - * @return Reference to member union_value - */ -MyUnion& union_struct::union_value() -{ - return m_union_value; -} - - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structv1.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structv1.h deleted file mode 100644 index 784ae7e7..00000000 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structv1.h +++ /dev/null @@ -1,437 +0,0 @@ -// 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 union_struct.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#include - -#if FASTCDR_VERSION_MAJOR == 1 - -#ifndef _FAST_DDS_GENERATED_UNION_STRUCT_H_ -#define _FAST_DDS_GENERATED_UNION_STRUCT_H_ - - -#include - -#include -#include -#include -#include -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(UNION_STRUCT_SOURCE) -#define UNION_STRUCT_DllAPI __declspec( dllexport ) -#else -#define UNION_STRUCT_DllAPI __declspec( dllimport ) -#endif // UNION_STRUCT_SOURCE -#else -#define UNION_STRUCT_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define UNION_STRUCT_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - - - - -/*! - * @brief This class represents the union MyUnion defined by the user in the IDL file. - * @ingroup union_struct - */ -class MyUnion -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport MyUnion(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~MyUnion(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object MyUnion that will be copied. - */ - eProsima_user_DllExport MyUnion( - const MyUnion& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object MyUnion that will be copied. - */ - eProsima_user_DllExport MyUnion( - MyUnion&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object MyUnion that will be copied. - */ - eProsima_user_DllExport MyUnion& operator =( - const MyUnion& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object MyUnion that will be copied. - */ - eProsima_user_DllExport MyUnion& operator =( - MyUnion&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x MyUnion object to compare. - */ - eProsima_user_DllExport bool operator ==( - const MyUnion& x) const; - - /*! - * @brief Comparison operator. - * @param x MyUnion object to compare. - */ - eProsima_user_DllExport bool operator !=( - const MyUnion& x) const; - - /*! - * @brief This function sets the discriminator value. - * @param __d New value for the discriminator. - * @exception eprosima::fastcdr::BadParamException This exception is thrown if the new value doesn't correspond to the selected union member. - */ - eProsima_user_DllExport void _d( - int32_t __d); - - /*! - * @brief This function returns the value of the discriminator. - * @return Value of the discriminator - */ - eProsima_user_DllExport int32_t _d() const; - - /*! - * @brief This function returns a reference to the discriminator. - * @return Reference to the discriminator. - */ - eProsima_user_DllExport int32_t& _d(); - - /*! - * @brief This function sets a value in member octet_value - * @param _octet_value New value for member octet_value - */ - eProsima_user_DllExport void octet_value( - uint8_t _octet_value); - - /*! - * @brief This function returns the value of member octet_value - * @return Value of member octet_value - * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection. - */ - eProsima_user_DllExport uint8_t octet_value() const; - - /*! - * @brief This function returns a reference to member octet_value - * @return Reference to member octet_value - * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection. - */ - eProsima_user_DllExport uint8_t& octet_value(); - - - /*! - * @brief This function sets a value in member long_value - * @param _long_value New value for member long_value - */ - eProsima_user_DllExport void long_value( - int32_t _long_value); - - /*! - * @brief This function returns the value of member long_value - * @return Value of member long_value - * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection. - */ - eProsima_user_DllExport int32_t long_value() const; - - /*! - * @brief This function returns a reference to member long_value - * @return Reference to member long_value - * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection. - */ - eProsima_user_DllExport int32_t& long_value(); - - - /*! - * @brief This function copies the value in member string_value - * @param _string_value New value to be copied in member string_value - */ - eProsima_user_DllExport void string_value( - const std::string& _string_value); - - /*! - * @brief This function moves the value in member string_value - * @param _string_value New value to be moved in member string_value - */ - eProsima_user_DllExport void string_value( - std::string&& _string_value); - - /*! - * @brief This function returns a constant reference to member string_value - * @return Constant reference to member string_value - * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection. - */ - eProsima_user_DllExport const std::string& string_value() const; - - /*! - * @brief This function returns a reference to member string_value - * @return Reference to member string_value - * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection. - */ - eProsima_user_DllExport std::string& string_value(); - - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const MyUnion& data, - size_t current_alignment = 0); - - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - - -private: - - int32_t m__d; - - uint8_t m_octet_value; - int32_t m_long_value; - std::string m_string_value; -}; - - - -/*! - * @brief This class represents the structure union_struct defined by the user in the IDL file. - * @ingroup union_struct - */ -class union_struct -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport union_struct(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~union_struct(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object union_struct that will be copied. - */ - eProsima_user_DllExport union_struct( - const union_struct& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object union_struct that will be copied. - */ - eProsima_user_DllExport union_struct( - union_struct&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object union_struct that will be copied. - */ - eProsima_user_DllExport union_struct& operator =( - const union_struct& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object union_struct that will be copied. - */ - eProsima_user_DllExport union_struct& operator =( - union_struct&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x union_struct object to compare. - */ - eProsima_user_DllExport bool operator ==( - const union_struct& x) const; - - /*! - * @brief Comparison operator. - * @param x union_struct object to compare. - */ - eProsima_user_DllExport bool operator !=( - const union_struct& x) const; - - /*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ - eProsima_user_DllExport void index( - uint32_t _index); - - /*! - * @brief This function returns the value of member index - * @return Value of member index - */ - eProsima_user_DllExport uint32_t index() const; - - /*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ - eProsima_user_DllExport uint32_t& index(); - - - /*! - * @brief This function copies the value in member union_value - * @param _union_value New value to be copied in member union_value - */ - eProsima_user_DllExport void union_value( - const MyUnion& _union_value); - - /*! - * @brief This function moves the value in member union_value - * @param _union_value New value to be moved in member union_value - */ - eProsima_user_DllExport void union_value( - MyUnion&& _union_value); - - /*! - * @brief This function returns a constant reference to member union_value - * @return Constant reference to member union_value - */ - eProsima_user_DllExport const MyUnion& union_value() const; - - /*! - * @brief This function returns a reference to member union_value - * @return Reference to member union_value - */ - eProsima_user_DllExport MyUnion& union_value(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const union_struct& data, - size_t current_alignment = 0); - - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - - -private: - - uint32_t m_index; - MyUnion m_union_value; - -}; - - -#endif // _FAST_DDS_GENERATED_UNION_STRUCT_H_ - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddspipe_core/test/unittest/types/endpoint/CMakeLists.txt b/ddspipe_core/test/unittest/types/endpoint/CMakeLists.txt index dfc2ce5f..41e58633 100644 --- a/ddspipe_core/test/unittest/types/endpoint/CMakeLists.txt +++ b/ddspipe_core/test/unittest/types/endpoint/CMakeLists.txt @@ -30,7 +30,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES fastcdr - fastrtps + fastdds cpp_utils ) @@ -69,7 +69,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES fastcdr - fastrtps + fastdds cpp_utils ) diff --git a/ddspipe_core/test/unittest/types/endpoint/GuidTest.cpp b/ddspipe_core/test/unittest/types/endpoint/GuidTest.cpp index 09b91d5f..21550513 100644 --- a/ddspipe_core/test/unittest/types/endpoint/GuidTest.cpp +++ b/ddspipe_core/test/unittest/types/endpoint/GuidTest.cpp @@ -15,7 +15,7 @@ #include #include -#include +#include #include #include @@ -44,41 +44,41 @@ TEST(GuidTest, is_valid) // Unknown guid invalid { Guid invalid_guid_1( - eprosima::fastrtps::rtps::GuidPrefix_t::unknown(), - eprosima::fastrtps::rtps::EntityId_t::unknown()); + eprosima::fastdds::rtps::GuidPrefix_t::unknown(), + eprosima::fastdds::rtps::EntityId_t::unknown()); ASSERT_FALSE(invalid_guid_1.is_valid()); Guid invalid_guid_2( - eprosima::fastrtps::rtps::GUID_t::unknown().guidPrefix, - eprosima::fastrtps::rtps::GUID_t::unknown().entityId); + eprosima::fastdds::rtps::GUID_t::unknown().guidPrefix, + eprosima::fastdds::rtps::GUID_t::unknown().entityId); ASSERT_FALSE(invalid_guid_2.is_valid()); } // GuidPrefix invalid { Guid invalid_guid( - eprosima::fastrtps::rtps::GuidPrefix_t(), // Invalid GuidPrefix - eprosima::fastrtps::rtps::EntityId_t(1)); // Valid EntityId + eprosima::fastdds::rtps::GuidPrefix_t(), // Invalid GuidPrefix + eprosima::fastdds::rtps::EntityId_t(1)); // Valid EntityId ASSERT_FALSE(invalid_guid.is_valid()); } // EntityId invalid { - eprosima::fastrtps::rtps::GuidPrefix_t guid_prefix; + eprosima::fastdds::rtps::GuidPrefix_t guid_prefix; std::istringstream("44.53.00.5f.45.50.52.4f.53.49.4d.41") >> guid_prefix; Guid valid_guid( guid_prefix, // Valid GuidPrefix - eprosima::fastrtps::rtps::EntityId_t()); // Invalid EntityId + eprosima::fastdds::rtps::EntityId_t()); // Invalid EntityId ASSERT_FALSE(valid_guid.is_valid()); } // Constrcutor with valid value { - eprosima::fastrtps::rtps::GuidPrefix_t guid_prefix; + eprosima::fastdds::rtps::GuidPrefix_t guid_prefix; std::istringstream("44.53.00.5f.45.50.52.4f.53.49.4d.41") >> guid_prefix; Guid valid_guid( guid_prefix, // Valid GuidPrefix - eprosima::fastrtps::rtps::EntityId_t(1)); // Valid EntityId + eprosima::fastdds::rtps::EntityId_t(1)); // Valid EntityId ASSERT_TRUE(valid_guid.is_valid()); } } diff --git a/ddspipe_core/test/unittest/types/topic/CMakeLists.txt b/ddspipe_core/test/unittest/types/topic/CMakeLists.txt index 863b02ec..82ab2b08 100644 --- a/ddspipe_core/test/unittest/types/topic/CMakeLists.txt +++ b/ddspipe_core/test/unittest/types/topic/CMakeLists.txt @@ -32,7 +32,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES fastcdr - fastrtps + fastdds cpp_utils ) @@ -70,7 +70,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES $<$:iphlpapi$Shlwapi> fastcdr - fastrtps + fastdds cpp_utils ) diff --git a/ddspipe_participants/include/ddspipe_participants/configuration/SimpleParticipantConfiguration.hpp b/ddspipe_participants/include/ddspipe_participants/configuration/SimpleParticipantConfiguration.hpp index 37fe7def..34615fff 100644 --- a/ddspipe_participants/include/ddspipe_participants/configuration/SimpleParticipantConfiguration.hpp +++ b/ddspipe_participants/include/ddspipe_participants/configuration/SimpleParticipantConfiguration.hpp @@ -51,7 +51,7 @@ struct SimpleParticipantConfiguration : public ParticipantConfiguration core::types::DomainId domain {0u}; - std::set whitelist {}; + std::set whitelist {}; core::types::TransportDescriptors transport {core::types::TransportDescriptors::builtin}; diff --git a/ddspipe_participants/include/ddspipe_participants/efficiency/cache_change/CacheChangePool.hpp b/ddspipe_participants/include/ddspipe_participants/efficiency/cache_change/CacheChangePool.hpp index 02790473..9e7b3f8a 100644 --- a/ddspipe_participants/include/ddspipe_participants/efficiency/cache_change/CacheChangePool.hpp +++ b/ddspipe_participants/include/ddspipe_participants/efficiency/cache_change/CacheChangePool.hpp @@ -14,8 +14,8 @@ #pragma once -#include -#include +#include +#include #include #include @@ -31,7 +31,7 @@ namespace core { * * TODO: implement this class as an IPool (or having an internal pool), without being force to be unbounded. */ -class CacheChangePool : public fastrtps::rtps::IChangePool, public utils::UnboundedPool +class CacheChangePool : public fastdds::rtps::IChangePool, public utils::UnboundedPool { public: @@ -47,20 +47,20 @@ class CacheChangePool : public fastrtps::rtps::IChangePool, public utils::Unboun //! Call UnboundedPool::reserve bool reserve_cache( - fastrtps::rtps::CacheChange_t*& cache_change) override; + fastdds::rtps::CacheChange_t*& cache_change) override; //! Call UnboundedPool::release bool release_cache( - fastrtps::rtps::CacheChange_t* cache_change) override; + fastdds::rtps::CacheChange_t* cache_change) override; protected: //! Override the UnboundedPool::create_element method to create a RouterCacheChange object. - fastrtps::rtps::CacheChange_t* new_element_() override; + fastdds::rtps::CacheChange_t* new_element_() override; //! Override the IPool::reset_element_ method to reset the CacheChange as a new object. void reset_element_( - fastrtps::rtps::CacheChange_t* change) override; + fastdds::rtps::CacheChange_t* change) override; }; } /* namespace core */ diff --git a/ddspipe_participants/include/ddspipe_participants/participant/dds/CommonParticipant.hpp b/ddspipe_participants/include/ddspipe_participants/participant/dds/CommonParticipant.hpp index e3e23896..669cd04f 100644 --- a/ddspipe_participants/include/ddspipe_participants/participant/dds/CommonParticipant.hpp +++ b/ddspipe_participants/include/ddspipe_participants/participant/dds/CommonParticipant.hpp @@ -18,11 +18,17 @@ #include +#include +#include +#include #include #include #include #include #include +#include +#include +#include #include #include @@ -73,13 +79,13 @@ class CommonParticipant : public core::IParticipant, public fastdds::dds::Domain ///////////////////////// DDSPIPE_PARTICIPANTS_DllAPI - virtual core::types::ParticipantId id() const noexcept override; + core::types::ParticipantId id() const noexcept override; DDSPIPE_PARTICIPANTS_DllAPI - virtual bool is_rtps_kind() const noexcept override; + bool is_rtps_kind() const noexcept override; DDSPIPE_PARTICIPANTS_DllAPI - virtual bool is_repeater() const noexcept override; + bool is_repeater() const noexcept override; DDSPIPE_PARTICIPANTS_DllAPI core::types::TopicQoS topic_qos() const noexcept override; @@ -106,17 +112,23 @@ class CommonParticipant : public core::IParticipant, public fastdds::dds::Domain // LISTENER METHODS ///////////////////////// - virtual void on_participant_discovery( + void on_participant_discovery( fastdds::dds::DomainParticipant* participant, - fastrtps::rtps::ParticipantDiscoveryInfo&& info) override; + fastdds::rtps::ParticipantDiscoveryStatus reason, + const fastdds::rtps::ParticipantBuiltinTopicData& info, + bool& /*should_be_ignored*/) override; - virtual void on_subscriber_discovery( + void on_data_reader_discovery( fastdds::dds::DomainParticipant* participant, - fastrtps::rtps::ReaderDiscoveryInfo&& info) override; + fastdds::rtps::ReaderDiscoveryStatus reason, + const fastdds::dds::SubscriptionBuiltinTopicData& info, + bool& /*should_be_ignored*/) override; - virtual void on_publisher_discovery( + void on_data_writer_discovery( fastdds::dds::DomainParticipant* participant, - fastrtps::rtps::WriterDiscoveryInfo&& info) override; + fastdds::rtps::WriterDiscoveryStatus reason, + const fastdds::dds::PublicationBuiltinTopicData& info, + bool& /*should_be_ignored*/) override; protected: @@ -134,6 +146,11 @@ class CommonParticipant : public core::IParticipant, public fastdds::dds::Domain // INTERNAL VIRTUAL METHODS ///////////////////////// + virtual + fastdds::dds::DomainParticipantQos + add_qos_properties_( + fastdds::dds::DomainParticipantQos& qos) const; + virtual fastdds::dds::DomainParticipantQos reckon_participant_qos_() const; diff --git a/ddspipe_participants/include/ddspipe_participants/participant/dynamic_types/DynTypesParticipant.hpp b/ddspipe_participants/include/ddspipe_participants/participant/dynamic_types/DynTypesParticipant.hpp index 928d1849..0ddfda67 100644 --- a/ddspipe_participants/include/ddspipe_participants/participant/dynamic_types/DynTypesParticipant.hpp +++ b/ddspipe_participants/include/ddspipe_participants/participant/dynamic_types/DynTypesParticipant.hpp @@ -18,8 +18,19 @@ #pragma once +#include +#include + +#include + #include -#include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -31,12 +42,10 @@ namespace ddspipe { namespace participants { /** - * This is an abomination Participant that is a Simple RTPS Participant with a built-in DDS Participant. - * The DDS Part that is only used to read type objects and type lookup services. + * Simple RTPS Participant able to route dynamic types in addition to user data. * - * TODO: separate these 2 participants */ -class DynTypesParticipant : public rtps::SimpleParticipant, public eprosima::fastdds::dds::DomainParticipantListener +class DynTypesParticipant : public rtps::SimpleParticipant { public: @@ -47,12 +56,6 @@ class DynTypesParticipant : public rtps::SimpleParticipant, public eprosima::fas std::shared_ptr payload_pool, std::shared_ptr discovery_database); - DDSPIPE_PARTICIPANTS_DllAPI - ~DynTypesParticipant(); - - DDSPIPE_PARTICIPANTS_DllAPI - virtual void init() override; - /** * @brief Create a writer object * @@ -72,32 +75,30 @@ class DynTypesParticipant : public rtps::SimpleParticipant, public eprosima::fas const core::ITopic& topic) override; DDSPIPE_PARTICIPANTS_DllAPI - void on_type_discovery( - eprosima::fastdds::dds::DomainParticipant* participant, - const eprosima::fastrtps::rtps::SampleIdentity& request_sample_id, - const eprosima::fastrtps::string_255& topic, - const eprosima::fastrtps::types::TypeIdentifier* identifier, - const eprosima::fastrtps::types::TypeObject* object, - eprosima::fastrtps::types::DynamicType_ptr dyn_type) override; + void on_reader_discovery( + fastdds::rtps::RTPSParticipant* participant, + fastdds::rtps::ReaderDiscoveryStatus reason, + const fastdds::rtps::SubscriptionBuiltinTopicData& info, + bool& should_be_ignored) override; DDSPIPE_PARTICIPANTS_DllAPI - virtual void on_type_information_received( - eprosima::fastdds::dds::DomainParticipant* participant, - const eprosima::fastrtps::string_255 topic_name, - const eprosima::fastrtps::string_255 type_name, - const eprosima::fastrtps::types::TypeInformation& type_information) override; + void on_writer_discovery( + fastdds::rtps::RTPSParticipant* participant, + fastdds::rtps::WriterDiscoveryStatus reason, + const fastdds::rtps::PublicationBuiltinTopicData& info, + bool& should_be_ignored) override; protected: - void internal_notify_type_object_( - eprosima::fastrtps::types::DynamicType_ptr dynamic_type); - - void initialize_internal_dds_participant_(); - - eprosima::fastdds::dds::DomainParticipant* dds_participant_; + void notify_type_discovered_( + const fastdds::dds::xtypes::TypeInformation& type_info, + const std::string& type_name); //! Type Object Internal Reader std::shared_ptr type_object_reader_; + + //! Received types set + std::set received_types_; }; } /* namespace participants */ diff --git a/ddspipe_participants/include/ddspipe_participants/participant/dynamic_types/ISchemaHandler.hpp b/ddspipe_participants/include/ddspipe_participants/participant/dynamic_types/ISchemaHandler.hpp index 3e0351a7..76a0d016 100644 --- a/ddspipe_participants/include/ddspipe_participants/participant/dynamic_types/ISchemaHandler.hpp +++ b/ddspipe_participants/include/ddspipe_participants/participant/dynamic_types/ISchemaHandler.hpp @@ -18,7 +18,10 @@ #pragma once -#include +#include + +#include +#include #include #include @@ -35,7 +38,8 @@ class ISchemaHandler public: virtual void add_schema( - const fastrtps::types::DynamicType_ptr& dynamic_type) = 0; + const fastdds::dds::DynamicType::_ref_type& dynamic_type, + const fastdds::dds::xtypes::TypeIdentifier& type_identifier) = 0; virtual void add_data( const core::types::DdsTopic& topic, diff --git a/ddspipe_participants/include/ddspipe_participants/participant/rtps/CommonParticipant.hpp b/ddspipe_participants/include/ddspipe_participants/participant/rtps/CommonParticipant.hpp index f39d0332..885605d0 100644 --- a/ddspipe_participants/include/ddspipe_participants/participant/rtps/CommonParticipant.hpp +++ b/ddspipe_participants/include/ddspipe_participants/participant/rtps/CommonParticipant.hpp @@ -16,13 +16,15 @@ #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -50,7 +52,7 @@ namespace rtps { */ class CommonParticipant : public core::IParticipant - , public fastrtps::rtps::RTPSParticipantListener + , public fastdds::rtps::RTPSParticipantListener { public: @@ -127,9 +129,11 @@ class CommonParticipant * This method only is for debugging purposes. */ DDSPIPE_PARTICIPANTS_DllAPI - virtual void onParticipantDiscovery( - fastrtps::rtps::RTPSParticipant* participant, - fastrtps::rtps::ParticipantDiscoveryInfo&& info) override; + virtual void on_participant_discovery( + fastdds::rtps::RTPSParticipant* participant, + fastdds::rtps::ParticipantDiscoveryStatus reason, + const fastdds::rtps::ParticipantBuiltinTopicData& info, + bool& /*should_be_ignored*/) override; /** * @brief Override method from \c RTPSParticipantListener . @@ -137,9 +141,11 @@ class CommonParticipant * This method adds to database the endpoint discovered or modified. */ DDSPIPE_PARTICIPANTS_DllAPI - virtual void onReaderDiscovery( - fastrtps::rtps::RTPSParticipant* participant, - fastrtps::rtps::ReaderDiscoveryInfo&& info) override; + virtual void on_reader_discovery( + fastdds::rtps::RTPSParticipant* participant, + fastdds::rtps::ReaderDiscoveryStatus reason, + const fastdds::rtps::SubscriptionBuiltinTopicData& info, + bool& /*should_be_ignored*/) override; /** * @brief Override method from \c RTPSParticipantListener . @@ -147,9 +153,11 @@ class CommonParticipant * This method adds to database the endpoint discovered or modified. */ DDSPIPE_PARTICIPANTS_DllAPI - virtual void onWriterDiscovery( - fastrtps::rtps::RTPSParticipant* participant, - fastrtps::rtps::WriterDiscoveryInfo&& info) override; + virtual void on_writer_discovery( + fastdds::rtps::RTPSParticipant* participant, + fastdds::rtps::WriterDiscoveryStatus reason, + const fastdds::rtps::PublicationBuiltinTopicData& info, + bool& /*should_be_ignored*/) override; ////////////////// // STATIC METHODS @@ -173,7 +181,7 @@ class CommonParticipant template DDSPIPE_PARTICIPANTS_DllAPI static std::shared_ptr create_descriptor( - std::set whitelist = {}); + std::set whitelist = {}); protected: @@ -186,26 +194,30 @@ class CommonParticipant const std::shared_ptr& participant_configuration, const std::shared_ptr& payload_pool, const std::shared_ptr& discovery_database, - const core::types::DomainId& domain_id, - const fastrtps::rtps::RTPSParticipantAttributes& participant_attributes); + const core::types::DomainId& domain_id); /** * @brief Auxiliary method to create the internal RTPS participant. */ void create_participant_( const core::types::DomainId& domain, - const fastrtps::rtps::RTPSParticipantAttributes& participant_attributes); + const fastdds::rtps::RTPSParticipantAttributes& participant_attributes); ///// // RTPS specific methods /** - * @brief Static method that gives the std attributes for a Participant. + * @brief Virtual method that sets the common properties of std attributes for a Participant. * - * @note This method must be specialized from inherit classes. */ - static fastrtps::rtps::RTPSParticipantAttributes reckon_participant_attributes_( - const ParticipantConfiguration* participant_configuration); + virtual fastdds::rtps::RTPSParticipantAttributes add_participant_att_properties_( + fastdds::rtps::RTPSParticipantAttributes& params) const; + + /** + * @brief Virtual method that gives the std attributes for a Participant. + * + */ + virtual fastdds::rtps::RTPSParticipantAttributes reckon_participant_attributes_() const; ///// // VARIABLES @@ -220,13 +232,13 @@ class CommonParticipant const std::shared_ptr discovery_database_; //! Internal RTPS Participant - eprosima::fastrtps::rtps::RTPSParticipant* rtps_participant_; + eprosima::fastdds::rtps::RTPSParticipant* rtps_participant_; //! Domain Id to create the internal RTPS Participant. core::types::DomainId domain_id_; //! Participant attributes to create the internal RTPS Participant. - fastrtps::rtps::RTPSParticipantAttributes participant_attributes_; + fastdds::rtps::RTPSParticipantAttributes participant_attributes_; }; } /* namespace rtps */ diff --git a/ddspipe_participants/include/ddspipe_participants/participant/rtps/DiscoveryServerParticipant.hpp b/ddspipe_participants/include/ddspipe_participants/participant/rtps/DiscoveryServerParticipant.hpp index 0751d4bf..e3640006 100644 --- a/ddspipe_participants/include/ddspipe_participants/participant/rtps/DiscoveryServerParticipant.hpp +++ b/ddspipe_participants/include/ddspipe_participants/participant/rtps/DiscoveryServerParticipant.hpp @@ -14,7 +14,7 @@ #pragma once -#include +#include #include #include @@ -41,8 +41,7 @@ class DiscoveryServerParticipant protected: - static fastrtps::rtps::RTPSParticipantAttributes reckon_participant_attributes_( - const DiscoveryServerParticipantConfiguration* participant_configuration); + fastdds::rtps::RTPSParticipantAttributes reckon_participant_attributes_() const override; }; diff --git a/ddspipe_participants/include/ddspipe_participants/participant/rtps/InitialPeersParticipant.hpp b/ddspipe_participants/include/ddspipe_participants/participant/rtps/InitialPeersParticipant.hpp index 6df6c01a..2eca30da 100644 --- a/ddspipe_participants/include/ddspipe_participants/participant/rtps/InitialPeersParticipant.hpp +++ b/ddspipe_participants/include/ddspipe_participants/participant/rtps/InitialPeersParticipant.hpp @@ -14,12 +14,11 @@ #pragma once -#include +#include #include -#include - #include +#include namespace eprosima { namespace ddspipe { @@ -42,8 +41,7 @@ class InitialPeersParticipant protected: - static fastrtps::rtps::RTPSParticipantAttributes reckon_participant_attributes_( - const InitialPeersParticipantConfiguration* configuration); + fastdds::rtps::RTPSParticipantAttributes reckon_participant_attributes_() const override; }; diff --git a/ddspipe_participants/include/ddspipe_participants/participant/rtps/SimpleParticipant.hpp b/ddspipe_participants/include/ddspipe_participants/participant/rtps/SimpleParticipant.hpp index ee18060e..71459bbc 100644 --- a/ddspipe_participants/include/ddspipe_participants/participant/rtps/SimpleParticipant.hpp +++ b/ddspipe_participants/include/ddspipe_participants/participant/rtps/SimpleParticipant.hpp @@ -52,8 +52,7 @@ class SimpleParticipant : public CommonParticipant /** * @brief Static method that gives the attributes for a Simple Participant. */ - static fastrtps::rtps::RTPSParticipantAttributes reckon_participant_attributes_( - const SimpleParticipantConfiguration* configuration); + fastdds::rtps::RTPSParticipantAttributes reckon_participant_attributes_() const override; }; } /* namespace rtps */ diff --git a/ddspipe_participants/include/ddspipe_participants/reader/auxiliar/BaseReader.hpp b/ddspipe_participants/include/ddspipe_participants/reader/auxiliar/BaseReader.hpp index 3754f499..999c90c3 100644 --- a/ddspipe_participants/include/ddspipe_participants/reader/auxiliar/BaseReader.hpp +++ b/ddspipe_participants/include/ddspipe_participants/reader/auxiliar/BaseReader.hpp @@ -136,7 +136,7 @@ class BaseReader : public core::IReader //! Get internal RTPS reader mutex DDSPIPE_PARTICIPANTS_DllAPI - fastrtps::RecursiveTimedMutex& get_rtps_mutex() const override; + fastdds::RecursiveTimedMutex& get_rtps_mutex() const override; //! Get number of unread cache changes in internal RTPS reader DDSPIPE_PARTICIPANTS_DllAPI diff --git a/ddspipe_participants/include/ddspipe_participants/reader/auxiliar/BlankReader.hpp b/ddspipe_participants/include/ddspipe_participants/reader/auxiliar/BlankReader.hpp index 338a716d..91214b44 100644 --- a/ddspipe_participants/include/ddspipe_participants/reader/auxiliar/BlankReader.hpp +++ b/ddspipe_participants/include/ddspipe_participants/reader/auxiliar/BlankReader.hpp @@ -64,7 +64,7 @@ class BlankReader : public core::IReader //! Get internal RTPS reader mutex DDSPIPE_PARTICIPANTS_DllAPI - fastrtps::RecursiveTimedMutex& get_rtps_mutex() const override; + fastdds::RecursiveTimedMutex& get_rtps_mutex() const override; //! Get number of unread cache changes in internal RTPS reader DDSPIPE_PARTICIPANTS_DllAPI diff --git a/ddspipe_participants/include/ddspipe_participants/reader/dds/CommonReader.hpp b/ddspipe_participants/include/ddspipe_participants/reader/dds/CommonReader.hpp index 2d6e0c0f..56a7c4bc 100644 --- a/ddspipe_participants/include/ddspipe_participants/reader/dds/CommonReader.hpp +++ b/ddspipe_participants/include/ddspipe_participants/reader/dds/CommonReader.hpp @@ -16,6 +16,7 @@ #include +#include #include #include diff --git a/ddspipe_participants/include/ddspipe_participants/reader/rpc/SimpleReader.hpp b/ddspipe_participants/include/ddspipe_participants/reader/rpc/SimpleReader.hpp index 939446c4..b358fd9e 100644 --- a/ddspipe_participants/include/ddspipe_participants/reader/rpc/SimpleReader.hpp +++ b/ddspipe_participants/include/ddspipe_participants/reader/rpc/SimpleReader.hpp @@ -48,17 +48,17 @@ class SimpleReader : public rtps::CommonReader const core::types::ParticipantId& participant_id, const core::types::DdsTopic& topic, const std::shared_ptr& payload_pool, - fastrtps::rtps::RTPSParticipant* rtps_participant); + fastdds::rtps::RTPSParticipant* rtps_participant); //! Override Parent method to create an RPC data type. DDSPIPE_PARTICIPANTS_DllAPI virtual core::types::RtpsPayloadData* create_data_( - const fastrtps::rtps::CacheChange_t& received_change) const noexcept override; + const fastdds::rtps::CacheChange_t& received_change) const noexcept override; //! Override Parent method to fill fields exclusive from RPC. DDSPIPE_PARTICIPANTS_DllAPI virtual void fill_received_data_( - const fastrtps::rtps::CacheChange_t& received_change, + const fastdds::rtps::CacheChange_t& received_change, core::types::RtpsPayloadData& data_to_fill) const noexcept override; }; diff --git a/ddspipe_participants/include/ddspipe_participants/reader/rtps/CommonReader.hpp b/ddspipe_participants/include/ddspipe_participants/reader/rtps/CommonReader.hpp index bf3f11f2..981728bb 100644 --- a/ddspipe_participants/include/ddspipe_participants/reader/rtps/CommonReader.hpp +++ b/ddspipe_participants/include/ddspipe_participants/reader/rtps/CommonReader.hpp @@ -16,17 +16,17 @@ #include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -44,11 +44,11 @@ namespace rtps { /** * Abstract generic class for a RTPS Reader wrapper. * - * It implements the ReaderListener for itself with \c onNewCacheChangeAdded and \c onReaderMatched callbacks. + * It implements the ReaderListener for itself with \c on_new_cache_change_added and \c on_reader_matched callbacks. * * @warning This object is not RAII and must be initialized before used. */ -class CommonReader : public BaseReader, public fastrtps::rtps::ReaderListener +class CommonReader : public BaseReader, public fastdds::rtps::ReaderListener { public: @@ -95,9 +95,9 @@ class CommonReader : public BaseReader, public fastrtps::rtps::ReaderListener * @param [in] change new change received */ DDSPIPE_PARTICIPANTS_DllAPI - void onNewCacheChangeAdded( - fastrtps::rtps::RTPSReader*, - const fastrtps::rtps::CacheChange_t* const change) noexcept override; + void on_new_cache_change_added( + fastdds::rtps::RTPSReader*, + const fastdds::rtps::CacheChange_t* const change) noexcept override; /** * @brief CommonReader Listener callback when a new Writer is matched or unmatched @@ -108,9 +108,9 @@ class CommonReader : public BaseReader, public fastrtps::rtps::ReaderListener * @param [in] info information about the matched Writer */ DDSPIPE_PARTICIPANTS_DllAPI - void onReaderMatched( - fastrtps::rtps::RTPSReader*, - fastrtps::rtps::MatchingInfo& info) noexcept override; + void on_reader_matched( + fastdds::rtps::RTPSReader*, + const fastdds::rtps::MatchingInfo& info) noexcept override; /** * This method is called when a new Writer is discovered, with a Topic that @@ -120,7 +120,7 @@ class CommonReader : public BaseReader, public fastrtps::rtps::ReaderListener */ DDSPIPE_PARTICIPANTS_DllAPI void on_requested_incompatible_qos( - fastrtps::rtps::RTPSReader*, + fastdds::rtps::RTPSReader*, fastdds::dds::PolicyMask qos) noexcept override; /** @@ -131,7 +131,7 @@ class CommonReader : public BaseReader, public fastrtps::rtps::ReaderListener */ DDSPIPE_PARTICIPANTS_DllAPI void on_sample_lost( - fastrtps::rtps::RTPSReader*, + fastdds::rtps::RTPSReader*, int32_t sample_lost_since_last_update) noexcept override; /** @@ -143,9 +143,9 @@ class CommonReader : public BaseReader, public fastrtps::rtps::ReaderListener */ DDSPIPE_PARTICIPANTS_DllAPI void on_sample_rejected( - fastrtps::rtps::RTPSReader*, + fastdds::rtps::RTPSReader*, eprosima::fastdds::dds::SampleRejectedStatusKind reason, - const fastrtps::rtps::CacheChange_t* const change) noexcept override; + const fastdds::rtps::CacheChange_t* const change) noexcept override; /** * This method is called when a new Writer is discovered, with a Topic that @@ -155,7 +155,7 @@ class CommonReader : public BaseReader, public fastrtps::rtps::ReaderListener */ DDSPIPE_PARTICIPANTS_DllAPI void on_incompatible_type( - fastrtps::rtps::RTPSReader* reader) noexcept override; + fastdds::rtps::RTPSReader* reader) noexcept override; ///////////////////////// // RPC REQUIRED METHODS @@ -168,7 +168,7 @@ class CommonReader : public BaseReader, public fastrtps::rtps::ReaderListener //! Get internal RTPS reader mutex DDSPIPE_PARTICIPANTS_DllAPI - fastrtps::RecursiveTimedMutex& get_rtps_mutex() const noexcept override; + fastdds::RecursiveTimedMutex& get_rtps_mutex() const noexcept override; //! Get number of unread cache changes in internal RTPS reader DDSPIPE_PARTICIPANTS_DllAPI @@ -193,11 +193,11 @@ class CommonReader : public BaseReader, public fastrtps::rtps::ReaderListener const core::types::ParticipantId& participant_id, const core::types::DdsTopic& topic, const std::shared_ptr& payload_pool, - fastrtps::rtps::RTPSParticipant* rtps_participant, - const fastrtps::rtps::HistoryAttributes& history_attributes, - const fastrtps::rtps::ReaderAttributes& reader_attributes, - const fastrtps::TopicAttributes& topic_attributes, - const fastrtps::ReaderQos& reader_qos); + fastdds::rtps::RTPSParticipant* rtps_participant, + const fastdds::rtps::HistoryAttributes& history_attributes, + const fastdds::rtps::ReaderAttributes& reader_attributes, + const fastdds::rtps::TopicDescription& topic_desc, + const fastdds::dds::ReaderQos& reader_qos); // Specific enable/disable do not need to be implemented @@ -206,10 +206,10 @@ class CommonReader : public BaseReader, public fastrtps::rtps::ReaderListener */ DDSPIPE_PARTICIPANTS_DllAPI virtual void internal_entities_creation_( - const fastrtps::rtps::HistoryAttributes& history_attributes, - const fastrtps::rtps::ReaderAttributes& reader_attributes, - const fastrtps::TopicAttributes& topic_attributes, - const fastrtps::ReaderQos& reader_qos); + const fastdds::rtps::HistoryAttributes& history_attributes, + const fastdds::rtps::ReaderAttributes& reader_attributes, + const fastdds::rtps::TopicDescription& topic_desc, + const fastdds::dds::ReaderQos& reader_qos); /** * @brief Return an allocated object @@ -218,14 +218,14 @@ class CommonReader : public BaseReader, public fastrtps::rtps::ReaderListener */ DDSPIPE_PARTICIPANTS_DllAPI virtual core::types::RtpsPayloadData* create_data_( - const fastrtps::rtps::CacheChange_t& received_change) const noexcept; + const fastdds::rtps::CacheChange_t& received_change) const noexcept; /** * @brief Auxiliary method used in \c take to fill the received data. */ DDSPIPE_PARTICIPANTS_DllAPI virtual void fill_received_data_( - const fastrtps::rtps::CacheChange_t& received_change, + const fastdds::rtps::CacheChange_t& received_change, core::types::RtpsPayloadData& data_to_fill) const noexcept; // Specific enable/disable do not need to be implemented @@ -260,21 +260,21 @@ class CommonReader : public BaseReader, public fastrtps::rtps::ReaderListener * * @return Default HistoryAttributes */ - static fastrtps::rtps::HistoryAttributes reckon_history_attributes_( + static fastdds::rtps::HistoryAttributes reckon_history_attributes_( const core::types::DdsTopic& topic) noexcept; /** * @brief Reader Attributes to create RTPS Reader */ - static fastrtps::rtps::ReaderAttributes reckon_reader_attributes_( + static fastdds::rtps::ReaderAttributes reckon_reader_attributes_( const core::types::DdsTopic& topic) noexcept; - //! Topic Attributes to create RTPS Reader - static fastrtps::TopicAttributes reckon_topic_attributes_( + //! Topic Description to create RTPS Reader + fastdds::rtps::TopicDescription reckon_topic_description_( const core::types::DdsTopic& topic) noexcept; //! Reader QoS to create RTPS Reader - static fastrtps::ReaderQos reckon_reader_qos_( + static fastdds::dds::ReaderQos reckon_reader_qos_( const core::types::DdsTopic& topic) noexcept; ///// @@ -282,24 +282,24 @@ class CommonReader : public BaseReader, public fastrtps::rtps::ReaderListener //! Whether a change received should be processed virtual bool should_accept_change_( - const fastrtps::rtps::CacheChange_t* change) noexcept; + const fastdds::rtps::CacheChange_t* change) noexcept; //! Whether a change received is from this Participant (to avoid auto-feedback) bool come_from_this_participant_( - const fastrtps::rtps::CacheChange_t* change) const noexcept; + const fastdds::rtps::CacheChange_t* change) const noexcept; //! Whether a guid references this Participant (to avoid auto-feedback) bool come_from_this_participant_( - const fastrtps::rtps::GUID_t guid) const noexcept; + const fastdds::rtps::GUID_t guid) const noexcept; utils::ReturnCode is_data_correct_( - const fastrtps::rtps::CacheChange_t* received_change) const noexcept; + const fastdds::rtps::CacheChange_t* received_change) const noexcept; ///// // EXTERNAL VARIABLES //! RTPS Participant - fastrtps::rtps::RTPSParticipant* rtps_participant_; + fastdds::rtps::RTPSParticipant* rtps_participant_; ///// // INTERNAL VARIABLES @@ -310,22 +310,22 @@ class CommonReader : public BaseReader, public fastrtps::rtps::ReaderListener core::types::DdsTopic topic_; //! RTPS Reader pointer - fastrtps::rtps::RTPSReader* rtps_reader_; + fastdds::rtps::RTPSReader* rtps_reader_; //! RTPS Reader History associated to \c rtps_reader_ - fastrtps::rtps::ReaderHistory* rtps_history_; + fastdds::rtps::ReaderHistory* rtps_history_; //! History attributes to create the History for the internal RTPS Reader. - fastrtps::rtps::HistoryAttributes history_attributes_; + fastdds::rtps::HistoryAttributes history_attributes_; //! Reader attributes to create the internal RTPS Reader. - fastrtps::rtps::ReaderAttributes reader_attributes_; + fastdds::rtps::ReaderAttributes reader_attributes_; - //! Topic attributes to create the internal RTPS Reader. - fastrtps::TopicAttributes topic_attributes_; + //! Topic description to create the internal RTPS Reader. + fastdds::rtps::TopicDescription topic_description_; //! Reader QoS to create the internal RTPS Reader. - fastrtps::ReaderQos reader_qos_; + fastdds::dds::ReaderQos reader_qos_; }; } /* namespace rtps */ diff --git a/ddspipe_participants/include/ddspipe_participants/reader/rtps/SimpleReader.hpp b/ddspipe_participants/include/ddspipe_participants/reader/rtps/SimpleReader.hpp index f219a107..a7fe7d1c 100644 --- a/ddspipe_participants/include/ddspipe_participants/reader/rtps/SimpleReader.hpp +++ b/ddspipe_participants/include/ddspipe_participants/reader/rtps/SimpleReader.hpp @@ -14,8 +14,12 @@ #pragma once +#include +#include +#include #include #include +#include namespace eprosima { namespace ddspipe { @@ -46,7 +50,7 @@ class SimpleReader : public CommonReader const core::types::ParticipantId& participant_id, const core::types::DdsTopic& topic, const std::shared_ptr& payload_pool, - fastrtps::rtps::RTPSParticipant* rtps_participant); + fastdds::rtps::RTPSParticipant* rtps_participant); }; } /* namespace rtps */ diff --git a/ddspipe_participants/include/ddspipe_participants/reader/rtps/SpecificQoSReader.hpp b/ddspipe_participants/include/ddspipe_participants/reader/rtps/SpecificQoSReader.hpp index 910665e9..71813456 100644 --- a/ddspipe_participants/include/ddspipe_participants/reader/rtps/SpecificQoSReader.hpp +++ b/ddspipe_participants/include/ddspipe_participants/reader/rtps/SpecificQoSReader.hpp @@ -51,7 +51,7 @@ class SpecificQoSReader : public CommonReader const core::types::ParticipantId& participant_id, const core::types::DdsTopic& topic, const std::shared_ptr& payload_pool, - fastrtps::rtps::RTPSParticipant* rtps_participant, + fastdds::rtps::RTPSParticipant* rtps_participant, const std::shared_ptr& discovery_database); protected: @@ -60,7 +60,7 @@ class SpecificQoSReader : public CommonReader * Specializes \c CommonReader method and set the QoS of the data received. */ virtual void fill_received_data_( - const fastrtps::rtps::CacheChange_t& received_change, + const fastdds::rtps::CacheChange_t& received_change, core::types::RtpsPayloadData& data_to_fill) const noexcept override; diff --git a/ddspipe_participants/include/ddspipe_participants/testing/entities/mock_entities.hpp b/ddspipe_participants/include/ddspipe_participants/testing/entities/mock_entities.hpp index cd6283ba..ced5f115 100644 --- a/ddspipe_participants/include/ddspipe_participants/testing/entities/mock_entities.hpp +++ b/ddspipe_participants/include/ddspipe_participants/testing/entities/mock_entities.hpp @@ -18,6 +18,7 @@ #include #include +#include #include #include diff --git a/ddspipe_participants/include/ddspipe_participants/testing/random_values.hpp b/ddspipe_participants/include/ddspipe_participants/testing/random_values.hpp index a1c0487f..ff32ffdd 100644 --- a/ddspipe_participants/include/ddspipe_participants/testing/random_values.hpp +++ b/ddspipe_participants/include/ddspipe_participants/testing/random_values.hpp @@ -30,8 +30,7 @@ types::Address random_address( DDSPIPE_PARTICIPANTS_DllAPI types::DiscoveryServerConnectionAddress random_connection_address( unsigned int seed = 0, - unsigned int size = 1, - bool ros = false); + unsigned int size = 1); } /* namespace testing */ } /* namespace participants */ diff --git a/ddspipe_participants/include/ddspipe_participants/types/address/Address.hpp b/ddspipe_participants/include/ddspipe_participants/types/address/Address.hpp index 00fd09a8..7a75dbc4 100644 --- a/ddspipe_participants/include/ddspipe_participants/types/address/Address.hpp +++ b/ddspipe_participants/include/ddspipe_participants/types/address/Address.hpp @@ -16,7 +16,7 @@ #include -#include +#include #include @@ -29,6 +29,8 @@ namespace types { using LocatorType = uint32_t; // Data Type for IP using IpType = std::string; +// Data Type for an interfaces whitelist entry +using WhitelistType = std::string; // Data Type for Domain name (DNS) using DomainType = std::string; // Data Type for Port diff --git a/ddspipe_participants/include/ddspipe_participants/types/address/DiscoveryServerConnectionAddress.hpp b/ddspipe_participants/include/ddspipe_participants/types/address/DiscoveryServerConnectionAddress.hpp index b497ef04..0391acf0 100644 --- a/ddspipe_participants/include/ddspipe_participants/types/address/DiscoveryServerConnectionAddress.hpp +++ b/ddspipe_participants/include/ddspipe_participants/types/address/DiscoveryServerConnectionAddress.hpp @@ -19,7 +19,6 @@ #include #include -#include namespace eprosima { namespace ddspipe { @@ -30,8 +29,7 @@ namespace types { * @brief Collection of Addresses to connect with a remote Disovery Server. * * An address will remain in an IP and a Port, IP version and Transport Protocol. - * This class has several address associated with one \c GuidPrefix in order to connect with - * a remote Discovery Server. + * This class has several address in order to connect with a remote Discovery Server. */ class DiscoveryServerConnectionAddress { @@ -40,18 +38,12 @@ class DiscoveryServerConnectionAddress /** * @brief Construct a new \c DiscoveryServerConnectionAddress object with all the parameters * - * @param discovery_server_guid_ : Guid Prefix of the remote Discovery Server * @param addresses_ collection of addresses */ DDSPIPE_PARTICIPANTS_DllAPI DiscoveryServerConnectionAddress( - core::types::GuidPrefix discovery_server_guid, std::set
addresses); - //! Discovery Server \c GuidPrefix Port getter - DDSPIPE_PARTICIPANTS_DllAPI - core::types::GuidPrefix discovery_server_guid_prefix() const noexcept; - //! Addresses getter DDSPIPE_PARTICIPANTS_DllAPI std::set
addresses() const noexcept; @@ -59,7 +51,6 @@ class DiscoveryServerConnectionAddress /** * @brief Whether the address is correct * - * Checks if GuidPrefix is correct. * Checks if it has at least one correct address. */ DDSPIPE_PARTICIPANTS_DllAPI @@ -77,9 +68,6 @@ class DiscoveryServerConnectionAddress protected: - //! Internal Discovery Server Guid Prefix object - core::types::GuidPrefix discovery_server_guid_prefix_; - //! Internal Addresses object std::set
addresses_; }; diff --git a/ddspipe_participants/include/ddspipe_participants/types/dds/RouterCacheChange.hpp b/ddspipe_participants/include/ddspipe_participants/types/dds/RouterCacheChange.hpp index 5f0d89da..54c049b7 100644 --- a/ddspipe_participants/include/ddspipe_participants/types/dds/RouterCacheChange.hpp +++ b/ddspipe_participants/include/ddspipe_participants/types/dds/RouterCacheChange.hpp @@ -14,7 +14,7 @@ #pragma once -#include +#include #include #include @@ -33,19 +33,19 @@ namespace types { * This Change is required to be used for features: * - Repeater participant: avoid redirecting the message to the source participant. */ -struct RouterCacheChange : public fastrtps::rtps::CacheChange_t +struct RouterCacheChange : public fastdds::rtps::CacheChange_t { public: //! Using parent constructors - using fastrtps::rtps::CacheChange_t::CacheChange_t; + using fastdds::rtps::CacheChange_t::CacheChange_t; /** * @brief GuidPrefix of the Participant that has sent this message through the pipe. * * @note it is not the same as origin writer, as there could be more pipes in the path. */ - fastrtps::rtps::GuidPrefix_t last_writer_guid_prefix; + fastdds::rtps::GuidPrefix_t last_writer_guid_prefix; }; } /* namespace types */ diff --git a/ddspipe_participants/include/ddspipe_participants/types/dds/TopicDataType.hpp b/ddspipe_participants/include/ddspipe_participants/types/dds/TopicDataType.hpp index 92515f96..6e5c0ab0 100644 --- a/ddspipe_participants/include/ddspipe_participants/types/dds/TopicDataType.hpp +++ b/ddspipe_participants/include/ddspipe_participants/types/dds/TopicDataType.hpp @@ -14,7 +14,16 @@ #pragma once +#include +#include + +#include +#include +#include #include +#include +#include +#include #include #include @@ -29,16 +38,17 @@ namespace dds { using DataType = core::types::RtpsPayloadData; -class TopicDataType : public eprosima::fastdds::dds::TopicDataType +class TopicDataType : public fastdds::dds::TopicDataType { public: //! Default constructor DDSPIPE_PARTICIPANTS_DllAPI TopicDataType( + const std::shared_ptr& payload_pool, const std::string& type_name, - const bool keyed, - const std::shared_ptr& payload_pool); + const fastdds::dds::xtypes::TypeIdentifierPair& type_identifiers, + const bool keyed); //! Default destructor DDSPIPE_PARTICIPANTS_DllAPI @@ -47,34 +57,43 @@ class TopicDataType : public eprosima::fastdds::dds::TopicDataType //! \c serialize method overriden from \c TopicDataType DDSPIPE_PARTICIPANTS_DllAPI virtual bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; + const void* const data, + fastdds::rtps::SerializedPayload_t& payload, + fastdds::dds::DataRepresentationId_t data_representation) override; //! \c deserialize method overriden from \c TopicDataType DDSPIPE_PARTICIPANTS_DllAPI virtual bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + fastdds::rtps::SerializedPayload_t& payload, void* data) override; - //! \c getSerializedSizeProvider method overriden from \c TopicDataType + //! \c calculate_serialized_size method overriden from \c TopicDataType DDSPIPE_PARTICIPANTS_DllAPI - virtual std::function getSerializedSizeProvider( - void* data) override; + virtual uint32_t calculate_serialized_size( + const void* const data, + fastdds::dds::DataRepresentationId_t data_representation) override; + + //! \c compute_key method overriden from \c TopicDataType + DDSPIPE_PARTICIPANTS_DllAPI + virtual bool compute_key( + fastdds::rtps::SerializedPayload_t& payload, + fastdds::rtps::InstanceHandle_t& handle, + bool force_md5 = false) override; - //! \c getKey method overriden from \c TopicDataType + //! \c compute_key method overriden from \c TopicDataType DDSPIPE_PARTICIPANTS_DllAPI - virtual bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* handle, + virtual bool compute_key( + const void* const /*data*/, + fastdds::rtps::InstanceHandle_t& /*handle*/, bool force_md5 = false) override; - //! \c createData method overriden from \c TopicDataType + //! \c create_data method overriden from \c TopicDataType DDSPIPE_PARTICIPANTS_DllAPI - virtual void* createData() override; + virtual void* create_data() override; - //! \c deleteData method overriden from \c TopicDataType + //! \c delete_data method overriden from \c TopicDataType DDSPIPE_PARTICIPANTS_DllAPI - virtual void deleteData( + virtual void delete_data( void* data) override; protected: diff --git a/ddspipe_participants/include/ddspipe_participants/types/security/tls/TlsConfiguration.hpp b/ddspipe_participants/include/ddspipe_participants/types/security/tls/TlsConfiguration.hpp index bb07c1c1..db4736c9 100644 --- a/ddspipe_participants/include/ddspipe_participants/types/security/tls/TlsConfiguration.hpp +++ b/ddspipe_participants/include/ddspipe_participants/types/security/tls/TlsConfiguration.hpp @@ -17,7 +17,7 @@ #include #include -#include +#include #include diff --git a/ddspipe_participants/include/ddspipe_participants/utils/utils.hpp b/ddspipe_participants/include/ddspipe_participants/utils/utils.hpp index 83242e28..1df31b23 100644 --- a/ddspipe_participants/include/ddspipe_participants/utils/utils.hpp +++ b/ddspipe_participants/include/ddspipe_participants/utils/utils.hpp @@ -14,9 +14,9 @@ #pragma once -#include -#include -#include +#include +#include +#include #include #include @@ -28,6 +28,16 @@ namespace ddspipe { namespace participants { namespace detail { +/** + * @brief Create an endpoint from info object + * + * Specialized for \c PublicationBuiltinTopicData and \c SubscriptionBuiltinTopicData . + */ +template +core::types::Endpoint create_endpoint_from_info_( + const DiscoveryBuiltinTopicData& info, + const core::types::ParticipantId participant_discoverer_id); + /** * @brief Get the QoS from a Writer from the \c DiscoveryDatabase . */ @@ -35,22 +45,12 @@ core::types::SpecificEndpointQoS specific_qos_of_writer_( const core::DiscoveryDatabase& database, const core::types::Guid& guid); -/** - * @brief Create a endpoint from info object - * - * Specialized for \c WriterDiscoveryInfo and \c ReaderDiscoveryInfo . - */ -template -core::types::Endpoint create_endpoint_from_info_( - const DiscoveryInfoKind& info, - const core::types::ParticipantId participant_discoverer_id); - bool come_from_same_participant_( - const fastrtps::rtps::GUID_t src_guid, - const fastrtps::rtps::GUID_t target_guid) noexcept; + const fastdds::rtps::GUID_t src_guid, + const fastdds::rtps::GUID_t target_guid) noexcept; -fastrtps::rtps::GUID_t guid_from_instance_handle( - const fastrtps::rtps::InstanceHandle_t& ihandle) noexcept; +fastdds::rtps::GUID_t guid_from_instance_handle( + const fastdds::rtps::InstanceHandle_t& ihandle) noexcept; } /* namespace detail */ } /* namespace participants */ diff --git a/ddspipe_participants/include/ddspipe_participants/writer/auxiliar/RtpsEchoWriter.hpp b/ddspipe_participants/include/ddspipe_participants/writer/auxiliar/RtpsEchoWriter.hpp index 87a9d17e..79b45e77 100644 --- a/ddspipe_participants/include/ddspipe_participants/writer/auxiliar/RtpsEchoWriter.hpp +++ b/ddspipe_participants/include/ddspipe_participants/writer/auxiliar/RtpsEchoWriter.hpp @@ -16,6 +16,8 @@ #include +#include + #include #include diff --git a/ddspipe_participants/include/ddspipe_participants/writer/rpc/SimpleWriter.hpp b/ddspipe_participants/include/ddspipe_participants/writer/rpc/SimpleWriter.hpp index 8f36c5ad..c74b70be 100644 --- a/ddspipe_participants/include/ddspipe_participants/writer/rpc/SimpleWriter.hpp +++ b/ddspipe_participants/include/ddspipe_participants/writer/rpc/SimpleWriter.hpp @@ -14,13 +14,11 @@ #pragma once -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include @@ -60,20 +58,20 @@ class SimpleWriter : public rtps::CommonWriter const core::types::ParticipantId& participant_id, const core::types::DdsTopic& topic, const std::shared_ptr& payload_pool, - fastrtps::rtps::RTPSParticipant* rtps_participant, + fastdds::rtps::RTPSParticipant* rtps_participant, const bool repeater = false); //! Override Parent method to fill fields only required for RPC. DDSPIPE_PARTICIPANTS_DllAPI virtual utils::ReturnCode fill_to_send_data_( - fastrtps::rtps::CacheChange_t* to_send_change_to_fill, - eprosima::fastrtps::rtps::WriteParams& to_send_params, + fastdds::rtps::CacheChange_t* to_send_change_to_fill, + eprosima::fastdds::rtps::WriteParams& to_send_params, const core::types::RtpsPayloadData& data) const noexcept; //! Override Parent method to fill fields after message is sent only required for RPC. DDSPIPE_PARTICIPANTS_DllAPI virtual void fill_sent_data_( - const eprosima::fastrtps::rtps::WriteParams& sent_params, + const eprosima::fastdds::rtps::WriteParams& sent_params, core::types::RtpsPayloadData& data_to_fill) const noexcept; }; diff --git a/ddspipe_participants/include/ddspipe_participants/writer/rtps/CommonWriter.hpp b/ddspipe_participants/include/ddspipe_participants/writer/rtps/CommonWriter.hpp index 14cd35eb..1bb98a1b 100644 --- a/ddspipe_participants/include/ddspipe_participants/writer/rtps/CommonWriter.hpp +++ b/ddspipe_participants/include/ddspipe_participants/writer/rtps/CommonWriter.hpp @@ -14,23 +14,30 @@ #pragma once -#include +#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include #include +#include #include #include -#include #include ///// @@ -54,11 +61,11 @@ namespace rtps { /** * Abstract generic class for a RTPS Writer wrapper. * - * It implements the WriterListener for itself with \c onWriterMatched callbacks. + * It implements the WriterListener for itself with \c on_writer_matched callbacks. * * @warning This object is not RAII and must be initialized before used. */ -class CommonWriter : public BaseWriter, public fastrtps::rtps::WriterListener +class CommonWriter : public BaseWriter, public fastdds::rtps::WriterListener { public: @@ -104,9 +111,9 @@ class CommonWriter : public BaseWriter, public fastrtps::rtps::WriterListener * @param [in] info information about the matched Reader */ DDSPIPE_PARTICIPANTS_DllAPI - void onWriterMatched( - fastrtps::rtps::RTPSWriter*, - fastrtps::rtps::MatchingInfo& info) noexcept override; + void on_writer_matched( + fastdds::rtps::RTPSWriter*, + const fastdds::rtps::MatchingInfo& info) noexcept override; /** * @brief CommonWriter Listener callback when all the Readers have received a change. @@ -117,9 +124,9 @@ class CommonWriter : public BaseWriter, public fastrtps::rtps::WriterListener * @param [in] ch the change that has been acknowledged by all the Readers. */ DDSPIPE_PARTICIPANTS_DllAPI - void onWriterChangeReceivedByAll( - fastrtps::rtps::RTPSWriter*, - fastrtps::rtps::CacheChange_t* change) override; + void on_writer_change_received_by_all( + fastdds::rtps::RTPSWriter*, + fastdds::rtps::CacheChange_t* change) override; /** * This method is called when a new Reader is discovered, with a Topic that @@ -129,8 +136,8 @@ class CommonWriter : public BaseWriter, public fastrtps::rtps::WriterListener */ DDSPIPE_PARTICIPANTS_DllAPI void on_offered_incompatible_qos( - fastrtps::rtps::RTPSWriter*, - fastdds::dds::PolicyMask qos) noexcept override; + fastdds::rtps::RTPSWriter*, + eprosima::fastdds::dds::PolicyMask qos) noexcept override; ///////////////////// // STATIC ATTRIBUTES @@ -156,12 +163,12 @@ class CommonWriter : public BaseWriter, public fastrtps::rtps::WriterListener const core::types::ParticipantId& participant_id, const core::types::DdsTopic& topic, const std::shared_ptr& payload_pool, - fastrtps::rtps::RTPSParticipant* rtps_participant, + fastdds::rtps::RTPSParticipant* rtps_participant, const bool repeater, - const fastrtps::rtps::HistoryAttributes& history_attributes, - const fastrtps::rtps::WriterAttributes& writer_attributes, - const fastrtps::TopicAttributes& topic_attributes, - const fastrtps::WriterQos& writer_qos, + const fastdds::rtps::HistoryAttributes& history_attributes, + const fastdds::rtps::WriterAttributes& writer_attributes, + const fastdds::rtps::TopicDescription& topic_description, + const fastdds::dds::WriterQos& writer_qos, const utils::PoolConfiguration& pool_configuration); // Specific enable/disable do not need to be implemented @@ -194,8 +201,8 @@ class CommonWriter : public BaseWriter, public fastrtps::rtps::WriterListener */ DDSPIPE_PARTICIPANTS_DllAPI virtual utils::ReturnCode fill_to_send_data_( - fastrtps::rtps::CacheChange_t* to_send_change_to_fill, - eprosima::fastrtps::rtps::WriteParams& to_send_params, + fastdds::rtps::CacheChange_t* to_send_change_to_fill, + eprosima::fastdds::rtps::WriteParams& to_send_params, const core::types::RtpsPayloadData& data) const noexcept; /** @@ -206,7 +213,7 @@ class CommonWriter : public BaseWriter, public fastrtps::rtps::WriterListener */ DDSPIPE_PARTICIPANTS_DllAPI virtual void fill_sent_data_( - const eprosima::fastrtps::rtps::WriteParams& sent_params, + const eprosima::fastdds::rtps::WriteParams& sent_params, core::types::RtpsPayloadData& data_to_fill) const noexcept; ///// @@ -221,30 +228,30 @@ class CommonWriter : public BaseWriter, public fastrtps::rtps::WriterListener * @param rtps_participant */ void internal_entities_creation_( - const fastrtps::rtps::HistoryAttributes& history_attributes, - const fastrtps::rtps::WriterAttributes& writer_attributes, - const fastrtps::TopicAttributes& topic_attributes, - const fastrtps::WriterQos& writer_qos, + const fastdds::rtps::HistoryAttributes& history_attributes, + const fastdds::rtps::WriterAttributes& writer_attributes, + const fastdds::rtps::TopicDescription& topic_description, + const fastdds::dds::WriterQos& writer_qos, const utils::PoolConfiguration& pool_configuration); /** * @brief History Attributes to create RTPS Writer History */ - static fastrtps::rtps::HistoryAttributes reckon_history_attributes_( + static fastdds::rtps::HistoryAttributes reckon_history_attributes_( const core::types::DdsTopic& topic) noexcept; /** * @brief Writer Attributes to create RTPS Writer */ - static fastrtps::rtps::WriterAttributes reckon_writer_attributes_( + static fastdds::rtps::WriterAttributes reckon_writer_attributes_( const core::types::DdsTopic& topic) noexcept; - //! Topic Attributes to create RTPS Writer - static fastrtps::TopicAttributes reckon_topic_attributes_( + //! Topic Description to create RTPS Writer + fastdds::rtps::TopicDescription reckon_topic_description_( const core::types::DdsTopic& topic) noexcept; //! QoS for RTPS Writer - static fastrtps::WriterQos reckon_writer_qos_( + static fastdds::dds::WriterQos reckon_writer_qos_( const core::types::DdsTopic& topic) noexcept; //! Cache Change Pool Configuration @@ -253,13 +260,13 @@ class CommonWriter : public BaseWriter, public fastrtps::rtps::WriterListener //! Whether a guid references this Participant bool come_from_this_participant_( - const fastrtps::rtps::GUID_t guid) const noexcept; + const fastdds::rtps::GUID_t guid) const noexcept; ///// // EXTERNAL VARIABLES //! RTPS Participant - fastrtps::rtps::RTPSParticipant* rtps_participant_; + fastdds::rtps::RTPSParticipant* rtps_participant_; //! Whether it is repeater or not (used for data filters and/or qos) bool repeater_; @@ -272,25 +279,25 @@ class CommonWriter : public BaseWriter, public fastrtps::rtps::WriterListener const std::shared_ptr& payload_pool_; //! RTPS CommonWriter pointer - fastrtps::rtps::RTPSWriter* rtps_writer_; + fastdds::rtps::RTPSWriter* rtps_writer_; //! RTPS CommonWriter History associated to \c rtps_reader_ - fastrtps::rtps::WriterHistory* rtps_history_; + fastdds::rtps::WriterHistory* rtps_history_; //! Data Filter used to filter cache changes at the RTPSWriter level. std::unique_ptr data_filter_; //! History attributes to create the History for the internal RTPS Writer. - fastrtps::rtps::HistoryAttributes history_attributes_; + fastdds::rtps::HistoryAttributes history_attributes_; //! Writer attributes to create the internal RTPS Writer. - fastrtps::rtps::WriterAttributes writer_attributes_; + fastdds::rtps::WriterAttributes writer_attributes_; - //! Topic attributes to create the internal RTPS Writer. - fastrtps::TopicAttributes topic_attributes_; + //! Topic description to create the internal RTPS Writer + fastdds::rtps::TopicDescription topic_description_; //! Writer QoS to create the internal RTPS Writer. - fastrtps::WriterQos writer_qos_; + fastdds::dds::WriterQos writer_qos_; //! Pool Configuration to create the internal History. utils::PoolConfiguration pool_configuration_; diff --git a/ddspipe_participants/include/ddspipe_participants/writer/rtps/MultiWriter.hpp b/ddspipe_participants/include/ddspipe_participants/writer/rtps/MultiWriter.hpp index 4f9047e0..86a01225 100644 --- a/ddspipe_participants/include/ddspipe_participants/writer/rtps/MultiWriter.hpp +++ b/ddspipe_participants/include/ddspipe_participants/writer/rtps/MultiWriter.hpp @@ -55,7 +55,7 @@ class MultiWriter : public BaseWriter const core::types::ParticipantId& participant_id, const core::types::DdsTopic& topic, const std::shared_ptr& payload_pool, - fastrtps::rtps::RTPSParticipant* rtps_participant, + fastdds::rtps::RTPSParticipant* rtps_participant, const bool repeater = false); /** @@ -102,7 +102,7 @@ class MultiWriter : public BaseWriter core::types::DdsTopic topic_; //! Reference to RTPS Participant. - fastrtps::rtps::RTPSParticipant* rtps_participant_; + fastdds::rtps::RTPSParticipant* rtps_participant_; //! Whether this Writer is a repeater. bool repeater_; diff --git a/ddspipe_participants/include/ddspipe_participants/writer/rtps/QoSSpecificWriter.hpp b/ddspipe_participants/include/ddspipe_participants/writer/rtps/QoSSpecificWriter.hpp index ea74d4eb..3a466618 100644 --- a/ddspipe_participants/include/ddspipe_participants/writer/rtps/QoSSpecificWriter.hpp +++ b/ddspipe_participants/include/ddspipe_participants/writer/rtps/QoSSpecificWriter.hpp @@ -14,6 +14,15 @@ #pragma once +#include + +#include +#include + +#include +#include +#include +#include #include #include @@ -48,14 +57,14 @@ class QoSSpecificWriter : public CommonWriter const core::types::ParticipantId& participant_id, const core::types::DdsTopic& topic, const std::shared_ptr& payload_pool, - fastrtps::rtps::RTPSParticipant* rtps_participant, + fastdds::rtps::RTPSParticipant* rtps_participant, const core::types::SpecificEndpointQoS& specific_qos, const bool repeater = false); protected: //! Specific writer QoS to override (more or less) the CommonWriter qos - static fastrtps::WriterQos reckon_writer_qos_( + static fastdds::dds::WriterQos reckon_writer_qos_( const core::types::SpecificEndpointQoS& specific_qos, const core::types::DdsTopic& topic) noexcept; diff --git a/ddspipe_participants/include/ddspipe_participants/writer/rtps/SimpleWriter.hpp b/ddspipe_participants/include/ddspipe_participants/writer/rtps/SimpleWriter.hpp index c18f24e6..a09cffd8 100644 --- a/ddspipe_participants/include/ddspipe_participants/writer/rtps/SimpleWriter.hpp +++ b/ddspipe_participants/include/ddspipe_participants/writer/rtps/SimpleWriter.hpp @@ -14,13 +14,11 @@ #pragma once -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include @@ -60,7 +58,7 @@ class SimpleWriter : public CommonWriter const core::types::ParticipantId& participant_id, const core::types::DdsTopic& topic, const std::shared_ptr& payload_pool, - fastrtps::rtps::RTPSParticipant* rtps_participant, + fastdds::rtps::RTPSParticipant* rtps_participant, const bool repeater = false); }; diff --git a/ddspipe_participants/include/ddspipe_participants/writer/rtps/filter/RepeaterDataFilter.hpp b/ddspipe_participants/include/ddspipe_participants/writer/rtps/filter/RepeaterDataFilter.hpp index 93ae3cab..fa012cb2 100644 --- a/ddspipe_participants/include/ddspipe_participants/writer/rtps/filter/RepeaterDataFilter.hpp +++ b/ddspipe_participants/include/ddspipe_participants/writer/rtps/filter/RepeaterDataFilter.hpp @@ -42,8 +42,8 @@ class RepeaterDataFilter : public SelfDataFilter */ DDSPIPE_PARTICIPANTS_DllAPI bool is_relevant( - const fastrtps::rtps::CacheChange_t& change, - const fastrtps::rtps::GUID_t& reader_guid + const fastdds::rtps::CacheChange_t& change, + const fastdds::rtps::GUID_t& reader_guid ) const override; }; diff --git a/ddspipe_participants/include/ddspipe_participants/writer/rtps/filter/SelfDataFilter.hpp b/ddspipe_participants/include/ddspipe_participants/writer/rtps/filter/SelfDataFilter.hpp index 4f401618..8b561cb2 100644 --- a/ddspipe_participants/include/ddspipe_participants/writer/rtps/filter/SelfDataFilter.hpp +++ b/ddspipe_participants/include/ddspipe_participants/writer/rtps/filter/SelfDataFilter.hpp @@ -21,14 +21,14 @@ ///// // Forward declarations namespace eprosima { -namespace fastrtps { +namespace fastdds { namespace rtps { struct CacheChange_t; struct GUID_t; } /* namespace rtps */ -} /* namespace fastrtps */ +} /* namespace fastdds */ } /* namespace eprosima */ namespace eprosima { @@ -51,8 +51,8 @@ class SelfDataFilter : public fastdds::rtps::IReaderDataFilter */ DDSPIPE_PARTICIPANTS_DllAPI bool is_relevant( - const fastrtps::rtps::CacheChange_t& change, - const fastrtps::rtps::GUID_t& reader_guid + const fastdds::rtps::CacheChange_t& change, + const fastdds::rtps::GUID_t& reader_guid ) const override; }; diff --git a/ddspipe_participants/package.xml b/ddspipe_participants/package.xml index eeb13bd8..b79728cf 100644 --- a/ddspipe_participants/package.xml +++ b/ddspipe_participants/package.xml @@ -16,7 +16,7 @@ cmake - fastrtps + fastdds cpp_utils cmake_utils ddspipe_core diff --git a/ddspipe_participants/project_settings.cmake b/ddspipe_participants/project_settings.cmake index 98d8dff1..76306296 100644 --- a/ddspipe_participants/project_settings.cmake +++ b/ddspipe_participants/project_settings.cmake @@ -26,12 +26,12 @@ set(MODULE_SUMMARY set(MODULE_FIND_PACKAGES fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ) -set(fastrtps_MINIMUM_VERSION "2.8") +set(fastdds_MINIMUM_VERSION "3.0.0") set(MODULE_DEPENDENCIES $<$:iphlpapi$Shlwapi> diff --git a/ddspipe_participants/src/cpp/configuration/DiscoveryServerParticipantConfiguration.cpp b/ddspipe_participants/src/cpp/configuration/DiscoveryServerParticipantConfiguration.cpp index 0af034b3..65308bf2 100644 --- a/ddspipe_participants/src/cpp/configuration/DiscoveryServerParticipantConfiguration.cpp +++ b/ddspipe_participants/src/cpp/configuration/DiscoveryServerParticipantConfiguration.cpp @@ -33,13 +33,6 @@ bool DiscoveryServerParticipantConfiguration::is_valid( return false; } - // Check DS Guid Prefix - if (!discovery_server_guid_prefix.is_valid()) - { - error_msg << "Non valid Participant Guid Prefix " << discovery_server_guid_prefix << ". "; - return false; - } - // Check listening addresses for (types::Address address : listening_addresses) { diff --git a/ddspipe_participants/src/cpp/configuration/SimpleParticipantConfiguration.cpp b/ddspipe_participants/src/cpp/configuration/SimpleParticipantConfiguration.cpp index b7ac65ae..65e9d6e6 100644 --- a/ddspipe_participants/src/cpp/configuration/SimpleParticipantConfiguration.cpp +++ b/ddspipe_participants/src/cpp/configuration/SimpleParticipantConfiguration.cpp @@ -35,16 +35,6 @@ bool SimpleParticipantConfiguration::is_valid( return false; } - // Check whitelist interfaces - for (types::IpType ip : whitelist) - { - if (!types::Address::is_ipv4_correct(ip)) - { - error_msg << "Incorrect IPv4 address " << ip << " in whitelist interfaces. "; - return false; - } - } - return true; } diff --git a/ddspipe_participants/src/cpp/configuration/XmlParticipantConfiguration.cpp b/ddspipe_participants/src/cpp/configuration/XmlParticipantConfiguration.cpp index 0d21b15e..c6dd1734 100644 --- a/ddspipe_participants/src/cpp/configuration/XmlParticipantConfiguration.cpp +++ b/ddspipe_participants/src/cpp/configuration/XmlParticipantConfiguration.cpp @@ -13,8 +13,8 @@ // limitations under the License. #include -#include +#include #include #include @@ -39,7 +39,7 @@ bool XmlParticipantConfiguration::is_valid( participant_profile.get_value(), qos); - if (res != utils::ReturnCode::RETCODE_OK) + if (res != fastdds::dds::RETCODE_OK) { error_msg << "Profile " << participant_profile.get_value() << " is not loaded in XML. "; return false; diff --git a/ddspipe_participants/src/cpp/efficiency/cache_change/CacheChangePool.cpp b/ddspipe_participants/src/cpp/efficiency/cache_change/CacheChangePool.cpp index 8dbbe143..04791689 100644 --- a/ddspipe_participants/src/cpp/efficiency/cache_change/CacheChangePool.cpp +++ b/ddspipe_participants/src/cpp/efficiency/cache_change/CacheChangePool.cpp @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include +#include #include #include @@ -24,36 +24,36 @@ namespace core { CacheChangePool::CacheChangePool( utils::PoolConfiguration configuration) - : utils::UnboundedPool(configuration) + : utils::UnboundedPool(configuration) { initialize_vector_(); } bool CacheChangePool::reserve_cache( - fastrtps::rtps::CacheChange_t*& cache_change) + fastdds::rtps::CacheChange_t*& cache_change) { return loan(cache_change); } bool CacheChangePool::release_cache( - fastrtps::rtps::CacheChange_t* cache_change) + fastdds::rtps::CacheChange_t* cache_change) { return return_loan(cache_change); } -fastrtps::rtps::CacheChange_t* CacheChangePool::new_element_() +fastdds::rtps::CacheChange_t* CacheChangePool::new_element_() { return new types::RouterCacheChange(); } void CacheChangePool::reset_element_( - fastrtps::rtps::CacheChange_t* change) + fastdds::rtps::CacheChange_t* change) { // NOTE: This could be done by =operator but it is deleted, so it must be done field by field - change->kind = fastrtps::rtps::ALIVE; + change->kind = fastdds::rtps::ChangeKind_t::ALIVE; change->sequenceNumber.high = 0; change->sequenceNumber.low = 0; - change->writerGUID = fastrtps::rtps::c_Guid_Unknown; + change->writerGUID = fastdds::rtps::c_Guid_Unknown; change->instanceHandle.clear(); change->isRead = 0; change->sourceTimestamp.seconds(0); diff --git a/ddspipe_participants/src/cpp/participant/auxiliar/EchoParticipant.cpp b/ddspipe_participants/src/cpp/participant/auxiliar/EchoParticipant.cpp index 095ebc76..622930b0 100644 --- a/ddspipe_participants/src/cpp/participant/auxiliar/EchoParticipant.cpp +++ b/ddspipe_participants/src/cpp/participant/auxiliar/EchoParticipant.cpp @@ -94,7 +94,7 @@ std::shared_ptr EchoParticipant::create_writer( } else { - logInfo(DDSPIPE_ECHO_DISCOVERY, "Ignoring topic " << topic.topic_name() << " as it is not RTPS."); + EPROSIMA_LOG_INFO(DDSPIPE_ECHO_DISCOVERY, "Ignoring topic " << topic.topic_name() << " as it is not RTPS."); } return std::make_shared(); diff --git a/ddspipe_participants/src/cpp/participant/dds/CommonParticipant.cpp b/ddspipe_participants/src/cpp/participant/dds/CommonParticipant.cpp index 11982ba4..bb40db1e 100644 --- a/ddspipe_participants/src/cpp/participant/dds/CommonParticipant.cpp +++ b/ddspipe_participants/src/cpp/participant/dds/CommonParticipant.cpp @@ -16,6 +16,7 @@ #include +#include #include #include @@ -59,7 +60,7 @@ CommonParticipant::~CommonParticipant() void CommonParticipant::init() { - logInfo(DDSPIPE_DDS_PARTICIPANT, "Initializing DDS Participant " << id() << "."); + EPROSIMA_LOG_INFO(DDSPIPE_DDS_PARTICIPANT, "Initializing DDS Participant " << id() << "."); // Force DDS entities to be created disabled // NOTE: this is very dangerous because we are modifying a global variable (and a not thread safe one) in a @@ -90,7 +91,7 @@ void CommonParticipant::init() throw utils::InitializationException(STR_ENTRY << "Error creating DDS Participant " << id() << "."); } - if (dds_participant_->enable() != utils::ReturnCode::RETCODE_OK) + if (dds_participant_->enable() != fastdds::dds::RETCODE_OK) { throw utils::InitializationException(STR_ENTRY << "Error enabling DDS Participant " << id() << "."); } @@ -216,40 +217,49 @@ std::shared_ptr CommonParticipant::create_reader( void CommonParticipant::on_participant_discovery( fastdds::dds::DomainParticipant* participant, - fastrtps::rtps::ParticipantDiscoveryInfo&& info) + fastdds::rtps::ParticipantDiscoveryStatus reason, + const fastdds::rtps::ParticipantBuiltinTopicData& info, + bool& /*should_be_ignored*/) { - if (info.info.m_guid.guidPrefix != participant->guid().guidPrefix) + if (info.guid.guidPrefix != participant->guid().guidPrefix) { - if (info.status == fastrtps::rtps::ParticipantDiscoveryInfo::DISCOVERED_PARTICIPANT) + if (reason == fastdds::rtps::ParticipantDiscoveryStatus::DISCOVERED_PARTICIPANT) { - logInfo(DDSPIPE_DISCOVERY, - "Found in Participant " << configuration_->id << " new Participant " << info.info.m_guid << "."); + EPROSIMA_LOG_INFO(DDSPIPE_DISCOVERY, + "Found in Participant " << configuration_->id << " new Participant " << info.guid << "."); } - else if (info.status == fastrtps::rtps::ParticipantDiscoveryInfo::CHANGED_QOS_PARTICIPANT) + else if (reason == fastdds::rtps::ParticipantDiscoveryStatus::CHANGED_QOS_PARTICIPANT) { - logInfo(DDSPIPE_DISCOVERY, "Participant " << info.info.m_guid << " changed QoS."); + EPROSIMA_LOG_INFO(DDSPIPE_DISCOVERY, + configuration_->id << " participant : " << "Participant " << info.guid << + " changed QoS."); } - else if (info.status == fastrtps::rtps::ParticipantDiscoveryInfo::REMOVED_PARTICIPANT) + else if (reason == fastdds::rtps::ParticipantDiscoveryStatus::REMOVED_PARTICIPANT) { - logInfo(DDSPIPE_DISCOVERY, "Participant " << info.info.m_guid << " removed."); + EPROSIMA_LOG_INFO(DDSPIPE_DISCOVERY, + configuration_->id << " participant : " << "Participant " << info.guid << " removed."); } - else if (info.status == fastrtps::rtps::ParticipantDiscoveryInfo::DROPPED_PARTICIPANT) + else if (reason == fastdds::rtps::ParticipantDiscoveryStatus::DROPPED_PARTICIPANT) { - logInfo(DDSPIPE_DISCOVERY, "Participant " << info.info.m_guid << " dropped."); + EPROSIMA_LOG_INFO(DDSPIPE_DISCOVERY, + configuration_->id << " participant : " << "Participant " << info.guid << " dropped."); } - else if (info.status == fastrtps::rtps::ParticipantDiscoveryInfo::IGNORED_PARTICIPANT) + else if (reason == fastdds::rtps::ParticipantDiscoveryStatus::IGNORED_PARTICIPANT) { - logInfo(DDSPIPE_DISCOVERY, "Participant " << info.info.m_guid << " ignored."); + EPROSIMA_LOG_INFO(DDSPIPE_DISCOVERY, + configuration_->id << " participant : " << "Participant " << info.guid << " ignored."); } } } -void CommonParticipant::on_subscriber_discovery( +void CommonParticipant::on_data_reader_discovery( fastdds::dds::DomainParticipant*, - fastrtps::rtps::ReaderDiscoveryInfo&& info) + fastdds::rtps::ReaderDiscoveryStatus reason, + const fastdds::dds::SubscriptionBuiltinTopicData& info, + bool& /*should_be_ignored*/) { // If reader is from other participant, store it in discovery database - if (detail::come_from_same_participant_(info.info.guid(), this->dds_participant_->guid())) + if (detail::come_from_same_participant_(info.guid, this->dds_participant_->guid())) { // Come from this participant, do nothing return; @@ -257,44 +267,49 @@ void CommonParticipant::on_subscriber_discovery( // Calculate endpoint info core::types::Endpoint info_reader = - detail::create_endpoint_from_info_(info, id()); + detail::create_endpoint_from_info_(info, id()); // If new endpoint discovered - if (info.status == fastrtps::rtps::ReaderDiscoveryInfo::DISCOVERY_STATUS::DISCOVERED_READER) + if (reason == fastdds::rtps::ReaderDiscoveryStatus::DISCOVERED_READER) { - logInfo(DDSPIPE_DISCOVERY, - "Found in Participant " << configuration_->id << " new Reader " << info.info.guid() << "."); + EPROSIMA_LOG_INFO(DDSPIPE_DISCOVERY, + "Found in Participant " << configuration_->id << " new Reader " << info.guid << "."); // TODO check logic because if an endpoint is lost by liveliness it may be inserted again when already in database this->discovery_database_->add_endpoint(info_reader); } - else if (info.status == fastrtps::rtps::ReaderDiscoveryInfo::DISCOVERY_STATUS::CHANGED_QOS_READER) + else if (reason == fastdds::rtps::ReaderDiscoveryStatus::CHANGED_QOS_READER) { - logInfo(DDSPIPE_DISCOVERY, "Reader " << info.info.guid() << " changed TopicQoS."); + EPROSIMA_LOG_INFO(DDSPIPE_DISCOVERY, + configuration_->id << " participant : " << "Reader " << info.guid << " changed TopicQoS."); this->discovery_database_->update_endpoint(info_reader); } - else if (info.status == fastrtps::rtps::ReaderDiscoveryInfo::REMOVED_READER) + else if (reason == fastdds::rtps::ReaderDiscoveryStatus::REMOVED_READER) { - logInfo(DDSPIPE_DISCOVERY, "Reader " << info.info.guid() << " removed."); + EPROSIMA_LOG_INFO(DDSPIPE_DISCOVERY, + configuration_->id << " participant : " << "Reader " << info.guid << " removed."); info_reader.active = false; this->discovery_database_->update_endpoint(info_reader); } - else if (info.status == fastrtps::rtps::ReaderDiscoveryInfo::IGNORED_READER) + else if (reason == fastdds::rtps::ReaderDiscoveryStatus::IGNORED_READER) { - logInfo(DDSPIPE_DISCOVERY, "Reader " << info.info.guid() << " ignored."); + EPROSIMA_LOG_INFO(DDSPIPE_DISCOVERY, + configuration_->id << " participant : " << "Reader " << info.guid << " ignored."); // Do not notify discovery database (design choice that might be changed in the future) } } -void CommonParticipant::on_publisher_discovery( +void CommonParticipant::on_data_writer_discovery( fastdds::dds::DomainParticipant*, - fastrtps::rtps::WriterDiscoveryInfo&& info) + fastdds::rtps::WriterDiscoveryStatus reason, + const fastdds::dds::PublicationBuiltinTopicData& info, + bool& /*should_be_ignored*/) { // If writer is from other participant, store it in discovery database - if (detail::come_from_same_participant_(info.info.guid(), this->dds_participant_->guid())) + if (detail::come_from_same_participant_(info.guid, this->dds_participant_->guid())) { // Come from this participant, do nothing return; @@ -302,33 +317,36 @@ void CommonParticipant::on_publisher_discovery( // Calculate endpoint info core::types::Endpoint info_writer = - detail::create_endpoint_from_info_(info, id()); + detail::create_endpoint_from_info_(info, id()); // If new endpoint discovered - if (info.status == fastrtps::rtps::WriterDiscoveryInfo::DISCOVERY_STATUS::DISCOVERED_WRITER) + if (reason == fastdds::rtps::WriterDiscoveryStatus::DISCOVERED_WRITER) { - logInfo(DDSPIPE_DISCOVERY, - "Found in Participant " << configuration_->id << " new Writer " << info.info.guid() << "."); + EPROSIMA_LOG_INFO(DDSPIPE_DISCOVERY, + "Found in Participant " << configuration_->id << " new Writer " << info.guid << "."); // TODO check logic because if an endpoint is lost by liveliness it may be inserted again when already in database this->discovery_database_->add_endpoint(info_writer); } - else if (info.status == fastrtps::rtps::WriterDiscoveryInfo::CHANGED_QOS_WRITER) + else if (reason == fastdds::rtps::WriterDiscoveryStatus::CHANGED_QOS_WRITER) { - logInfo(DDSPIPE_DISCOVERY, "Writer " << info.info.guid() << " changed TopicQoS."); + EPROSIMA_LOG_INFO(DDSPIPE_DISCOVERY, + configuration_->id << " participant : " << "Writer " << info.guid << " changed TopicQoS."); this->discovery_database_->update_endpoint(info_writer); } - else if (info.status == fastrtps::rtps::WriterDiscoveryInfo::REMOVED_WRITER) + else if (reason == fastdds::rtps::WriterDiscoveryStatus::REMOVED_WRITER) { - logInfo(DDSPIPE_DISCOVERY, "Writer " << info.info.guid() << " removed."); + EPROSIMA_LOG_INFO(DDSPIPE_DISCOVERY, + configuration_->id << " participant : " << "Writer " << info.guid << " removed."); info_writer.active = false; this->discovery_database_->update_endpoint(info_writer); } - else if (info.status == fastrtps::rtps::WriterDiscoveryInfo::IGNORED_WRITER) + else if (reason == fastdds::rtps::WriterDiscoveryStatus::IGNORED_WRITER) { - logInfo(DDSPIPE_DISCOVERY, "Writer " << info.info.guid() << " ignored."); + EPROSIMA_LOG_INFO(DDSPIPE_DISCOVERY, + configuration_->id << " participant : " << "Writer " << info.guid << " ignored."); // Do not notify discovery database (design choice that might be changed in the future) } @@ -345,10 +363,10 @@ CommonParticipant::CommonParticipant( // Do nothing } -fastdds::dds::DomainParticipantQos CommonParticipant::reckon_participant_qos_() const +fastdds::dds::DomainParticipantQos CommonParticipant::add_qos_properties_( + fastdds::dds::DomainParticipantQos& qos) const { - auto qos = fastdds::dds::DomainParticipantFactory::get_instance()->get_default_participant_qos(); - + // Enforce ignore local endpoints on XML participants qos.properties().properties().emplace_back( "fastdds.ignore_local_endpoints", "true"); @@ -366,6 +384,15 @@ fastdds::dds::DomainParticipantQos CommonParticipant::reckon_participant_qos_() return qos; } +fastdds::dds::DomainParticipantQos CommonParticipant::reckon_participant_qos_() const +{ + auto qos = fastdds::dds::DomainParticipantFactory::get_instance()->get_default_participant_qos(); + + add_qos_properties_(qos); + + return qos; +} + fastdds::dds::DomainParticipant* CommonParticipant::create_dds_participant_() { // Set listener mask so reader read its own messages @@ -403,9 +430,10 @@ fastdds::dds::Topic* CommonParticipant::topic_related_( dds_participant_->register_type( eprosima::fastdds::dds::TypeSupport( new TopicDataType( + payload_pool_, topic.type_name, - topic.topic_qos.keyed, - payload_pool_)) + topic.type_identifiers, + topic.topic_qos.keyed)) ); } diff --git a/ddspipe_participants/src/cpp/participant/dds/XmlParticipant.cpp b/ddspipe_participants/src/cpp/participant/dds/XmlParticipant.cpp index a4b08208..38353996 100644 --- a/ddspipe_participants/src/cpp/participant/dds/XmlParticipant.cpp +++ b/ddspipe_participants/src/cpp/participant/dds/XmlParticipant.cpp @@ -14,13 +14,13 @@ #include -#include - +#include #include -#include +#include #include #include +#include #include #include @@ -32,9 +32,6 @@ namespace participants { namespace dds { -using namespace eprosima::fastrtps::xmlparser; - - XmlParticipant::XmlParticipant( const std::shared_ptr& participant_configuration, const std::shared_ptr& payload_pool, @@ -42,14 +39,14 @@ XmlParticipant::XmlParticipant( : CommonParticipant(participant_configuration, payload_pool, discovery_database) , xml_specific_configuration_(*reinterpret_cast(configuration_.get())) { - // Replace the configuration's domain with the XML's domainId - eprosima::fastrtps::ParticipantAttributes attr; - + fastdds::dds::DomainParticipantExtendedQos extended_qos; if (xml_specific_configuration_.participant_profile.is_set() && - XMLProfileManager::fillParticipantAttributes(xml_specific_configuration_.participant_profile - .get_value(), attr) == XMLP_ret::XML_OK) + fastdds::dds::RETCODE_OK == + fastdds::dds::DomainParticipantFactory::get_instance()->get_participant_extended_qos_from_profile( + xml_specific_configuration_.participant_profile.get_value(), + extended_qos)) { - configuration_->domain = attr.domainId; + configuration_->domain = extended_qos.domainId(); } } @@ -62,7 +59,7 @@ std::shared_ptr XmlParticipant::create_writer( } catch (const utils::InitializationException& e) { - logWarning( + EPROSIMA_LOG_WARNING( DDSPIPE_XMLPARTICIPANT, e.what() << ". Execution continue but this topic will not be published in Participant " << id() << "."); @@ -79,7 +76,7 @@ std::shared_ptr XmlParticipant::create_reader( } catch (const utils::InitializationException& e) { - logWarning( + EPROSIMA_LOG_WARNING( DDSPIPE_XMLPARTICIPANT, e.what() << ". Execution continue but this topic will not be subscribed in Participant " << id() << "."); @@ -99,7 +96,7 @@ fastdds::dds::DomainParticipantQos XmlParticipant::reckon_participant_qos_() con qos ); - if (res != fastrtps::types::ReturnCode_t::ReturnCodeValue::RETCODE_OK) + if (res != fastdds::dds::RETCODE_OK) { throw utils::ConfigurationException(STR_ENTRY << "Participant profile <" << xml_specific_configuration_.participant_profile.get_value() @@ -107,10 +104,8 @@ fastdds::dds::DomainParticipantQos XmlParticipant::reckon_participant_qos_() con } } - // Enforce ignore local endpoints on XML participants - qos.properties().properties().emplace_back( - "fastdds.ignore_local_endpoints", - "true"); + // Set qos properties + add_qos_properties_(qos); return qos; } diff --git a/ddspipe_participants/src/cpp/participant/dynamic_types/DynTypesParticipant.cpp b/ddspipe_participants/src/cpp/participant/dynamic_types/DynTypesParticipant.cpp index 4cbbaf9e..f2d60025 100644 --- a/ddspipe_participants/src/cpp/participant/dynamic_types/DynTypesParticipant.cpp +++ b/ddspipe_participants/src/cpp/participant/dynamic_types/DynTypesParticipant.cpp @@ -18,20 +18,17 @@ #include -#include - #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include + +#include #include +#include #include #include #include @@ -44,8 +41,6 @@ namespace ddspipe { namespace participants { using namespace eprosima::ddspipe::core; -using namespace eprosima::ddspipe::core::types; -using namespace eprosima::fastrtps::types; DynTypesParticipant::DynTypesParticipant( std::shared_ptr participant_configuration, @@ -61,19 +56,6 @@ DynTypesParticipant::DynTypesParticipant( // Do nothing } -DynTypesParticipant::~DynTypesParticipant() -{ - dds_participant_->set_listener(nullptr); - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->delete_participant(dds_participant_); - -} - -void DynTypesParticipant::init() -{ - CommonParticipant::init(); - initialize_internal_dds_participant_(); -} - std::shared_ptr DynTypesParticipant::create_writer( const ITopic& topic) { @@ -85,7 +67,7 @@ std::shared_ptr DynTypesParticipant::create_reader( const ITopic& topic) { // If type object topic, return the internal reader for type objects - if (is_type_object_topic(topic)) + if (core::types::is_type_object_topic(topic)) { return this->type_object_reader_; } @@ -94,210 +76,94 @@ std::shared_ptr DynTypesParticipant::create_reader( return rtps::SimpleParticipant::create_reader(topic); } -void DynTypesParticipant::on_type_discovery( - eprosima::fastdds::dds::DomainParticipant* /* participant */, - const fastrtps::rtps::SampleIdentity& /* request_sample_id */, - const fastrtps::string_255& /* topic */, - const fastrtps::types::TypeIdentifier* identifier, - const fastrtps::types::TypeObject* object, - fastrtps::types::DynamicType_ptr dyn_type) +void DynTypesParticipant::on_reader_discovery( + fastdds::rtps::RTPSParticipant* participant, + fastdds::rtps::ReaderDiscoveryStatus reason, + const fastdds::rtps::SubscriptionBuiltinTopicData& info, + bool& should_be_ignored) { - if (nullptr != dyn_type) + if (info.guid.guidPrefix != participant->getGuid().guidPrefix) { - // Register type obj in singleton factory - TypeObjectFactory::get_instance()->add_type_object( - dyn_type->get_name(), identifier, object); - internal_notify_type_object_(dyn_type); - } -} - -void DynTypesParticipant::on_type_information_received( - eprosima::fastdds::dds::DomainParticipant* participant, - const fastrtps::string_255 /* topic_name */, - const fastrtps::string_255 type_name, - const fastrtps::types::TypeInformation& type_information) -{ - std::string type_name_ = type_name.to_string(); - const TypeIdentifier* type_identifier = nullptr; - const TypeObject* type_object = nullptr; - DynamicType_ptr dynamic_type(nullptr); - - // Check if complete identifier already present in factory - type_identifier = TypeObjectFactory::get_instance()->get_type_identifier(type_name_, true); - if (type_identifier) - { - type_object = TypeObjectFactory::get_instance()->get_type_object(type_name_, true); - } - - // If complete not found, try with minimal - if (!type_object) - { - type_identifier = TypeObjectFactory::get_instance()->get_type_identifier(type_name_, false); - if (type_identifier) - { - type_object = TypeObjectFactory::get_instance()->get_type_object(type_name_, false); - } - } + // Get type information + const auto type_info = info.type_information.type_information; + const auto type_name = info.type_name.to_string(); - // Build dynamic type if type identifier and object found in factory - if (type_identifier && type_object) - { - dynamic_type = TypeObjectFactory::get_instance()->build_dynamic_type(type_name_, type_identifier, type_object); - } + rtps::CommonParticipant::on_reader_discovery(participant, reason, info, should_be_ignored); - // Request type object through TypeLookup if not present in factory, or if type building failed - if (!dynamic_type) - { - std::function callback( - [this] - (const std::string& /* type_name */, const DynamicType_ptr type) - { - this->internal_notify_type_object_(type); - }); - // Registering type and creating reader - participant->register_remote_type( - type_information, - type_name_, - callback); - } - else - { - internal_notify_type_object_(dynamic_type); + notify_type_discovered_(type_info, type_name); } } -void DynTypesParticipant::internal_notify_type_object_( - DynamicType_ptr dynamic_type) +void DynTypesParticipant::on_writer_discovery( + fastdds::rtps::RTPSParticipant* participant, + fastdds::rtps::WriterDiscoveryStatus reason, + const fastdds::rtps::PublicationBuiltinTopicData& info, + bool& should_be_ignored) { - logInfo(DDSPIPE_DYNTYPES_PARTICIPANT, - "Participant " << this->id() << " discovered type object " << dynamic_type->get_name()); - - monitor_type_discovered(dynamic_type->get_name()); + if (info.guid.guidPrefix != participant->getGuid().guidPrefix) + { + // Get type information + const auto type_info = info.type_information.type_information; + const auto type_name = info.type_name.to_string(); - // Create data containing Dynamic Type - auto data = std::make_unique(); - data->dynamic_type = dynamic_type; // TODO: add constructor with param + rtps::CommonParticipant::on_writer_discovery(participant, reason, info, should_be_ignored); - // Insert new data in internal reader queue - type_object_reader_->simulate_data_reception(std::move(data)); + notify_type_discovered_(type_info, type_name); + } } -void DynTypesParticipant::initialize_internal_dds_participant_() +void DynTypesParticipant::notify_type_discovered_( + const fastdds::dds::xtypes::TypeInformation& type_info, + const std::string& type_name) { - - std::shared_ptr configuration = - std::dynamic_pointer_cast(this->configuration_); - - eprosima::fastdds::dds::DomainParticipantQos pqos; - pqos.name(this->id()); - - // Set app properties - pqos.properties().properties().emplace_back( - "fastdds.application.id", - configuration->app_id, - "true"); - pqos.properties().properties().emplace_back( - "fastdds.application.metadata", - configuration->app_metadata, - "true"); - - // Set Type LookUp to ON - pqos.wire_protocol().builtin.typelookup_config.use_server = false; - pqos.wire_protocol().builtin.typelookup_config.use_client = true; - - // Configure Participant transports - if (configuration->transport == core::types::TransportDescriptors::builtin) + // Check if it exists already + if (received_types_.find(type_name) != received_types_.end()) { - if (!configuration->whitelist.empty()) - { - pqos.transport().use_builtin_transports = false; - - std::shared_ptr shm_transport = - std::make_shared(); - pqos.transport().user_transports.push_back(shm_transport); - - std::shared_ptr udp_transport = - create_descriptor(configuration->whitelist); - pqos.transport().user_transports.push_back(udp_transport); - } + EPROSIMA_LOG_INFO(DDSPIPE_DYNTYPES_PARTICIPANT, + "Type " << type_name << " was already received, aborting propagation."); + return; } - else if (configuration->transport == core::types::TransportDescriptors::shm_only) - { - pqos.transport().use_builtin_transports = false; - std::shared_ptr shm_transport = - std::make_shared(); - pqos.transport().user_transports.push_back(shm_transport); - } - else if (configuration->transport == core::types::TransportDescriptors::udp_only) + const auto type_identifier = type_info.complete().typeid_with_size().type_id(); + fastdds::dds::xtypes::TypeObject dyn_type_object; + if (fastdds::dds::RETCODE_OK != + fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_object( + type_identifier, + dyn_type_object)) { - pqos.transport().use_builtin_transports = false; - - std::shared_ptr udp_transport = - create_descriptor(configuration->whitelist); - pqos.transport().user_transports.push_back(udp_transport); + EPROSIMA_LOG_INFO(DDSPIPE_DYNTYPES_PARTICIPANT, + "Failed to get type object of " << type_name << " type"); + return; } - // Participant discovery filter configuration - switch (configuration->ignore_participant_flags) + // Create Dynamic Type + fastdds::dds::DynamicType::_ref_type dyn_type = + fastdds::dds::DynamicTypeBuilderFactory::get_instance()->create_type_w_type_object( + dyn_type_object)->build(); + if (!dyn_type) { - case core::types::IgnoreParticipantFlags::no_filter: - pqos.wire_protocol().builtin.discovery_config.ignoreParticipantFlags = - eprosima::fastrtps::rtps::ParticipantFilteringFlags_t::NO_FILTER; - break; - case core::types::IgnoreParticipantFlags::filter_different_host: - pqos.wire_protocol().builtin.discovery_config.ignoreParticipantFlags = - eprosima::fastrtps::rtps::ParticipantFilteringFlags_t::FILTER_DIFFERENT_HOST; - break; - case core::types::IgnoreParticipantFlags::filter_different_process: - pqos.wire_protocol().builtin.discovery_config.ignoreParticipantFlags = - eprosima::fastrtps::rtps::ParticipantFilteringFlags_t::FILTER_DIFFERENT_PROCESS; - break; - case core::types::IgnoreParticipantFlags::filter_same_process: - pqos.wire_protocol().builtin.discovery_config.ignoreParticipantFlags = - eprosima::fastrtps::rtps::ParticipantFilteringFlags_t::FILTER_SAME_PROCESS; - break; - case core::types::IgnoreParticipantFlags::filter_different_and_same_process: - pqos.wire_protocol().builtin.discovery_config.ignoreParticipantFlags = - static_cast( - eprosima::fastrtps::rtps::ParticipantFilteringFlags_t::FILTER_DIFFERENT_PROCESS | - eprosima::fastrtps::rtps::ParticipantFilteringFlags_t::FILTER_SAME_PROCESS); - break; - default: - break; + EPROSIMA_LOG_WARNING(DDSPIPE_DYNTYPES_PARTICIPANT, + "Failed to create Dynamic Type " << type_name); + return; } - // Force DDS entities to be created disabled - // NOTE: this is very dangerous because we are modifying a global variable (and a not thread safe one) in a - // local function. - // However, this is required, otherwise we could fail in two points: - // - receive in this object, maybe in same thread a discovery callback, which could use this variable - // (e.g to check if the Participant called is this one) - // - lose a discovery callback - fastdds::dds::DomainParticipantFactoryQos fact_qos; - fact_qos.entity_factory().autoenable_created_entities = false; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_qos( - fact_qos); + // Notify type_identifier + // NOTE: We assume each type_name corresponds to only one type_identifier + EPROSIMA_LOG_INFO(DDSPIPE_DYNTYPES_PARTICIPANT, + "Participant " << this->id() << " discovered type object " << dyn_type->get_name()); - // CREATE THE PARTICIPANT - dds_participant_ = eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->create_participant( - configuration->domain, - pqos); + monitor_type_discovered(type_name); - dds_participant_->set_listener(this); + // If not, add it to the received types set + received_types_.insert(type_name); - dds_participant_->enable(); - - // Restore default DomainParticipantQoS (create enabled entities) after creating and enabling this participant - // WARNING: not thread safe at the moment of this writing, see note above. - fact_qos.entity_factory().autoenable_created_entities = true; - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_qos( - fact_qos); + // Create data containing Dynamic Type + auto data = std::make_unique(); + data->dynamic_type = dyn_type; // TODO: add constructor with param + data->type_identifier = type_identifier; - if (dds_participant_ == nullptr) - { - throw utils::InitializationException("Error creating DDS Participant."); - } + // Insert new data in internal reader queue + type_object_reader_->simulate_data_reception(std::move(data)); } } /* namespace participants */ diff --git a/ddspipe_participants/src/cpp/participant/dynamic_types/SchemaParticipant.cpp b/ddspipe_participants/src/cpp/participant/dynamic_types/SchemaParticipant.cpp index 5fbb30e7..0ca32f89 100644 --- a/ddspipe_participants/src/cpp/participant/dynamic_types/SchemaParticipant.cpp +++ b/ddspipe_participants/src/cpp/participant/dynamic_types/SchemaParticipant.cpp @@ -80,7 +80,7 @@ std::shared_ptr SchemaParticipant::create_writer( { if (!utils::can_cast(topic)) { - logWarning(DDSPIPE_SCHEMA_PARTICIPANT, "Not creating Writer for topic " << topic.topic_name()); + EPROSIMA_LOG_WARNING(DDSPIPE_SCHEMA_PARTICIPANT, "Not creating Writer for topic " << topic.topic_name()); return std::make_shared(); } return std::make_shared(id(), dynamic_cast(topic), payload_pool_, diff --git a/ddspipe_participants/src/cpp/participant/rtps/CommonParticipant.cpp b/ddspipe_participants/src/cpp/participant/rtps/CommonParticipant.cpp index 46adae8f..a8caea41 100644 --- a/ddspipe_participants/src/cpp/participant/rtps/CommonParticipant.cpp +++ b/ddspipe_participants/src/cpp/participant/rtps/CommonParticipant.cpp @@ -15,12 +15,12 @@ #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include @@ -54,13 +54,11 @@ CommonParticipant::CommonParticipant( const std::shared_ptr& participant_configuration, const std::shared_ptr& payload_pool, const std::shared_ptr& discovery_database, - const core::types::DomainId& domain_id, - const fastrtps::rtps::RTPSParticipantAttributes& participant_attributes) + const core::types::DomainId& domain_id) : configuration_(participant_configuration) , payload_pool_(payload_pool) , discovery_database_(discovery_database) , domain_id_(domain_id) - , participant_attributes_(participant_attributes) { // Do nothing } @@ -69,117 +67,139 @@ CommonParticipant::~CommonParticipant() { if (rtps_participant_) { - fastrtps::rtps::RTPSDomain::removeRTPSParticipant(rtps_participant_); + fastdds::rtps::RTPSDomain::removeRTPSParticipant(rtps_participant_); } } void CommonParticipant::init() { + participant_attributes_ = reckon_participant_attributes_(); create_participant_( domain_id_, participant_attributes_); } -void CommonParticipant::onParticipantDiscovery( - fastrtps::rtps::RTPSParticipant* participant, - fastrtps::rtps::ParticipantDiscoveryInfo&& info) +void CommonParticipant::on_participant_discovery( + fastdds::rtps::RTPSParticipant* participant, + fastdds::rtps::ParticipantDiscoveryStatus reason, + const fastdds::rtps::ParticipantBuiltinTopicData& info, + bool&) { - if (info.info.m_guid.guidPrefix != participant->getGuid().guidPrefix) + if (info.guid.guidPrefix != participant->getGuid().guidPrefix) { - if (info.status == fastrtps::rtps::ParticipantDiscoveryInfo::DISCOVERED_PARTICIPANT) + if (reason == fastdds::rtps::ParticipantDiscoveryStatus::DISCOVERED_PARTICIPANT) { - logInfo(DDSPIPE_DISCOVERY, - "Found in Participant " << configuration_->id << " new Participant " << info.info.m_guid << "."); + EPROSIMA_LOG_INFO(DDSPIPE_DISCOVERY, + "Found in Participant " << configuration_->id << " new Participant " << info.guid << "."); } - else if (info.status == fastrtps::rtps::ParticipantDiscoveryInfo::CHANGED_QOS_PARTICIPANT) + else if (reason == fastdds::rtps::ParticipantDiscoveryStatus::CHANGED_QOS_PARTICIPANT) { - logInfo(DDSPIPE_DISCOVERY, "Participant " << info.info.m_guid << " changed QoS."); + EPROSIMA_LOG_INFO(DDSPIPE_DISCOVERY, + configuration_->id << " participant : " << "Participant " << info.guid << + " changed QoS."); } - else if (info.status == fastrtps::rtps::ParticipantDiscoveryInfo::REMOVED_PARTICIPANT) + else if (reason == fastdds::rtps::ParticipantDiscoveryStatus::REMOVED_PARTICIPANT) { - logInfo(DDSPIPE_DISCOVERY, "Participant " << info.info.m_guid << " removed."); + EPROSIMA_LOG_INFO(DDSPIPE_DISCOVERY, + configuration_->id << " participant : " << "Participant " << info.guid << " removed."); } - else if (info.status == fastrtps::rtps::ParticipantDiscoveryInfo::DROPPED_PARTICIPANT) + else if (reason == fastdds::rtps::ParticipantDiscoveryStatus::DROPPED_PARTICIPANT) { - logInfo(DDSPIPE_DISCOVERY, "Participant " << info.info.m_guid << " dropped."); + EPROSIMA_LOG_INFO(DDSPIPE_DISCOVERY, + configuration_->id << " participant : " << "Participant " << info.guid << " dropped."); } - else if (info.status == fastrtps::rtps::ParticipantDiscoveryInfo::IGNORED_PARTICIPANT) + else if (reason == fastdds::rtps::ParticipantDiscoveryStatus::IGNORED_PARTICIPANT) { - logInfo(DDSPIPE_DISCOVERY, "Participant " << info.info.m_guid << " ignored."); + EPROSIMA_LOG_INFO(DDSPIPE_DISCOVERY, + configuration_->id << " participant : " << "Participant " << info.guid << " ignored."); } } } -void CommonParticipant::onReaderDiscovery( - fastrtps::rtps::RTPSParticipant* participant, - fastrtps::rtps::ReaderDiscoveryInfo&& info) +void CommonParticipant::on_reader_discovery( + fastdds::rtps::RTPSParticipant* participant, + fastdds::rtps::ReaderDiscoveryStatus reason, + const fastdds::rtps::SubscriptionBuiltinTopicData& info, + bool&) { - if (info.info.guid().guidPrefix != participant->getGuid().guidPrefix) + if (info.guid.guidPrefix != participant->getGuid().guidPrefix) { - core::types::Endpoint info_reader = detail::create_endpoint_from_info_( + core::types::Endpoint info_reader = + detail::create_endpoint_from_info_( info, this->id()); - if (info.status == fastrtps::rtps::ReaderDiscoveryInfo::DISCOVERED_READER) + if (reason == fastdds::rtps::ReaderDiscoveryStatus::DISCOVERED_READER) { - logInfo(DDSPIPE_DISCOVERY, - "Found in Participant " << configuration_->id << " new Reader " << info.info.guid() << "."); + EPROSIMA_LOG_INFO(DDSPIPE_DISCOVERY, + "Found in Participant " << configuration_->id << " new Reader " << info.guid << "."); this->discovery_database_->add_endpoint(info_reader); } - else if (info.status == fastrtps::rtps::ReaderDiscoveryInfo::CHANGED_QOS_READER) + else if (reason == fastdds::rtps::ReaderDiscoveryStatus::CHANGED_QOS_READER) { - logInfo(DDSPIPE_DISCOVERY, "Reader " << info.info.guid() << " changed TopicQoS."); + EPROSIMA_LOG_INFO(DDSPIPE_DISCOVERY, + configuration_->id << " participant : " << "Reader " << info.guid << + " changed TopicQoS."); this->discovery_database_->update_endpoint(info_reader); } - else if (info.status == fastrtps::rtps::ReaderDiscoveryInfo::REMOVED_READER) + else if (reason == fastdds::rtps::ReaderDiscoveryStatus::REMOVED_READER) { - logInfo(DDSPIPE_DISCOVERY, "Reader " << info.info.guid() << " removed."); + EPROSIMA_LOG_INFO(DDSPIPE_DISCOVERY, + configuration_->id << " participant : " << "Reader " << info.guid << " removed."); info_reader.active = false; this->discovery_database_->update_endpoint(info_reader); } - else if (info.status == fastrtps::rtps::ReaderDiscoveryInfo::IGNORED_READER) + else if (reason == fastdds::rtps::ReaderDiscoveryStatus::IGNORED_READER) { - logInfo(DDSPIPE_DISCOVERY, "Reader " << info.info.guid() << " ignored."); + EPROSIMA_LOG_INFO(DDSPIPE_DISCOVERY, + configuration_->id << " participant : " << "Reader " << info.guid << " ignored."); // Do not notify discovery database (design choice that might be changed in the future) } } } -void CommonParticipant::onWriterDiscovery( - fastrtps::rtps::RTPSParticipant* participant, - fastrtps::rtps::WriterDiscoveryInfo&& info) +void CommonParticipant::on_writer_discovery( + fastdds::rtps::RTPSParticipant* participant, + fastdds::rtps::WriterDiscoveryStatus reason, + const fastdds::rtps::PublicationBuiltinTopicData& info, + bool&) { - if (info.info.guid().guidPrefix != participant->getGuid().guidPrefix) + if (info.guid.guidPrefix != participant->getGuid().guidPrefix) { - core::types::Endpoint info_writer = detail::create_endpoint_from_info_( + core::types::Endpoint info_writer = + detail::create_endpoint_from_info_( info, this->id()); - if (info.status == fastrtps::rtps::WriterDiscoveryInfo::DISCOVERED_WRITER) + if (reason == fastdds::rtps::WriterDiscoveryStatus::DISCOVERED_WRITER) { - logInfo(DDSPIPE_DISCOVERY, - "Found in Participant " << configuration_->id << " new Writer " << info.info.guid() << "."); + EPROSIMA_LOG_INFO(DDSPIPE_DISCOVERY, + "Found in Participant " << configuration_->id << " new Writer " << info.guid << "."); this->discovery_database_->add_endpoint(info_writer); } - else if (info.status == fastrtps::rtps::WriterDiscoveryInfo::CHANGED_QOS_WRITER) + else if (reason == fastdds::rtps::WriterDiscoveryStatus::CHANGED_QOS_WRITER) { - logInfo(DDSPIPE_DISCOVERY, "Writer " << info.info.guid() << " changed TopicQoS."); + EPROSIMA_LOG_INFO(DDSPIPE_DISCOVERY, + configuration_->id << " participant : " << "Writer " << info.guid << + " changed TopicQoS."); this->discovery_database_->update_endpoint(info_writer); } - else if (info.status == fastrtps::rtps::WriterDiscoveryInfo::REMOVED_WRITER) + else if (reason == fastdds::rtps::WriterDiscoveryStatus::REMOVED_WRITER) { - logInfo(DDSPIPE_DISCOVERY, "Writer " << info.info.guid() << " removed."); + EPROSIMA_LOG_INFO(DDSPIPE_DISCOVERY, + configuration_->id << " participant : " << "Writer " << info.guid << " removed."); info_writer.active = false; this->discovery_database_->update_endpoint(info_writer); } - else if (info.status == fastrtps::rtps::WriterDiscoveryInfo::IGNORED_WRITER) + else if (reason == fastdds::rtps::WriterDiscoveryStatus::IGNORED_WRITER) { - logInfo(DDSPIPE_DISCOVERY, "Writer " << info.info.guid() << " ignored."); + EPROSIMA_LOG_INFO(DDSPIPE_DISCOVERY, + configuration_->id << " participant : " << "Writer " << info.guid << " ignored."); // Do not notify discovery database (design choice that might be changed in the future) } @@ -204,25 +224,16 @@ template<> DDSPIPE_PARTICIPANTS_DllAPI std::shared_ptr CommonParticipant::create_descriptor( - std::set whitelist) + std::set whitelist) { std::shared_ptr udp_transport = std::make_shared(); - for (const types::IpType& ip : whitelist) + for (const types::WhitelistType& iface : whitelist) { - if (types::Address::is_ipv4_correct(ip)) - { - udp_transport->interfaceWhiteList.emplace_back(ip); - logInfo(DDSPIPE_COMMON_PARTICIPANT, - "Adding " << ip << " to UDP whitelist interfaces."); - } - else - { - // Invalid address, continue with next one - logWarning(DDSPIPE_COMMON_PARTICIPANT, - "Not valid IPv4. Discarding UDP whitelist interface " << ip << "."); - } + udp_transport->interfaceWhiteList.emplace_back(iface); + EPROSIMA_LOG_INFO(DDSPIPE_COMMON_PARTICIPANT, + "Adding " << iface << " to UDP whitelist interfaces."); } return udp_transport; @@ -232,25 +243,16 @@ template<> DDSPIPE_PARTICIPANTS_DllAPI std::shared_ptr CommonParticipant::create_descriptor( - std::set whitelist) + std::set whitelist) { std::shared_ptr udp_transport = std::make_shared(); - for (const types::IpType& ip : whitelist) + for (const types::WhitelistType& iface : whitelist) { - if (types::Address::is_ipv6_correct(ip)) - { - udp_transport->interfaceWhiteList.emplace_back(ip); - logInfo(DDSPIPE_COMMON_PARTICIPANT, - "Adding " << ip << " to UDP whitelist interfaces."); - } - else - { - // Invalid address, continue with next one - logWarning(DDSPIPE_COMMON_PARTICIPANT, - "Not valid IPv6. Discarding UDP whitelist interface " << ip << "."); - } + udp_transport->interfaceWhiteList.emplace_back(iface); + EPROSIMA_LOG_INFO(DDSPIPE_COMMON_PARTICIPANT, + "Adding " << iface << " to UDP whitelist interfaces."); } return udp_transport; @@ -260,25 +262,16 @@ template<> DDSPIPE_PARTICIPANTS_DllAPI std::shared_ptr CommonParticipant::create_descriptor( - std::set whitelist) + std::set whitelist) { std::shared_ptr tcp_transport = std::make_shared(); - for (const types::IpType& ip : whitelist) + for (const types::WhitelistType& iface : whitelist) { - if (types::Address::is_ipv4_correct(ip)) - { - tcp_transport->interfaceWhiteList.emplace_back(ip); - logInfo(DDSPIPE_COMMON_PARTICIPANT, - "Adding " << ip << " to TCP whitelist interfaces."); - } - else - { - // Invalid address, continue with next one - logWarning(DDSPIPE_COMMON_PARTICIPANT, - "Not valid IPv4. Discarding TCP whitelist interface " << ip << "."); - } + tcp_transport->interfaceWhiteList.emplace_back(iface); + EPROSIMA_LOG_INFO(DDSPIPE_COMMON_PARTICIPANT, + "Adding " << iface << " to TCP whitelist interfaces."); } return tcp_transport; @@ -288,25 +281,16 @@ template<> DDSPIPE_PARTICIPANTS_DllAPI std::shared_ptr CommonParticipant::create_descriptor( - std::set whitelist) + std::set whitelist) { std::shared_ptr tcp_transport = std::make_shared(); - for (const types::IpType& ip : whitelist) + for (const types::WhitelistType& iface : whitelist) { - if (types::Address::is_ipv6_correct(ip)) - { - tcp_transport->interfaceWhiteList.emplace_back(ip); - logInfo(DDSPIPE_COMMON_PARTICIPANT, - "Adding " << ip << " to TCP whitelist interfaces."); - } - else - { - // Invalid address, continue with next one - logWarning(DDSPIPE_COMMON_PARTICIPANT, - "Not valid IPv6. Discarding TCP whitelist interface " << ip << "."); - } + tcp_transport->interfaceWhiteList.emplace_back(iface); + EPROSIMA_LOG_INFO(DDSPIPE_COMMON_PARTICIPANT, + "Adding " << iface << " to TCP whitelist interfaces."); } return tcp_transport; @@ -334,14 +318,14 @@ core::types::TopicQoS CommonParticipant::topic_qos() const noexcept void CommonParticipant::create_participant_( const core::types::DomainId& domain, - const fastrtps::rtps::RTPSParticipantAttributes& participant_attributes) + const fastdds::rtps::RTPSParticipantAttributes& participant_attributes) { - logInfo(DDSPIPE_RTPS_PARTICIPANT, + EPROSIMA_LOG_INFO(DDSPIPE_RTPS_PARTICIPANT, "Creating Participant in domain " << domain); // Listener must be set in creation as no callbacks should be missed // It is safe to do so here as object is already created and callbacks do not require anything set in this method - rtps_participant_ = fastrtps::rtps::RTPSDomain::createParticipant( + rtps_participant_ = fastdds::rtps::RTPSDomain::createParticipant( domain, participant_attributes, this); @@ -352,7 +336,7 @@ void CommonParticipant::create_participant_( utils::Formatter() << "Error creating RTPS Participant " << this->id()); } - logInfo(DDSPIPE_RTPS_PARTICIPANT, + EPROSIMA_LOG_INFO(DDSPIPE_RTPS_PARTICIPANT, "New Participant created with id " << this->id() << " in domain " << domain << " with guid " << rtps_participant_->getGuid() << (this->is_repeater() ? " (repeater)" : " (non repeater)")); @@ -478,15 +462,10 @@ std::shared_ptr CommonParticipant::create_reader( } } -fastrtps::rtps::RTPSParticipantAttributes -CommonParticipant::reckon_participant_attributes_( - const ParticipantConfiguration* participant_configuration) +fastdds::rtps::RTPSParticipantAttributes +CommonParticipant::add_participant_att_properties_( + fastdds::rtps::RTPSParticipantAttributes& params) const { - fastrtps::rtps::RTPSParticipantAttributes params; - - // Add Participant name - params.setName(participant_configuration->id.c_str()); - // Ignore the local endpoints so that the reader and writer of the same participant don't match. params.properties.properties().emplace_back( "fastdds.ignore_local_endpoints", @@ -495,16 +474,29 @@ CommonParticipant::reckon_participant_attributes_( // Set app properties params.properties.properties().emplace_back( "fastdds.application.id", - participant_configuration->app_id, + configuration_->app_id, "true"); params.properties.properties().emplace_back( "fastdds.application.metadata", - participant_configuration->app_metadata, + configuration_->app_metadata, "true"); return params; } +fastdds::rtps::RTPSParticipantAttributes +CommonParticipant::reckon_participant_attributes_() const +{ + fastdds::rtps::RTPSParticipantAttributes params; + + // Add Participant name + params.setName(configuration_->id.c_str()); + + add_participant_att_properties_(params); + + return params; +} + } /* namespace rtps */ } /* namespace participants */ } /* namespace ddspipe */ diff --git a/ddspipe_participants/src/cpp/participant/rtps/DiscoveryServerParticipant.cpp b/ddspipe_participants/src/cpp/participant/rtps/DiscoveryServerParticipant.cpp index b74e30d8..24ee2f96 100644 --- a/ddspipe_participants/src/cpp/participant/rtps/DiscoveryServerParticipant.cpp +++ b/ddspipe_participants/src/cpp/participant/rtps/DiscoveryServerParticipant.cpp @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include -#include -#include -#include +#include +#include +#include +#include #include #include @@ -38,21 +38,29 @@ DiscoveryServerParticipant::DiscoveryServerParticipant( participant_configuration, payload_pool, discovery_database, - participant_configuration->domain, - reckon_participant_attributes_(participant_configuration.get())) + participant_configuration->domain) { } -fastrtps::rtps::RTPSParticipantAttributes -DiscoveryServerParticipant::reckon_participant_attributes_( - const DiscoveryServerParticipantConfiguration* configuration) +fastdds::rtps::RTPSParticipantAttributes +DiscoveryServerParticipant::reckon_participant_attributes_() const { // Use default as base attributes - fastrtps::rtps::RTPSParticipantAttributes params = CommonParticipant::reckon_participant_attributes_(configuration); + fastdds::rtps::RTPSParticipantAttributes params = CommonParticipant::reckon_participant_attributes_(); + + std::shared_ptr discovery_server_configuration = + std::dynamic_pointer_cast(configuration_); + + if (discovery_server_configuration == nullptr) + { + throw utils::ConfigurationException( + "Failed to cast ParticipantConfiguration to DiscoveryServerParticipantConfiguration."); + } // Auxiliary variable to save characters and improve readability - const core::types::GuidPrefix& discovery_server_guid_prefix = configuration->discovery_server_guid_prefix; - const auto& tls_config = configuration->tls_configuration; + const core::types::GuidPrefix& discovery_server_guid_prefix = + discovery_server_configuration->discovery_server_guid_prefix; + const auto& tls_config = discovery_server_configuration->tls_configuration; // Needed values to check at the end if descriptor must be set bool has_listening_addresses = false; @@ -68,14 +76,14 @@ DiscoveryServerParticipant::reckon_participant_attributes_( ///// // Set listening addresses - for (types::Address address : configuration->listening_addresses) + for (types::Address address : discovery_server_configuration->listening_addresses) { if (!address.is_valid()) { // Invalid address, continue with next one - logWarning(DDSPIPE_DISCOVERYSERVER_PARTICIPANT, + EPROSIMA_LOG_WARNING(DDSPIPE_DISCOVERYSERVER_PARTICIPANT, "Discard listening address: " << address << - " in Participant " << configuration->id << " initialization."); + " in Participant " << discovery_server_configuration->id << " initialization."); continue; } @@ -121,7 +129,7 @@ DiscoveryServerParticipant::reckon_participant_attributes_( else { descriptor = create_descriptor( - configuration->whitelist); + discovery_server_configuration->whitelist); descriptor->add_listener_port(address.port()); descriptor->set_WAN_address(address.ip()); @@ -140,7 +148,8 @@ DiscoveryServerParticipant::reckon_participant_attributes_( has_listening_tcp_ipv6 = true; std::shared_ptr descriptor = - create_descriptor(configuration->whitelist); + create_descriptor( + discovery_server_configuration->whitelist); descriptor->add_listener_port(address.port()); @@ -161,21 +170,21 @@ DiscoveryServerParticipant::reckon_participant_attributes_( // For any, UDP or TCP // Create Locator - eprosima::fastrtps::rtps::Locator_t locator; + eprosima::fastdds::rtps::Locator_t locator; locator.kind = address.get_locator_kind(); // IP if (address.is_ipv4()) { - eprosima::fastrtps::rtps::IPLocator::setIPv4(locator, address.ip()); + eprosima::fastdds::rtps::IPLocator::setIPv4(locator, address.ip()); } else { - eprosima::fastrtps::rtps::IPLocator::setIPv6(locator, address.ip()); + eprosima::fastdds::rtps::IPLocator::setIPv6(locator, address.ip()); } // Port - eprosima::fastrtps::rtps::IPLocator::setPhysicalPort(locator, address.port()); + eprosima::fastdds::rtps::IPLocator::setPhysicalPort(locator, address.port()); if (address.is_tcp()) { @@ -185,8 +194,8 @@ DiscoveryServerParticipant::reckon_participant_attributes_( // port announced is equal to the internal port. // If external port is defined, announced port is external port. This is the one clients, // should try to connect, which should match network router public port. - eprosima::fastrtps::rtps::IPLocator::setPhysicalPort(locator, address.external_port()); - eprosima::fastrtps::rtps::IPLocator::setLogicalPort(locator, address.external_port()); + eprosima::fastdds::rtps::IPLocator::setPhysicalPort(locator, address.external_port()); + eprosima::fastdds::rtps::IPLocator::setLogicalPort(locator, address.external_port()); } // Add listening address to builtin @@ -194,45 +203,38 @@ DiscoveryServerParticipant::reckon_participant_attributes_( params.defaultUnicastLocatorList.push_back(locator); logDebug(DDSPIPE_DISCOVERYSERVER_PARTICIPANT, - "Add listening address " << address << " to Participant " << configuration->id << "."); + "Add listening address " << address << " to Participant " << discovery_server_configuration->id << "."); } ///// // Set connection addresses - for (types::DiscoveryServerConnectionAddress connection_address : configuration->connection_addresses) + for (types::DiscoveryServerConnectionAddress connection_address : + discovery_server_configuration->connection_addresses) { if (!connection_address.is_valid()) { // Invalid connection address, continue with next one - logWarning(DDSPIPE_DISCOVERYSERVER_PARTICIPANT, - "Discard connection address with remote server: " << - connection_address.discovery_server_guid_prefix() << - " in Participant " << configuration->id << " initialization."); + EPROSIMA_LOG_WARNING(DDSPIPE_DISCOVERYSERVER_PARTICIPANT, + "Discard connection address with remote server in Participant " << + discovery_server_configuration->id << " initialization."); continue; } - // Set Server GUID - core::types::GuidPrefix server_prefix = connection_address.discovery_server_guid_prefix(); - for (types::Address address : connection_address.addresses()) { if (!address.is_valid()) { // Invalid ip address, continue with next one - logWarning(DDSPIPE_DISCOVERYSERVER_PARTICIPANT, - "Discard connection address with remote server: " << - connection_address.discovery_server_guid_prefix() << - " due to invalid ip address " << address.ip() << " in Participant " << configuration->id << + EPROSIMA_LOG_WARNING(DDSPIPE_DISCOVERYSERVER_PARTICIPANT, + "Discard connection address with remote server due to invalid ip address " << + address.ip() << " in Participant " << discovery_server_configuration->id << " initialization."); continue; } has_connection_addresses = true; - eprosima::fastrtps::rtps::RemoteServerAttributes server_attr; - server_attr.guidPrefix = server_prefix; - - eprosima::fastrtps::rtps::Locator_t locator; + eprosima::fastdds::rtps::Locator_t locator; // KIND locator.kind = address.get_locator_kind(); @@ -252,25 +254,24 @@ DiscoveryServerParticipant::reckon_participant_attributes_( // IP if (address.is_ipv4()) { - eprosima::fastrtps::rtps::IPLocator::setIPv4(locator, address.ip()); + eprosima::fastdds::rtps::IPLocator::setIPv4(locator, address.ip()); } else { - eprosima::fastrtps::rtps::IPLocator::setIPv6(locator, address.ip()); + eprosima::fastdds::rtps::IPLocator::setIPv6(locator, address.ip()); } // PORT - eprosima::fastrtps::rtps::IPLocator::setPhysicalPort(locator, address.port()); - eprosima::fastrtps::rtps::IPLocator::setLogicalPort(locator, address.port()); + eprosima::fastdds::rtps::IPLocator::setPhysicalPort(locator, address.port()); + eprosima::fastdds::rtps::IPLocator::setLogicalPort(locator, address.port()); // Warning: Logical port is not needed unless domain could change // Add as remote server and add it to builtin - server_attr.metatrafficUnicastLocatorList.push_back(locator); - params.builtin.discovery_config.m_DiscoveryServers.push_back(server_attr); + params.builtin.discovery_config.m_DiscoveryServers.push_back(locator); logDebug(DDSPIPE_DISCOVERYSERVER_PARTICIPANT, - "Add connection address " << address << " for server " << server_prefix << - " to Participant " << configuration->id << "."); + "Add connection address " << address << " to Server Participant " << + discovery_server_configuration->id << "."); } } @@ -279,18 +280,18 @@ DiscoveryServerParticipant::reckon_participant_attributes_( if (has_listening_addresses) { params.builtin.discovery_config.discoveryProtocol = - fastrtps::rtps::DiscoveryProtocol::SERVER; + fastdds::rtps::DiscoveryProtocol::SERVER; } else { params.builtin.discovery_config.discoveryProtocol = - fastrtps::rtps::DiscoveryProtocol::SUPER_CLIENT; + fastdds::rtps::DiscoveryProtocol::SUPER_CLIENT; if (!has_connection_addresses) { - logWarning(DDSPIPE_DISCOVERYSERVER_PARTICIPANT, - "Creating Participant " << configuration->id << " without listening or connection addresses. " << - "It will not communicate with any other Participant."); + EPROSIMA_LOG_WARNING(DDSPIPE_DISCOVERYSERVER_PARTICIPANT, + "Creating Participant " << discovery_server_configuration->id << + " without listening or connection addresses. It will not communicate with any other Participant."); } } @@ -305,7 +306,8 @@ DiscoveryServerParticipant::reckon_participant_attributes_( if (has_connection_tcp_ipv4 && !has_listening_tcp_ipv4) { std::shared_ptr descriptor = - create_descriptor(configuration->whitelist); + create_descriptor( + discovery_server_configuration->whitelist); // Enable TLS if (tls_config.is_active()) @@ -316,12 +318,13 @@ DiscoveryServerParticipant::reckon_participant_attributes_( params.userTransports.push_back(descriptor); logDebug(DDSPIPE_DISCOVERYSERVER_PARTICIPANT, - "Adding TCPv4 Transport to Participant " << configuration->id << "."); + "Adding TCPv4 Transport to Participant " << discovery_server_configuration->id << "."); } if (has_connection_tcp_ipv6 && !has_listening_tcp_ipv6) { std::shared_ptr descriptor = - create_descriptor(configuration->whitelist); + create_descriptor( + discovery_server_configuration->whitelist); // Enable TLS if (tls_config.is_active()) @@ -332,31 +335,33 @@ DiscoveryServerParticipant::reckon_participant_attributes_( params.userTransports.push_back(descriptor); logDebug(DDSPIPE_DISCOVERYSERVER_PARTICIPANT, - "Adding TCPv6 Transport to Participant " << configuration->id << "."); + "Adding TCPv6 Transport to Participant " << discovery_server_configuration->id << "."); } // If has UDP, create descriptor because it has not been created yet if (has_udp_ipv4) { std::shared_ptr descriptor = - create_descriptor(configuration->whitelist); + create_descriptor( + discovery_server_configuration->whitelist); params.userTransports.push_back(descriptor); logDebug(DDSPIPE_DISCOVERYSERVER_PARTICIPANT, - "Adding UDPv4 Transport to Participant " << configuration->id << "."); + "Adding UDPv4 Transport to Participant " << discovery_server_configuration->id << "."); } if (has_udp_ipv6) { std::shared_ptr descriptor_v6 = - create_descriptor(configuration->whitelist); + create_descriptor( + discovery_server_configuration->whitelist); params.userTransports.push_back(descriptor_v6); logDebug(DDSPIPE_DISCOVERYSERVER_PARTICIPANT, - "Adding UDPv6 Transport to Participant " << configuration->id << "."); + "Adding UDPv6 Transport to Participant " << discovery_server_configuration->id << "."); } logDebug(DDSPIPE_DISCOVERYSERVER_PARTICIPANT, - "Configured Participant " << configuration->id << " with server guid: " << + "Configured Participant " << discovery_server_configuration->id << " with server guid: " << discovery_server_guid_prefix); return params; diff --git a/ddspipe_participants/src/cpp/participant/rtps/InitialPeersParticipant.cpp b/ddspipe_participants/src/cpp/participant/rtps/InitialPeersParticipant.cpp index c38a8e14..f639723f 100644 --- a/ddspipe_participants/src/cpp/participant/rtps/InitialPeersParticipant.cpp +++ b/ddspipe_participants/src/cpp/participant/rtps/InitialPeersParticipant.cpp @@ -12,11 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include @@ -34,19 +35,26 @@ InitialPeersParticipant::InitialPeersParticipant( participant_configuration, payload_pool, discovery_database, - participant_configuration->domain, - reckon_participant_attributes_(participant_configuration.get())) + participant_configuration->domain) { } -fastrtps::rtps::RTPSParticipantAttributes InitialPeersParticipant::reckon_participant_attributes_( - const InitialPeersParticipantConfiguration* configuration) +fastdds::rtps::RTPSParticipantAttributes InitialPeersParticipant::reckon_participant_attributes_() const { // Use default as base attributes - fastrtps::rtps::RTPSParticipantAttributes params = CommonParticipant::reckon_participant_attributes_(configuration); + fastdds::rtps::RTPSParticipantAttributes params = CommonParticipant::reckon_participant_attributes_(); + + std::shared_ptr initial_peers_configuration = + std::dynamic_pointer_cast(configuration_); + + if (initial_peers_configuration == nullptr) + { + throw utils::ConfigurationException( + "Failed to cast ParticipantConfiguration to InitialPeersParticipantConfiguration."); + } // Auxiliary variable to save characters and improve readability - const auto& tls_config = configuration->tls_configuration; + const auto& tls_config = initial_peers_configuration->tls_configuration; // Needed values to check at the end if descriptor must be set bool has_listening_addresses = false; @@ -63,14 +71,14 @@ fastrtps::rtps::RTPSParticipantAttributes InitialPeersParticipant::reckon_partic ///// // Set listening addresses - for (const types::Address& address : configuration->listening_addresses) + for (const types::Address& address : initial_peers_configuration->listening_addresses) { if (!address.is_valid()) { // Invalid address, continue with next one - logWarning(DDSPIPE_INITIALPEERS_PARTICIPANT, + EPROSIMA_LOG_WARNING(DDSPIPE_INITIALPEERS_PARTICIPANT, "Discard listening address: " << address << - " in Participant " << configuration->id << " initialization."); + " in Participant " << initial_peers_configuration->id << " initialization."); continue; } @@ -116,7 +124,7 @@ fastrtps::rtps::RTPSParticipantAttributes InitialPeersParticipant::reckon_partic else { descriptor = create_descriptor( - configuration->whitelist); + initial_peers_configuration->whitelist); descriptor->add_listener_port(address.port()); descriptor->set_WAN_address(address.ip()); @@ -135,7 +143,8 @@ fastrtps::rtps::RTPSParticipantAttributes InitialPeersParticipant::reckon_partic has_listening_tcp_ipv6 = true; std::shared_ptr descriptor = - create_descriptor(configuration->whitelist); + create_descriptor( + initial_peers_configuration->whitelist); descriptor->add_listener_port(address.port()); @@ -156,21 +165,21 @@ fastrtps::rtps::RTPSParticipantAttributes InitialPeersParticipant::reckon_partic // For any, UDP or TCP // Create Locator - eprosima::fastrtps::rtps::Locator_t locator; + eprosima::fastdds::rtps::Locator_t locator; locator.kind = address.get_locator_kind(); // IP if (address.is_ipv4()) { - eprosima::fastrtps::rtps::IPLocator::setIPv4(locator, address.ip()); + eprosima::fastdds::rtps::IPLocator::setIPv4(locator, address.ip()); } else { - eprosima::fastrtps::rtps::IPLocator::setIPv6(locator, address.ip()); + eprosima::fastdds::rtps::IPLocator::setIPv6(locator, address.ip()); } // Set Logical port for every locator - eprosima::fastrtps::rtps::IPLocator::setPhysicalPort(locator, address.port()); + eprosima::fastdds::rtps::IPLocator::setPhysicalPort(locator, address.port()); // In TCP case, set Physical port if (address.is_tcp()) @@ -181,8 +190,8 @@ fastrtps::rtps::RTPSParticipantAttributes InitialPeersParticipant::reckon_partic // port announced is equal to the internal port. // If external port is defined, announced port is external port. This is the one clients, // should try to connect, which should match network router public port. - eprosima::fastrtps::rtps::IPLocator::setPhysicalPort(locator, address.external_port()); - eprosima::fastrtps::rtps::IPLocator::setLogicalPort(locator, 0); + eprosima::fastdds::rtps::IPLocator::setPhysicalPort(locator, address.external_port()); + eprosima::fastdds::rtps::IPLocator::setLogicalPort(locator, 0); } // Add listening address to builtin @@ -190,24 +199,24 @@ fastrtps::rtps::RTPSParticipantAttributes InitialPeersParticipant::reckon_partic params.defaultUnicastLocatorList.push_back(locator); logDebug(DDSPIPE_INITIALPEERS_PARTICIPANT, - "Add listening address " << address << " to Participant " << configuration->id << "."); + "Add listening address " << address << " to Participant " << initial_peers_configuration->id << "."); } ///// // Set connection addresses - for (const types::Address& connection_address : configuration->connection_addresses) + for (const types::Address& connection_address : initial_peers_configuration->connection_addresses) { if (!connection_address.is_valid()) { // Invalid connection address, continue with next one - logWarning(DDSPIPE_INITIALPEERS_PARTICIPANT, + EPROSIMA_LOG_WARNING(DDSPIPE_INITIALPEERS_PARTICIPANT, "Discard connection address: " << connection_address << - " in Participant " << configuration->id << " initialization."); + " in Participant " << initial_peers_configuration->id << " initialization."); continue; } // Create Locator for connection initial peers - eprosima::fastrtps::rtps::Locator_t locator; + eprosima::fastdds::rtps::Locator_t locator; // KIND locator.kind = connection_address.get_locator_kind(); @@ -229,15 +238,15 @@ fastrtps::rtps::RTPSParticipantAttributes InitialPeersParticipant::reckon_partic // IP if (connection_address.is_ipv4()) { - eprosima::fastrtps::rtps::IPLocator::setIPv4(locator, connection_address.ip()); + eprosima::fastdds::rtps::IPLocator::setIPv4(locator, connection_address.ip()); } else { - eprosima::fastrtps::rtps::IPLocator::setIPv6(locator, connection_address.ip()); + eprosima::fastdds::rtps::IPLocator::setIPv6(locator, connection_address.ip()); } // Set Physical port for every locator - eprosima::fastrtps::rtps::IPLocator::setPhysicalPort(locator, connection_address.port()); + eprosima::fastdds::rtps::IPLocator::setPhysicalPort(locator, connection_address.port()); // TCP client side // Initial peer physical port must match server's public port. If server specified an external port, @@ -246,7 +255,7 @@ fastrtps::rtps::RTPSParticipantAttributes InitialPeersParticipant::reckon_partic // In TCP case, set Logical port if (connection_address.is_tcp()) { - eprosima::fastrtps::rtps::IPLocator::setLogicalPort(locator, 0); + eprosima::fastdds::rtps::IPLocator::setLogicalPort(locator, 0); } // Add it to builtin @@ -254,7 +263,7 @@ fastrtps::rtps::RTPSParticipantAttributes InitialPeersParticipant::reckon_partic logDebug(DDSPIPE_INITIALPEERS_PARTICIPANT, "Add connection address " << connection_address << - " to Participant " << configuration->id << "."); + " to Participant " << initial_peers_configuration->id << "."); } ///// @@ -264,7 +273,8 @@ fastrtps::rtps::RTPSParticipantAttributes InitialPeersParticipant::reckon_partic if (has_connection_tcp_ipv4 && !has_listening_tcp_ipv4) { std::shared_ptr descriptor = - create_descriptor(configuration->whitelist); + create_descriptor( + initial_peers_configuration->whitelist); // Enable TLS if (tls_config.is_active()) @@ -275,13 +285,14 @@ fastrtps::rtps::RTPSParticipantAttributes InitialPeersParticipant::reckon_partic params.userTransports.push_back(descriptor); logDebug(DDSPIPE_INITIALPEERS_PARTICIPANT, - "Adding TCPv4 Transport to Participant " << configuration->id << "."); + "Adding TCPv4 Transport to Participant " << initial_peers_configuration->id << "."); } if (has_connection_tcp_ipv6 && !has_listening_tcp_ipv6) { std::shared_ptr descriptor = - create_descriptor(configuration->whitelist); + create_descriptor( + initial_peers_configuration->whitelist); // Enable TLS if (tls_config.is_active()) @@ -292,28 +303,30 @@ fastrtps::rtps::RTPSParticipantAttributes InitialPeersParticipant::reckon_partic params.userTransports.push_back(descriptor); logDebug(DDSPIPE_INITIALPEERS_PARTICIPANT, - "Adding TCPv6 Transport to Participant " << configuration->id << "."); + "Adding TCPv6 Transport to Participant " << initial_peers_configuration->id << "."); } // If has UDP, create descriptor because it has not been created yet if (has_udp_ipv4) { std::shared_ptr descriptor = - create_descriptor(configuration->whitelist); + create_descriptor( + initial_peers_configuration->whitelist); params.userTransports.push_back(descriptor); logDebug(DDSPIPE_INITIALPEERS_PARTICIPANT, - "Adding UDPv4 Transport to Participant " << configuration->id << "."); + "Adding UDPv4 Transport to Participant " << initial_peers_configuration->id << "."); } if (has_udp_ipv6) { std::shared_ptr descriptor_v6 = - create_descriptor(configuration->whitelist); + create_descriptor( + initial_peers_configuration->whitelist); params.userTransports.push_back(descriptor_v6); logDebug(DDSPIPE_INITIALPEERS_PARTICIPANT, - "Adding UDPv6 Transport to Participant " << configuration->id << "."); + "Adding UDPv6 Transport to Participant " << initial_peers_configuration->id << "."); } // To avoid creating a multicast transport in UDP when non listening addresses @@ -322,21 +335,21 @@ fastrtps::rtps::RTPSParticipantAttributes InitialPeersParticipant::reckon_partic { if (has_connection_udp_ipv4) { - eprosima::fastrtps::rtps::Locator_t locator; + eprosima::fastdds::rtps::Locator_t locator; locator.kind = LOCATOR_KIND_UDPv4; params.builtin.metatrafficUnicastLocatorList.push_back(locator); } if (has_connection_udp_ipv6) { - eprosima::fastrtps::rtps::Locator_t locator; + eprosima::fastdds::rtps::Locator_t locator; locator.kind = LOCATOR_KIND_UDPv6; params.builtin.metatrafficUnicastLocatorList.push_back(locator); } } logDebug(DDSPIPE_INITIALPEERS_PARTICIPANT, - "Configured Participant " << configuration->id); + "Configured Participant " << initial_peers_configuration->id); return params; } diff --git a/ddspipe_participants/src/cpp/participant/rtps/SimpleParticipant.cpp b/ddspipe_participants/src/cpp/participant/rtps/SimpleParticipant.cpp index 12c42db1..2aeb3c17 100644 --- a/ddspipe_participants/src/cpp/participant/rtps/SimpleParticipant.cpp +++ b/ddspipe_participants/src/cpp/participant/rtps/SimpleParticipant.cpp @@ -14,11 +14,13 @@ #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include + +#include #include @@ -35,22 +37,28 @@ SimpleParticipant::SimpleParticipant( participant_configuration, payload_pool, discovery_database, - participant_configuration->domain, - reckon_participant_attributes_(participant_configuration.get())) + participant_configuration->domain) { } -fastrtps::rtps::RTPSParticipantAttributes -SimpleParticipant::reckon_participant_attributes_( - const SimpleParticipantConfiguration* configuration) +fastdds::rtps::RTPSParticipantAttributes +SimpleParticipant::reckon_participant_attributes_() const { // Use default as base attributes - fastrtps::rtps::RTPSParticipantAttributes params = CommonParticipant::reckon_participant_attributes_(configuration); + fastdds::rtps::RTPSParticipantAttributes params = CommonParticipant::reckon_participant_attributes_(); + + std::shared_ptr simple_configuration = + std::dynamic_pointer_cast(configuration_); + + if (simple_configuration == nullptr) + { + throw utils::ConfigurationException("Failed to cast ParticipantConfiguration to SimpleParticipantConfiguration."); + } // Configure Participant transports - if (configuration->transport == core::types::TransportDescriptors::builtin) + if (simple_configuration->transport == core::types::TransportDescriptors::builtin) { - if (!configuration->whitelist.empty()) + if (!simple_configuration->whitelist.empty()) { params.useBuiltinTransports = false; @@ -59,11 +67,11 @@ SimpleParticipant::reckon_participant_attributes_( params.userTransports.push_back(shm_transport); std::shared_ptr udp_transport = - create_descriptor(configuration->whitelist); + create_descriptor(simple_configuration->whitelist); params.userTransports.push_back(udp_transport); } } - else if (configuration->transport == core::types::TransportDescriptors::shm_only) + else if (simple_configuration->transport == core::types::TransportDescriptors::shm_only) { params.useBuiltinTransports = false; @@ -71,39 +79,39 @@ SimpleParticipant::reckon_participant_attributes_( std::make_shared(); params.userTransports.push_back(shm_transport); } - else if (configuration->transport == core::types::TransportDescriptors::udp_only) + else if (simple_configuration->transport == core::types::TransportDescriptors::udp_only) { params.useBuiltinTransports = false; std::shared_ptr udp_transport = - create_descriptor(configuration->whitelist); + create_descriptor(simple_configuration->whitelist); params.userTransports.push_back(udp_transport); } // Participant discovery filter configuration - switch (configuration->ignore_participant_flags) + switch (simple_configuration->ignore_participant_flags) { case core::types::IgnoreParticipantFlags::no_filter: params.builtin.discovery_config.ignoreParticipantFlags = - eprosima::fastrtps::rtps::ParticipantFilteringFlags_t::NO_FILTER; + eprosima::fastdds::rtps::ParticipantFilteringFlags::NO_FILTER; break; case core::types::IgnoreParticipantFlags::filter_different_host: params.builtin.discovery_config.ignoreParticipantFlags = - eprosima::fastrtps::rtps::ParticipantFilteringFlags_t::FILTER_DIFFERENT_HOST; + eprosima::fastdds::rtps::ParticipantFilteringFlags::FILTER_DIFFERENT_HOST; break; case core::types::IgnoreParticipantFlags::filter_different_process: params.builtin.discovery_config.ignoreParticipantFlags = - eprosima::fastrtps::rtps::ParticipantFilteringFlags_t::FILTER_DIFFERENT_PROCESS; + eprosima::fastdds::rtps::ParticipantFilteringFlags::FILTER_DIFFERENT_PROCESS; break; case core::types::IgnoreParticipantFlags::filter_same_process: params.builtin.discovery_config.ignoreParticipantFlags = - eprosima::fastrtps::rtps::ParticipantFilteringFlags_t::FILTER_SAME_PROCESS; + eprosima::fastdds::rtps::ParticipantFilteringFlags::FILTER_SAME_PROCESS; break; case core::types::IgnoreParticipantFlags::filter_different_and_same_process: params.builtin.discovery_config.ignoreParticipantFlags = - static_cast( - eprosima::fastrtps::rtps::ParticipantFilteringFlags_t::FILTER_DIFFERENT_PROCESS | - eprosima::fastrtps::rtps::ParticipantFilteringFlags_t::FILTER_SAME_PROCESS); + static_cast( + eprosima::fastdds::rtps::ParticipantFilteringFlags::FILTER_DIFFERENT_PROCESS | + eprosima::fastdds::rtps::ParticipantFilteringFlags::FILTER_SAME_PROCESS); break; default: break; diff --git a/ddspipe_participants/src/cpp/reader/auxiliar/BaseReader.cpp b/ddspipe_participants/src/cpp/reader/auxiliar/BaseReader.cpp index 2a4fbbf4..87449a8f 100644 --- a/ddspipe_participants/src/cpp/reader/auxiliar/BaseReader.cpp +++ b/ddspipe_participants/src/cpp/reader/auxiliar/BaseReader.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -190,7 +191,7 @@ core::types::Guid BaseReader::guid() const throw utils::UnsupportedException("guid method not allowed for non RTPS readers."); } -fastrtps::RecursiveTimedMutex& BaseReader::get_rtps_mutex() const +fastdds::RecursiveTimedMutex& BaseReader::get_rtps_mutex() const { throw utils::UnsupportedException("get_rtps_mutex method not allowed for non RTPS readers."); } diff --git a/ddspipe_participants/src/cpp/reader/auxiliar/BlankReader.cpp b/ddspipe_participants/src/cpp/reader/auxiliar/BlankReader.cpp index 1f824b10..5f74af42 100644 --- a/ddspipe_participants/src/cpp/reader/auxiliar/BlankReader.cpp +++ b/ddspipe_participants/src/cpp/reader/auxiliar/BlankReader.cpp @@ -13,6 +13,7 @@ // limitations under the License. #include +#include #include @@ -48,7 +49,7 @@ core::types::Guid BlankReader::guid() const throw utils::UnsupportedException("guid method not allowed for non RTPS readers."); } -fastrtps::RecursiveTimedMutex& BlankReader::get_rtps_mutex() const +fastdds::RecursiveTimedMutex& BlankReader::get_rtps_mutex() const { throw utils::UnsupportedException("get_rtps_mutex method not allowed for non RTPS readers."); } diff --git a/ddspipe_participants/src/cpp/reader/auxiliar/InternalReader.cpp b/ddspipe_participants/src/cpp/reader/auxiliar/InternalReader.cpp index b04a8a59..8b628455 100644 --- a/ddspipe_participants/src/cpp/reader/auxiliar/InternalReader.cpp +++ b/ddspipe_participants/src/cpp/reader/auxiliar/InternalReader.cpp @@ -18,6 +18,7 @@ #include #include +#include #include diff --git a/ddspipe_participants/src/cpp/reader/dds/CommonReader.cpp b/ddspipe_participants/src/cpp/reader/dds/CommonReader.cpp index ae19b3a9..da1dd7ed 100644 --- a/ddspipe_participants/src/cpp/reader/dds/CommonReader.cpp +++ b/ddspipe_participants/src/cpp/reader/dds/CommonReader.cpp @@ -48,13 +48,14 @@ CommonReader::~CommonReader() dds_participant_->delete_subscriber(dds_subscriber_); } - logInfo(DDSPIPE_DDS_READER, "Deleting CommonReader created in Participant " << + EPROSIMA_LOG_INFO(DDSPIPE_DDS_READER, "Deleting CommonReader created in Participant " << participant_id_ << " for topic " << topic_); } void CommonReader::init() { - logInfo(DDSPIPE_DDS_READER, "Initializing reader in " << participant_id_ << " for topic " << topic_ << "."); + EPROSIMA_LOG_INFO(DDSPIPE_DDS_READER, + "Initializing reader in " << participant_id_ << " for topic " << topic_ << "."); // Create subscriber dds_subscriber_ = dds_participant_->create_subscriber( @@ -71,21 +72,12 @@ void CommonReader::init() // Create CommonReader // Listener must be set in creation as no callbacks should be missed // It is safe to do so here as object is already created and callbacks do not require anything set in this method - #if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 12 - reader_ = dds_subscriber_->create_datareader_with_payload_pool( - dds_topic_, - reckon_reader_qos_(), - payload_pool_, - nullptr, - eprosima::fastdds::dds::StatusMask::all()); - #else reader_ = dds_subscriber_->create_datareader( dds_topic_, reckon_reader_qos_(), nullptr, eprosima::fastdds::dds::StatusMask::all(), payload_pool_); - #endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 if (!reader_) { @@ -103,7 +95,8 @@ void CommonReader::init() void CommonReader::on_data_available( fastdds::dds::DataReader* /* reader */) { - logInfo(DDSPIPE_DDS_READER, "On data available in reader in " << participant_id_ << " for topic " << topic_ << "."); + EPROSIMA_LOG_INFO(DDSPIPE_DDS_READER, + "On data available in reader in " << participant_id_ << " for topic " << topic_ << "."); // The CommonReader notifies the reception of a message to the Monitor when a on_data_available event is received. // An on_data_available event can be received with more than one message, but figuring out the number of messages @@ -121,7 +114,7 @@ void CommonReader::on_sample_lost( fastdds::dds::DataReader* reader, const fastdds::dds::SampleLostStatus& status) { - logWarning(DDSPIPE_DDS_READER, + EPROSIMA_LOG_WARNING(DDSPIPE_DDS_READER, "SAMPLE_LOST | On reader " << *this << " a data sample was lost and will not be received"); monitor_msg_lost(topic_, participant_id_); @@ -131,7 +124,7 @@ void CommonReader::on_requested_incompatible_qos( fastdds::dds::DataReader* reader, const fastdds::dds::RequestedIncompatibleQosStatus& status) { - logWarning(DDSPIPE_DDS_READER, + EPROSIMA_LOG_WARNING(DDSPIPE_DDS_READER, "TOPIC_MISMATCH_QOS | Reader " << *this << " found a remote Writer with incompatible QoS"); monitor_qos_mismatch(topic_); @@ -142,7 +135,7 @@ void CommonReader::on_inconsistent_topic( fastdds::dds::Topic* topic, fastdds::dds::InconsistentTopicStatus status) { - logWarning(DDSPIPE_DDS_READER, + EPROSIMA_LOG_WARNING(DDSPIPE_DDS_READER, "TOPIC_MISMATCH_TYPE | Reader " << *this << " found a remote Writer with same topic name but incompatible type"); @@ -173,7 +166,7 @@ utils::ReturnCode CommonReader::take_nts_( // NOTE: we assume this function is always called from the same thread // NOTE: we assume this function is always called with nullptr data - logInfo(DDSPIPE_DDS_READER, "Taking data in " << participant_id_ << " for topic " << topic_ << "."); + EPROSIMA_LOG_INFO(DDSPIPE_DDS_READER, "Taking data in " << participant_id_ << " for topic " << topic_ << "."); // Check if there is data available if (!(reader_->get_unread_count() > 0)) @@ -193,19 +186,19 @@ utils::ReturnCode CommonReader::take_nts_( // If the payload owner is not set, rtps_data won't release the payload on destruction rtps_data->payload_owner = payload_pool_.get(); - if (!ret) + if (ret != fastdds::dds::RETCODE_OK) { // There has been an error taking the data. Exit. return ret; } } while (!should_accept_sample_(info)); - logInfo(DDSPIPE_DDS_READER, "Data taken in " << participant_id_ << " for topic " << topic_ << "."); + EPROSIMA_LOG_INFO(DDSPIPE_DDS_READER, "Data taken in " << participant_id_ << " for topic " << topic_ << "."); // Verify that the rtps_data object is valid if (!rtps_data) { - logError(DDSPIPE_DDS_READER, "The data taken by the reader is not valid."); + EPROSIMA_LOG_ERROR(DDSPIPE_DDS_READER, "The data taken by the reader is not valid."); return utils::ReturnCode::RETCODE_ERROR; } diff --git a/ddspipe_participants/src/cpp/reader/dds/SimpleReader.cpp b/ddspipe_participants/src/cpp/reader/dds/SimpleReader.cpp index 6d3327af..f10605f9 100644 --- a/ddspipe_participants/src/cpp/reader/dds/SimpleReader.cpp +++ b/ddspipe_participants/src/cpp/reader/dds/SimpleReader.cpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include -#include +#include +#include #include #include diff --git a/ddspipe_participants/src/cpp/reader/dds/SpecificQoSReader.cpp b/ddspipe_participants/src/cpp/reader/dds/SpecificQoSReader.cpp index 85aafba1..a6542490 100644 --- a/ddspipe_participants/src/cpp/reader/dds/SpecificQoSReader.cpp +++ b/ddspipe_participants/src/cpp/reader/dds/SpecificQoSReader.cpp @@ -13,8 +13,8 @@ // limitations under the License. -#include -#include +#include +#include #include #include @@ -58,7 +58,7 @@ void SpecificQoSReader::fill_received_data_( { // Get a message from a writer not in database, this is an error. // Remove data and make as it has not been received. - logError( + EPROSIMA_LOG_ERROR( DDSPIPE_SpecificQoSReader, "Received a message from Writer " << data_to_fill.source_guid << " that is not stored in DB."); } diff --git a/ddspipe_participants/src/cpp/reader/rpc/SimpleReader.cpp b/ddspipe_participants/src/cpp/reader/rpc/SimpleReader.cpp index 77243822..402ea971 100644 --- a/ddspipe_participants/src/cpp/reader/rpc/SimpleReader.cpp +++ b/ddspipe_participants/src/cpp/reader/rpc/SimpleReader.cpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include -#include +#include +#include #include #include @@ -31,27 +31,27 @@ SimpleReader::SimpleReader( const core::types::ParticipantId& participant_id, const core::types::DdsTopic& topic, const std::shared_ptr& payload_pool, - fastrtps::rtps::RTPSParticipant* rtps_participant) + fastdds::rtps::RTPSParticipant* rtps_participant) : CommonReader( participant_id, topic, payload_pool, rtps_participant, reckon_history_attributes_(topic), reckon_reader_attributes_(topic), - reckon_topic_attributes_(topic), + reckon_topic_description_(topic), reckon_reader_qos_(topic)) { - logInfo(DDSPIPE_RPC_READER, "Creating RPC Reader for topic " << topic_); + EPROSIMA_LOG_INFO(DDSPIPE_RPC_READER, "Creating RPC Reader for topic " << topic_); } //! Override Parent method to create an RPC data type. core::types::RtpsPayloadData* SimpleReader::create_data_( - const fastrtps::rtps::CacheChange_t& received_change) const noexcept + const fastdds::rtps::CacheChange_t& received_change) const noexcept { return new core::types::RpcPayloadData(); } //! Override Parent method to fill fields exclusive from RPC. void SimpleReader::fill_received_data_( - const fastrtps::rtps::CacheChange_t& received_change, + const fastdds::rtps::CacheChange_t& received_change, core::types::RtpsPayloadData& data_to_fill) const noexcept { CommonReader::fill_received_data_(received_change, data_to_fill); diff --git a/ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp b/ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp index f7e24810..befc5e95 100644 --- a/ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp +++ b/ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp @@ -12,8 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include -#include +#include +#include +#include + +#include #include #include @@ -38,11 +41,11 @@ CommonReader::CommonReader( const ParticipantId& participant_id, const DdsTopic& topic, const std::shared_ptr& payload_pool, - fastrtps::rtps::RTPSParticipant* rtps_participant, - const fastrtps::rtps::HistoryAttributes& history_attributes, - const fastrtps::rtps::ReaderAttributes& reader_attributes, - const fastrtps::TopicAttributes& topic_attributes, - const fastrtps::ReaderQos& reader_qos) + fastdds::rtps::RTPSParticipant* rtps_participant, + const fastdds::rtps::HistoryAttributes& history_attributes, + const fastdds::rtps::ReaderAttributes& reader_attributes, + const fastdds::rtps::TopicDescription& topic_description, + const fastdds::dds::ReaderQos& reader_qos) : BaseReader(participant_id, topic.topic_qos.max_rx_rate, topic.topic_qos.downsampling) , rtps_participant_(rtps_participant) , payload_pool_(payload_pool) @@ -51,7 +54,7 @@ CommonReader::CommonReader( , rtps_history_(nullptr) , history_attributes_(history_attributes) , reader_attributes_(reader_attributes) - , topic_attributes_(topic_attributes) + , topic_description_(topic_description) , reader_qos_(reader_qos) { // Do nothing. @@ -66,8 +69,8 @@ CommonReader::~CommonReader() if (rtps_reader_) { // Unset listener before destruction (not necessary in principle, but just in case) - rtps_reader_->setListener(nullptr); - fastrtps::rtps::RTPSDomain::removeRTPSReader(rtps_reader_); + rtps_reader_->set_listener(nullptr); + fastdds::rtps::RTPSDomain::removeRTPSReader(rtps_reader_); } // Delete History @@ -76,7 +79,7 @@ CommonReader::~CommonReader() delete rtps_history_; } - logInfo(DDSPIPE_RTPS_READER, "Deleting CommonReader created in Participant " << + EPROSIMA_LOG_INFO(DDSPIPE_RTPS_READER, "Deleting CommonReader created in Participant " << participant_id_ << " for topic " << topic_); } @@ -85,26 +88,26 @@ void CommonReader::init() internal_entities_creation_( history_attributes_, reader_attributes_, - topic_attributes_, + topic_description_, reader_qos_); } void CommonReader::internal_entities_creation_( - const fastrtps::rtps::HistoryAttributes& history_attributes, - const fastrtps::rtps::ReaderAttributes& reader_attributes, - const fastrtps::TopicAttributes& topic_attributes, - const fastrtps::ReaderQos& reader_qos) + const fastdds::rtps::HistoryAttributes& history_attributes, + const fastdds::rtps::ReaderAttributes& reader_attributes, + const fastdds::rtps::TopicDescription& topic_description, + const fastdds::dds::ReaderQos& reader_qos) { // Copy reader attributes because fast needs it non const (do not ask why) - fastrtps::rtps::ReaderAttributes non_const_reader_attributes = reader_attributes; + fastdds::rtps::ReaderAttributes non_const_reader_attributes = reader_attributes; // Create History - rtps_history_ = new fastrtps::rtps::ReaderHistory(history_attributes); + rtps_history_ = new fastdds::rtps::ReaderHistory(history_attributes); // Create CommonReader // Listener must be set in creation as no callbacks should be missed // It is safe to do so here as object is already created and callbacks do not require anything set in this method - rtps_reader_ = fastrtps::rtps::RTPSDomain::createRTPSReader( + rtps_reader_ = fastdds::rtps::RTPSDomain::createRTPSReader( rtps_participant_, non_const_reader_attributes, payload_pool_, @@ -120,18 +123,18 @@ void CommonReader::internal_entities_creation_( // Set listener after entity creation to avoid SEGFAULT (produced when callback using rtps_reader_ is // invoked before the variable is fully set) - rtps_reader_->setListener(this); + rtps_reader_->set_listener(this); // Register reader with topic - if (!rtps_participant_->registerReader(rtps_reader_, topic_attributes, reader_qos)) + if (!rtps_participant_->register_reader(rtps_reader_, topic_description, reader_qos)) { // In case it fails, remove reader and throw exception - fastrtps::rtps::RTPSDomain::removeRTPSReader(rtps_reader_); + fastdds::rtps::RTPSDomain::removeRTPSReader(rtps_reader_); throw utils::InitializationException(utils::Formatter() << "Error registering topic " << topic_ << " for Simple RTPSReader in Participant " << participant_id_); } - logInfo(DDSPIPE_RTPS_READER, "New CommonReader created in Participant " << participant_id_ << " for topic " << + EPROSIMA_LOG_INFO(DDSPIPE_RTPS_READER, "New CommonReader created in Participant " << participant_id_ << " for topic " << topic_ << " with guid " << rtps_reader_->getGuid()); } @@ -140,7 +143,7 @@ core::types::Guid CommonReader::guid() const noexcept return rtps_reader_->getGuid(); } -fastrtps::RecursiveTimedMutex& CommonReader::get_rtps_mutex() const noexcept +fastdds::RecursiveTimedMutex& CommonReader::get_rtps_mutex() const noexcept { return rtps_reader_->getMutex(); } @@ -164,11 +167,9 @@ utils::ReturnCode CommonReader::take_nts_( return utils::ReturnCode::RETCODE_NO_DATA; } - fastrtps::rtps::CacheChange_t* received_change = nullptr; - fastrtps::rtps::WriterProxy* wp = nullptr; - // Read first change of the history - if (!rtps_reader_->nextUntakenCache(&received_change, &wp)) + auto received_change = rtps_reader_->next_untaken_cache(); + if (!received_change) { // Error reading. return utils::ReturnCode::RETCODE_ERROR; @@ -176,10 +177,10 @@ utils::ReturnCode CommonReader::take_nts_( // If data received is not correct, discard it and remove it from history auto ret = is_data_correct_(received_change); - if (!ret) + if (ret != utils::ReturnCode::RETCODE_OK) { // Remove the change in the History and release it in the reader - rtps_reader_->getHistory()->remove_change(received_change); + rtps_reader_->get_history()->remove_change(received_change); return ret; } @@ -189,19 +190,19 @@ utils::ReturnCode CommonReader::take_nts_( data.reset(data_ptr); // Remove the change in the History and release it in the reader - rtps_reader_->getHistory()->remove_change(received_change); + rtps_reader_->get_history()->remove_change(received_change); return utils::ReturnCode::RETCODE_OK; } RtpsPayloadData* CommonReader::create_data_( - const fastrtps::rtps::CacheChange_t& received_change) const noexcept + const fastdds::rtps::CacheChange_t& received_change) const noexcept { return new RtpsPayloadData(); } void CommonReader::fill_received_data_( - const fastrtps::rtps::CacheChange_t& received_change, + const fastdds::rtps::CacheChange_t& received_change, RtpsPayloadData& data_to_fill) const noexcept { // Store the new data that has arrived in the Track data @@ -216,12 +217,8 @@ void CommonReader::fill_received_data_( // NOTE: in case of keyed topics an empty payload is possible if (received_change.serializedPayload.length > 0) { - eprosima::fastrtps::rtps::IPayloadPool* payload_owner = - const_cast(received_change.payload_owner()); - payload_pool_->get_payload( received_change.serializedPayload, - payload_owner, data_to_fill.payload); data_to_fill.payload_owner = payload_pool_.get(); @@ -251,13 +248,13 @@ void CommonReader::enable_nts_() noexcept // However, if the topic is best_effort, the reader will discard the samples received when it was disabled. if (topic_.topic_qos.is_reliable()) { - std::lock_guard lock(get_rtps_mutex()); + std::lock_guard lock(get_rtps_mutex()); on_data_available_(); } } bool CommonReader::should_accept_change_( - const fastrtps::rtps::CacheChange_t* change) noexcept + const fastdds::rtps::CacheChange_t* change) noexcept { // Reject samples sent by a Writer from the same Participant this Reader belongs to if (come_from_this_participant_(change)) @@ -269,23 +266,23 @@ bool CommonReader::should_accept_change_( } bool CommonReader::come_from_this_participant_( - const fastrtps::rtps::CacheChange_t* change) const noexcept + const fastdds::rtps::CacheChange_t* change) const noexcept { return come_from_this_participant_(change->writerGUID); } bool CommonReader::come_from_this_participant_( - const fastrtps::rtps::GUID_t guid) const noexcept + const fastdds::rtps::GUID_t guid) const noexcept { return guid.guidPrefix == rtps_reader_->getGuid().guidPrefix; } -fastrtps::rtps::HistoryAttributes CommonReader::reckon_history_attributes_( +fastdds::rtps::HistoryAttributes CommonReader::reckon_history_attributes_( const core::types::DdsTopic& topic) noexcept { - fastrtps::rtps::HistoryAttributes att; + fastdds::rtps::HistoryAttributes att; att.memoryPolicy = - eprosima::fastrtps::rtps::MemoryManagementPolicy_t::PREALLOCATED_WITH_REALLOC_MEMORY_MODE; + eprosima::fastdds::rtps::MemoryManagementPolicy_t::PREALLOCATED_WITH_REALLOC_MEMORY_MODE; att.maximumReservedCaches = topic.topic_qos.history_depth; if (att.maximumReservedCaches > 0 && att.initialReservedCaches > att.maximumReservedCaches) @@ -297,10 +294,10 @@ fastrtps::rtps::HistoryAttributes CommonReader::reckon_history_attributes_( return att; } -fastrtps::rtps::ReaderAttributes CommonReader::reckon_reader_attributes_( +fastdds::rtps::ReaderAttributes CommonReader::reckon_reader_attributes_( const core::types::DdsTopic& topic) noexcept { - fastrtps::rtps::ReaderAttributes att; + fastdds::rtps::ReaderAttributes att; // Set Durability att.endpoint.durabilityKind = topic.topic_qos.durability_qos; @@ -311,14 +308,14 @@ fastrtps::rtps::ReaderAttributes CommonReader::reckon_reader_attributes_( // Set if topic has key if (topic.topic_qos.keyed) { - att.endpoint.topicKind = eprosima::fastrtps::rtps::WITH_KEY; + att.endpoint.topicKind = eprosima::fastdds::rtps::WITH_KEY; // If the topic has a key, request inline qos (containing the instance handle) - att.expectsInlineQos = true; + att.expects_inline_qos = true; } else { - att.endpoint.topicKind = eprosima::fastrtps::rtps::NO_KEY; + att.endpoint.topicKind = eprosima::fastdds::rtps::NO_KEY; } // Ownership and Partitions are not part of RTPS, thus they are set in properties @@ -326,36 +323,62 @@ fastrtps::rtps::ReaderAttributes CommonReader::reckon_reader_attributes_( return att; } -fastrtps::TopicAttributes CommonReader::reckon_topic_attributes_( +fastdds::rtps::TopicDescription CommonReader::reckon_topic_description_( const core::types::DdsTopic& topic) noexcept { - fastrtps::TopicAttributes att; + fastdds::rtps::TopicDescription topic_description; - // Set if topic has key - if (topic.topic_qos.keyed) + topic_description.topic_name = topic.m_topic_name; + topic_description.type_name = topic.type_name; + + // Check TypeIdentifierPair in DdsTopic is not empty + if (topic.type_identifiers == fastdds::dds::xtypes::TypeIdentifierPair()) { - att.topicKind = eprosima::fastrtps::rtps::WITH_KEY; + return topic_description; } - else + + // Set TypeInformation of the discovered type + fastdds::dds::xtypes::TypeInformation type_information; + + auto try_get_type_information = [&](const fastdds::dds::xtypes::TypeIdentifierPair& identifiers) -> bool + { + return fastdds::dds::RETCODE_OK == + fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry(). + get_type_information( + identifiers, type_information); + }; + + if (!try_get_type_information(topic.type_identifiers)) { - att.topicKind = eprosima::fastrtps::rtps::NO_KEY; - } + // If get_type_information fails with TypeIdentifierPair try just with complete + fastdds::dds::xtypes::TypeIdentifierPair complete_only; + complete_only.type_identifier1(topic.type_identifiers.type_identifier1()); - // Set Topic attributes - att.topicName = topic.m_topic_name; - att.topicDataType = topic.type_name; + if (!try_get_type_information(complete_only)) + { + // If get_type_information fails with complete TypeIdentifier try just with minimal + fastdds::dds::xtypes::TypeIdentifierPair minimal_only; + minimal_only.type_identifier2(topic.type_identifiers.type_identifier2()); - // Set Topic history attributes - att.historyQos.kind = eprosima::fastdds::dds::HistoryQosPolicyKind::KEEP_LAST_HISTORY_QOS; - att.historyQos.depth = topic.topic_qos.history_depth; + if (!try_get_type_information(minimal_only)) + { + EPROSIMA_LOG_WARNING(DDSPIPE_RTPS_COMMONREADER_LISTENER, + "Failed to get TypeInformation for type " << topic.type_name); - return att; + return topic_description; + } + } + } + + topic_description.type_information = type_information; + + return topic_description; } -fastrtps::ReaderQos CommonReader::reckon_reader_qos_( +fastdds::dds::ReaderQos CommonReader::reckon_reader_qos_( const core::types::DdsTopic& topic) noexcept { - fastrtps::ReaderQos properties; + fastdds::dds::ReaderQos properties; // Set Durability properties.m_durability.kind = @@ -381,9 +404,9 @@ fastrtps::ReaderQos CommonReader::reckon_reader_qos_( return properties; } -void CommonReader::onNewCacheChangeAdded( - fastrtps::rtps::RTPSReader* reader, - const fastrtps::rtps::CacheChange_t* const change) noexcept +void CommonReader::on_new_cache_change_added( + fastdds::rtps::RTPSReader* reader, + const fastdds::rtps::CacheChange_t* const change) noexcept { monitor_msg_rx(topic_, participant_id_); @@ -403,7 +426,7 @@ void CommonReader::onNewCacheChangeAdded( // Remove received change if the CommonReader is disbled and the topic is not reliable if (!topic_.topic_qos.is_reliable()) { - reader->getHistory()->remove_change((fastrtps::rtps::CacheChange_t*)change); + reader->get_history()->remove_change((fastdds::rtps::CacheChange_t*)change); logDebug(DDSPIPE_RTPS_COMMONREADER_LISTENER, "Change removed from history"); } @@ -411,7 +434,7 @@ void CommonReader::onNewCacheChangeAdded( } else { - logInfo( + EPROSIMA_LOG_INFO( DDSPIPE_RTPS_COMMONREADER_LISTENER, "Rejected received data in reader " << *this << "."); @@ -421,25 +444,25 @@ void CommonReader::onNewCacheChangeAdded( // WARNING: Removing an unacceptable change here is valid given that Fast-DDS internal reader's mutex is locked. // If the mutex wasn't locked, the track's transmit thread could take an unacceptable sample before it gets // deleted here. - reader->getHistory()->remove_change((fastrtps::rtps::CacheChange_t*)change); + reader->get_history()->remove_change((fastdds::rtps::CacheChange_t*)change); } } -void CommonReader::onReaderMatched( - fastrtps::rtps::RTPSReader*, - fastrtps::rtps::MatchingInfo& info) noexcept +void CommonReader::on_reader_matched( + fastdds::rtps::RTPSReader*, + const fastdds::rtps::MatchingInfo& info) noexcept { if (!come_from_this_participant_(info.remoteEndpointGuid)) { - if (info.status == fastrtps::rtps::MatchingStatus::MATCHED_MATCHING) + if (info.status == fastdds::rtps::MatchingStatus::MATCHED_MATCHING) { - logInfo(DDSPIPE_RTPS_COMMONREADER_LISTENER, + EPROSIMA_LOG_INFO(DDSPIPE_RTPS_COMMONREADER_LISTENER, "Reader " << *this << " in topic " << topic_.serialize() << " matched with a new Writer with guid " << info.remoteEndpointGuid); } else { - logInfo(DDSPIPE_RTPS_COMMONREADER_LISTENER, + EPROSIMA_LOG_INFO(DDSPIPE_RTPS_COMMONREADER_LISTENER, "Reader " << *this << " in topic " << topic_.serialize() << " unmatched with Writer " << info.remoteEndpointGuid); } @@ -447,10 +470,10 @@ void CommonReader::onReaderMatched( } void CommonReader::on_requested_incompatible_qos( - fastrtps::rtps::RTPSReader*, - fastdds::dds::PolicyMask qos) noexcept + fastdds::rtps::RTPSReader*, + eprosima::fastdds::dds::PolicyMask qos) noexcept { - logWarning(DDSPIPE_RTPS_COMMONREADER_LISTENER, + EPROSIMA_LOG_WARNING(DDSPIPE_RTPS_COMMONREADER_LISTENER, "TOPIC_MISMATCH_QOS | Reader " << *this << " found a remote Writer with incompatible QoS: " << utils::qos_policy_mask_to_string(qos)); @@ -459,19 +482,19 @@ void CommonReader::on_requested_incompatible_qos( } void CommonReader::on_sample_lost( - fastrtps::rtps::RTPSReader*, + fastdds::rtps::RTPSReader*, int32_t sample_lost_since_last_update) noexcept { - logWarning(DDSPIPE_RTPS_COMMONREADER_LISTENER, + EPROSIMA_LOG_WARNING(DDSPIPE_RTPS_COMMONREADER_LISTENER, "SAMPLE_LOST | On reader " << *this << " a data sample was lost and will not be received"); monitor_msg_lost(topic_, participant_id_); } void CommonReader::on_sample_rejected( - fastrtps::rtps::RTPSReader*, + fastdds::rtps::RTPSReader*, eprosima::fastdds::dds::SampleRejectedStatusKind reason, - const fastrtps::rtps::CacheChange_t* const change) noexcept + const fastdds::rtps::CacheChange_t* const change) noexcept { std::string reason_str; switch (reason) @@ -492,15 +515,15 @@ void CommonReader::on_sample_rejected( reason_str = "UNKNOWN"; break; } - logInfo(DDSPIPE_RTPS_COMMONREADER_LISTENER, + EPROSIMA_LOG_INFO(DDSPIPE_RTPS_COMMONREADER_LISTENER, "Reader " << *this << " rejected a sample from " << change->writerGUID << ". Reason: " << reason_str); } void CommonReader::on_incompatible_type( - fastrtps::rtps::RTPSReader* reader) noexcept + fastdds::rtps::RTPSReader* reader) noexcept { - logWarning(DDSPIPE_RTPS_COMMONREADER_LISTENER, + EPROSIMA_LOG_WARNING(DDSPIPE_RTPS_COMMONREADER_LISTENER, "TOPIC_MISMATCH_TYPE | Reader " << *this << " discovered a Writer with a matching Topic name but with an incompatible type"); @@ -509,12 +532,12 @@ void CommonReader::on_incompatible_type( } utils::ReturnCode CommonReader::is_data_correct_( - const fastrtps::rtps::CacheChange_t* received_change) const noexcept + const fastdds::rtps::CacheChange_t* received_change) const noexcept { // Check that the guid is consistent - if (received_change->writerGUID == fastrtps::rtps::GUID_t::unknown()) + if (received_change->writerGUID == fastdds::rtps::GUID_t::unknown()) { - logWarning(DDSPIPE_RTPS_COMMONREADER_LISTENER, + EPROSIMA_LOG_WARNING(DDSPIPE_RTPS_COMMONREADER_LISTENER, "Error taking data without correct writer GUID."); return utils::ReturnCode::RETCODE_ERROR; @@ -524,9 +547,9 @@ utils::ReturnCode CommonReader::is_data_correct_( if (!(received_change->serializedPayload.max_size > 0)) { // Data with 0 bytes is only correct if keyed topic and if data is being disposed - if (!(topic_.topic_qos.keyed && received_change->kind != eprosima::fastrtps::rtps::ChangeKind_t::ALIVE)) + if (!(topic_.topic_qos.keyed && received_change->kind != eprosima::fastdds::rtps::ChangeKind_t::ALIVE)) { - logWarning(DDSPIPE_RTPS_COMMONREADER_LISTENER, + EPROSIMA_LOG_WARNING(DDSPIPE_RTPS_COMMONREADER_LISTENER, "Error taking data with length " << received_change->serializedPayload.length << "."); return utils::ReturnCode::RETCODE_ERROR; diff --git a/ddspipe_participants/src/cpp/reader/rtps/SimpleReader.cpp b/ddspipe_participants/src/cpp/reader/rtps/SimpleReader.cpp index 5f80bdaa..3f4f7789 100644 --- a/ddspipe_participants/src/cpp/reader/rtps/SimpleReader.cpp +++ b/ddspipe_participants/src/cpp/reader/rtps/SimpleReader.cpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include -#include +#include +#include #include #include @@ -28,12 +28,12 @@ SimpleReader::SimpleReader( const core::types::ParticipantId& participant_id, const core::types::DdsTopic& topic, const std::shared_ptr& payload_pool, - fastrtps::rtps::RTPSParticipant* rtps_participant) + fastdds::rtps::RTPSParticipant* rtps_participant) : CommonReader( participant_id, topic, payload_pool, rtps_participant, reckon_history_attributes_(topic), reckon_reader_attributes_(topic), - reckon_topic_attributes_(topic), + reckon_topic_description_(topic), reckon_reader_qos_(topic)) { } diff --git a/ddspipe_participants/src/cpp/reader/rtps/SpecificQoSReader.cpp b/ddspipe_participants/src/cpp/reader/rtps/SpecificQoSReader.cpp index da05dbb3..31b6b2da 100644 --- a/ddspipe_participants/src/cpp/reader/rtps/SpecificQoSReader.cpp +++ b/ddspipe_participants/src/cpp/reader/rtps/SpecificQoSReader.cpp @@ -13,8 +13,8 @@ // limitations under the License. -#include -#include +#include +#include #include #include @@ -31,20 +31,20 @@ SpecificQoSReader::SpecificQoSReader( const core::types::ParticipantId& participant_id, const core::types::DdsTopic& topic, const std::shared_ptr& payload_pool, - fastrtps::rtps::RTPSParticipant* rtps_participant, + fastdds::rtps::RTPSParticipant* rtps_participant, const std::shared_ptr& discovery_database) : CommonReader( participant_id, topic, payload_pool, rtps_participant, reckon_history_attributes_(topic), reckon_reader_attributes_(topic), - reckon_topic_attributes_(topic), + reckon_topic_description_(topic), reckon_reader_qos_(topic)) , discovery_database_(discovery_database) { } void SpecificQoSReader::fill_received_data_( - const fastrtps::rtps::CacheChange_t& received_change, + const fastdds::rtps::CacheChange_t& received_change, core::types::RtpsPayloadData& data_to_fill) const noexcept { CommonReader::fill_received_data_(received_change, data_to_fill); @@ -61,7 +61,7 @@ void SpecificQoSReader::fill_received_data_( { // Get a message from a writer not in database, this is an error. // Remove data and make as it has not been received. - logError( + EPROSIMA_LOG_ERROR( DDSPIPE_SpecificQoSReader, "Received a message from Writer " << data_to_fill.source_guid << " that is not stored in DB."); } diff --git a/ddspipe_participants/src/cpp/testing/random_values.cpp b/ddspipe_participants/src/cpp/testing/random_values.cpp index 2f535513..12e4f8c0 100644 --- a/ddspipe_participants/src/cpp/testing/random_values.cpp +++ b/ddspipe_participants/src/cpp/testing/random_values.cpp @@ -31,8 +31,7 @@ Address random_address( DiscoveryServerConnectionAddress random_connection_address( unsigned int seed /* = 0 */, - unsigned int size /* = 1 */, - bool ros /* = false */) + unsigned int size /* = 1 */) { std::set
addresses; for (unsigned int i = 0; i < size; ++i) @@ -42,7 +41,6 @@ DiscoveryServerConnectionAddress random_connection_address( } return DiscoveryServerConnectionAddress( - core::testing::random_guid_prefix(seed, ros), addresses ); } diff --git a/ddspipe_participants/src/cpp/types/address/Address.cpp b/ddspipe_participants/src/cpp/types/address/Address.cpp index f7e0e774..2f5bf16d 100644 --- a/ddspipe_participants/src/cpp/types/address/Address.cpp +++ b/ddspipe_participants/src/cpp/types/address/Address.cpp @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include +#include #include #include @@ -74,7 +74,7 @@ Address::Address( } catch (const utils::DNSException& ) { - logWarning( + EPROSIMA_LOG_WARNING( DDSPIPE_ADDRESS, "Address created without IP because given domain " << domain << " was not found."); } } @@ -114,7 +114,7 @@ Address::Address( } catch (const utils::DNSException& ) { - logWarning( + EPROSIMA_LOG_WARNING( DDSPIPE_ADDRESS, "Address created without IP because given domain " << domain << " was not found."); } } @@ -280,13 +280,13 @@ bool Address::operator ==( bool Address::is_ipv4_correct( const IpType& ip) noexcept { - return eprosima::fastrtps::rtps::IPLocator::isIPv4(ip); + return eprosima::fastdds::rtps::IPLocator::isIPv4(ip); } bool Address::is_ipv6_correct( const IpType& ip) noexcept { - return eprosima::fastrtps::rtps::IPLocator::isIPv6(ip); + return eprosima::fastdds::rtps::IPLocator::isIPv6(ip); } PortType Address::default_port() noexcept @@ -328,7 +328,7 @@ IpType Address::resolve_dns( IpVersion ip_version) { std::pair, std::set> dns_response = - fastrtps::rtps::IPLocator::resolveNameDNS(domain); + fastdds::rtps::IPLocator::resolveNameDNS(domain); if (ip_version == IpVersion::v4) { @@ -339,7 +339,7 @@ IpType Address::resolve_dns( } else { - logInfo( + EPROSIMA_LOG_INFO( DDSPIPE_ADDRESS, "Getting first IpVersion::v4: " << dns_response.first.begin()->data() << " for Domain name: " << domain << @@ -356,7 +356,7 @@ IpType Address::resolve_dns( } else { - logInfo( + EPROSIMA_LOG_INFO( DDSPIPE_ADDRESS, "Getting first IpVersion::v6: " << dns_response.second.begin()->data() << " for Domain name: " << domain << @@ -370,7 +370,7 @@ std::pair Address::resolve_dns( DomainType domain) { std::pair, std::set> dns_response = - fastrtps::rtps::IPLocator::resolveNameDNS(domain); + fastdds::rtps::IPLocator::resolveNameDNS(domain); if (dns_response.first.empty()) { @@ -383,7 +383,7 @@ std::pair Address::resolve_dns( } else { - logInfo( + EPROSIMA_LOG_INFO( DDSPIPE_ADDRESS, "Getting first IpVersion::v6: " << dns_response.second.begin()->data() << " for Domain name: " << domain << @@ -393,7 +393,7 @@ std::pair Address::resolve_dns( } else { - logInfo( + EPROSIMA_LOG_INFO( DDSPIPE_ADDRESS, "Getting first IpVersion::v4: " << dns_response.first.begin()->data() << " for Domain name: " << domain << diff --git a/ddspipe_participants/src/cpp/types/address/DiscoveryServerConnectionAddress.cpp b/ddspipe_participants/src/cpp/types/address/DiscoveryServerConnectionAddress.cpp index d23de30c..550ea9e9 100644 --- a/ddspipe_participants/src/cpp/types/address/DiscoveryServerConnectionAddress.cpp +++ b/ddspipe_participants/src/cpp/types/address/DiscoveryServerConnectionAddress.cpp @@ -20,18 +20,11 @@ namespace participants { namespace types { DiscoveryServerConnectionAddress::DiscoveryServerConnectionAddress( - core::types::GuidPrefix discovery_server_guid, std::set
addresses) - : discovery_server_guid_prefix_(discovery_server_guid) - , addresses_(addresses) + : addresses_(addresses) { } -core::types::GuidPrefix DiscoveryServerConnectionAddress::discovery_server_guid_prefix() const noexcept -{ - return discovery_server_guid_prefix_; -} - std::set
DiscoveryServerConnectionAddress::addresses() const noexcept { return addresses_; @@ -39,11 +32,6 @@ std::set
DiscoveryServerConnectionAddress::addresses() const noexcept bool DiscoveryServerConnectionAddress::is_valid() const noexcept { - if (!discovery_server_guid_prefix_.is_valid()) - { - return false; - } - for (auto address : addresses_) { if (address.is_valid()) @@ -58,30 +46,20 @@ bool DiscoveryServerConnectionAddress::is_valid() const noexcept bool DiscoveryServerConnectionAddress::operator <( const DiscoveryServerConnectionAddress& other) const noexcept { - if (this->discovery_server_guid_prefix() == other.discovery_server_guid_prefix()) - { - // Same Guid - return this->addresses() < other.addresses(); - } - else - { - // Different guid - return this->discovery_server_guid_prefix() < other.discovery_server_guid_prefix(); - } + return this->addresses() < other.addresses(); } bool DiscoveryServerConnectionAddress::operator ==( const DiscoveryServerConnectionAddress& other) const noexcept { - return (this->discovery_server_guid_prefix() == other.discovery_server_guid_prefix()) && - (this->addresses() == other.addresses()); + return (this->addresses() == other.addresses()); } std::ostream& operator <<( std::ostream& output, const DiscoveryServerConnectionAddress& address) { - output << "{{" << address.discovery_server_guid_prefix() << "}["; + output << "{["; for (auto a : address.addresses()) { output << a << ","; diff --git a/ddspipe_participants/src/cpp/types/dds/TopicDataType.cpp b/ddspipe_participants/src/cpp/types/dds/TopicDataType.cpp index d5f53e6e..54280e63 100644 --- a/ddspipe_participants/src/cpp/types/dds/TopicDataType.cpp +++ b/ddspipe_participants/src/cpp/types/dds/TopicDataType.cpp @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include + #include #include @@ -27,21 +29,23 @@ namespace dds { using eprosima::ddspipe::core::types::operator <<; TopicDataType::TopicDataType( + const std::shared_ptr& payload_pool, const std::string& type_name, - const bool keyed, - const std::shared_ptr& payload_pool) - : type_name_(type_name) + const fastdds::dds::xtypes::TypeIdentifierPair& type_identifiers, + const bool keyed) + : payload_pool_(payload_pool) + , type_name_(type_name) , keyed_(keyed) - , payload_pool_(payload_pool) { // Set topic data - m_typeSize = 4; - m_isGetKeyDefined = keyed_; - auto_fill_type_object(false); - auto_fill_type_information(false); + max_serialized_type_size = 4; + is_compute_key_provided = keyed_; // Set name - setName(type_name_.c_str()); + set_name(type_name_.c_str()); + + // Set Type Identifiers + type_identifiers_ = type_identifiers; } TopicDataType::~TopicDataType() @@ -50,10 +54,11 @@ TopicDataType::~TopicDataType() } bool TopicDataType::serialize( - void* data, - fastrtps::rtps::SerializedPayload_t* target_payload) + const void* data, + fastdds::rtps::SerializedPayload_t& target_payload, + fastdds::dds::DataRepresentationId_t data_representation) { - DataType* src_payload = static_cast(data); + const DataType* src_payload = static_cast(data); logDebug(DDSPIPE_DDS_TYPESUPPORT, "Serializing data " << *src_payload << "."); @@ -62,68 +67,76 @@ bool TopicDataType::serialize( // The src and dst Payload Pools are the same. The payload can be referenced. // We do not call get_payload since Fast-DDS doesn't call release_payload internally. // If we did, there would be leaks. - target_payload->data = src_payload->payload.data; + target_payload.data = src_payload->payload.data; } else { - logWarning(DDSPIPE_DDS_TYPESUPPORT, "Copying the payload between two different payload pools."); + EPROSIMA_LOG_WARNING(DDSPIPE_DDS_TYPESUPPORT, "Copying the payload between two different payload pools."); // The src and dst Payload Pools are different. The payload must be copied. - target_payload->copy(&src_payload->payload); + target_payload.copy(&src_payload->payload); } return true; } bool TopicDataType::deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* src_payload, + fastdds::rtps::SerializedPayload_t& src_payload, void* data) { - logDebug(DDSPIPE_DDS_TYPESUPPORT, "Deserializing data " << *src_payload << "."); + logDebug(DDSPIPE_DDS_TYPESUPPORT, "Deserializing data " << src_payload << "."); DataType* target_payload = static_cast(data); // Get data and store it in PayloadPool - eprosima::fastrtps::rtps::IPayloadPool* payload_owner = - static_cast(payload_pool_.get()); - - payload_pool_->get_payload(*src_payload, payload_owner, target_payload->payload); + payload_pool_->get_payload(src_payload, target_payload->payload); return true; } -std::function TopicDataType::getSerializedSizeProvider( - void* data) +uint32_t TopicDataType::calculate_serialized_size( + const void* const data, + fastdds::dds::DataRepresentationId_t /* data_representation */) { - return [data]() -> uint32_t - { - auto p = static_cast(data); - return p->payload.length; - }; + const auto p = static_cast(data); + return p->payload.length; +} + +bool TopicDataType::compute_key( + fastdds::rtps::SerializedPayload_t& payload, + fastdds::rtps::InstanceHandle_t& handle, + bool /* = false */) +{ + // NOTE: This method returns false because Fast DDS always sends the KEY_HASH in inline QoS. + // As a result, the reader will never call this method when communicating with a Fast DDS writer. + // This would only be needed if receiving data from another DDS vendor that omits the KEY_HASH. + // Workaround in that case (different DDS vendor that omits KEY_HASH): set expects_inline_qos_ to + // true in DataReaderQos + return false; } -bool TopicDataType::getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* handle, +bool TopicDataType::compute_key( + const void* const data, + fastdds::rtps::InstanceHandle_t& handle, bool /* = false */) { - if (m_isGetKeyDefined) + if (is_compute_key_provided) { // Load the instanceHandle from data into handle - auto p = static_cast(data); - *handle = p->instanceHandle; + const auto p = static_cast(data); + handle = p->instanceHandle; return true; } return false; } -void* TopicDataType::createData() +void* TopicDataType::create_data() { return reinterpret_cast(new DataType()); } -void TopicDataType::deleteData( +void TopicDataType::delete_data( void* data) { delete(reinterpret_cast(data)); diff --git a/ddspipe_participants/src/cpp/types/security/tls/TlsConfiguration.cpp b/ddspipe_participants/src/cpp/types/security/tls/TlsConfiguration.cpp index 0289af91..c2d5e963 100644 --- a/ddspipe_participants/src/cpp/types/security/tls/TlsConfiguration.cpp +++ b/ddspipe_participants/src/cpp/types/security/tls/TlsConfiguration.cpp @@ -61,7 +61,7 @@ void TlsConfiguration::enable_tls( { if (!compatible()) { - logError(DDSPIPE_DISCOVERYSERVER_PARTICIPANT, + EPROSIMA_LOG_ERROR(DDSPIPE_DISCOVERYSERVER_PARTICIPANT, "TLS Configuration expected a Client configuration."); throw utils::ConfigurationException("TLS Configuration expected a Client configuration."); } @@ -74,7 +74,7 @@ void TlsConfiguration::enable_tls( { if (!compatible()) { - logError(DDSPIPE_DISCOVERYSERVER_PARTICIPANT, + EPROSIMA_LOG_ERROR(DDSPIPE_DISCOVERYSERVER_PARTICIPANT, "TLS Configuration expected a Server configuration."); throw utils::ConfigurationException("TLS Configuration expected a Server configuration."); } diff --git a/ddspipe_participants/src/cpp/utils/utils.cpp b/ddspipe_participants/src/cpp/utils/utils.cpp index b163f0ce..9bbd5071 100644 --- a/ddspipe_participants/src/cpp/utils/utils.cpp +++ b/ddspipe_participants/src/cpp/utils/utils.cpp @@ -12,6 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include +#include + #include #include @@ -25,28 +28,28 @@ namespace ddspipe { namespace participants { namespace detail { -template +template core::types::Endpoint create_common_endpoint_from_info_( - const DiscoveryInfoKind& info, + const DiscoveryBuiltinTopicData& info, const core::types::ParticipantId participant_discoverer_id) { // Endpoint struct to fill core::types::Endpoint endpoint; // Parse GUID - endpoint.guid = info.info.guid(); + endpoint.guid = info.guid; // Parse TopicQoS // Durability - endpoint.topic.topic_qos.durability_qos.set_value(info.info.m_qos.m_durability.durabilityKind()); + endpoint.topic.topic_qos.durability_qos.set_value(info.durability.durabilityKind()); // Reliability - if (info.info.m_qos.m_reliability.kind == fastdds::dds::BEST_EFFORT_RELIABILITY_QOS) + if (info.reliability.kind == fastdds::dds::BEST_EFFORT_RELIABILITY_QOS) { - endpoint.topic.topic_qos.reliability_qos.set_value(fastrtps::rtps::BEST_EFFORT); + endpoint.topic.topic_qos.reliability_qos.set_value(fastdds::rtps::BEST_EFFORT); } - else if (info.info.m_qos.m_reliability.kind == fastdds::dds::RELIABLE_RELIABILITY_QOS) + else if (info.reliability.kind == fastdds::dds::RELIABLE_RELIABILITY_QOS) { - endpoint.topic.topic_qos.reliability_qos.set_value(fastrtps::rtps::RELIABLE); + endpoint.topic.topic_qos.reliability_qos.set_value(fastdds::rtps::RELIABLE); } else { @@ -55,23 +58,29 @@ core::types::Endpoint create_common_endpoint_from_info_( "Invalid ReliabilityQoS value found while parsing DiscoveryInfo for Endpoint creation."); } // Set Topic with Partitions - endpoint.topic.topic_qos.use_partitions.set_value(!info.info.m_qos.m_partition.empty()); + endpoint.topic.topic_qos.use_partitions.set_value(!info.partition.empty()); // Set Topic with ownership - endpoint.topic.topic_qos.ownership_qos.set_value(info.info.m_qos.m_ownership.kind); + endpoint.topic.topic_qos.ownership_qos.set_value(info.ownership.kind); // Set Topic key - endpoint.topic.topic_qos.keyed.set_value(info.info.topicKind() == eprosima::fastrtps::rtps::TopicKind_t::WITH_KEY); + endpoint.topic.topic_qos.keyed.set_value(info.topic_kind == eprosima::fastdds::rtps::TopicKind_t::WITH_KEY); + + // Set TypeIdentifier + endpoint.topic.type_identifiers.type_identifier1( + info.type_information.type_information.complete().typeid_with_size().type_id()); + endpoint.topic.type_identifiers.type_identifier2( + info.type_information.type_information.minimal().typeid_with_size().type_id()); // Parse Topic core::types::DdsTopic info_topic; - endpoint.topic.m_topic_name = std::string(info.info.topicName()); - endpoint.topic.type_name = std::string(info.info.typeName()); + endpoint.topic.m_topic_name = std::string(info.topic_name); + endpoint.topic.type_name = std::string(info.type_name); endpoint.topic.m_internal_type_discriminator = core::types::INTERNAL_TOPIC_TYPE_RTPS; endpoint.topic.m_topic_discoverer = participant_discoverer_id; // Parse specific QoS of the entity if (endpoint.topic.topic_qos.has_partitions()) { - endpoint.specific_qos.partitions = info.info.m_qos.m_partition; + endpoint.specific_qos.partitions = info.partition; } // Set participant that discovered @@ -83,8 +92,8 @@ core::types::Endpoint create_common_endpoint_from_info_( template<> DDSPIPE_PARTICIPANTS_DllAPI -core::types::Endpoint create_endpoint_from_info_( - const fastrtps::rtps::WriterDiscoveryInfo& info, +core::types::Endpoint create_endpoint_from_info_( + const fastdds::rtps::PublicationBuiltinTopicData& info, const core::types::ParticipantId participant_discoverer_id) { // Create Endpoint from common info @@ -93,7 +102,7 @@ core::types::Endpoint create_endpoint_from_info_ DDSPIPE_PARTICIPANTS_DllAPI -core::types::Endpoint create_endpoint_from_info_( - const fastrtps::rtps::ReaderDiscoveryInfo& info, +core::types::Endpoint create_endpoint_from_info_( + const fastdds::rtps::SubscriptionBuiltinTopicData& info, const core::types::ParticipantId participant_discoverer_id) { // Create Endpoint from common info @@ -125,16 +134,16 @@ core::types::SpecificEndpointQoS specific_qos_of_writer_( } bool come_from_same_participant_( - const fastrtps::rtps::GUID_t src_guid, - const fastrtps::rtps::GUID_t target_guid) noexcept + const fastdds::rtps::GUID_t src_guid, + const fastdds::rtps::GUID_t target_guid) noexcept { return src_guid.guidPrefix == target_guid.guidPrefix; } -fastrtps::rtps::GUID_t guid_from_instance_handle( - const fastrtps::rtps::InstanceHandle_t& ihandle) noexcept +fastdds::rtps::GUID_t guid_from_instance_handle( + const fastdds::rtps::InstanceHandle_t& ihandle) noexcept { - return fastrtps::rtps::iHandle2GUID(ihandle); + return fastdds::rtps::iHandle2GUID(ihandle); } } /* namespace detail */ diff --git a/ddspipe_participants/src/cpp/writer/auxiliar/BaseWriter.cpp b/ddspipe_participants/src/cpp/writer/auxiliar/BaseWriter.cpp index 842dfb0e..decbc911 100644 --- a/ddspipe_participants/src/cpp/writer/auxiliar/BaseWriter.cpp +++ b/ddspipe_participants/src/cpp/writer/auxiliar/BaseWriter.cpp @@ -13,6 +13,8 @@ // limitations under the License. #include +#include + #include #include @@ -71,24 +73,19 @@ utils::ReturnCode BaseWriter::write( { std::lock_guard lock(mutex_); - if (enabled_.load()) - { - if (!should_send_sample_()) - { - return utils::ReturnCode::RETCODE_OK; - } - else - { - return write_nts_(data); - } - - } - else + if (!enabled_.load()) { logDevError(DDSPIPE_BASEWRITER, "Attempt to write data from disabled Writer in topic in Participant " << participant_id_); return utils::ReturnCode::RETCODE_NOT_ENABLED; } + + if (!should_send_sample_()) + { + return utils::ReturnCode::RETCODE_OK; + } + + return write_nts_(data); } void BaseWriter::enable_() noexcept diff --git a/ddspipe_participants/src/cpp/writer/auxiliar/RtpsEchoWriter.cpp b/ddspipe_participants/src/cpp/writer/auxiliar/RtpsEchoWriter.cpp index a1e6480f..64389393 100644 --- a/ddspipe_participants/src/cpp/writer/auxiliar/RtpsEchoWriter.cpp +++ b/ddspipe_participants/src/cpp/writer/auxiliar/RtpsEchoWriter.cpp @@ -13,6 +13,7 @@ // limitations under the License. #include +#include #include diff --git a/ddspipe_participants/src/cpp/writer/dds/CommonWriter.cpp b/ddspipe_participants/src/cpp/writer/dds/CommonWriter.cpp index bfb4d46b..0ed6bba9 100644 --- a/ddspipe_participants/src/cpp/writer/dds/CommonWriter.cpp +++ b/ddspipe_participants/src/cpp/writer/dds/CommonWriter.cpp @@ -13,9 +13,9 @@ // limitations under the License. -#include -#include -#include +#include +#include +#include #include #include @@ -49,13 +49,14 @@ CommonWriter::~CommonWriter() dds_participant_->delete_publisher(dds_publisher_); } - logInfo(DDSPIPE_DDS_WRITER, "Deleting CommonWriter created in Participant " << + EPROSIMA_LOG_INFO(DDSPIPE_DDS_WRITER, "Deleting CommonWriter created in Participant " << participant_id_ << " for topic " << topic_); } void CommonWriter::init() { - logInfo(DDSPIPE_DDS_WRITER, "Initializing writer in " << participant_id_ << " for topic " << topic_ << "."); + EPROSIMA_LOG_INFO(DDSPIPE_DDS_WRITER, + "Initializing writer in " << participant_id_ << " for topic " << topic_ << "."); // Create publisher dds_publisher_ = dds_participant_->create_publisher( @@ -69,21 +70,12 @@ void CommonWriter::init() participant_id_ << " in topic " << topic_ << "."); } - #if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 12 - writer_ = dds_publisher_->create_datawriter_with_payload_pool( - dds_topic_, - reckon_writer_qos_(), - payload_pool_, - nullptr, - eprosima::fastdds::dds::StatusMask::all()); - #else writer_ = dds_publisher_->create_datawriter( dds_topic_, reckon_writer_qos_(), nullptr, eprosima::fastdds::dds::StatusMask::all(), payload_pool_); - #endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 if (!writer_) { @@ -114,7 +106,7 @@ CommonWriter::CommonWriter( utils::ReturnCode CommonWriter::write_nts_( core::IRoutingData& data) noexcept { - logInfo(DDSPIPE_DDS_WRITER, "Writing data in " << participant_id_ << " for topic " << topic_ << "."); + EPROSIMA_LOG_INFO(DDSPIPE_DDS_WRITER, "Writing data in " << participant_id_ << " for topic " << topic_ << "."); auto& rtps_data = dynamic_cast(data); @@ -125,14 +117,7 @@ utils::ReturnCode CommonWriter::write_nts_( } else { - if (payload_pool_->write(writer_, &rtps_data)) - { - return utils::ReturnCode::RETCODE_OK; - } - else - { - return utils::ReturnCode::RETCODE_ERROR; - } + return payload_pool_->write(writer_, &rtps_data); } } @@ -182,7 +167,7 @@ fastdds::dds::DataWriterQos CommonWriter::reckon_writer_qos_() const noexcept } // Set minimum deadline so it matches with everything - qos.deadline().period = eprosima::fastrtps::Duration_t(0); + qos.deadline().period = eprosima::fastdds::dds::Duration_t(0); return qos; } diff --git a/ddspipe_participants/src/cpp/writer/dds/MultiWriter.cpp b/ddspipe_participants/src/cpp/writer/dds/MultiWriter.cpp index 497119bd..6f14ed87 100644 --- a/ddspipe_participants/src/cpp/writer/dds/MultiWriter.cpp +++ b/ddspipe_participants/src/cpp/writer/dds/MultiWriter.cpp @@ -13,9 +13,9 @@ // limitations under the License. -#include -#include -#include +#include +#include +#include #include #include @@ -56,7 +56,7 @@ MultiWriter::~MultiWriter() writer.second->disable(); } - logInfo(DDSPIPE_RTPS_WRITER, "Deleting MultiWriter created in Participant " << + EPROSIMA_LOG_INFO(DDSPIPE_RTPS_WRITER, "Deleting MultiWriter created in Participant " << participant_id_ << " for topic " << topic_); } diff --git a/ddspipe_participants/src/cpp/writer/dds/SimpleWriter.cpp b/ddspipe_participants/src/cpp/writer/dds/SimpleWriter.cpp index 59dd746a..e3c844b2 100644 --- a/ddspipe_participants/src/cpp/writer/dds/SimpleWriter.cpp +++ b/ddspipe_participants/src/cpp/writer/dds/SimpleWriter.cpp @@ -13,9 +13,9 @@ // limitations under the License. -#include -#include -#include +#include +#include +#include #include #include diff --git a/ddspipe_participants/src/cpp/writer/dynamic_types/SchemaWriter.cpp b/ddspipe_participants/src/cpp/writer/dynamic_types/SchemaWriter.cpp index 4c09e45c..a678610d 100644 --- a/ddspipe_participants/src/cpp/writer/dynamic_types/SchemaWriter.cpp +++ b/ddspipe_participants/src/cpp/writer/dynamic_types/SchemaWriter.cpp @@ -49,7 +49,7 @@ utils::ReturnCode SchemaWriter::write_nts_( { auto& rtps_data = dynamic_cast(data); - logInfo(DDSPIPE_SCHEMA_WRITER, + EPROSIMA_LOG_INFO(DDSPIPE_SCHEMA_WRITER, "Data in topic: " << topic_ << " received: " << rtps_data.payload @@ -62,7 +62,7 @@ utils::ReturnCode SchemaWriter::write_nts_( } catch (const utils::Exception& e) { - logWarning( + EPROSIMA_LOG_WARNING( DDSPIPE_SCHEMA_WRITER, "Error writting data in topic " << topic_ << " : <" << e.what() << ">."); return utils::ReturnCode::RETCODE_ERROR; diff --git a/ddspipe_participants/src/cpp/writer/dynamic_types/TypeObjectWriter.cpp b/ddspipe_participants/src/cpp/writer/dynamic_types/TypeObjectWriter.cpp index aceaa1eb..7222908a 100644 --- a/ddspipe_participants/src/cpp/writer/dynamic_types/TypeObjectWriter.cpp +++ b/ddspipe_participants/src/cpp/writer/dynamic_types/TypeObjectWriter.cpp @@ -18,8 +18,7 @@ #include -#include -#include +#include #include #include @@ -52,11 +51,13 @@ utils::ReturnCode TypeObjectWriter::write_nts_( // Add schema try { - schema_handler_->add_schema(dynamic_type_data.dynamic_type); + assert(fastdds::dds::xtypes::EK_COMPLETE == dynamic_type_data.type_identifier._d()); + schema_handler_->add_schema( + dynamic_type_data.dynamic_type, dynamic_type_data.type_identifier); } catch (const utils::Exception& e) { - logError( + EPROSIMA_LOG_ERROR( DDSPIPE_TYPEOBJECT_WRITER, "Error generating schema for type " << dynamic_type_data.dynamic_type->get_name() << " : <" << e.what() << ">."); diff --git a/ddspipe_participants/src/cpp/writer/rpc/SimpleWriter.cpp b/ddspipe_participants/src/cpp/writer/rpc/SimpleWriter.cpp index c41c4322..3a8cd234 100644 --- a/ddspipe_participants/src/cpp/writer/rpc/SimpleWriter.cpp +++ b/ddspipe_participants/src/cpp/writer/rpc/SimpleWriter.cpp @@ -13,9 +13,9 @@ // limitations under the License. -#include -#include -#include +#include +#include +#include #include #include @@ -37,22 +37,22 @@ SimpleWriter::SimpleWriter( const core::types::ParticipantId& participant_id, const core::types::DdsTopic& topic, const std::shared_ptr& payload_pool, - fastrtps::rtps::RTPSParticipant* rtps_participant, + fastdds::rtps::RTPSParticipant* rtps_participant, const bool repeater /* = false */) : CommonWriter( participant_id, topic, payload_pool, rtps_participant, repeater, reckon_history_attributes_(topic), reckon_writer_attributes_(topic), - reckon_topic_attributes_(topic), + reckon_topic_description_(topic), reckon_writer_qos_(topic), reckon_cache_change_pool_configuration_(topic)) { - logInfo(DDSPIPE_RPC_WRITER, "Creating RPC Writer for topic " << topic_); + EPROSIMA_LOG_INFO(DDSPIPE_RPC_WRITER, "Creating RPC Writer for topic " << topic_); } utils::ReturnCode SimpleWriter::fill_to_send_data_( - fastrtps::rtps::CacheChange_t* to_send_change_to_fill, - eprosima::fastrtps::rtps::WriteParams& to_send_params, + fastdds::rtps::CacheChange_t* to_send_change_to_fill, + fastdds::rtps::WriteParams& to_send_params, const core::types::RtpsPayloadData& data) const noexcept { CommonWriter::fill_to_send_data_( @@ -70,7 +70,7 @@ utils::ReturnCode SimpleWriter::fill_to_send_data_( } void SimpleWriter::fill_sent_data_( - const eprosima::fastrtps::rtps::WriteParams& sent_params, + const fastdds::rtps::WriteParams& sent_params, core::types::RtpsPayloadData& data_to_fill) const noexcept { CommonWriter::fill_sent_data_( diff --git a/ddspipe_participants/src/cpp/writer/rtps/CommonWriter.cpp b/ddspipe_participants/src/cpp/writer/rtps/CommonWriter.cpp index 31cc609d..f38eaf51 100644 --- a/ddspipe_participants/src/cpp/writer/rtps/CommonWriter.cpp +++ b/ddspipe_participants/src/cpp/writer/rtps/CommonWriter.cpp @@ -12,10 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. - -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -23,10 +26,10 @@ #include #include +#include #include #include #include -#include namespace eprosima { namespace ddspipe { @@ -42,12 +45,12 @@ CommonWriter::CommonWriter( const ParticipantId& participant_id, const DdsTopic& topic, const std::shared_ptr& payload_pool, - fastrtps::rtps::RTPSParticipant* rtps_participant, + fastdds::rtps::RTPSParticipant* rtps_participant, const bool repeater, - const fastrtps::rtps::HistoryAttributes& history_attributes, - const fastrtps::rtps::WriterAttributes& writer_attributes, - const fastrtps::TopicAttributes& topic_attributes, - const fastrtps::WriterQos& writer_qos, + const fastdds::rtps::HistoryAttributes& history_attributes, + const fastdds::rtps::WriterAttributes& writer_attributes, + const fastdds::rtps::TopicDescription& topic_description, + const fastdds::dds::WriterQos& writer_qos, const utils::PoolConfiguration& pool_configuration) : BaseWriter(participant_id, topic.topic_qos.max_tx_rate) , rtps_participant_(rtps_participant) @@ -58,7 +61,7 @@ CommonWriter::CommonWriter( , rtps_history_(nullptr) , history_attributes_(history_attributes) , writer_attributes_(writer_attributes) - , topic_attributes_(topic_attributes) + , topic_description_(topic_description) , writer_qos_(writer_qos) , pool_configuration_(pool_configuration) { @@ -82,7 +85,7 @@ CommonWriter::~CommonWriter() } // Delete the CommonWriter the History is cleaned - fastrtps::rtps::RTPSDomain::removeRTPSWriter(rtps_writer_); + fastdds::rtps::RTPSDomain::removeRTPSWriter(rtps_writer_); } // Delete History @@ -91,7 +94,7 @@ CommonWriter::~CommonWriter() delete rtps_history_; } - logInfo(DDSPIPE_RTPS_COMMONWRITER, "Deleting CommonWriter created in Participant " << + EPROSIMA_LOG_INFO(DDSPIPE_RTPS_COMMONWRITER, "Deleting CommonWriter created in Participant " << participant_id_ << " for topic " << topic_); } @@ -100,35 +103,35 @@ void CommonWriter::init() internal_entities_creation_( history_attributes_, writer_attributes_, - topic_attributes_, + topic_description_, writer_qos_, pool_configuration_); } -void CommonWriter::onWriterMatched( - fastrtps::rtps::RTPSWriter*, - fastrtps::rtps::MatchingInfo& info) noexcept +void CommonWriter::on_writer_matched( + fastdds::rtps::RTPSWriter*, + const fastdds::rtps::MatchingInfo& info) noexcept { if (!come_from_this_participant_(info.remoteEndpointGuid)) { - if (info.status == fastrtps::rtps::MatchingStatus::MATCHED_MATCHING) + if (info.status == fastdds::rtps::MatchingStatus::MATCHED_MATCHING) { - logInfo(DDSPIPE_RTPS_COMMONWRITER_LISTENER, + EPROSIMA_LOG_INFO(DDSPIPE_RTPS_COMMONWRITER_LISTENER, "Writer " << *this << " in topic " << topic_.serialize() << " matched with a new Reader with guid " << info.remoteEndpointGuid); } else { - logInfo(DDSPIPE_RTPS_COMMONWRITER_LISTENER, + EPROSIMA_LOG_INFO(DDSPIPE_RTPS_COMMONWRITER_LISTENER, "Writer " << *this << " in topic " << topic_.serialize() << " unmatched with Reader " << info.remoteEndpointGuid); } } } -void CommonWriter::onWriterChangeReceivedByAll( - fastrtps::rtps::RTPSWriter* /*writer*/, - fastrtps::rtps::CacheChange_t* change) +void CommonWriter::on_writer_change_received_by_all( + fastdds::rtps::RTPSWriter* /*writer*/, + fastdds::rtps::CacheChange_t* change) { if (writer_qos_.m_reliability.kind == fastdds::dds::BEST_EFFORT_RELIABILITY_QOS || writer_qos_.m_durability.kind == fastdds::dds::VOLATILE_DURABILITY_QOS) @@ -138,16 +141,16 @@ void CommonWriter::onWriterChangeReceivedByAll( } void CommonWriter::on_offered_incompatible_qos( - fastrtps::rtps::RTPSWriter*, + fastdds::rtps::RTPSWriter*, fastdds::dds::PolicyMask qos) noexcept { - logWarning(DDSPIPE_RTPS_COMMONWRITER_LISTENER, + EPROSIMA_LOG_WARNING(DDSPIPE_RTPS_COMMONWRITER_LISTENER, "Writer " << *this << " found a remote Reader with incompatible QoS: " << utils::qos_policy_mask_to_string(qos)); } bool CommonWriter::come_from_this_participant_( - const fastrtps::rtps::GUID_t guid) const noexcept + const fastdds::rtps::GUID_t guid) const noexcept { return guid.guidPrefix == rtps_writer_->getGuid().guidPrefix; } @@ -166,17 +169,17 @@ utils::ReturnCode CommonWriter::write_nts_( } // Take new Change from history - fastrtps::rtps::CacheChange_t* new_change; + fastdds::rtps::CacheChange_t* new_change; if (topic_.topic_qos.keyed) { - new_change = rtps_writer_->new_change( + new_change = rtps_history_->create_change( rtps_data.kind, rtps_data.instanceHandle); } else { - new_change = rtps_writer_->new_change(rtps_data.kind); + new_change = rtps_history_->create_change(rtps_data.kind); } // If still is not able to get a change, return an error code @@ -190,20 +193,20 @@ utils::ReturnCode CommonWriter::write_nts_( rtps_data.source_guid); // Get params to write (if set) - eprosima::fastrtps::rtps::WriteParams write_params; + fastdds::rtps::WriteParams write_params; // Fill cache change with specific data to send auto ret = fill_to_send_data_(new_change, write_params, rtps_data); - if (!ret) + if (ret != utils::ReturnCode::RETCODE_OK) { - logError(DDSPIPE_RTPS_COMMONWRITER, "Error setting change to send."); + EPROSIMA_LOG_ERROR(DDSPIPE_RTPS_COMMONWRITER, "Error setting change to send."); return ret; } // Send data by adding it to CommonWriter History rtps_history_->add_change(new_change, write_params); - // In the case of BEST_EFFORT, add_change calls onWriterChangeReceivedByAll (which removes the change). + // In the case of BEST_EFFORT, add_change calls on_writer_change_received_by_all (which removes the change). // At this point, write params is now the output of adding change fill_sent_data_(write_params, rtps_data); @@ -212,8 +215,8 @@ utils::ReturnCode CommonWriter::write_nts_( } utils::ReturnCode CommonWriter::fill_to_send_data_( - fastrtps::rtps::CacheChange_t* to_send_change_to_fill, - eprosima::fastrtps::rtps::WriteParams& to_send_params, + fastdds::rtps::CacheChange_t* to_send_change_to_fill, + fastdds::rtps::WriteParams& to_send_params, const RtpsPayloadData& data) const noexcept { if (repeater_) @@ -233,11 +236,9 @@ utils::ReturnCode CommonWriter::fill_to_send_data_( // Get the Payload without copy only if it has length if (data.payload.length > 0) { - eprosima::fastrtps::rtps::IPayloadPool* payload_owner = payload_pool_.get(); if (!payload_pool_->get_payload( - const_cast(data.payload), - payload_owner, - (*to_send_change_to_fill))) + data.payload, + to_send_change_to_fill->serializedPayload)) { logDevError(DDSPIPE_RTPS_COMMONWRITER, "Error getting Payload."); return utils::ReturnCode::RETCODE_ERROR; @@ -254,50 +255,49 @@ utils::ReturnCode CommonWriter::fill_to_send_data_( } void CommonWriter::fill_sent_data_( - const eprosima::fastrtps::rtps::WriteParams& params, + const fastdds::rtps::WriteParams& params, core::types::RtpsPayloadData& data_to_fill) const noexcept { // Do nothing } void CommonWriter::internal_entities_creation_( - const fastrtps::rtps::HistoryAttributes& history_attributes, - const fastrtps::rtps::WriterAttributes& writer_attributes, - const fastrtps::TopicAttributes& topic_attributes, - const fastrtps::WriterQos& writer_qos, + const fastdds::rtps::HistoryAttributes& history_attributes, + const fastdds::rtps::WriterAttributes& writer_attributes, + const fastdds::rtps::TopicDescription& topic_description, + const fastdds::dds::WriterQos& writer_qos, const utils::PoolConfiguration& pool_configuration) { // Copy writer attributes because fast needs it non const (do not ask why) - fastrtps::rtps::WriterAttributes non_const_writer_attributes = writer_attributes; - - // Create History - rtps_history_ = new fastrtps::rtps::WriterHistory(history_attributes); + fastdds::rtps::WriterAttributes non_const_writer_attributes = writer_attributes; // Create CommonWriter // Listener must be set in creation as no callbacks should be missed // It is safe to do so here as object is already created and callbacks do not require anything set in this method if (repeater_) { - logDebug(DDSPIPE_RTPS_COMMONWRITER, "CommonWriter created with repeater filter"); - - rtps_writer_ = fastrtps::rtps::RTPSDomain::createRTPSWriter( - rtps_participant_, - non_const_writer_attributes, + // Create History + rtps_history_ = new fastdds::rtps::WriterHistory( + history_attributes, payload_pool_, - std::make_shared(pool_configuration), - rtps_history_, - this); + std::make_shared(pool_configuration)); + + logDebug(DDSPIPE_RTPS_COMMONWRITER, "CommonWriter created with repeater filter"); } else { - rtps_writer_ = fastrtps::rtps::RTPSDomain::createRTPSWriter( - rtps_participant_, - non_const_writer_attributes, - payload_pool_, - rtps_history_, - this); + // Create History + rtps_history_ = new fastdds::rtps::WriterHistory( + history_attributes, + payload_pool_); } + rtps_writer_ = fastdds::rtps::RTPSDomain::createRTPSWriter( + rtps_participant_, + non_const_writer_attributes, + rtps_history_, + this); + if (!rtps_writer_) { throw utils::InitializationException( @@ -306,10 +306,10 @@ void CommonWriter::internal_entities_creation_( } // Register writer with topic - if (!rtps_participant_->registerWriter(rtps_writer_, topic_attributes, writer_qos)) + if (!rtps_participant_->register_writer(rtps_writer_, topic_description, writer_qos)) { // In case it fails, remove writer and throw exception - fastrtps::rtps::RTPSDomain::removeRTPSWriter(rtps_writer_); + fastdds::rtps::RTPSDomain::removeRTPSWriter(rtps_writer_); throw utils::InitializationException(utils::Formatter() << "Error registering topic " << topic_ << " for Simple RTPSWriter in Participant " << participant_id_); } @@ -327,20 +327,20 @@ void CommonWriter::internal_entities_creation_( rtps_writer_->reader_data_filter(data_filter_.get()); - logInfo( + EPROSIMA_LOG_INFO( DDSPIPE_RTPS_COMMONWRITER, "New CommonWriter created in Participant " << participant_id_ << " for topic " << topic_ << " with guid " << rtps_writer_->getGuid()); } -fastrtps::rtps::HistoryAttributes CommonWriter::reckon_history_attributes_( +fastdds::rtps::HistoryAttributes CommonWriter::reckon_history_attributes_( const core::types::DdsTopic& topic) noexcept { - fastrtps::rtps::HistoryAttributes att; + fastdds::rtps::HistoryAttributes att; att.memoryPolicy = - eprosima::fastrtps::rtps::MemoryManagementPolicy_t::PREALLOCATED_WITH_REALLOC_MEMORY_MODE; + fastdds::rtps::MemoryManagementPolicy_t::PREALLOCATED_WITH_REALLOC_MEMORY_MODE; att.maximumReservedCaches = topic.topic_qos.history_depth; if (att.maximumReservedCaches > 0 && att.initialReservedCaches > att.maximumReservedCaches) @@ -352,10 +352,10 @@ fastrtps::rtps::HistoryAttributes CommonWriter::reckon_history_attributes_( return att; } -fastrtps::rtps::WriterAttributes CommonWriter::reckon_writer_attributes_( +fastdds::rtps::WriterAttributes CommonWriter::reckon_writer_attributes_( const core::types::DdsTopic& topic) noexcept { - fastrtps::rtps::WriterAttributes att; + fastdds::rtps::WriterAttributes att; // Set Durability att.endpoint.durabilityKind = topic.topic_qos.durability_qos; @@ -366,63 +366,94 @@ fastrtps::rtps::WriterAttributes CommonWriter::reckon_writer_attributes_( // Set if topic has key if (topic.topic_qos.keyed) { - att.endpoint.topicKind = eprosima::fastrtps::rtps::WITH_KEY; + att.endpoint.topicKind = fastdds::rtps::WITH_KEY; } else { - att.endpoint.topicKind = eprosima::fastrtps::rtps::NO_KEY; + att.endpoint.topicKind = fastdds::rtps::NO_KEY; } // Other attributes as partitions and ownership are not used in this writer // Set write mode // ATTENTION: Changing this will change the logic of removing changes added. Please be careful. - att.mode = fastrtps::rtps::RTPSWriterPublishMode::SYNCHRONOUS_WRITER; + att.mode = fastdds::rtps::RTPSWriterPublishMode::SYNCHRONOUS_WRITER; return att; } -fastrtps::TopicAttributes CommonWriter::reckon_topic_attributes_( +fastdds::rtps::TopicDescription CommonWriter::reckon_topic_description_( const core::types::DdsTopic& topic) noexcept { - fastrtps::TopicAttributes att; + fastdds::rtps::TopicDescription topic_description; - // Set if topic has key - if (topic.topic_qos.keyed) + topic_description.type_name = topic.type_name; + topic_description.topic_name = topic.m_topic_name; + + // Check TypeIdentifierPair in DdsTopic is not empty + fastdds::dds::xtypes::TypeIdentifierPair empty_type_identifiers; + if (topic.type_identifiers == empty_type_identifiers) { - att.topicKind = eprosima::fastrtps::rtps::WITH_KEY; + return topic_description; } - else + + // Set TypeInformation of the discovered type + fastdds::dds::xtypes::TypeInformation type_information; + + auto try_get_type_information = [&](const fastdds::dds::xtypes::TypeIdentifierPair& identifiers) -> bool + { + return fastdds::dds::RETCODE_OK == + fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry(). + get_type_information( + identifiers, type_information); + }; + + if (!try_get_type_information(topic.type_identifiers)) { - att.topicKind = eprosima::fastrtps::rtps::NO_KEY; + // If get_type_information fails with TypeIdentifierPair try just with complete + fastdds::dds::xtypes::TypeIdentifierPair complete_only; + complete_only.type_identifier1(topic.type_identifiers.type_identifier1()); + + if (!try_get_type_information(complete_only)) + { + // If get_type_information fails with complete TypeIdentifier try just with minimal + fastdds::dds::xtypes::TypeIdentifierPair minimal_only; + minimal_only.type_identifier2(topic.type_identifiers.type_identifier2()); + + if (!try_get_type_information(minimal_only)) + { + EPROSIMA_LOG_WARNING(DDSPIPE_RTPS_COMMONREADER_LISTENER, + "Failed to get TypeInformation for type " << topic.type_name); + + return topic_description; + } + } } - // Set Topic attributes - att.topicName = topic.m_topic_name; - att.topicDataType = topic.type_name; + topic_description.type_information = type_information; - return att; + return topic_description; } -fastrtps::WriterQos CommonWriter::reckon_writer_qos_( +fastdds::dds::WriterQos CommonWriter::reckon_writer_qos_( const core::types::DdsTopic& topic) noexcept { - fastrtps::WriterQos qos; + fastdds::dds::WriterQos qos; // Set Durability qos.m_durability.kind = (topic.topic_qos.is_transient_local() - ? eprosima::fastdds::dds::DurabilityQosPolicyKind_t::TRANSIENT_LOCAL_DURABILITY_QOS - : eprosima::fastdds::dds::DurabilityQosPolicyKind_t::VOLATILE_DURABILITY_QOS); + ? fastdds::dds::DurabilityQosPolicyKind_t::TRANSIENT_LOCAL_DURABILITY_QOS + : fastdds::dds::DurabilityQosPolicyKind_t::VOLATILE_DURABILITY_QOS); // Set Reliability qos.m_reliability.kind = (topic.topic_qos.is_reliable() - ? eprosima::fastdds::dds::ReliabilityQosPolicyKind::RELIABLE_RELIABILITY_QOS - : eprosima::fastdds::dds::ReliabilityQosPolicyKind::BEST_EFFORT_RELIABILITY_QOS); + ? fastdds::dds::ReliabilityQosPolicyKind::RELIABLE_RELIABILITY_QOS + : fastdds::dds::ReliabilityQosPolicyKind::BEST_EFFORT_RELIABILITY_QOS); // Set minimum deadline so it matches with everything - qos.m_deadline.period = eprosima::fastrtps::Duration_t(0); + qos.m_deadline.period = fastdds::dds::Duration_t(0); // Partitions and specific ownership strength are not set in common. diff --git a/ddspipe_participants/src/cpp/writer/rtps/MultiWriter.cpp b/ddspipe_participants/src/cpp/writer/rtps/MultiWriter.cpp index 0a369a4f..cf0fd9e5 100644 --- a/ddspipe_participants/src/cpp/writer/rtps/MultiWriter.cpp +++ b/ddspipe_participants/src/cpp/writer/rtps/MultiWriter.cpp @@ -13,9 +13,9 @@ // limitations under the License. -#include -#include -#include +#include +#include +#include #include #include @@ -39,7 +39,7 @@ MultiWriter::MultiWriter( const ParticipantId& participant_id, const DdsTopic& topic, const std::shared_ptr& payload_pool, - fastrtps::rtps::RTPSParticipant* rtps_participant, + fastdds::rtps::RTPSParticipant* rtps_participant, const bool repeater /* = false */) : BaseWriter(participant_id) , payload_pool_(payload_pool) @@ -62,7 +62,7 @@ MultiWriter::~MultiWriter() delete writer.second; } - logInfo(DDSPIPE_RTPS_WRITER, "Deleting MultiWriter created in Participant " << + EPROSIMA_LOG_INFO(DDSPIPE_RTPS_WRITER, "Deleting MultiWriter created in Participant " << participant_id_ << " for topic " << topic_); } diff --git a/ddspipe_participants/src/cpp/writer/rtps/QoSSpecificWriter.cpp b/ddspipe_participants/src/cpp/writer/rtps/QoSSpecificWriter.cpp index 7bfd9431..a4041eb5 100644 --- a/ddspipe_participants/src/cpp/writer/rtps/QoSSpecificWriter.cpp +++ b/ddspipe_participants/src/cpp/writer/rtps/QoSSpecificWriter.cpp @@ -26,26 +26,26 @@ QoSSpecificWriter::QoSSpecificWriter( const ParticipantId& participant_id, const DdsTopic& topic, const std::shared_ptr& payload_pool, - fastrtps::rtps::RTPSParticipant* rtps_participant, + fastdds::rtps::RTPSParticipant* rtps_participant, const SpecificEndpointQoS& specific_qos, const bool repeater /* = false */) : CommonWriter( participant_id, topic, payload_pool, rtps_participant, repeater , reckon_history_attributes_(topic) , reckon_writer_attributes_(topic) - , reckon_topic_attributes_(topic) + , reckon_topic_description_(topic) , reckon_writer_qos_(specific_qos, topic) // this modifies the qos of the Common Writer , reckon_cache_change_pool_configuration_(topic)) , specific_qos_(specific_qos) { } -fastrtps::WriterQos QoSSpecificWriter::reckon_writer_qos_( +fastdds::dds::WriterQos QoSSpecificWriter::reckon_writer_qos_( const SpecificEndpointQoS& specific_qos, const DdsTopic& topic) noexcept { // Get QoS from parent class - fastrtps::WriterQos qos = CommonWriter::reckon_writer_qos_(topic); + fastdds::dds::WriterQos qos = CommonWriter::reckon_writer_qos_(topic); // Set Partitions if (topic.topic_qos.has_partitions()) diff --git a/ddspipe_participants/src/cpp/writer/rtps/SimpleWriter.cpp b/ddspipe_participants/src/cpp/writer/rtps/SimpleWriter.cpp index e4953953..69b4edbb 100644 --- a/ddspipe_participants/src/cpp/writer/rtps/SimpleWriter.cpp +++ b/ddspipe_participants/src/cpp/writer/rtps/SimpleWriter.cpp @@ -13,9 +13,9 @@ // limitations under the License. -#include -#include -#include +#include +#include +#include #include #include @@ -35,13 +35,13 @@ SimpleWriter::SimpleWriter( const core::types::ParticipantId& participant_id, const core::types::DdsTopic& topic, const std::shared_ptr& payload_pool, - fastrtps::rtps::RTPSParticipant* rtps_participant, + fastdds::rtps::RTPSParticipant* rtps_participant, const bool repeater /* = false */) : CommonWriter( participant_id, topic, payload_pool, rtps_participant, repeater, reckon_history_attributes_(topic), reckon_writer_attributes_(topic), - reckon_topic_attributes_(topic), + reckon_topic_description_(topic), reckon_writer_qos_(topic), reckon_cache_change_pool_configuration_(topic)) { diff --git a/ddspipe_participants/src/cpp/writer/rtps/filter/RepeaterDataFilter.cpp b/ddspipe_participants/src/cpp/writer/rtps/filter/RepeaterDataFilter.cpp index d95c00ff..444630a8 100644 --- a/ddspipe_participants/src/cpp/writer/rtps/filter/RepeaterDataFilter.cpp +++ b/ddspipe_participants/src/cpp/writer/rtps/filter/RepeaterDataFilter.cpp @@ -13,8 +13,8 @@ // limitations under the License. -#include -#include +#include +#include #include #include @@ -26,8 +26,8 @@ namespace participants { namespace rtps { bool RepeaterDataFilter::is_relevant( - const fastrtps::rtps::CacheChange_t& change, - const fastrtps::rtps::GUID_t& reader_guid) const + const fastdds::rtps::CacheChange_t& change, + const fastdds::rtps::GUID_t& reader_guid) const { if (!SelfDataFilter::is_relevant(change, reader_guid)) { diff --git a/ddspipe_participants/src/cpp/writer/rtps/filter/SelfDataFilter.cpp b/ddspipe_participants/src/cpp/writer/rtps/filter/SelfDataFilter.cpp index 03876cc4..f3a874de 100644 --- a/ddspipe_participants/src/cpp/writer/rtps/filter/SelfDataFilter.cpp +++ b/ddspipe_participants/src/cpp/writer/rtps/filter/SelfDataFilter.cpp @@ -13,8 +13,8 @@ // limitations under the License. -#include -#include +#include +#include #include #include @@ -26,8 +26,8 @@ namespace participants { namespace rtps { bool SelfDataFilter::is_relevant( - const fastrtps::rtps::CacheChange_t& change, - const fastrtps::rtps::GUID_t& reader_guid) const + const fastdds::rtps::CacheChange_t& change, + const fastdds::rtps::GUID_t& reader_guid) const { // It is relevant only if the reader does not belong to same participant as writer return change.writerGUID.guidPrefix != reader_guid.guidPrefix; diff --git a/ddspipe_participants/src/cpp/xml/XmlHandler.cpp b/ddspipe_participants/src/cpp/xml/XmlHandler.cpp index 450d47b9..e4a7bf08 100644 --- a/ddspipe_participants/src/cpp/xml/XmlHandler.cpp +++ b/ddspipe_participants/src/cpp/xml/XmlHandler.cpp @@ -12,9 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include +#include +#include -#include +#include #include @@ -26,17 +27,21 @@ utils::ReturnCode XmlHandler::load_xml( const XmlHandlerConfiguration& configuration) { // Load default xml profiles - // Note: we assume this function cannot fail - fastrtps::xmlparser::XMLProfileManager::loadDefaultXMLFile(); + fastdds::dds::ReturnCode_t ret = fastdds::dds::DomainParticipantFactory::get_instance()->load_profiles(); + + if (ret != fastdds::dds::RETCODE_OK) + { + return utils::ReturnCode::RETCODE_ERROR; + } // Load string if exist if (configuration.raw.is_set()) { - fastrtps::xmlparser::XMLP_ret res = fastrtps::xmlparser::XMLProfileManager::loadXMLString( + ret = fastdds::dds::DomainParticipantFactory::get_instance()->load_XML_profiles_string( configuration.raw->c_str(), configuration.raw->size()); - if (res != fastrtps::xmlparser::XMLP_ret::XML_OK) + if (ret != fastdds::dds::RETCODE_OK) { return utils::ReturnCode::RETCODE_ERROR; } @@ -45,9 +50,9 @@ utils::ReturnCode XmlHandler::load_xml( // Load files for (const auto& file : configuration.files) { - fastrtps::xmlparser::XMLP_ret res = fastrtps::xmlparser::XMLProfileManager::loadXMLFile(file); + ret = fastdds::dds::DomainParticipantFactory::get_instance()->load_XML_profiles_file(file); - if (res != fastrtps::xmlparser::XMLP_ret::XML_OK) + if (ret != fastdds::dds::RETCODE_OK) { return utils::ReturnCode::RETCODE_ERROR; } diff --git a/ddspipe_participants/src/cpp/xml/XmlHandlerConfiguration.cpp b/ddspipe_participants/src/cpp/xml/XmlHandlerConfiguration.cpp index aa683e6a..a7892574 100644 --- a/ddspipe_participants/src/cpp/xml/XmlHandlerConfiguration.cpp +++ b/ddspipe_participants/src/cpp/xml/XmlHandlerConfiguration.cpp @@ -15,8 +15,6 @@ #include #include -#include - #include namespace eprosima { @@ -27,19 +25,6 @@ namespace participants { bool XmlHandlerConfiguration::is_valid( utils::Formatter& error_msg) const noexcept { - // TODO decide if correct xml format must be checked in this function - // Check string - // if (raw.is_set()) - // { - // fastrtps::xmlparser::up_base_node_t _; - // fastrtps::xmlparser::XMLP_ret ret = fastrtps::xmlparser::XMLParser::loadXML(raw, _); - // if (ret != fastrtps::xmlparser::XMLP_ret::XML_OK) - // { - // error_msg << "String " << raw.get_reference() << " is not a valid XML configuration. "; - // return false; - // } - // } - // Check files for (const auto& file : files) { diff --git a/ddspipe_yaml/include/ddspipe_yaml/YamlReader.hpp b/ddspipe_yaml/include/ddspipe_yaml/YamlReader.hpp index 3a7b94f7..467b1fe0 100644 --- a/ddspipe_yaml/include/ddspipe_yaml/YamlReader.hpp +++ b/ddspipe_yaml/include/ddspipe_yaml/YamlReader.hpp @@ -51,14 +51,13 @@ enum YamlReaderVersion * @brief First version. * * @version 0.1.0 - * @version 0.2.0 */ V_1_0, /** * @brief Version 2.0 * - * @version 0.3.0 + * @version 0.1.0 * * - Adds builtin-topics tag. * - Adds participants list. @@ -70,7 +69,7 @@ enum YamlReaderVersion /** * @brief Version 3.0 * - * @version 0.4.0 + * @version 0.1.0 * * - Change wan to initial peers participant * - Add Specs @@ -80,7 +79,7 @@ enum YamlReaderVersion /** * @brief Version 3.1. * - * @version 0.5.0 + * @version 0.2.0 * * - Add XML load by file or raw * - Add xml participant @@ -88,9 +87,9 @@ enum YamlReaderVersion V_3_1, /** - * @brief Latest version. + * @brief Version 4.0. * - * @version 0.6.0 + * @version 0.3.0 * * - Forwarding Routes. * - Remove Unused Entities. @@ -102,6 +101,16 @@ enum YamlReaderVersion */ V_4_0, + /** + * @brief Latest version. + * + * @version 1.0.0 + * + * - Make discovery server's guid prefix optional. + * - Remove server's guid prefix from discovery server clients' connection addresses. + */ + V_5_0, + /** * @brief Main version. * diff --git a/ddspipe_yaml/include/ddspipe_yaml/yaml_configuration_tags.hpp b/ddspipe_yaml/include/ddspipe_yaml/yaml_configuration_tags.hpp index af69c6ec..cd84c6f0 100644 --- a/ddspipe_yaml/include/ddspipe_yaml/yaml_configuration_tags.hpp +++ b/ddspipe_yaml/include/ddspipe_yaml/yaml_configuration_tags.hpp @@ -28,6 +28,7 @@ constexpr const char* VERSION_TAG_V_2_0("v2.0"); //! Version v2.0 constexpr const char* VERSION_TAG_V_3_0("v3.0"); //! Version v3.0 constexpr const char* VERSION_TAG_V_3_1("v3.1"); //! Version v3.1 constexpr const char* VERSION_TAG_V_4_0("v4.0"); //! Version v4.0 +constexpr const char* VERSION_TAG_V_5_0("v5.0"); //! Version v5.0 // Topics related tags constexpr const char* ALLOWLIST_TAG("allowlist"); //! List of allowed topics @@ -143,7 +144,6 @@ constexpr const char* TIMESTAMP_NANOSECONDS_TAG("nanoseconds"); //! TODO: add co constexpr const char* DDS_PUBLISHING_ENABLE_TAG("enable"); //! Whether the publishing is enabled constexpr const char* DDS_PUBLISHING_DOMAIN_TAG("domain"); //! The DDS domain id to publish in constexpr const char* DDS_PUBLISHING_TOPIC_NAME_TAG("topic-name"); //! The DDS topic name to publish in -constexpr const char* DDS_PUBLISHING_PUBLISH_TYPE_TAG("publish-type"); //! Whether the LogEntry type should be published // Custom routes related tags constexpr const char* ROUTES_TAG("routes"); //! Forwarding routes diff --git a/ddspipe_yaml/package.xml b/ddspipe_yaml/package.xml index 39838b53..5b8b670d 100644 --- a/ddspipe_yaml/package.xml +++ b/ddspipe_yaml/package.xml @@ -18,7 +18,7 @@ cmake_utils yamlcpp - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants diff --git a/ddspipe_yaml/project_settings.cmake b/ddspipe_yaml/project_settings.cmake index 0c290e84..12ff026c 100644 --- a/ddspipe_yaml/project_settings.cmake +++ b/ddspipe_yaml/project_settings.cmake @@ -27,7 +27,7 @@ set(MODULE_SUMMARY set(MODULE_FIND_PACKAGES yaml-cpp fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants diff --git a/ddspipe_yaml/src/cpp/YamlReader_participants.cpp b/ddspipe_yaml/src/cpp/YamlReader_participants.cpp index e1ae6e67..8cce876b 100644 --- a/ddspipe_yaml/src/cpp/YamlReader_participants.cpp +++ b/ddspipe_yaml/src/cpp/YamlReader_participants.cpp @@ -137,7 +137,8 @@ void YamlReader::fill( // Optional whitelist interfaces if (YamlReader::is_tag_present(yml, WHITELIST_INTERFACES_TAG)) { - object.whitelist = YamlReader::get_set(yml, WHITELIST_INTERFACES_TAG, version); + object.whitelist = YamlReader::get_set(yml, WHITELIST_INTERFACES_TAG, + version); } // Optional get Transport descriptors @@ -194,7 +195,8 @@ void YamlReader::fill( // Optional whitelist interfaces if (YamlReader::is_tag_present(yml, WHITELIST_INTERFACES_TAG)) { - object.whitelist = YamlReader::get_set(yml, WHITELIST_INTERFACES_TAG, version); + object.whitelist = YamlReader::get_set(yml, WHITELIST_INTERFACES_TAG, + version); } // Optional listening addresses @@ -229,10 +231,22 @@ void YamlReader::fill( YamlReader::get(yml, version); break; - default: + case V_2_0: + case V_3_0: + case V_3_1: + case V_4_0: object.discovery_server_guid_prefix = YamlReader::get(yml, DISCOVERY_SERVER_GUID_PREFIX_TAG, version); break; + + case V_5_0: + default: + if (YamlReader::is_tag_present(yml, DISCOVERY_SERVER_GUID_PREFIX_TAG)) + { + object.discovery_server_guid_prefix = + YamlReader::get(yml, DISCOVERY_SERVER_GUID_PREFIX_TAG, version); + } + break; } } @@ -262,7 +276,8 @@ void YamlReader::fill( // Optional whitelist interfaces if (YamlReader::is_tag_present(yml, WHITELIST_INTERFACES_TAG)) { - object.whitelist = YamlReader::get_set(yml, WHITELIST_INTERFACES_TAG, version); + object.whitelist = YamlReader::get_set(yml, WHITELIST_INTERFACES_TAG, + version); } // Optional listening addresses diff --git a/ddspipe_yaml/src/cpp/YamlReader_types.cpp b/ddspipe_yaml/src/cpp/YamlReader_types.cpp index a542f4bf..cbadb8ef 100644 --- a/ddspipe_yaml/src/cpp/YamlReader_types.cpp +++ b/ddspipe_yaml/src/cpp/YamlReader_types.cpp @@ -98,6 +98,7 @@ YamlReaderVersion YamlReader::get( {VERSION_TAG_V_3_0, YamlReaderVersion::V_3_0}, {VERSION_TAG_V_3_1, YamlReaderVersion::V_3_1}, {VERSION_TAG_V_4_0, YamlReaderVersion::V_4_0}, + {VERSION_TAG_V_5_0, YamlReaderVersion::V_5_0}, }); } @@ -165,24 +166,29 @@ GuidPrefix YamlReader::get( } // ROS DS is optional. - bool ros_id; + bool ros_id = false; bool ros_id_set = is_tag_present(yml, DISCOVERY_SERVER_ID_ROS_TAG); if (ros_id_set) { ros_id = get_scalar(yml, DISCOVERY_SERVER_ID_ROS_TAG); } - // Id is mandatory if guid is not present - uint32_t id = get_scalar(yml, DISCOVERY_SERVER_ID_TAG); + // Id is optional. + uint32_t id = 0; + bool id_set = is_tag_present(yml, DISCOVERY_SERVER_ID_TAG); + if (id_set) + { + id = get_scalar(yml, DISCOVERY_SERVER_ID_TAG); + } - // Create GuidPrefix - if (ros_id_set) + if (ros_id_set || id_set) { return GuidPrefix(ros_id, id); } else { - return GuidPrefix(id); + // Return unknown prefix -> delegate assignment on Fast-DDS + return GuidPrefix(); } } @@ -222,7 +228,7 @@ Address YamlReader::get
( // If neither set, get default if (ip_set && domain_name_set) { - logWarning(ddspipe_YAML, + EPROSIMA_LOG_WARNING(ddspipe_YAML, "Tag <" << ADDRESS_DNS_TAG << "> will not be used as <" << ADDRESS_IP_TAG << "> is set."); domain_name_set = false; } @@ -301,28 +307,22 @@ DiscoveryServerConnectionAddress _get_discovery_server_connection_address_v1( const Yaml& yml, const YamlReaderVersion version) { - // GuidPrefix required - GuidPrefix server_guid = YamlReader::get(yml, version); - // Addresses required std::set
addresses = YamlReader::get_set
(yml, COLLECTION_ADDRESSES_TAG, version); // Create Connection Address - return DiscoveryServerConnectionAddress(server_guid, addresses); + return DiscoveryServerConnectionAddress(addresses); } DiscoveryServerConnectionAddress _get_discovery_server_connection_address_latest( const Yaml& yml, const YamlReaderVersion version) { - // GuidPrefix required - GuidPrefix server_guid = YamlReader::get(yml, DISCOVERY_SERVER_GUID_PREFIX_TAG, version); - // Addresses required std::set
addresses = YamlReader::get_set
(yml, COLLECTION_ADDRESSES_TAG, version); // Create Connection Address - return DiscoveryServerConnectionAddress(server_guid, addresses); + return DiscoveryServerConnectionAddress(addresses); } template <> @@ -362,12 +362,6 @@ void YamlReader::fill( { object.topic_name = get(yml, DDS_PUBLISHING_TOPIC_NAME_TAG, version); } - - // Optional publish type - if (is_tag_present(yml, DDS_PUBLISHING_PUBLISH_TYPE_TAG)) - { - object.publish_type = get(yml, DDS_PUBLISHING_PUBLISH_TYPE_TAG, version); - } } template <> @@ -788,10 +782,14 @@ std::ostream& operator <<( break; case V_4_0: - case LATEST: os << VERSION_TAG_V_4_0; break; + case V_5_0: + case LATEST: + os << VERSION_TAG_V_5_0; + break; + default: utils::tsnh(STR_ENTRY << "Value of YamlReaderVersion out of enumeration."); break; diff --git a/ddspipe_yaml/test/unittest/entities/address/CMakeLists.txt b/ddspipe_yaml/test/unittest/entities/address/CMakeLists.txt index 143b72bb..9983c0c1 100644 --- a/ddspipe_yaml/test/unittest/entities/address/CMakeLists.txt +++ b/ddspipe_yaml/test/unittest/entities/address/CMakeLists.txt @@ -39,7 +39,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES yaml-cpp fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants @@ -72,7 +72,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES yaml-cpp fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants diff --git a/ddspipe_yaml/test/unittest/entities/address/test_units/YamlGetEntityDiscoveryServerAddressTest_get_ds_address.ipp b/ddspipe_yaml/test/unittest/entities/address/test_units/YamlGetEntityDiscoveryServerAddressTest_get_ds_address.ipp index 033cabcf..1eaec143 100644 --- a/ddspipe_yaml/test/unittest/entities/address/test_units/YamlGetEntityDiscoveryServerAddressTest_get_ds_address.ipp +++ b/ddspipe_yaml/test/unittest/entities/address/test_units/YamlGetEntityDiscoveryServerAddressTest_get_ds_address.ipp @@ -44,13 +44,6 @@ TEST(YamlGetEntityDiscoveryServerAddressTest, get_ds_address) { Yaml yml_ds_address; - // Get random guid prefix and add it to yaml - core::types::GuidPrefix guid_prefix = random_guid_prefix(); - Yaml yml_guid; - guid_prefix_to_yaml(yml_guid, guid_prefix); - - yml_ds_address[DISCOVERY_SERVER_GUID_PREFIX_TAG] = yml_guid; - // Get random address and add it to yaml participants::types::Address address = random_address(); Yaml yml_addresses; @@ -70,7 +63,6 @@ TEST(YamlGetEntityDiscoveryServerAddressTest, get_ds_address) YamlReader::get(yml, "ds-address", LATEST); // Check result - ASSERT_EQ(guid_prefix, result.discovery_server_guid_prefix()); ASSERT_EQ(result.addresses().size(), 1u); ASSERT_EQ(address, *result.addresses().begin()); } @@ -79,13 +71,6 @@ TEST(YamlGetEntityDiscoveryServerAddressTest, get_ds_address) { Yaml yml_ds_address; - // Get random guid prefix and add it to yaml - core::types::GuidPrefix guid_prefix = random_guid_prefix(); - Yaml yml_guid; - guid_prefix_to_yaml(yml_guid, guid_prefix); - - yml_ds_address[DISCOVERY_SERVER_GUID_PREFIX_TAG] = yml_guid; - // Get random address and add it to yaml Yaml yml_addresses; std::vector addresses; @@ -111,7 +96,6 @@ TEST(YamlGetEntityDiscoveryServerAddressTest, get_ds_address) YamlReader::get(yml, "ds-address", LATEST); // Check result - ASSERT_EQ(guid_prefix, result.discovery_server_guid_prefix()); ASSERT_EQ(result.addresses().size(), TEST_ADDRESSES_NUMBER); // Check every address introduced in yaml is in result diff --git a/ddspipe_yaml/test/unittest/entities/address/test_units/YamlGetEntityDiscoveryServerAddressTest_get_ds_address_negative.ipp b/ddspipe_yaml/test/unittest/entities/address/test_units/YamlGetEntityDiscoveryServerAddressTest_get_ds_address_negative.ipp index 4069f358..b0da4e83 100644 --- a/ddspipe_yaml/test/unittest/entities/address/test_units/YamlGetEntityDiscoveryServerAddressTest_get_ds_address_negative.ipp +++ b/ddspipe_yaml/test/unittest/entities/address/test_units/YamlGetEntityDiscoveryServerAddressTest_get_ds_address_negative.ipp @@ -50,25 +50,6 @@ TEST(YamlGetEntityDiscoveryServerAddressTest, get_ds_address_negative) eprosima::utils::ConfigurationException); } - // no guid prefix - { - Yaml yml_ds_address; - - // Get random address and add it to yaml - participants::types::Address address = eprosima::ddspipe::participants::testing::random_address(); - Yaml yml_addresses; - Yaml yml_address; - ddspipe::yaml::testing::address_to_yaml(yml_address, address); - yml_addresses.push_back(yml_address); - yml_ds_address[COLLECTION_ADDRESSES_TAG] = yml_addresses; - - Yaml yml; - yml["connection-address"] = yml_ds_address; - ASSERT_THROW( - YamlReader::get(yml, "connection-address", LATEST), - eprosima::utils::ConfigurationException); - } - // no addresses { Yaml yml_ds_address; @@ -86,33 +67,6 @@ TEST(YamlGetEntityDiscoveryServerAddressTest, get_ds_address_negative) eprosima::utils::ConfigurationException); } - // error format in guid prefix - { - Yaml yml_ds_address; - - // Get random address and add it to yaml - participants::types::Address address = eprosima::ddspipe::participants::testing::random_address(); - Yaml yml_addresses; - Yaml yml_address; - ddspipe::yaml::testing::address_to_yaml(yml_address, address); - yml_addresses.push_back(yml_address); - yml_ds_address[COLLECTION_ADDRESSES_TAG] = yml_addresses; - - // Guid Prefix error format (inside a sequence) - core::types::GuidPrefix guid_prefix = eprosima::ddspipe::core::testing::random_guid_prefix(); - Yaml yml_guid; - guid_prefix_to_yaml(yml_guid, guid_prefix); - Yaml yml_guid_aux; - yml_guid_aux.push_back(yml_guid); - yml_ds_address[DISCOVERY_SERVER_GUID_PREFIX_TAG] = yml_guid_aux; - - Yaml yml; - yml["connection-address"] = yml_ds_address; - ASSERT_THROW( - YamlReader::get(yml, "connection-address", LATEST), - eprosima::utils::ConfigurationException); - } - // error format in addresses { Yaml yml_ds_address; diff --git a/ddspipe_yaml/test/unittest/entities/guid/CMakeLists.txt b/ddspipe_yaml/test/unittest/entities/guid/CMakeLists.txt index e67669ec..605db8fc 100644 --- a/ddspipe_yaml/test/unittest/entities/guid/CMakeLists.txt +++ b/ddspipe_yaml/test/unittest/entities/guid/CMakeLists.txt @@ -36,7 +36,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES yaml-cpp fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants diff --git a/ddspipe_yaml/test/unittest/entities/guid/YamlGetEntityGuidPrefixTest.cpp b/ddspipe_yaml/test/unittest/entities/guid/YamlGetEntityGuidPrefixTest.cpp index e71c0366..ff562c00 100644 --- a/ddspipe_yaml/test/unittest/entities/guid/YamlGetEntityGuidPrefixTest.cpp +++ b/ddspipe_yaml/test/unittest/entities/guid/YamlGetEntityGuidPrefixTest.cpp @@ -89,9 +89,9 @@ TEST(YamlGetEntityGuidPrefixTest, get_guidprefix_explicitly) Yaml yml; yml["guid_prefix"] = yml_gp; - ASSERT_THROW( + ASSERT_EQ( YamlReader::get(yml, "guid_prefix", LATEST), - eprosima::utils::ConfigurationException); + core::types::GuidPrefix()); } // TODO: this tests requires to modify fastrtps core::types::GuidPrefix >> operator so it returns a non valid guid diff --git a/ddspipe_yaml/test/unittest/entities/topic/CMakeLists.txt b/ddspipe_yaml/test/unittest/entities/topic/CMakeLists.txt index cf536cc3..373cdba5 100644 --- a/ddspipe_yaml/test/unittest/entities/topic/CMakeLists.txt +++ b/ddspipe_yaml/test/unittest/entities/topic/CMakeLists.txt @@ -38,7 +38,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES yaml-cpp fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants diff --git a/ddspipe_yaml/test/unittest/entities/transport/CMakeLists.txt b/ddspipe_yaml/test/unittest/entities/transport/CMakeLists.txt index 2e3f25e9..a54dc70c 100644 --- a/ddspipe_yaml/test/unittest/entities/transport/CMakeLists.txt +++ b/ddspipe_yaml/test/unittest/entities/transport/CMakeLists.txt @@ -36,7 +36,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES yaml-cpp fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants @@ -73,7 +73,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES yaml-cpp fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants diff --git a/ddspipe_yaml/test/unittest/yaml_reader/forwarding_routes/routes/CMakeLists.txt b/ddspipe_yaml/test/unittest/yaml_reader/forwarding_routes/routes/CMakeLists.txt index ea1970cd..fd12f1f5 100644 --- a/ddspipe_yaml/test/unittest/yaml_reader/forwarding_routes/routes/CMakeLists.txt +++ b/ddspipe_yaml/test/unittest/yaml_reader/forwarding_routes/routes/CMakeLists.txt @@ -37,7 +37,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES yaml-cpp fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants diff --git a/ddspipe_yaml/test/unittest/yaml_reader/forwarding_routes/topic_routes/CMakeLists.txt b/ddspipe_yaml/test/unittest/yaml_reader/forwarding_routes/topic_routes/CMakeLists.txt index a32d1a3b..6f1733e7 100644 --- a/ddspipe_yaml/test/unittest/yaml_reader/forwarding_routes/topic_routes/CMakeLists.txt +++ b/ddspipe_yaml/test/unittest/yaml_reader/forwarding_routes/topic_routes/CMakeLists.txt @@ -36,7 +36,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES yaml-cpp fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants diff --git a/ddspipe_yaml/test/unittest/yaml_reader/log_configuration/CMakeLists.txt b/ddspipe_yaml/test/unittest/yaml_reader/log_configuration/CMakeLists.txt index 9c7ce189..0840be99 100644 --- a/ddspipe_yaml/test/unittest/yaml_reader/log_configuration/CMakeLists.txt +++ b/ddspipe_yaml/test/unittest/yaml_reader/log_configuration/CMakeLists.txt @@ -33,7 +33,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES yaml-cpp fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_yaml diff --git a/ddspipe_yaml/test/unittest/yaml_reader/monitoring/CMakeLists.txt b/ddspipe_yaml/test/unittest/yaml_reader/monitoring/CMakeLists.txt index 60dfaec0..e38c635c 100644 --- a/ddspipe_yaml/test/unittest/yaml_reader/monitoring/CMakeLists.txt +++ b/ddspipe_yaml/test/unittest/yaml_reader/monitoring/CMakeLists.txt @@ -35,7 +35,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES yaml-cpp fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants diff --git a/ddspipe_yaml/test/unittest/yaml_reader/scalar/CMakeLists.txt b/ddspipe_yaml/test/unittest/yaml_reader/scalar/CMakeLists.txt index 8c07047b..31c9731c 100644 --- a/ddspipe_yaml/test/unittest/yaml_reader/scalar/CMakeLists.txt +++ b/ddspipe_yaml/test/unittest/yaml_reader/scalar/CMakeLists.txt @@ -37,7 +37,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES yaml-cpp fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants diff --git a/ddspipe_yaml/test/unittest/yaml_writer/CMakeLists.txt b/ddspipe_yaml/test/unittest/yaml_writer/CMakeLists.txt index 700c4396..b245030b 100644 --- a/ddspipe_yaml/test/unittest/yaml_writer/CMakeLists.txt +++ b/ddspipe_yaml/test/unittest/yaml_writer/CMakeLists.txt @@ -41,7 +41,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES yaml-cpp fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants @@ -75,7 +75,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES yaml-cpp fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants