Fast RTPS  Version 2.4.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 constexpr uint32_t BOUND_UNLIMITED = 0;
41 
43 {
44 protected:
45 
47 
48  inline void add_builder_to_list(
49  DynamicTypeBuilder* pBuilder);
50 
52  DynamicType_ptr other);
53 
55  const TypeDescriptor* descriptor,
56  TypeObject& object,
57  bool complete = true) const;
58 
60  const TypeDescriptor* descriptor) const;
61 
63  const TypeDescriptor* descriptor) const;
64 
66  const TypeDescriptor* descriptor,
67  TypeObject& object,
68  bool complete = true) const;
69 
71  const TypeDescriptor* descriptor,
72  TypeObject& object,
73  bool complete = true) const;
74 
76  const TypeDescriptor* descriptor,
77  TypeObject& object,
78  bool complete = true) const;
79 
81  const TypeDescriptor* descriptor,
82  TypeObject& object,
83  const std::vector<const MemberDescriptor*> members,
84  bool complete = true) const;
85 
87  const TypeDescriptor* descriptor,
88  TypeObject& object,
89  const std::vector<const MemberDescriptor*> members,
90  bool complete = true) const;
91 
93  const TypeDescriptor* descriptor,
94  TypeObject& object,
95  const std::vector<const MemberDescriptor*> members,
96  bool complete = true) const;
97 
99  const TypeDescriptor* descriptor,
100  TypeObject& object,
101  const std::vector<const MemberDescriptor*> members,
102  bool complete = true) const;
103 
105  const TypeDescriptor* descriptor,
106  TypeObject& object,
107  const std::vector<const MemberDescriptor*> members,
108  bool complete = true) const;
109 
111  const TypeDescriptor* descriptor,
112  TypeObject& object,
113  const std::vector<const MemberDescriptor*> members,
114  bool complete = true) const;
115 
118  const MemberDescriptor* member) const;
119 
121  AppliedAnnotationSeq& annotations,
122  const TypeDescriptor* descriptor) const;
123 
124 #ifndef DISABLE_DYNAMIC_MEMORY_CHECK
125  std::vector<DynamicTypeBuilder*> builders_list_;
126  mutable std::recursive_mutex mutex_;
127 #endif // ifndef DISABLE_DYNAMIC_MEMORY_CHECK
128 
129 public:
130 
132 
133  RTPS_DllAPI static ReturnCode_t delete_instance();
134 
136 
138  TypeKind kind);
139 
141  DynamicTypeBuilder* builder);
142 
144  DynamicType* type);
145 
147  const TypeDescriptor* descriptor,
148  const std::string& name = "");
149 
151  const DynamicTypeBuilder* type);
152 
154 
156 
158 
160 
162 
164 
166 
168 
170 
172 
174 
176 
178 
180  uint32_t bound = MAX_STRING_LENGTH);
181 
183  uint32_t bound = MAX_STRING_LENGTH);
184 
186  const DynamicTypeBuilder* element_type,
187  uint32_t bound = MAX_ELEMENTS_COUNT);
188 
190  const DynamicType_ptr type,
191  uint32_t bound = MAX_ELEMENTS_COUNT);
192 
194  const DynamicTypeBuilder* element_type,
195  const std::vector<uint32_t>& bounds);
196 
198  const DynamicType_ptr type,
199  const std::vector<uint32_t>& bounds);
200 
202  DynamicTypeBuilder* key_element_type,
203  DynamicTypeBuilder* element_type,
204  uint32_t bound = MAX_ELEMENTS_COUNT);
205 
207  DynamicType_ptr key_type,
208  DynamicType_ptr value_type,
209  uint32_t bound = MAX_ELEMENTS_COUNT);
210 
212  uint32_t bound);
213 
215 
217  DynamicTypeBuilder* base_type,
218  const std::string& sName);
219 
221  DynamicType_ptr base_type,
222  const std::string& sName);
223 
225 
227 
229  DynamicTypeBuilder* parent_type);
230 
232  DynamicTypeBuilder* discriminator_type);
233 
235  DynamicType_ptr discriminator_type);
236 
238  const std::string& name);
239 
241  const TypeDescriptor* descriptor,
242  const std::string& name = "");
243 
245  const DynamicTypeBuilder* other);
246 
248  DynamicTypeBuilder* base_type,
249  const std::string& sName);
250 
252  DynamicType_ptr base_type,
253  const std::string& sName);
254 
256 
258 
260 
262 
264 
266 
268 
270 
272 
274 
276 
278 
280 
282  uint32_t bound = MAX_STRING_LENGTH);
283 
285  uint32_t bound = MAX_STRING_LENGTH);
286 
288  uint32_t bound);
289 
290  RTPS_DllAPI void build_type_identifier(
291  const DynamicType_ptr type,
292  TypeIdentifier& identifier,
293  bool complete = true) const;
294 
295  RTPS_DllAPI void build_type_identifier(
296  const TypeDescriptor* descriptor,
297  TypeIdentifier& identifier,
298  bool complete = true) const;
299 
300  RTPS_DllAPI void build_type_object(
301  const DynamicType_ptr type,
302  TypeObject& object,
303  bool complete = true,
304  bool force = false) const;
305 
306  RTPS_DllAPI void build_type_object(
307  const TypeDescriptor* descriptor,
308  TypeObject& object,
309  const std::vector<const MemberDescriptor*>* members = nullptr,
310  bool complete = true,
311  bool force = false) const;
312 
313  RTPS_DllAPI bool is_empty() const;
314 };
315 
316 } // namespace types
317 } // namespace fastrtps
318 } // namespace eprosima
319 
320 #endif // TYPES_DYNAMIC_TYPE_BUILDER_FACTORY_H
This class represents the union AnnotationParameterValue defined by the user in the IDL file.
Definition: AnnotationParameterValue.h:165
Definition: DynamicTypePtr.h:27
Definition: DynamicTypeBuilderFactory.h:43
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:125
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:126
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:186
Definition: TypeDescriptor.h:29
Definition: TypeIdentifier.h:81
Definition: TypeObject.h:4429
constexpr uint32_t BOUND_UNLIMITED
A special value indicating an unlimited quantity.
Definition: DynamicTypeBuilderFactory.h:40
const int32_t MAX_ELEMENTS_COUNT
Definition: TypesBase.h:274
std::vector< AppliedAnnotation > AppliedAnnotationSeq
Definition: AnnotationParameterValue.h:1116
octet TypeKind
Definition: TypesBase.h:116
const int32_t MAX_STRING_LENGTH
Definition: TypesBase.h:275
eProsima namespace.
Definition: LibrarySettingsAttributes.h:23