Fast RTPS  Version 2.14.1
Fast RTPS
Loading...
Searching...
No Matches
MemberDescriptor.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_MEMBER_DESCRIPTOR_H
16#define TYPES_MEMBER_DESCRIPTOR_H
17
18#include <fastrtps/types/TypesBase.h>
19#include <fastrtps/types/DynamicTypePtr.h>
20
21namespace eprosima {
22namespace fastrtps {
23namespace types {
24
25class DynamicType;
26class AnnotationDescriptor;
27
29{
30protected:
31
32 std::string name_; // Name of the member
33 MemberId id_; // MemberId, it should be filled automatically when the member is added.
34 DynamicType_ptr type_; // Member's Type.
35 std::string default_value_; // Default value of the member in string.
36 uint32_t index_; // Definition order of the member inside it's parent.
37 std::vector<uint64_t> labels_; // Case Labels for unions.
38 bool default_label_; // TRUE if it's the default option of a union.
39
40 std::vector<AnnotationDescriptor*> annotation_; // Annotations to apply
41
43 friend class DynamicData;
44 friend class DynamicTypeMember;
45 friend class TypeObjectFactory;
46
48 const std::string& sDefaultValue) const;
49
51 const std::string& sName) const;
52
54 const DynamicType_ptr& type);
55
56public:
57
58 RTPS_DllAPI MemberDescriptor();
59
60 RTPS_DllAPI MemberDescriptor(
61 uint32_t index,
62 const std::string& name);
63
64 RTPS_DllAPI MemberDescriptor(
65 MemberId id,
66 const std::string& name,
67 DynamicType_ptr type);
68
69 RTPS_DllAPI MemberDescriptor(
70 MemberId id,
71 const std::string& name,
72 DynamicType_ptr type,
73 const std::string& defaultValue);
74
75 RTPS_DllAPI MemberDescriptor(
76 MemberId id,
77 const std::string& name,
78 DynamicType_ptr type,
79 const std::string& defaultValue,
80 const std::vector<uint64_t>& unionLabels,
81 bool isDefaultLabel);
82
83 RTPS_DllAPI MemberDescriptor(
84 const MemberDescriptor* descriptor);
85
86 RTPS_DllAPI ~MemberDescriptor();
87
89 const std::vector<uint64_t>& labels) const;
90
92 const MemberDescriptor* other);
93
94 RTPS_DllAPI bool equals(
95 const MemberDescriptor* other) const;
96
97 RTPS_DllAPI TypeKind get_kind() const;
98
99 RTPS_DllAPI MemberId get_id() const;
100
101 RTPS_DllAPI uint32_t get_index() const;
102
103 RTPS_DllAPI std::string get_name() const;
104
105 RTPS_DllAPI std::vector<uint64_t> get_union_labels() const;
106
107 RTPS_DllAPI std::string get_default_value() const
108 {
109 if (!default_value_.empty())
110 {
111 return default_value_;
112 }
113 // Try annotation
114 return annotation_get_default();
115 }
116
117 RTPS_DllAPI bool is_default_union_value() const;
118
119 RTPS_DllAPI bool is_consistent(
120 TypeKind parentKind) const;
121
122 RTPS_DllAPI void add_union_case_index(
123 uint64_t value);
124
125 RTPS_DllAPI void set_id(
126 MemberId id);
127
128 RTPS_DllAPI void set_index(
129 uint32_t index);
130
131 RTPS_DllAPI void set_name(
132 const std::string& name);
133
134 RTPS_DllAPI void set_type(
135 DynamicType_ptr type);
136
137 RTPS_DllAPI DynamicType_ptr get_type() const
138 {
139 return type_;
140 }
141
142 RTPS_DllAPI void set_default_union_value(
143 bool bDefault);
144
145 RTPS_DllAPI void set_default_value(
146 const std::string& value)
147 {
148 default_value_ = value;
149 }
150
151 // Annotations
153 AnnotationDescriptor& descriptor);
154
156 const std::string& annotation_name,
157 const std::string& key,
158 const std::string& value);
159
161 const std::string& name) const;
162
163 // Annotations application
164 RTPS_DllAPI bool annotation_is_optional() const;
165
166 RTPS_DllAPI bool annotation_is_key() const;
167
168 RTPS_DllAPI bool annotation_is_must_understand() const;
169
170 RTPS_DllAPI bool annotation_is_non_serialized() const;
171
172 RTPS_DllAPI bool annotation_is_value() const;
173
174 RTPS_DllAPI bool annotation_is_default_literal() const;
175
176 RTPS_DllAPI bool annotation_is_position() const;
177
178 RTPS_DllAPI bool annotation_is_bit_bound() const;
179
180 // Annotations getters
181 RTPS_DllAPI bool annotation_get_key() const;
182
183 RTPS_DllAPI std::string annotation_get_value() const;
184
185 RTPS_DllAPI std::string annotation_get_default() const;
186
187 RTPS_DllAPI uint16_t annotation_get_position() const;
188
189 RTPS_DllAPI uint16_t annotation_get_bit_bound() const;
190
191 // Annotations setters
192 RTPS_DllAPI void annotation_set_optional(
193 bool optional);
194
195 RTPS_DllAPI void annotation_set_key(
196 bool key);
197
199 bool must_understand);
200
202 bool non_serialized);
203
204 RTPS_DllAPI void annotation_set_value(
205 const std::string& value);
206
207 RTPS_DllAPI void annotation_set_default(
208 const std::string& default_value);
209
211
212 RTPS_DllAPI void annotation_set_position(
213 uint16_t position);
214
215 RTPS_DllAPI void annotation_set_bit_bound(
216 uint16_t bit_bound);
217};
218
219} // namespace types
220} // namespace fastrtps
221} // namespace eprosima
222
223#endif // TYPES_MEMBER_DESCRIPTOR_H
Definition AnnotationDescriptor.h:29
Definition DynamicData.h:44
Definition DynamicTypePtr.h:27
Definition DynamicTypeBuilderFactory.h:40
Definition DynamicTypeMember.h:29
Definition MemberDescriptor.h:29
RTPS_DllAPI bool annotation_is_key() const
RTPS_DllAPI bool annotation_is_default_literal() const
RTPS_DllAPI std::string annotation_get_default() const
bool default_label_
Definition MemberDescriptor.h:38
RTPS_DllAPI uint16_t annotation_get_position() const
RTPS_DllAPI void add_union_case_index(uint64_t value)
RTPS_DllAPI bool annotation_is_position() const
RTPS_DllAPI void annotation_set_default(const std::string &default_value)
RTPS_DllAPI bool annotation_is_bit_bound() const
bool is_default_value_consistent(const std::string &sDefaultValue) const
DynamicType_ptr type_
Definition MemberDescriptor.h:34
RTPS_DllAPI MemberDescriptor(MemberId id, const std::string &name, DynamicType_ptr type, const std::string &defaultValue)
uint32_t index_
Definition MemberDescriptor.h:36
RTPS_DllAPI bool is_consistent(TypeKind parentKind) const
RTPS_DllAPI void annotation_set_position(uint16_t position)
ReturnCode_t apply_annotation(AnnotationDescriptor &descriptor)
RTPS_DllAPI TypeKind get_kind() const
std::string name_
Definition MemberDescriptor.h:32
RTPS_DllAPI void annotation_set_value(const std::string &value)
bool check_union_labels(const std::vector< uint64_t > &labels) const
RTPS_DllAPI ReturnCode_t copy_from(const MemberDescriptor *other)
RTPS_DllAPI std::string get_name() const
RTPS_DllAPI void annotation_set_bit_bound(uint16_t bit_bound)
AnnotationDescriptor * get_annotation(const std::string &name) const
RTPS_DllAPI std::vector< uint64_t > get_union_labels() const
RTPS_DllAPI void annotation_set_optional(bool optional)
std::string default_value_
Definition MemberDescriptor.h:35
RTPS_DllAPI void annotation_set_must_understand(bool must_understand)
RTPS_DllAPI MemberDescriptor(uint32_t index, const std::string &name)
RTPS_DllAPI void set_default_union_value(bool bDefault)
RTPS_DllAPI void set_type(DynamicType_ptr type)
RTPS_DllAPI DynamicType_ptr get_type() const
Definition MemberDescriptor.h:137
RTPS_DllAPI void annotation_set_non_serialized(bool non_serialized)
void copy_annotations_from_type(const DynamicType_ptr &type)
RTPS_DllAPI uint32_t get_index() const
RTPS_DllAPI bool annotation_is_non_serialized() const
RTPS_DllAPI void set_default_value(const std::string &value)
Definition MemberDescriptor.h:145
RTPS_DllAPI bool equals(const MemberDescriptor *other) const
RTPS_DllAPI void annotation_set_key(bool key)
MemberId id_
Definition MemberDescriptor.h:33
bool is_type_name_consistent(const std::string &sName) const
RTPS_DllAPI bool is_default_union_value() const
std::vector< uint64_t > labels_
Definition MemberDescriptor.h:37
RTPS_DllAPI void set_index(uint32_t index)
ReturnCode_t apply_annotation(const std::string &annotation_name, const std::string &key, const std::string &value)
RTPS_DllAPI MemberId get_id() const
RTPS_DllAPI std::string get_default_value() const
Definition MemberDescriptor.h:107
RTPS_DllAPI bool annotation_get_key() const
RTPS_DllAPI bool annotation_is_value() const
RTPS_DllAPI MemberDescriptor(const MemberDescriptor *descriptor)
RTPS_DllAPI bool annotation_is_optional() const
RTPS_DllAPI void set_id(MemberId id)
RTPS_DllAPI uint16_t annotation_get_bit_bound() const
RTPS_DllAPI MemberDescriptor(MemberId id, const std::string &name, DynamicType_ptr type, const std::string &defaultValue, const std::vector< uint64_t > &unionLabels, bool isDefaultLabel)
RTPS_DllAPI MemberDescriptor(MemberId id, const std::string &name, DynamicType_ptr type)
std::vector< AnnotationDescriptor * > annotation_
Definition MemberDescriptor.h:40
RTPS_DllAPI bool annotation_is_must_understand() const
RTPS_DllAPI void set_name(const std::string &name)
RTPS_DllAPI std::string annotation_get_value() const
This class represents the enumeration ReturnCode_t.
Definition TypesBase.h:190
Definition TypeObjectFactory.h:29
uint32_t MemberId
Definition TypesBase.h:285
octet TypeKind
Definition TypesBase.h:120
eProsima namespace.
Definition LibrarySettingsAttributes.h:23