Fast RTPS  Version 2.14.1
Fast RTPS
Loading...
Searching...
No Matches
TypeObjectFactory.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 TYPE_OBJECT_TYPE_FACTORY_H
16#define TYPE_OBJECT_TYPE_FACTORY_H
17
18#include <fastrtps/types/TypeObject.h>
19#include <fastrtps/types/DynamicTypeBuilder.h>
20#include <fastrtps/types/DynamicTypeBuilderPtr.h>
21#include <fastrtps/types/DynamicTypePtr.h>
22#include <mutex>
23
24namespace eprosima {
25namespace fastrtps {
26namespace types {
27
29{
30private:
31 mutable std::recursive_mutex m_MutexIdentifiers;
32 mutable std::recursive_mutex m_MutexObjects;
33 mutable std::recursive_mutex m_MutexInformations;
34
35protected:
37 mutable std::map<const std::string, const TypeIdentifier*> identifiers_; // Basic, builtin and EK_MINIMAL
38 std::map<const std::string, const TypeIdentifier*> complete_identifiers_; // Only EK_COMPLETE
39 std::map<const TypeIdentifier*, const TypeObject*> objects_; // EK_MINIMAL
40 std::map<const TypeIdentifier*, const TypeObject*> complete_objects_; // EK_COMPLETE
41 mutable std::vector<TypeIdentifier*> identifiers_created_;
42 mutable std::map<const TypeIdentifier*, TypeInformation*> informations_;
43 mutable std::vector<TypeInformation*> informations_created_;
44 std::map<std::string, std::string> aliases_; // Aliases
45
47 TypeDescriptor& descriptor,
48 const TypeObject* object,
49 const DynamicType_ptr annotation_member_type = DynamicType_ptr(nullptr)) const;
50
52 const TypeIdentifier* identifier) const;
53
55 const TypeIdentifier* identifier) const;
56
58 const TypeIdentifier* identifier) const;
59
61 const TypeIdentifier* identifier);
62
64
66 DynamicTypeBuilder_ptr& type_builder,
67 const AppliedAnnotationSeq& annotations) const;
68
70 DynamicTypeBuilder_ptr& parent_type_builder,
71 MemberId member_id,
72 const AppliedAnnotationSeq& annotations) const;
73
74 std::string get_key_from_hash(
75 const DynamicType_ptr annotation_descriptor_type,
76 const NameHash& hash) const;
77
84 TypeInformation* info,
85 const TypeIdentifier* ident) const;
86
94 TypeInformation* info,
95 const TypeIdentifier* ident) const;
96
103 TypeInformation* info,
104 const TypeIdentifier* identifier) const;
105
112 TypeInformation* info,
113 const TypeIdentifier* identifier) const;
114
121 TypeInformation* info,
122 const TypeIdentifier* identifier) const;
123
124public:
125 RTPS_DllAPI static TypeObjectFactory* get_instance();
126
127 RTPS_DllAPI static ReturnCode_t delete_instance();
128
130
137 const std::string &type_name) const;
138
145 const TypeIdentifier* identifier) const;
146
147 RTPS_DllAPI const TypeObject* get_type_object(
148 const std::string& type_name,
149 bool complete = false) const;
150
151 RTPS_DllAPI const TypeObject* get_type_object(
152 const TypeIdentifier* identifier) const;
153
155 const std::string& type_name) const;
156
157 RTPS_DllAPI std::string get_type_name(
158 const TypeKind kind) const;
159
160 RTPS_DllAPI std::string get_type_name(
161 const TypeIdentifier* identifier) const;
162
164 TypeKind kind) const;
165
167 const std::string& type_name,
168 bool complete = false) const;
169
171 const std::string& type_name) const;
172
174 uint32_t bound,
175 bool wide = false);
176
178 const std::string& type_name,
179 uint32_t bound,
180 bool complete = false);
181
183 const std::string& type_name,
184 const std::vector<uint32_t> &bound,
185 bool complete = false);
186
188 const std::string& key_type_name,
189 const std::string& value_type_name,
190 uint32_t bound,
191 bool complete = false);
192
194 const std::string& name,
195 const TypeIdentifier* identifier,
196 const TypeObject* object = nullptr) const;
197
199 const TypeIdentifier* identifier) const;
200
201 RTPS_DllAPI void add_type_identifier(
202 const std::string& type_name,
203 const TypeIdentifier* identifier);
204
205 RTPS_DllAPI void add_type_object(
206 const std::string& type_name,
207 const TypeIdentifier* identifier,
208 const TypeObject* object);
209
210 RTPS_DllAPI inline void add_alias(
211 const std::string& alias_name,
212 const std::string& target_type)
213 {
214 std::unique_lock<std::recursive_mutex> scoped(m_MutexIdentifiers);
215 aliases_.emplace(std::pair<std::string, std::string>(alias_name, target_type));
216 }
217
229 const TypeIdentifierSeq& identifiers,
230 const OctetSeq& in_continuation_point,
231 OctetSeq& out_continuation_point,
232 size_t max_size) const;
233
243 const TypeIdentifier& identifier,
244 TypeObject& object) const;
245
252 const TypeIdentifier& identifier) const;
253
267 const TypeInformation& information) const;
268};
269
270} // namespace types
271} // namespace fastrtps
272} // namespace eprosima
273
274#endif // TYPE_OBJECT_TYPE_FACTORY_H
Definition DynamicTypePtr.h:27
Definition DynamicTypeBuilderPtr.h:27
This class represents the enumeration ReturnCode_t.
Definition TypesBase.h:190
Definition TypeDescriptor.h:30
Definition TypeIdentifier.h:81
Definition TypeObject.h:7986
Definition TypeObjectFactory.h:29
RTPS_DllAPI const TypeIdentifier * get_type_identifier_trying_complete(const std::string &type_name) const
RTPS_DllAPI const TypeInformation * get_type_information(const std::string &type_name) const
get_type_information Retrieves the TypeInformation of the named type.
const TypeIdentifier * try_get_complete(const TypeIdentifier *identifier) const
std::map< const std::string, const TypeIdentifier * > complete_identifiers_
Definition TypeObjectFactory.h:38
std::vector< TypeInformation * > informations_created_
Definition TypeObjectFactory.h:43
RTPS_DllAPI const TypeIdentifier * get_primitive_type_identifier(TypeKind kind) const
RTPS_DllAPI const TypeObject * get_type_object(const TypeIdentifier *identifier) const
void fill_complete_information(TypeInformation *info, const TypeIdentifier *ident) const
Fills the TypeInformation provided with the complete TypeIdentifiers and its complete dependencies if...
RTPS_DllAPI std::string get_type_name(const TypeKind kind) const
std::map< const TypeIdentifier *, TypeInformation * > informations_
Definition TypeObjectFactory.h:42
RTPS_DllAPI const TypeIdentifier * get_sequence_identifier(const std::string &type_name, uint32_t bound, bool complete=false)
RTPS_DllAPI void add_alias(const std::string &alias_name, const std::string &target_type)
Definition TypeObjectFactory.h:210
std::map< const TypeIdentifier *, const TypeObject * > objects_
Definition TypeObjectFactory.h:39
RTPS_DllAPI void add_type_object(const std::string &type_name, const TypeIdentifier *identifier, const TypeObject *object)
static RTPS_DllAPI TypeObjectFactory * get_instance()
RTPS_DllAPI const TypeIdentifier * get_array_identifier(const std::string &type_name, const std::vector< uint32_t > &bound, bool complete=false)
RTPS_DllAPI TypeKind get_type_kind(const std::string &type_name) const
RTPS_DllAPI bool typelookup_check_type_identifier(const TypeIdentifier &identifier) const
Checks if a TypeIdentifier is already known by the factory.
void apply_member_annotations(DynamicTypeBuilder_ptr &parent_type_builder, MemberId member_id, const AppliedAnnotationSeq &annotations) const
std::map< std::string, std::string > aliases_
Definition TypeObjectFactory.h:44
RTPS_DllAPI const TypeIdentifier * get_map_identifier(const std::string &key_type_name, const std::string &value_type_name, uint32_t bound, bool complete=false)
std::string get_key_from_hash(const DynamicType_ptr annotation_descriptor_type, const NameHash &hash) const
RTPS_DllAPI DynamicType_ptr build_dynamic_type(const std::string &name, const TypeIdentifier *identifier, const TypeObject *object=nullptr) const
void fill_complete_minimal_dependant_types(TypeInformation *info, const TypeIdentifier *identifier) const
Auxiliar function to fill minimal information with complete dependencies.
static RTPS_DllAPI ReturnCode_t delete_instance()
void fill_minimal_dependant_types(TypeInformation *info, const TypeIdentifier *identifier) const
Auxiliar function to fill minimal dependencies.
RTPS_DllAPI bool is_type_identifier_complete(const TypeIdentifier *identifier) const
std::map< const std::string, const TypeIdentifier * > identifiers_
Definition TypeObjectFactory.h:37
RTPS_DllAPI TypeInformation * get_type_information(const TypeIdentifier *identifier) const
get_type_information Retrieves the TypeInformation of the given TypeIdentifier.
std::map< const TypeIdentifier *, const TypeObject * > complete_objects_
Definition TypeObjectFactory.h:40
RTPS_DllAPI std::string get_type_name(const TypeIdentifier *identifier) const
RTPS_DllAPI const TypeIdentifier * get_type_identifier(const std::string &type_name, bool complete=false) const
RTPS_DllAPI const TypeObject * get_type_object(const std::string &type_name, bool complete=false) const
RTPS_DllAPI const TypeObject * typelookup_get_type_object_from_information(const TypeInformation &information) const
Retrieves the CompleteTypeObject from the given TypeInformation.
RTPS_DllAPI void add_type_identifier(const std::string &type_name, const TypeIdentifier *identifier)
void fill_complete_dependant_types(TypeInformation *info, const TypeIdentifier *identifier) const
Auxiliar function to fill complete dependencies.
DynamicType_ptr build_dynamic_type(TypeDescriptor &descriptor, const TypeObject *object, const DynamicType_ptr annotation_member_type=DynamicType_ptr(nullptr)) const
void fill_minimal_information(TypeInformation *info, const TypeIdentifier *ident) const
Fills the TypeInformation provided with the minimal TypeIdentifiers and its minimal dependencies.
void apply_type_annotations(DynamicTypeBuilder_ptr &type_builder, const AppliedAnnotationSeq &annotations) const
RTPS_DllAPI const TypeIdentifier * typelookup_get_type(const TypeIdentifier &identifier, TypeObject &object) const
Fills the given object with the complete version of the given identifier.
std::string generate_name_and_store_type_identifier(const TypeIdentifier *identifier) const
RTPS_DllAPI const TypeIdentifier * get_string_identifier(uint32_t bound, bool wide=false)
RTPS_DllAPI TypeIdentifierWithSizeSeq typelookup_get_type_dependencies(const TypeIdentifierSeq &identifiers, const OctetSeq &in_continuation_point, OctetSeq &out_continuation_point, size_t max_size) const
Returns a TypeIdentifierWithSizeSeq object filled with the dependencies of the given identifiers.
void nullify_all_entries(const TypeIdentifier *identifier)
const TypeIdentifier * get_stored_type_identifier(const TypeIdentifier *identifier) const
std::vector< TypeIdentifier * > identifiers_created_
Definition TypeObjectFactory.h:41
Definition TypeObject.h:7431
uint32_t MemberId
Definition TypesBase.h:285
std::vector< TypeIdentifier > TypeIdentifierSeq
Definition TypeIdentifier.h:428
std::vector< TypeIdentifierWithSize > TypeIdentifierWithSizeSeq
Definition TypeObject.h:7863
std::vector< octet > OctetSeq
Definition TypesBase.h:47
std::vector< AppliedAnnotation > AppliedAnnotationSeq
Definition AnnotationParameterValue.h:1150
octet TypeKind
Definition TypesBase.h:120
std::array< uint8_t, 4 > NameHash
Definition TypesBase.h:179
eProsima namespace.
Definition LibrarySettingsAttributes.h:23