Fast RTPS  Version 2.6.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 
41  friend class DynamicTypeBuilder;
43  friend class MemberDescriptor;
44  friend class TypeDescriptor;
45  friend class DynamicData;
46  friend class DynamicDataFactory;
47  friend class AnnotationDescriptor;
48  friend class TypeObjectFactory;
49  friend class DynamicTypeMember;
50  friend class DynamicDataHelper;
52 
53  DynamicType();
54 
55  RTPS_DllAPI DynamicType(
56  const TypeDescriptor* descriptor);
57 
59  const DynamicTypeBuilder* other);
60 
61  RTPS_DllAPI virtual ~DynamicType();
62 
63  RTPS_DllAPI virtual void clear();
64 
66  const DynamicTypeBuilder* other);
67 
68  // Checks if there is a member with the given name.
70  const std::string& name) const;
71 
72  // This method is used by Dynamic Data to override the name of the types based on ALIAS.
73  void set_name(
74  const std::string& name);
75 
77  AnnotationDescriptor& descriptor);
78 
80  const std::string& annotation_name,
81  const std::string& key,
82  const std::string& value);
83 
85  MemberId id,
86  AnnotationDescriptor& descriptor);
87 
89  MemberId id,
90  const std::string& annotation_name,
91  const std::string& key,
92  const std::string& value);
93 
95  AnnotationDescriptor& descriptor,
96  uint32_t idx);
97 
98  uint32_t get_annotation_count();
99 
101 
103 
105 
107 
109  DynamicTypeMember& member,
110  MemberId id);
111 
113  DynamicTypeMember& member,
114  const std::string& name);
115 
117  std::map<MemberId, DynamicTypeMember*> member_by_id_; // Aggregated members
118  std::map<std::string, DynamicTypeMember*> member_by_name_; // Uses the pointers from "member_by_id_".
119  std::string name_;
122 
123 public:
124 
125  RTPS_DllAPI bool equals(
126  const DynamicType* other) const;
127 
128  RTPS_DllAPI ReturnCode_t get_all_members(
129  std::map<MemberId, DynamicTypeMember*>& members);
130 
132  std::map<std::string, DynamicTypeMember*>& members);
133 
134  RTPS_DllAPI uint32_t get_bounds(
135  uint32_t index = 0) const;
136 
137  RTPS_DllAPI uint32_t get_bounds_size() const;
138 
139  RTPS_DllAPI ReturnCode_t get_descriptor(
140  TypeDescriptor* descriptor) const;
141 
142  RTPS_DllAPI const TypeDescriptor* get_descriptor() const;
143 
144  RTPS_DllAPI TypeDescriptor* get_descriptor();
145 
146  RTPS_DllAPI bool key_annotation() const;
147 
148  RTPS_DllAPI inline TypeKind get_kind() const
149  {
150  return kind_;
151  }
152 
153  RTPS_DllAPI std::string get_name() const;
154 
155  RTPS_DllAPI MemberId get_members_count() const;
156 
157  RTPS_DllAPI uint32_t get_total_bounds() const;
158 
159  RTPS_DllAPI const TypeDescriptor* get_type_descriptor() const
160  {
161  return descriptor_;
162  }
163 
164  RTPS_DllAPI bool has_children() const;
165 
166  RTPS_DllAPI bool is_consistent() const;
167 
168  RTPS_DllAPI bool is_complex_kind() const;
169 
170  RTPS_DllAPI bool is_discriminator_type() const;
171 
172  RTPS_DllAPI size_t get_size() const;
173 
174 };
175 
176 } // namespace types
177 } // namespace fastrtps
178 } // namespace eprosima
179 
180 #endif // TYPES_DYNAMIC_TYPE_H
RTPS_DllAPI uint32_t get_bounds(uint32_t index=0) const
ReturnCode_t copy_from_builder(const DynamicTypeBuilder *other)
bool is_key_defined_
Definition: DynamicType.h:121
RTPS_DllAPI bool key_annotation() const
Definition: DynamicTypeBuilderFactory.h:39
Definition: TypeObjectFactory.h:28
TypeDescriptor * descriptor_
Definition: DynamicType.h:116
RTPS_DllAPI TypeKind get_kind() const
Definition: DynamicType.h:148
Definition: TypeDescriptor.h:29
RTPS_DllAPI size_t get_size() const
RTPS_DllAPI const TypeDescriptor * get_descriptor() const
Definition: DynamicData.h:43
uint32_t MemberId
Definition: TypesBase.h:272
RTPS_DllAPI bool is_complex_kind() const
RTPS_DllAPI const TypeDescriptor * get_type_descriptor() const
Definition: DynamicType.h:159
ReturnCode_t apply_annotation_to_member(MemberId id, AnnotationDescriptor &descriptor)
RTPS_DllAPI bool equals(const DynamicType *other) const
DynamicType_ptr get_element_type() const
Definition: DynamicTypeMember.h:28
friend class fastdds::dds::DomainParticipantImpl
Definition: DynamicType.h:51
DynamicType_ptr get_key_element_type() const
ReturnCode_t get_member(DynamicTypeMember &member, MemberId id)
RTPS_DllAPI MemberId get_members_count() const
eProsima namespace.
Definition: LibrarySettingsAttributes.h:23
Definition: DynamicTypeBuilder.h:31
virtual RTPS_DllAPI void clear()
Definition: MemberDescriptor.h:28
RTPS_DllAPI ReturnCode_t get_all_members_by_name(std::map< std::string, DynamicTypeMember *> &members)
octet TypeKind
Definition: TypesBase.h:119
DynamicType_ptr get_discriminator_type() const
This class represents the enumeration ReturnCode_t.
Definition: TypesBase.h:188
std::string name_
Definition: DynamicType.h:119
Definition: DynamicType.h:37
Definition: DynamicDataFactory.h:31
bool exists_member_by_name(const std::string &name) const
TypeKind kind_
Definition: DynamicType.h:120
RTPS_DllAPI bool is_consistent() const
Definition: AnnotationDescriptor.h:28
ReturnCode_t get_annotation(AnnotationDescriptor &descriptor, uint32_t idx)
RTPS_DllAPI uint32_t get_total_bounds() const
std::map< std::string, DynamicTypeMember * > member_by_name_
Definition: DynamicType.h:118
RTPS_DllAPI uint32_t get_bounds_size() const
RTPS_DllAPI std::string get_name() const
ReturnCode_t get_member_by_name(DynamicTypeMember &member, const std::string &name)
RTPS_DllAPI bool has_children() const
Definition: DynamicDataHelper.hpp:29
void set_name(const std::string &name)
ReturnCode_t apply_annotation(AnnotationDescriptor &descriptor)
DynamicType_ptr get_base_type() const
std::map< MemberId, DynamicTypeMember * > member_by_id_
Definition: DynamicType.h:117
RTPS_DllAPI bool is_discriminator_type() const
Definition: DynamicTypePtr.h:26
RTPS_DllAPI ReturnCode_t get_all_members(std::map< MemberId, DynamicTypeMember *> &members)