Fast RTPS  Version 2.14.5
Fast RTPS
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 
24 namespace eprosima {
25 namespace fastrtps {
26 namespace types {
27 
29 {
30 private:
31 
32  mutable std::recursive_mutex m_MutexIdentifiers;
33  mutable std::recursive_mutex m_MutexObjects;
34  mutable std::recursive_mutex m_MutexInformations;
35 
36 protected:
37 
39  mutable std::map<const std::string, const TypeIdentifier*> identifiers_; // Basic, builtin and EK_MINIMAL
40  std::map<const std::string, const TypeIdentifier*> complete_identifiers_; // Only EK_COMPLETE
41  std::map<const TypeIdentifier*, const TypeObject*> objects_; // EK_MINIMAL
42  std::map<const TypeIdentifier*, const TypeObject*> complete_objects_; // EK_COMPLETE
43  mutable std::vector<TypeIdentifier*> identifiers_created_;
44  mutable std::map<const TypeIdentifier*, TypeInformation*> informations_;
45  mutable std::vector<TypeInformation*> informations_created_;
46  std::map<std::string, std::string> aliases_; // Aliases
47 
49  TypeDescriptor& descriptor,
50  const TypeObject* object,
51  const DynamicType_ptr annotation_member_type = DynamicType_ptr(nullptr)) const;
52 
54  const TypeIdentifier* identifier) const;
55 
57  const TypeIdentifier* identifier) const;
58 
60  const TypeIdentifier* identifier) const;
61 
63  const TypeIdentifier* identifier);
64 
66 
68 
70  DynamicTypeBuilder_ptr& type_builder,
71  const AppliedAnnotationSeq& annotations) const;
72 
74  DynamicTypeBuilder_ptr& parent_type_builder,
75  MemberId member_id,
76  const AppliedAnnotationSeq& annotations) const;
77 
78  std::string get_key_from_hash(
79  const DynamicType_ptr annotation_descriptor_type,
80  const NameHash& hash) const;
81 
88  TypeInformation* info,
89  const TypeIdentifier* ident) const;
90 
98  TypeInformation* info,
99  const TypeIdentifier* ident) const;
100 
107  TypeInformation* info,
108  const TypeIdentifier* identifier) const;
109 
116  TypeInformation* info,
117  const TypeIdentifier* identifier) const;
118 
125  TypeInformation* info,
126  const TypeIdentifier* identifier) const;
127 
128 public:
129 
130  RTPS_DllAPI static TypeObjectFactory* get_instance();
131 
132  RTPS_DllAPI static ReturnCode_t delete_instance();
133 
135 
142  const std::string& type_name) const;
143 
150  const TypeIdentifier* identifier) const;
151 
152  RTPS_DllAPI const TypeObject* get_type_object(
153  const std::string& type_name,
154  bool complete = false) const;
155 
156  RTPS_DllAPI const TypeObject* get_type_object(
157  const TypeIdentifier* identifier) const;
158 
159  RTPS_DllAPI TypeKind get_type_kind(
160  const std::string& type_name) const;
161 
162  RTPS_DllAPI std::string get_type_name(
163  const TypeKind kind) const;
164 
165  RTPS_DllAPI std::string get_type_name(
166  const TypeIdentifier* identifier) const;
167 
169  TypeKind kind) const;
170 
172  const std::string& type_name,
173  bool complete = false) const;
174 
176  const std::string& type_name) const;
177 
179  uint32_t bound,
180  bool wide = false);
181 
183  const std::string& type_name,
184  uint32_t bound,
185  bool complete = false);
186 
188  const std::string& type_name,
189  const std::vector<uint32_t>& bound,
190  bool complete = false);
191 
192  RTPS_DllAPI const TypeIdentifier* get_map_identifier(
193  const std::string& key_type_name,
194  const std::string& value_type_name,
195  uint32_t bound,
196  bool complete = false);
197 
199  const std::string& name,
200  const TypeIdentifier* identifier,
201  const TypeObject* object = nullptr) const;
202 
203  RTPS_DllAPI bool is_type_identifier_complete(
204  const TypeIdentifier* identifier) const;
205 
206  RTPS_DllAPI void add_type_identifier(
207  const std::string& type_name,
208  const TypeIdentifier* identifier);
209 
210  RTPS_DllAPI void add_type_object(
211  const std::string& type_name,
212  const TypeIdentifier* identifier,
213  const TypeObject* object);
214 
215  RTPS_DllAPI inline void add_alias(
216  const std::string& alias_name,
217  const std::string& target_type)
218  {
219  std::unique_lock<std::recursive_mutex> scoped(m_MutexIdentifiers);
220  aliases_.emplace(std::pair<std::string, std::string>(alias_name, target_type));
221  }
222 
234  const TypeIdentifierSeq& identifiers,
235  const OctetSeq& in_continuation_point,
236  OctetSeq& out_continuation_point,
237  size_t max_size) const;
238 
248  const TypeIdentifier& identifier,
249  TypeObject& object) const;
250 
257  const TypeIdentifier& identifier) const;
258 
272  const TypeInformation& information) const;
273 };
274 
275 } // namespace types
276 } // namespace fastrtps
277 } // namespace eprosima
278 
279 #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 TypeObject * typelookup_get_type_object_from_information(const TypeInformation &information) const
Retrieves the CompleteTypeObject from the given TypeInformation.
RTPS_DllAPI const TypeObject * get_type_object(const std::string &type_name, bool complete=false) const
std::map< const std::string, const TypeIdentifier * > complete_identifiers_
Definition: TypeObjectFactory.h:40
std::vector< TypeInformation * > informations_created_
Definition: TypeObjectFactory.h:45
const TypeIdentifier * try_get_complete(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:44
RTPS_DllAPI void add_alias(const std::string &alias_name, const std::string &target_type)
Definition: TypeObjectFactory.h:215
std::map< const TypeIdentifier *, const TypeObject * > objects_
Definition: TypeObjectFactory.h:41
RTPS_DllAPI void add_type_object(const std::string &type_name, const TypeIdentifier *identifier, const TypeObject *object)
RTPS_DllAPI const TypeIdentifier * get_type_identifier(const std::string &type_name, bool complete=false) const
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)
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:46
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.
RTPS_DllAPI const TypeIdentifier * get_array_identifier(const std::string &type_name, const std::vector< uint32_t > &bound, bool complete=false)
static RTPS_DllAPI ReturnCode_t delete_instance()
RTPS_DllAPI const TypeObject * get_type_object(const TypeIdentifier *identifier) const
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
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.
std::map< const std::string, const TypeIdentifier * > identifiers_
Definition: TypeObjectFactory.h:39
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::map< const TypeIdentifier *, const TypeObject * > complete_objects_
Definition: TypeObjectFactory.h:42
RTPS_DllAPI std::string get_type_name(const TypeIdentifier *identifier) const
const TypeIdentifier * get_stored_type_identifier(const TypeIdentifier *identifier) const
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.
RTPS_DllAPI TypeInformation * get_type_information(const TypeIdentifier *identifier) const
get_type_information Retrieves the TypeInformation of the given TypeIdentifier.
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.
RTPS_DllAPI const TypeIdentifier * get_string_identifier(uint32_t bound, bool wide=false)
RTPS_DllAPI const TypeIdentifier * get_primitive_type_identifier(TypeKind kind) const
void apply_type_annotations(DynamicTypeBuilder_ptr &type_builder, const AppliedAnnotationSeq &annotations) const
static RTPS_DllAPI TypeObjectFactory * get_instance()
std::string generate_name_and_store_type_identifier(const TypeIdentifier *identifier) const
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)
RTPS_DllAPI const TypeIdentifier * get_sequence_identifier(const std::string &type_name, uint32_t bound, bool complete=false)
std::vector< TypeIdentifier * > identifiers_created_
Definition: TypeObjectFactory.h:43
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