DynamicDataFactory.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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_DATA_FACTORY_H
  15. #define TYPES_DYNAMIC_DATA_FACTORY_H
  16. #include <fastrtps/types/TypesBase.h>
  17. #include <fastrtps/types/DynamicTypePtr.h>
  18. #include <fastrtps/types/DynamicTypeBuilder.h>
  19. #include <fastrtps/types/DynamicType.h>
  20. #include <fastrtps/types/DynamicData.h>
  21. #include <mutex>
  22. //#define DISABLE_DYNAMIC_MEMORY_CHECK
  23. namespace eprosima {
  24. namespace fastrtps {
  25. namespace types {
  26. class DynamicDataFactory
  27. {
  28. protected:
  29. DynamicDataFactory();
  30. ReturnCode_t create_members(
  31. DynamicData* pData,
  32. DynamicType_ptr pType);
  33. #ifndef DISABLE_DYNAMIC_MEMORY_CHECK
  34. std::vector<DynamicData*> dynamic_datas_;
  35. mutable std::recursive_mutex mutex_;
  36. #endif
  37. public:
  38. ~DynamicDataFactory();
  39. RTPS_DllAPI static DynamicDataFactory* get_instance();
  40. RTPS_DllAPI static ReturnCode_t delete_instance();
  41. RTPS_DllAPI DynamicData* create_data(DynamicTypeBuilder* pBuilder);
  42. RTPS_DllAPI DynamicData* create_data(DynamicType_ptr pType);
  43. RTPS_DllAPI DynamicData* create_copy(const DynamicData* pData);
  44. RTPS_DllAPI ReturnCode_t delete_data(DynamicData* pData);
  45. RTPS_DllAPI bool is_empty() const;
  46. };
  47. } // namespace types
  48. } // namespace fastrtps
  49. } // namespace eprosima
  50. #endif // TYPES_DYNAMIC_DATA_FACTORY_H