DynamicPubSubType.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Copyright 2018 Proyectos y Sistemas de Mantenimiento SL (eProsima).
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #ifndef TYPES_DYNAMIC_PUB_SUB_TYPE_H
  15. #define TYPES_DYNAMIC_PUB_SUB_TYPE_H
  16. #include <fastrtps/types/TypesBase.h>
  17. #include <fastdds/dds/topic/TopicDataType.hpp>
  18. #include <fastrtps/types/DynamicTypePtr.h>
  19. #include <fastrtps/types/DynamicDataPtr.h>
  20. #include <fastrtps/utils/md5.h>
  21. namespace eprosima {
  22. namespace fastrtps {
  23. namespace types {
  24. class DynamicPubSubType : public eprosima::fastdds::dds::TopicDataType
  25. {
  26. protected:
  27. void UpdateDynamicTypeInfo();
  28. DynamicType_ptr dynamic_type_;
  29. MD5 m_md5;
  30. unsigned char* m_keyBuffer;
  31. public:
  32. RTPS_DllAPI DynamicPubSubType();
  33. RTPS_DllAPI DynamicPubSubType(
  34. DynamicType_ptr pDynamicType);
  35. RTPS_DllAPI virtual ~DynamicPubSubType();
  36. RTPS_DllAPI void* createData() override;
  37. RTPS_DllAPI void deleteData (
  38. void * data) override;
  39. RTPS_DllAPI bool deserialize (
  40. eprosima::fastrtps::rtps::SerializedPayload_t* payload,
  41. void* data) override;
  42. RTPS_DllAPI bool getKey(
  43. void* data,
  44. eprosima::fastrtps::rtps::InstanceHandle_t* ihandle,
  45. bool force_md5 = false) override;
  46. RTPS_DllAPI std::function<uint32_t()> getSerializedSizeProvider(
  47. void* data) override;
  48. RTPS_DllAPI bool serialize(
  49. void* data,
  50. eprosima::fastrtps::rtps::SerializedPayload_t* payload) override;
  51. RTPS_DllAPI void CleanDynamicType();
  52. RTPS_DllAPI DynamicType_ptr GetDynamicType() const;
  53. RTPS_DllAPI ReturnCode_t SetDynamicType(
  54. DynamicData_ptr pData);
  55. RTPS_DllAPI ReturnCode_t SetDynamicType(
  56. DynamicType_ptr pType);
  57. };
  58. } // namespace types
  59. } // namespace fastrtps
  60. } // namespace eprosima
  61. #endif // TYPES_DYNAMIC_PUB_SUB_TYPE_H