Fast DDS  Version 3.6.1.0
Fast DDS
DynamicTypeBuilderFactory.hpp
1 // Copyright 2023 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 
15 #ifndef FASTDDS_DDS_XTYPES_DYNAMIC_TYPES__DYNAMICTYPEBUILDERFACTORY_HPP
16 #define FASTDDS_DDS_XTYPES_DYNAMIC_TYPES__DYNAMICTYPEBUILDERFACTORY_HPP
17 
18 #include <functional>
19 #include <memory>
20 #include <string>
21 
22 #include <fastdds/dds/core/ReturnCode.hpp>
23 #include <fastdds/dds/xtypes/dynamic_types/DynamicType.hpp>
24 #include <fastdds/dds/xtypes/dynamic_types/TypeDescriptor.hpp>
25 #include <fastdds/dds/xtypes/dynamic_types/Types.hpp>
26 #include <fastdds/fastdds_dll.hpp>
27 
28 namespace eprosima {
29 namespace fastdds {
30 namespace dds {
31 
32 namespace xtypes {
33 class TypeObject;
34 } // namespace xtypes
35 
36 class DynamicTypeBuilderFactory : public std::enable_shared_from_this<DynamicTypeBuilderFactory>
37 {
38 public:
39 
41 
48 
55  FASTDDS_EXPORTED_API static ReturnCode_t delete_instance();
56 
62  FASTDDS_EXPORTED_API virtual traits<DynamicType>::ref_type get_primitive_type(
63  TypeKind kind) = 0;
64 
70  FASTDDS_EXPORTED_API virtual traits<DynamicTypeBuilder>::ref_type create_type(
71  traits<TypeDescriptor>::ref_type descriptor) = 0;
72 
80 
87  const xtypes::TypeObject& type_object) = 0;
88 
96  uint32_t bound) = 0;
97 
105  uint32_t bound) = 0;
106 
115  traits<DynamicType>::ref_type element_type,
116  uint32_t bound) = 0;
117 
125  traits<DynamicType>::ref_type element_type,
126  const BoundSeq& bound) = 0;
127 
137  traits<DynamicType>::ref_type key_element_type,
138  traits<DynamicType>::ref_type element_type,
139  uint32_t bound) = 0;
140 
147  uint32_t bound) = 0;
148 
153  FASTDDS_EXPORTED_API virtual void set_preprocessor(
154  const std::string& preprocessor) = 0;
155 
165  const std::string& document_url,
166  const std::string& type_name,
167  const IncludePathSeq& include_paths) = 0;
168 
185  FASTDDS_EXPORTED_API virtual ReturnCode_t for_each_type_w_uri(
186  const std::string& document_url,
187  const IncludePathSeq& include_paths,
188  std::function<bool(traits<DynamicTypeBuilder>::ref_type)> callback) = 0;
189 
200  const std::string& document,
201  const std::string& type_name,
202  const IncludePathSeq& include_paths) = 0;
203 
210  FASTDDS_EXPORTED_API virtual ReturnCode_t delete_type(
212 
213 protected:
214 
216 
217  virtual ~DynamicTypeBuilderFactory() = default;
218 
220 
221 private:
222 
224  const DynamicTypeBuilderFactory&) = delete;
225 
227  DynamicTypeBuilderFactory&&) = delete;
228 
229  DynamicTypeBuilderFactory& operator =(
230  const DynamicTypeBuilderFactory&) = delete;
231 
232  DynamicTypeBuilderFactory& operator =(
233  DynamicTypeBuilderFactory&&) = delete;
234 
235 };
236 
237 } // namespace dds
238 } // namespace fastdds
239 } // namespace eprosima
240 
241 #endif // FASTDDS_DDS_XTYPES_DYNAMIC_TYPES__DYNAMICTYPEBUILDERFACTORY_HPP
Definition: DynamicTypeBuilderFactory.hpp:37
virtual FASTDDS_EXPORTED_API traits< DynamicTypeBuilder >::ref_type create_type_w_uri(const std::string &document_url, const std::string &type_name, const IncludePathSeq &include_paths)=0
Creates a new DynamicTypeBuilder reference by parsing the type description at the given URL.
virtual FASTDDS_EXPORTED_API traits< DynamicTypeBuilder >::ref_type create_type_copy(traits< DynamicType >::ref_type type)=0
Creates a new DynamicTypeBuilder reference based on the given DynamicType reference.
static FASTDDS_EXPORTED_API traits< DynamicTypeBuilderFactory >::ref_type get_instance()
Returns the singleton factory object.
typename traits< DynamicTypeBuilderFactory >::ref_type _ref_type
Definition: DynamicTypeBuilderFactory.hpp:40
virtual FASTDDS_EXPORTED_API traits< DynamicType >::ref_type get_primitive_type(TypeKind kind)=0
Retrieves the cached DynamicType reference associated to a given primitive.
virtual FASTDDS_EXPORTED_API traits< DynamicTypeBuilder >::ref_type create_type(traits< TypeDescriptor >::ref_type descriptor)=0
Creates a new DynamicTypeBuilder reference based on the given TypeDescriptor state.
virtual FASTDDS_EXPORTED_API traits< DynamicTypeBuilder >::ref_type create_array_type(traits< DynamicType >::ref_type element_type, const BoundSeq &bound)=0
Creates a new DynamicTypeBuilder reference representing an array.
virtual FASTDDS_EXPORTED_API ReturnCode_t for_each_type_w_uri(const std::string &document_url, const IncludePathSeq &include_paths, std::function< bool(traits< DynamicTypeBuilder >::ref_type)> callback)=0
Parse an input document and apply a callback on each encountered type.
virtual FASTDDS_EXPORTED_API traits< DynamicTypeBuilder >::ref_type create_map_type(traits< DynamicType >::ref_type key_element_type, traits< DynamicType >::ref_type element_type, uint32_t bound)=0
Creates a new DynamicTypeBuilder reference representing a map.
static FASTDDS_EXPORTED_API ReturnCode_t delete_instance()
Resets the singleton reference.
virtual FASTDDS_EXPORTED_API traits< DynamicTypeBuilder >::ref_type create_wstring_type(uint32_t bound)=0
Creates a new DynamicTypeBuilder reference representing a bounded wstring type.
virtual FASTDDS_EXPORTED_API traits< DynamicTypeBuilder >::ref_type create_type_w_document(const std::string &document, const std::string &type_name, const IncludePathSeq &include_paths)=0
Creates a new DynamicTypeBuilder reference by parsing the type description contained in the given str...
virtual FASTDDS_EXPORTED_API traits< DynamicTypeBuilder >::ref_type create_bitmask_type(uint32_t bound)=0
Creates a new DynamicTypeBuilder reference representing a bitmask.
virtual FASTDDS_EXPORTED_API traits< DynamicTypeBuilder >::ref_type create_string_type(uint32_t bound)=0
Creates a new DynamicTypeBuilder reference representing a bounded string type.
virtual FASTDDS_EXPORTED_API traits< DynamicTypeBuilder >::ref_type create_type_w_type_object(const xtypes::TypeObject &type_object)=0
Creates a new DynamicTypeBuilder reference based on the given xtypes::TypeObject instance.
virtual FASTDDS_EXPORTED_API ReturnCode_t delete_type(traits< DynamicType >::ref_type &type)=0
Resets the internal reference if it is cached.
traits< DynamicTypeBuilderFactory >::ref_type _this()
virtual FASTDDS_EXPORTED_API traits< DynamicTypeBuilder >::ref_type create_sequence_type(traits< DynamicType >::ref_type element_type, uint32_t bound)=0
Creates a new DynamicTypeBuilder reference representing a sequence.
virtual FASTDDS_EXPORTED_API void set_preprocessor(const std::string &preprocessor)=0
Sets the path to the preprocessor executable to be used when parsing type descriptions.
This class represents the union TypeObject defined by the user in the IDL file.
Definition: dds_xtypes_typeobject.hpp:23463
Definition: DomainParticipant.hpp:46
std::vector< std::string > IncludePathSeq
Definition: dynamic_language_binding.hpp:64
std::vector< uint32_t > BoundSeq
Definition: dynamic_language_binding.hpp:68
int32_t ReturnCode_t
Definition: DDSReturnCode.hpp:59
uint8_t TypeKind
Definition: dynamic_language_binding.hpp:70
typename ::std::shared_ptr< T > ref_type
Definition: type_traits.hpp:29