Fast RTPS  Version 2.14.1
Fast RTPS
Loading...
Searching...
No Matches
DynamicTypeBuilder.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_BUILDER_H
16#define TYPES_DYNAMIC_TYPE_BUILDER_H
17
18#include <fastrtps/types/TypesBase.h>
19#include <fastrtps/types/DynamicTypePtr.h>
20
21namespace eprosima {
22namespace fastrtps {
23namespace types {
24
25class AnnotationDescriptor;
26class TypeDescriptor;
27class MemberDescriptor;
28class DynamicType;
29class DynamicTypeMember;
30
32{
33protected:
35
37
39
41
42 friend class DynamicType;
44
46 std::map<MemberId, DynamicTypeMember*> member_by_id_; // Aggregated members
47 std::map<std::string, DynamicTypeMember*> member_by_name_; // Uses the pointers from "member_by_id_".
48 std::string name_;
51 uint32_t max_index_;
52
54 MemberId id,
55 AnnotationDescriptor& descriptor);
56
58 MemberId id,
59 const std::string& annotation_name,
60 const std::string& key,
61 const std::string& value);
62
64
65 // Checks if there is a member with the given name.
66 bool exists_member_by_name(const std::string& name) const;
67
69
70 void clear();
71
73
74public:
76 uint32_t index,
77 const std::string& name);
78
79 RTPS_DllAPI ReturnCode_t add_member(const MemberDescriptor* descriptor);
80
82 MemberId id,
83 const std::string& name,
84 DynamicTypeBuilder* type_ = nullptr);
85
87 MemberId id,
88 const std::string& name,
89 DynamicTypeBuilder* type_,
90 const std::string& defaultValue);
91
93 MemberId id,
94 const std::string& name,
95 DynamicTypeBuilder* type_,
96 const std::string& defaultValue,
97 const std::vector<uint64_t>& unionLabels,
98 bool isDefaultLabel);
99
101 MemberId id,
102 const std::string& name,
103 DynamicType_ptr type_ = DynamicType_ptr(nullptr));
104
106 MemberId id,
107 const std::string& name,
108 DynamicType_ptr type_,
109 const std::string& defaultValue);
110
112 MemberId id,
113 const std::string& name,
114 DynamicType_ptr type_,
115 const std::string& defaultValue,
116 const std::vector<uint64_t>& unionLabels,
117 bool isDefaultLabel);
118
120
122 const std::string& annotation_name,
123 const std::string& key,
124 const std::string& value);
125
127 MemberId id,
128 AnnotationDescriptor& descriptor);
129
131 MemberId id,
132 const std::string& annotation_name,
133 const std::string& key,
134 const std::string& value);
135
136 RTPS_DllAPI DynamicType_ptr build();
137
138 RTPS_DllAPI ReturnCode_t copy_from(const DynamicTypeBuilder* other);
139
140 ReturnCode_t get_all_members(std::map<MemberId, DynamicTypeMember*>& members);
141
142 RTPS_DllAPI inline TypeKind get_kind() const
143 {
144 return kind_;
145 }
146
147 RTPS_DllAPI std::string get_name() const;
148
149 RTPS_DllAPI MemberId get_member_id_by_name(const std::string& name) const;
150
152 {
153 return descriptor_;
154 }
155
156 bool is_consistent() const;
157
159
160 RTPS_DllAPI ReturnCode_t set_name(const std::string& name);
161};
162
163} // namespace types
164} // namespace fastrtps
165} // namespace eprosima
166
167#endif // TYPES_DYNAMIC_TYPE_BUILDER_H
Definition AnnotationDescriptor.h:29
Definition DynamicTypePtr.h:27
Definition DynamicTypeBuilderFactory.h:40
Definition DynamicTypeBuilder.h:32
RTPS_DllAPI ReturnCode_t add_member(MemberId id, const std::string &name, DynamicType_ptr type_, const std::string &defaultValue, const std::vector< uint64_t > &unionLabels, bool isDefaultLabel)
RTPS_DllAPI ReturnCode_t add_member(MemberId id, const std::string &name, DynamicType_ptr type_=DynamicType_ptr(nullptr))
MemberId current_member_id_
Definition DynamicTypeBuilder.h:50
RTPS_DllAPI ReturnCode_t add_member(const MemberDescriptor *descriptor)
ReturnCode_t copy_from_builder(const DynamicTypeBuilder *other)
RTPS_DllAPI ReturnCode_t add_member(MemberId id, const std::string &name, DynamicTypeBuilder *type_, const std::string &defaultValue, const std::vector< uint64_t > &unionLabels, bool isDefaultLabel)
ReturnCode_t _apply_annotation_to_member(MemberId id, AnnotationDescriptor &descriptor)
RTPS_DllAPI MemberId get_member_id_by_name(const std::string &name) const
RTPS_DllAPI ReturnCode_t add_member(MemberId id, const std::string &name, DynamicType_ptr type_, const std::string &defaultValue)
const TypeDescriptor * get_type_descriptor() const
Definition DynamicTypeBuilder.h:151
RTPS_DllAPI ReturnCode_t set_name(const std::string &name)
RTPS_DllAPI TypeKind get_kind() const
Definition DynamicTypeBuilder.h:142
RTPS_DllAPI ReturnCode_t add_member(MemberId id, const std::string &name, DynamicTypeBuilder *type_=nullptr)
std::string name_
Definition DynamicTypeBuilder.h:48
RTPS_DllAPI ReturnCode_t apply_annotation(AnnotationDescriptor &descriptor)
DynamicTypeBuilder(const DynamicTypeBuilder *builder)
RTPS_DllAPI std::string get_name() const
TypeDescriptor * descriptor_
Definition DynamicTypeBuilder.h:45
ReturnCode_t get_all_members(std::map< MemberId, DynamicTypeMember * > &members)
DynamicTypeBuilder(const TypeDescriptor *descriptor)
RTPS_DllAPI ReturnCode_t add_empty_member(uint32_t index, const std::string &name)
std::map< MemberId, DynamicTypeMember * > member_by_id_
Definition DynamicTypeBuilder.h:46
ReturnCode_t _apply_annotation_to_member(MemberId id, const std::string &annotation_name, const std::string &key, const std::string &value)
RTPS_DllAPI ReturnCode_t apply_annotation_to_member(MemberId id, const std::string &annotation_name, const std::string &key, const std::string &value)
RTPS_DllAPI ReturnCode_t add_member(MemberId id, const std::string &name, DynamicTypeBuilder *type_, const std::string &defaultValue)
TypeKind kind_
Definition DynamicTypeBuilder.h:49
std::map< std::string, DynamicTypeMember * > member_by_name_
Definition DynamicTypeBuilder.h:47
RTPS_DllAPI ReturnCode_t apply_annotation(const std::string &annotation_name, const std::string &key, const std::string &value)
uint32_t max_index_
Definition DynamicTypeBuilder.h:51
bool exists_member_by_name(const std::string &name) const
RTPS_DllAPI ReturnCode_t copy_from(const DynamicTypeBuilder *other)
RTPS_DllAPI ReturnCode_t apply_annotation_to_member(MemberId id, AnnotationDescriptor &descriptor)
RTPS_DllAPI DynamicType_ptr build()
bool check_union_configuration(const MemberDescriptor *descriptor)
Definition DynamicType.h:38
Definition MemberDescriptor.h:29
This class represents the enumeration ReturnCode_t.
Definition TypesBase.h:190
Definition TypeDescriptor.h:30
uint32_t MemberId
Definition TypesBase.h:285
octet TypeKind
Definition TypesBase.h:120
eProsima namespace.
Definition LibrarySettingsAttributes.h:23