Fast RTPS  Version 2.5.0
Fast RTPS
DynamicTypeBuilderFactory.h
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 
15 #ifndef TYPES_DYNAMIC_TYPE_BUILDER_FACTORY_H
16 #define TYPES_DYNAMIC_TYPE_BUILDER_FACTORY_H
17 
18 #include <fastrtps/types/TypesBase.h>
19 #include <fastrtps/types/AnnotationParameterValue.h>
20 #include <fastrtps/types/DynamicTypePtr.h>
21 #include <mutex>
22 
23 //#define DISABLE_DYNAMIC_MEMORY_CHECK
24 
25 namespace eprosima {
26 namespace fastrtps {
27 namespace types {
28 
29 class AnnotationDescriptor;
30 class DynamicTypeBuilder;
31 class TypeDescriptor;
32 class TypeIdentifier;
33 class MemberDescriptor;
34 class TypeObject;
35 class DynamicType;
36 class DynamicType_ptr;
37 class AnnotationParameterValue;
38 
40 {
41 protected:
42 
44 
45  inline void add_builder_to_list(
46  DynamicTypeBuilder* pBuilder);
47 
49  DynamicType_ptr other);
50 
52  const TypeDescriptor* descriptor,
53  TypeObject& object,
54  bool complete = true) const;
55 
57  const TypeDescriptor* descriptor) const;
58 
60  const TypeDescriptor* descriptor) const;
61 
63  const TypeDescriptor* descriptor,
64  TypeObject& object,
65  bool complete = true) const;
66 
68  const TypeDescriptor* descriptor,
69  TypeObject& object,
70  bool complete = true) const;
71 
73  const TypeDescriptor* descriptor,
74  TypeObject& object,
75  bool complete = true) const;
76 
78  const TypeDescriptor* descriptor,
79  TypeObject& object,
80  const std::vector<const MemberDescriptor*> members,
81  bool complete = true) const;
82 
84  const TypeDescriptor* descriptor,
85  TypeObject& object,
86  const std::vector<const MemberDescriptor*> members,
87  bool complete = true) const;
88 
90  const TypeDescriptor* descriptor,
91  TypeObject& object,
92  const std::vector<const MemberDescriptor*> members,
93  bool complete = true) const;
94 
96  const TypeDescriptor* descriptor,
97  TypeObject& object,
98  const std::vector<const MemberDescriptor*> members,
99  bool complete = true) const;
100 
102  const TypeDescriptor* descriptor,
103  TypeObject& object,
104  const std::vector<const MemberDescriptor*> members,
105  bool complete = true) const;
106 
108  const TypeDescriptor* descriptor,
109  TypeObject& object,
110  const std::vector<const MemberDescriptor*> members,
111  bool complete = true) const;
112 
115  const MemberDescriptor* member) const;
116 
118  AppliedAnnotationSeq& annotations,
119  const TypeDescriptor* descriptor) const;
120 
121 #ifndef DISABLE_DYNAMIC_MEMORY_CHECK
122  std::vector<DynamicTypeBuilder*> builders_list_;
123  mutable std::recursive_mutex mutex_;
124 #endif // ifndef DISABLE_DYNAMIC_MEMORY_CHECK
125 
126 public:
127 
129 
130  RTPS_DllAPI static ReturnCode_t delete_instance();
131 
133 
135  TypeKind kind);
136 
138  DynamicTypeBuilder* builder);
139 
141  DynamicType* type);
142 
144  const TypeDescriptor* descriptor,
145  const std::string& name = "");
146 
148  const DynamicTypeBuilder* type);
149 
151 
153 
155 
157 
159 
161 
163 
165 
167 
169 
171 
173 
175 
177  uint32_t bound = MAX_STRING_LENGTH);
178 
180  uint32_t bound = MAX_STRING_LENGTH);
181 
183  const DynamicTypeBuilder* element_type,
184  uint32_t bound = MAX_ELEMENTS_COUNT);
185 
187  const DynamicType_ptr type,
188  uint32_t bound = MAX_ELEMENTS_COUNT);
189 
191  const DynamicTypeBuilder* element_type,
192  const std::vector<uint32_t>& bounds);
193 
195  const DynamicType_ptr type,
196  const std::vector<uint32_t>& bounds);
197 
199  DynamicTypeBuilder* key_element_type,
200  DynamicTypeBuilder* element_type,
201  uint32_t bound = MAX_ELEMENTS_COUNT);
202 
204  DynamicType_ptr key_type,
205  DynamicType_ptr value_type,
206  uint32_t bound = MAX_ELEMENTS_COUNT);
207 
209  uint32_t bound);
210 
212 
214  DynamicTypeBuilder* base_type,
215  const std::string& sName);
216 
218  DynamicType_ptr base_type,
219  const std::string& sName);
220 
222 
224 
226  DynamicTypeBuilder* parent_type);
227 
229  DynamicTypeBuilder* discriminator_type);
230 
232  DynamicType_ptr discriminator_type);
233 
235  const std::string& name);
236 
238  const TypeDescriptor* descriptor,
239  const std::string& name = "");
240 
242  const DynamicTypeBuilder* other);
243 
245  DynamicTypeBuilder* base_type,
246  const std::string& sName);
247 
249  DynamicType_ptr base_type,
250  const std::string& sName);
251 
253 
255 
257 
259 
261 
263 
265 
267 
269 
271 
273 
275 
277 
279  uint32_t bound = MAX_STRING_LENGTH);
280 
282  uint32_t bound = MAX_STRING_LENGTH);
283 
285  uint32_t bound);
286 
287  RTPS_DllAPI void build_type_identifier(
288  const DynamicType_ptr type,
289  TypeIdentifier& identifier,
290  bool complete = true) const;
291 
292  RTPS_DllAPI void build_type_identifier(
293  const TypeDescriptor* descriptor,
294  TypeIdentifier& identifier,
295  bool complete = true) const;
296 
297  RTPS_DllAPI void build_type_object(
298  const DynamicType_ptr type,
299  TypeObject& object,
300  bool complete = true,
301  bool force = false) const;
302 
303  RTPS_DllAPI void build_type_object(
304  const TypeDescriptor* descriptor,
305  TypeObject& object,
306  const std::vector<const MemberDescriptor*>* members = nullptr,
307  bool complete = true,
308  bool force = false) const;
309 
310  RTPS_DllAPI bool is_empty() const;
311 };
312 
313 } // namespace types
314 } // namespace fastrtps
315 } // namespace eprosima
316 
317 #endif // TYPES_DYNAMIC_TYPE_BUILDER_FACTORY_H
This class represents the union AnnotationParameterValue defined by the user in the IDL file.
Definition: AnnotationParameterValue.h:166
Definition: DynamicTypePtr.h:27
Definition: DynamicTypeBuilderFactory.h:40
RTPS_DllAPI DynamicTypeBuilder * create_custom_builder(const TypeDescriptor *descriptor, const std::string &name="")
RTPS_DllAPI DynamicTypeBuilder * create_alias_builder(DynamicTypeBuilder *base_type, const std::string &sName)
void build_enum_type_code(const TypeDescriptor *descriptor, TypeObject &object, const std::vector< const MemberDescriptor * > members, bool complete=true) const
RTPS_DllAPI DynamicTypeBuilder * create_float128_builder()
RTPS_DllAPI DynamicType_ptr create_float128_type()
RTPS_DllAPI DynamicTypeBuilder * create_int64_builder()
RTPS_DllAPI DynamicTypeBuilder * create_sequence_builder(const DynamicType_ptr type, uint32_t bound=MAX_ELEMENTS_COUNT)
DynamicType_ptr build_type(DynamicType_ptr other)
RTPS_DllAPI DynamicType_ptr create_string_type(uint32_t bound=MAX_STRING_LENGTH)
RTPS_DllAPI DynamicType_ptr create_uint32_type()
RTPS_DllAPI DynamicType_ptr create_float32_type()
RTPS_DllAPI DynamicType_ptr create_wstring_type(uint32_t bound=MAX_STRING_LENGTH)
RTPS_DllAPI void build_type_identifier(const TypeDescriptor *descriptor, TypeIdentifier &identifier, bool complete=true) const
RTPS_DllAPI DynamicTypeBuilder * create_sequence_builder(const DynamicTypeBuilder *element_type, uint32_t bound=MAX_ELEMENTS_COUNT)
RTPS_DllAPI DynamicTypeBuilder * create_union_builder(DynamicTypeBuilder *discriminator_type)
RTPS_DllAPI DynamicTypeBuilder * create_map_builder(DynamicType_ptr key_type, DynamicType_ptr value_type, uint32_t bound=MAX_ELEMENTS_COUNT)
void build_bitset_type_code(const TypeDescriptor *descriptor, TypeObject &object, const std::vector< const MemberDescriptor * > members, bool complete=true) const
RTPS_DllAPI DynamicType_ptr create_type(const DynamicTypeBuilder *other)
RTPS_DllAPI DynamicTypeBuilder * create_bitmask_builder(uint32_t bound)
RTPS_DllAPI DynamicTypeBuilder * create_array_builder(const DynamicTypeBuilder *element_type, const std::vector< uint32_t > &bounds)
RTPS_DllAPI DynamicType_ptr create_type(const TypeDescriptor *descriptor, const std::string &name="")
RTPS_DllAPI DynamicType_ptr create_float64_type()
RTPS_DllAPI DynamicType_ptr create_alias_type(DynamicTypeBuilder *base_type, const std::string &sName)
RTPS_DllAPI DynamicTypeBuilder * create_uint16_builder()
RTPS_DllAPI DynamicType_ptr get_primitive_type(TypeKind kind)
RTPS_DllAPI DynamicTypeBuilder * create_alias_builder(DynamicType_ptr base_type, const std::string &sName)
RTPS_DllAPI DynamicTypeBuilder * create_union_builder(DynamicType_ptr discriminator_type)
RTPS_DllAPI DynamicTypeBuilder * create_bitset_builder()
void build_alias_type_code(const TypeDescriptor *descriptor, TypeObject &object, bool complete=true) const
static RTPS_DllAPI ReturnCode_t delete_instance()
RTPS_DllAPI DynamicTypeBuilder * create_int16_builder()
void build_string16_type_code(const TypeDescriptor *descriptor) const
RTPS_DllAPI DynamicTypeBuilder * create_map_builder(DynamicTypeBuilder *key_element_type, DynamicTypeBuilder *element_type, uint32_t bound=MAX_ELEMENTS_COUNT)
RTPS_DllAPI DynamicTypeBuilder * create_uint64_builder()
RTPS_DllAPI DynamicTypeBuilder * create_float32_builder()
RTPS_DllAPI DynamicTypeBuilder * create_string_builder(uint32_t bound=MAX_STRING_LENGTH)
RTPS_DllAPI DynamicType_ptr create_uint64_type()
void build_bitmask_type_code(const TypeDescriptor *descriptor, TypeObject &object, const std::vector< const MemberDescriptor * > members, bool complete=true) const
RTPS_DllAPI DynamicTypeBuilder * create_bool_builder()
RTPS_DllAPI DynamicTypeBuilder * create_enum_builder()
RTPS_DllAPI DynamicTypeBuilder * create_char8_builder()
void build_annotation_type_code(const TypeDescriptor *descriptor, TypeObject &object, const std::vector< const MemberDescriptor * > members, bool complete=true) const
RTPS_DllAPI ReturnCode_t delete_type(DynamicType *type)
RTPS_DllAPI void build_type_object(const TypeDescriptor *descriptor, TypeObject &object, const std::vector< const MemberDescriptor * > *members=nullptr, bool complete=true, bool force=false) const
RTPS_DllAPI DynamicTypeBuilder * create_char16_builder()
RTPS_DllAPI ReturnCode_t delete_builder(DynamicTypeBuilder *builder)
RTPS_DllAPI void build_type_object(const DynamicType_ptr type, TypeObject &object, bool complete=true, bool force=false) const
RTPS_DllAPI DynamicType_ptr create_annotation_primitive(const std::string &name)
RTPS_DllAPI DynamicTypeBuilder * create_byte_builder()
void build_struct_type_code(const TypeDescriptor *descriptor, TypeObject &object, const std::vector< const MemberDescriptor * > members, bool complete=true) const
void build_map_type_code(const TypeDescriptor *descriptor, TypeObject &object, bool complete=true) const
void apply_type_annotations(AppliedAnnotationSeq &annotations, const TypeDescriptor *descriptor) const
void build_sequence_type_code(const TypeDescriptor *descriptor, TypeObject &object, bool complete=true) const
std::vector< DynamicTypeBuilder * > builders_list_
Definition: DynamicTypeBuilderFactory.h:122
void set_annotation_default_value(AnnotationParameterValue &apv, const MemberDescriptor *member) const
RTPS_DllAPI DynamicType_ptr create_alias_type(DynamicType_ptr base_type, const std::string &sName)
RTPS_DllAPI DynamicType_ptr create_uint16_type()
RTPS_DllAPI DynamicTypeBuilder * create_uint32_builder()
std::recursive_mutex mutex_
Definition: DynamicTypeBuilderFactory.h:123
RTPS_DllAPI DynamicTypeBuilder * create_float64_builder()
void add_builder_to_list(DynamicTypeBuilder *pBuilder)
void build_union_type_code(const TypeDescriptor *descriptor, TypeObject &object, const std::vector< const MemberDescriptor * > members, bool complete=true) const
RTPS_DllAPI DynamicTypeBuilder * create_builder_copy(const DynamicTypeBuilder *type)
void build_array_type_code(const TypeDescriptor *descriptor, TypeObject &object, bool complete=true) const
RTPS_DllAPI DynamicTypeBuilder * create_int32_builder()
RTPS_DllAPI DynamicTypeBuilder * create_array_builder(const DynamicType_ptr type, const std::vector< uint32_t > &bounds)
RTPS_DllAPI DynamicTypeBuilder * create_child_struct_builder(DynamicTypeBuilder *parent_type)
RTPS_DllAPI DynamicTypeBuilder * create_struct_builder()
RTPS_DllAPI DynamicType_ptr create_char16_type()
static RTPS_DllAPI DynamicTypeBuilderFactory * get_instance()
RTPS_DllAPI DynamicTypeBuilder * create_wstring_builder(uint32_t bound=MAX_STRING_LENGTH)
RTPS_DllAPI void build_type_identifier(const DynamicType_ptr type, TypeIdentifier &identifier, bool complete=true) const
void build_string8_type_code(const TypeDescriptor *descriptor) const
RTPS_DllAPI DynamicType_ptr create_bitset_type(uint32_t bound)
Definition: DynamicTypeBuilder.h:32
Definition: DynamicType.h:38
Definition: MemberDescriptor.h:29
This class represents the enumeration ReturnCode_t.
Definition: TypesBase.h:189
Definition: TypeDescriptor.h:30
Definition: TypeIdentifier.h:81
Definition: TypeObject.h:4429
const int32_t MAX_ELEMENTS_COUNT
Definition: TypesBase.h:277
std::vector< AppliedAnnotation > AppliedAnnotationSeq
Definition: AnnotationParameterValue.h:1124
octet TypeKind
Definition: TypesBase.h:119
const int32_t MAX_STRING_LENGTH
Definition: TypesBase.h:278
eProsima namespace.
Definition: LibrarySettingsAttributes.h:23