Fast RTPS  Version 2.1.0
Fast RTPS
DynamicType.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_H
16 #define TYPES_DYNAMIC_TYPE_H
17 
18 #include <fastrtps/types/TypesBase.h>
19 #include <fastrtps/types/DynamicTypePtr.h>
20 
21 namespace eprosima {
22 
23 namespace fastdds {
24 namespace dds {
25 class DomainParticipantImpl;
26 } // namespace dds
27 } // namespace fastdds
28 
29 namespace fastrtps {
30 namespace types {
31 
32 class AnnotationDescriptor;
33 class TypeDescriptor;
34 class DynamicTypeMember;
35 class DynamicTypeBuilder;
36 
38 {
39 protected:
40  friend class DynamicTypeBuilder;
42  friend class MemberDescriptor;
43  friend class TypeDescriptor;
44  friend class DynamicData;
45  friend class DynamicDataFactory;
46  friend class AnnotationDescriptor;
47  friend class TypeObjectFactory;
48  friend class DynamicTypeMember;
49  friend class DynamicDataHelper;
51 
53 
54  DynamicType(const TypeDescriptor* descriptor);
55 
57 
58  virtual ~DynamicType();
59 
60  virtual void clear();
61 
63 
64  // Checks if there is a member with the given name.
65  bool exists_member_by_name(const std::string& name) const;
66 
67  // This method is used by Dynamic Data to override the name of the types based on ALIAS.
68  void set_name(const std::string& name);
69 
71 
73  const std::string& annotation_name,
74  const std::string& key,
75  const std::string& value);
76 
78  MemberId id,
79  AnnotationDescriptor& descriptor);
80 
82  MemberId id,
83  const std::string& annotation_name,
84  const std::string& key,
85  const std::string& value);
86 
88  AnnotationDescriptor& descriptor,
89  uint32_t idx);
90 
92 
94 
96 
98 
100 
102  DynamicTypeMember& member,
103  MemberId id);
104 
106  DynamicTypeMember& member,
107  const std::string& name);
108 
110  std::map<MemberId, DynamicTypeMember*> member_by_id_; // Aggregated members
111  std::map<std::string, DynamicTypeMember*> member_by_name_; // Uses the pointers from "member_by_id_".
112  std::string name_;
115 
116 public:
117  RTPS_DllAPI bool equals(const DynamicType* other) const;
118 
119  RTPS_DllAPI ReturnCode_t get_all_members(std::map<MemberId, DynamicTypeMember*>& members);
120 
121  RTPS_DllAPI ReturnCode_t get_all_members_by_name(std::map<std::string, DynamicTypeMember*>& members);
122 
123  RTPS_DllAPI uint32_t get_bounds(uint32_t index = 0) const;
124 
125  RTPS_DllAPI uint32_t get_bounds_size() const;
126 
127  RTPS_DllAPI ReturnCode_t get_descriptor(TypeDescriptor* descriptor) const;
128 
129  RTPS_DllAPI const TypeDescriptor* get_descriptor() const;
130 
132 
133  RTPS_DllAPI bool key_annotation() const;
134 
135  RTPS_DllAPI inline TypeKind get_kind() const
136  {
137  return kind_;
138  }
139 
140  RTPS_DllAPI std::string get_name() const;
141 
142  RTPS_DllAPI MemberId get_members_count() const;
143 
144  RTPS_DllAPI uint32_t get_total_bounds() const;
145 
146  RTPS_DllAPI const TypeDescriptor* get_type_descriptor() const
147  {
148  return descriptor_;
149  }
150 
151  RTPS_DllAPI bool has_children() const;
152 
153  RTPS_DllAPI bool is_consistent() const;
154 
155  RTPS_DllAPI bool is_complex_kind() const;
156 
157  RTPS_DllAPI bool is_discriminator_type() const;
158 
159  RTPS_DllAPI size_t get_size() const;
160 
161 };
162 
163 } // namespace types
164 } // namespace fastrtps
165 } // namespace eprosima
166 
167 #endif // TYPES_DYNAMIC_TYPE_H
eprosima::fastrtps::types::DynamicType::get_member
ReturnCode_t get_member(DynamicTypeMember &member, MemberId id)
eprosima::fastrtps::types::MemberId
uint32_t MemberId
Definition: TypesBase.h:272
eprosima::fastrtps::types::DynamicType::name_
std::string name_
Definition: DynamicType.h:112
eprosima::fastrtps::types::DynamicType::get_members_count
RTPS_DllAPI MemberId get_members_count() const
eprosima::fastrtps::types::DynamicType::exists_member_by_name
bool exists_member_by_name(const std::string &name) const
eprosima::fastrtps::types::DynamicType::get_discriminator_type
DynamicType_ptr get_discriminator_type() const
eprosima::fastrtps::types::DynamicType::DynamicType
DynamicType(const DynamicTypeBuilder *other)
eprosima::fastrtps::types::DynamicType::is_consistent
RTPS_DllAPI bool is_consistent() const
eprosima::fastrtps::types::DynamicDataFactory
Definition: DynamicDataFactory.h:32
eprosima::fastrtps::types::DynamicType::kind_
TypeKind kind_
Definition: DynamicType.h:113
eprosima::fastrtps::types::DynamicType
Definition: DynamicType.h:38
eprosima::fastrtps::types::TypeObjectFactory
Definition: TypeObjectFactory.h:29
eprosima::fastrtps::types::DynamicType::DynamicType
DynamicType()
eprosima::fastrtps::types::DynamicType::get_annotation
ReturnCode_t get_annotation(AnnotationDescriptor &descriptor, uint32_t idx)
eprosima::fastrtps::types::DynamicType::get_descriptor
RTPS_DllAPI ReturnCode_t get_descriptor(TypeDescriptor *descriptor) const
eprosima::fastrtps::types::DynamicType::member_by_name_
std::map< std::string, DynamicTypeMember * > member_by_name_
Definition: DynamicType.h:111
eprosima::fastrtps::types::AnnotationDescriptor
Definition: AnnotationDescriptor.h:29
eprosima::fastrtps::types::TypeDescriptor
Definition: TypeDescriptor.h:29
eprosima::fastrtps::types::MemberDescriptor
Definition: MemberDescriptor.h:29
eprosima::fastrtps::types::DynamicType::get_total_bounds
RTPS_DllAPI uint32_t get_total_bounds() const
eprosima::fastrtps::types::DynamicType::get_member_by_name
ReturnCode_t get_member_by_name(DynamicTypeMember &member, const std::string &name)
eprosima::fastrtps::types::DynamicType::~DynamicType
virtual ~DynamicType()
eprosima::fastrtps::types::DynamicType::set_name
void set_name(const std::string &name)
eprosima::fastrtps::types::TypeKind
octet TypeKind
Definition: TypesBase.h:115
eprosima::fastrtps::types::DynamicTypeBuilder
Definition: DynamicTypeBuilder.h:32
eprosima::fastrtps::types::DynamicType::apply_annotation
ReturnCode_t apply_annotation(AnnotationDescriptor &descriptor)
eprosima::fastrtps::types::DynamicType::member_by_id_
std::map< MemberId, DynamicTypeMember * > member_by_id_
Definition: DynamicType.h:110
eprosima::fastrtps::types::DynamicType::get_name
RTPS_DllAPI std::string get_name() const
eprosima::fastrtps::types::DynamicType::get_bounds_size
RTPS_DllAPI uint32_t get_bounds_size() const
eprosima::fastrtps::types::DynamicType::get_base_type
DynamicType_ptr get_base_type() const
eprosima::fastrtps::types::ReturnCode_t
Definition: TypesBase.h:204
eprosima::fastrtps::types::DynamicType::has_children
RTPS_DllAPI bool has_children() const
eprosima::fastrtps::types::DynamicType::apply_annotation
ReturnCode_t apply_annotation(const std::string &annotation_name, const std::string &key, const std::string &value)
eprosima::fastrtps::types::DynamicType::get_bounds
RTPS_DllAPI uint32_t get_bounds(uint32_t index=0) const
eprosima::fastrtps::types::DynamicType::is_discriminator_type
RTPS_DllAPI bool is_discriminator_type() const
eprosima::fastrtps::types::DynamicType::copy_from_builder
ReturnCode_t copy_from_builder(const DynamicTypeBuilder *other)
eprosima::fastrtps::types::DynamicType::is_key_defined_
bool is_key_defined_
Definition: DynamicType.h:114
eprosima::fastrtps::types::DynamicType::key_annotation
RTPS_DllAPI bool key_annotation() const
eprosima::fastrtps::types::DynamicType::get_annotation_count
uint32_t get_annotation_count()
eprosima::fastrtps::types::DynamicType::DynamicType
DynamicType(const TypeDescriptor *descriptor)
eprosima::fastrtps::types::DynamicType::get_descriptor
RTPS_DllAPI const TypeDescriptor * get_descriptor() const
eprosima::fastrtps::types::DynamicType::is_complex_kind
RTPS_DllAPI bool is_complex_kind() const
eprosima::fastrtps::types::DynamicTypeBuilderFactory
Definition: DynamicTypeBuilderFactory.h:40
eprosima::fastrtps::types::DynamicType::clear
virtual void clear()
eprosima::fastrtps::types::DynamicType::descriptor_
TypeDescriptor * descriptor_
Definition: DynamicType.h:109
eprosima::fastrtps::types::DynamicType::apply_annotation_to_member
ReturnCode_t apply_annotation_to_member(MemberId id, AnnotationDescriptor &descriptor)
eprosima::fastrtps::types::DynamicType::get_kind
RTPS_DllAPI TypeKind get_kind() const
Definition: DynamicType.h:135
eprosima::fastrtps::types::DynamicType::apply_annotation_to_member
ReturnCode_t apply_annotation_to_member(MemberId id, const std::string &annotation_name, const std::string &key, const std::string &value)
eprosima::fastrtps::types::DynamicType::get_size
RTPS_DllAPI size_t get_size() const
eprosima::fastrtps::types::DynamicType::get_element_type
DynamicType_ptr get_element_type() const
eprosima::fastrtps::types::DynamicType::get_descriptor
RTPS_DllAPI TypeDescriptor * get_descriptor()
eprosima::fastrtps::types::DynamicType::get_type_descriptor
RTPS_DllAPI const TypeDescriptor * get_type_descriptor() const
Definition: DynamicType.h:146
eprosima::fastrtps::types::DynamicType::get_all_members
RTPS_DllAPI ReturnCode_t get_all_members(std::map< MemberId, DynamicTypeMember * > &members)
eprosima::fastrtps::types::DynamicDataHelper
Definition: DynamicDataHelper.hpp:30
eprosima::fastrtps::types::DynamicType::equals
RTPS_DllAPI bool equals(const DynamicType *other) const
eprosima::fastrtps::types::DynamicTypeMember
Definition: DynamicTypeMember.h:29
eprosima::fastrtps::types::DynamicData
Definition: DynamicData.h:32
eprosima::fastrtps::types::DynamicType_ptr
Definition: DynamicTypePtr.h:27
eprosima
eProsima namespace.
Definition: LibrarySettingsAttributes.h:23
eprosima::fastrtps::types::DynamicType::get_all_members_by_name
RTPS_DllAPI ReturnCode_t get_all_members_by_name(std::map< std::string, DynamicTypeMember * > &members)
eprosima::fastrtps::types::DynamicType::DomainParticipantImpl
friend class fastdds::dds::DomainParticipantImpl
Definition: DynamicType.h:50
eprosima::fastrtps::types::DynamicType::get_key_element_type
DynamicType_ptr get_key_element_type() const