FastRTPS  Version 2.11.2
FastRTPS
TypeDescriptor.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_TYPE_DESCRIPTOR_H
16 #define TYPES_TYPE_DESCRIPTOR_H
17 
18 #include <fastrtps/types/AnnotationDescriptor.h>
19 #include <fastrtps/types/DynamicTypePtr.h>
20 #include <fastrtps/types/TypesBase.h>
21 
22 class MemberDescriptor;
23 class DynamicType;
24 
25 namespace eprosima {
26 namespace fastrtps {
27 namespace types {
28 
30 {
31 protected:
32 
33  TypeKind kind_; // Type Kind.
34  std::string name_; // Type Name.
35  DynamicType_ptr base_type_; // SuperType of an structure or base type of an alias type.
36  DynamicType_ptr discriminator_type_; // Discrimination type for a union.
37  std::vector<uint32_t> bound_; // Length for strings, arrays, sequences, maps and bitmasks.
38  DynamicType_ptr element_type_; // Value Type for arrays, sequences, maps, bitmasks.
39  DynamicType_ptr key_element_type_; // Key Type for maps.
40  std::vector<AnnotationDescriptor*> annotation_; // Annotations to apply
41 
42  RTPS_DllAPI void clean();
43 
44  static bool is_type_name_consistent(
45  const std::string& sName);
46 
48  friend class TypeObjectFactory;
49  friend class DynamicType;
50  friend class MemberDescriptor;
51  friend class DynamicDataHelper;
52 
53 public:
54 
55  RTPS_DllAPI TypeDescriptor();
56 
57  RTPS_DllAPI TypeDescriptor(
58  const TypeDescriptor* other);
59 
60  RTPS_DllAPI TypeDescriptor(
61  const std::string& name,
62  TypeKind kind);
63 
64  RTPS_DllAPI ~TypeDescriptor();
65 
66  RTPS_DllAPI ReturnCode_t copy_from(
67  const TypeDescriptor* descriptor);
68 
69  RTPS_DllAPI bool equals(
70  const TypeDescriptor* descriptor) const;
71 
72  RTPS_DllAPI bool is_consistent() const;
73 
74  RTPS_DllAPI DynamicType_ptr get_base_type() const;
75 
76  RTPS_DllAPI uint32_t get_bounds(
77  uint32_t index = 0) const;
78 
79  RTPS_DllAPI uint32_t get_bounds_size() const;
80 
81  RTPS_DllAPI DynamicType_ptr get_discriminator_type() const;
82 
83  RTPS_DllAPI DynamicType_ptr get_element_type() const;
84 
85  RTPS_DllAPI DynamicType_ptr get_key_element_type() const;
86 
87  RTPS_DllAPI TypeKind get_kind() const;
88 
89  RTPS_DllAPI std::string get_name() const;
90 
91  RTPS_DllAPI uint32_t get_total_bounds() const;
92 
93  RTPS_DllAPI void set_kind(
94  TypeKind kind);
95 
96  RTPS_DllAPI void set_name(
97  std::string name);
98 
99  RTPS_DllAPI ReturnCode_t apply_annotation(
100  AnnotationDescriptor& descriptor);
101 
102  RTPS_DllAPI ReturnCode_t apply_annotation(
103  const std::string& annotation_name,
104  const std::string& key,
105  const std::string& value);
106 
108  const std::string& name) const;
109 
110  // Annotations application
111  RTPS_DllAPI bool annotation_is_extensibility() const;
112 
113  RTPS_DllAPI bool annotation_is_mutable() const;
114 
115  RTPS_DllAPI bool annotation_is_final() const;
116 
117  RTPS_DllAPI bool annotation_is_appendable() const;
118 
119  RTPS_DllAPI bool annotation_is_nested() const;
120 
121  RTPS_DllAPI bool annotation_is_bit_bound() const;
122 
123  RTPS_DllAPI bool annotation_is_key() const;
124 
125  RTPS_DllAPI bool annotation_is_non_serialized() const;
126 
127  // Annotation getters
128  RTPS_DllAPI std::string annotation_get_extensibility() const;
129 
130  RTPS_DllAPI bool annotation_get_nested() const;
131 
132  RTPS_DllAPI uint16_t annotation_get_bit_bound() const;
133 
134  RTPS_DllAPI bool annotation_get_key() const;
135 
136  // Annotation setters
137  RTPS_DllAPI void annotation_set_extensibility(
138  const std::string& extensibility);
139 
140  RTPS_DllAPI void annotation_set_mutable();
141 
142  RTPS_DllAPI void annotation_set_final();
143 
144  RTPS_DllAPI void annotation_set_appendable();
145 
146  RTPS_DllAPI void annotation_set_nested(
147  bool nested);
148 
149  RTPS_DllAPI void annotation_set_bit_bound(
150  uint16_t bit_bound);
151 
152  RTPS_DllAPI void annotation_set_key(
153  bool key);
154 
155  RTPS_DllAPI void annotation_set_non_serialized(
156  bool non_serialized);
157 };
158 
159 } // namespace types
160 } // namespace fastrtps
161 } // namespace eprosima
162 
163 #endif // TYPES_TYPE_DESCRIPTOR_H
eprosima::fastrtps::types::TypeDescriptor::annotation_set_key
RTPS_DllAPI void annotation_set_key(bool key)
eprosima::fastrtps::types::TypeDescriptor::get_key_element_type
RTPS_DllAPI DynamicType_ptr get_key_element_type() const
eprosima::fastrtps::types::TypeDescriptor::get_bounds_size
RTPS_DllAPI uint32_t get_bounds_size() const
eprosima::fastrtps::types::TypeDescriptor::annotation_set_final
RTPS_DllAPI void annotation_set_final()
eprosima::fastrtps::types::TypeDescriptor::is_type_name_consistent
static bool is_type_name_consistent(const std::string &sName)
eprosima::fastrtps::types::TypeDescriptor::annotation_is_non_serialized
RTPS_DllAPI bool annotation_is_non_serialized() const
extensibility
Definition: BuiltinAnnotationsTypeObject.h:72
eprosima::fastrtps::types::TypeDescriptor::annotation_
std::vector< AnnotationDescriptor * > annotation_
Definition: TypeDescriptor.h:40
eprosima::fastrtps::types::TypeDescriptor::apply_annotation
RTPS_DllAPI ReturnCode_t apply_annotation(AnnotationDescriptor &descriptor)
eprosima::fastrtps::types::TypeDescriptor::key_element_type_
DynamicType_ptr key_element_type_
Definition: TypeDescriptor.h:39
eprosima::fastrtps::types::DynamicType
Definition: DynamicType.h:37
eprosima::fastrtps::types::TypeDescriptor::set_name
RTPS_DllAPI void set_name(std::string name)
eprosima::fastrtps::types::TypeObjectFactory
Definition: TypeObjectFactory.h:28
eprosima::fastrtps::types::TypeDescriptor::annotation_get_extensibility
RTPS_DllAPI std::string annotation_get_extensibility() const
eprosima::fastrtps::types::TypeDescriptor::get_base_type
RTPS_DllAPI DynamicType_ptr get_base_type() const
eprosima::fastrtps::types::TypeDescriptor::name_
std::string name_
Definition: TypeDescriptor.h:34
eprosima::fastrtps::types::TypeDescriptor::element_type_
DynamicType_ptr element_type_
Definition: TypeDescriptor.h:38
eprosima::fastrtps::types::TypeDescriptor::annotation_is_mutable
RTPS_DllAPI bool annotation_is_mutable() const
eprosima::fastrtps::types::AnnotationDescriptor
Definition: AnnotationDescriptor.h:28
eprosima::fastrtps::types::TypeDescriptor
Definition: TypeDescriptor.h:29
eprosima::fastrtps::types::MemberDescriptor
Definition: MemberDescriptor.h:28
eprosima::fastrtps::types::TypeDescriptor::annotation_is_appendable
RTPS_DllAPI bool annotation_is_appendable() const
eprosima::fastrtps::types::TypeKind
octet TypeKind
Definition: TypesBase.h:119
eprosima::fastrtps::types::TypeDescriptor::annotation_get_bit_bound
RTPS_DllAPI uint16_t annotation_get_bit_bound() const
eprosima::fastrtps::types::TypeDescriptor::annotation_set_extensibility
RTPS_DllAPI void annotation_set_extensibility(const std::string &extensibility)
eprosima::fastrtps::types::TypeDescriptor::kind_
TypeKind kind_
Definition: TypeDescriptor.h:33
eprosima::fastrtps::types::TypeDescriptor::get_annotation
RTPS_DllAPI AnnotationDescriptor * get_annotation(const std::string &name) const
eprosima::fastrtps::types::ReturnCode_t
This class represents the enumeration ReturnCode_t.
Definition: TypesBase.h:188
eprosima::fastrtps::types::TypeDescriptor::is_consistent
RTPS_DllAPI bool is_consistent() const
eprosima::fastrtps::types::TypeDescriptor::annotation_set_bit_bound
RTPS_DllAPI void annotation_set_bit_bound(uint16_t bit_bound)
eprosima::fastrtps::types::TypeDescriptor::annotation_get_nested
RTPS_DllAPI bool annotation_get_nested() const
eprosima::fastrtps::types::TypeDescriptor::annotation_set_mutable
RTPS_DllAPI void annotation_set_mutable()
eprosima::fastrtps::types::TypeDescriptor::get_discriminator_type
RTPS_DllAPI DynamicType_ptr get_discriminator_type() const
eprosima::fastrtps::types::DynamicTypeBuilderFactory
Definition: DynamicTypeBuilderFactory.h:39
eprosima::fastrtps::types::TypeDescriptor::annotation_set_nested
RTPS_DllAPI void annotation_set_nested(bool nested)
eprosima::fastrtps::types::TypeDescriptor::~TypeDescriptor
RTPS_DllAPI ~TypeDescriptor()
eprosima::fastrtps::types::TypeDescriptor::annotation_is_bit_bound
RTPS_DllAPI bool annotation_is_bit_bound() const
eprosima::fastrtps::types::TypeDescriptor::annotation_is_nested
RTPS_DllAPI bool annotation_is_nested() const
eprosima::fastrtps::types::TypeDescriptor::set_kind
RTPS_DllAPI void set_kind(TypeKind kind)
eprosima::fastrtps::types::TypeDescriptor::copy_from
RTPS_DllAPI ReturnCode_t copy_from(const TypeDescriptor *descriptor)
eprosima::fastrtps::types::TypeDescriptor::get_total_bounds
RTPS_DllAPI uint32_t get_total_bounds() const
eprosima::fastrtps::types::TypeDescriptor::discriminator_type_
DynamicType_ptr discriminator_type_
Definition: TypeDescriptor.h:36
eprosima::fastrtps::types::TypeDescriptor::get_name
RTPS_DllAPI std::string get_name() const
eprosima::fastrtps::types::TypeDescriptor::get_bounds
RTPS_DllAPI uint32_t get_bounds(uint32_t index=0) const
eprosima::fastrtps::types::TypeDescriptor::annotation_is_key
RTPS_DllAPI bool annotation_is_key() const
eprosima::fastrtps::types::DynamicDataHelper
Definition: DynamicDataHelper.hpp:29
eprosima::fastrtps::types::TypeDescriptor::TypeDescriptor
RTPS_DllAPI TypeDescriptor()
eprosima::fastrtps::types::TypeDescriptor::bound_
std::vector< uint32_t > bound_
Definition: TypeDescriptor.h:37
eprosima::fastrtps::types::TypeDescriptor::annotation_set_non_serialized
RTPS_DllAPI void annotation_set_non_serialized(bool non_serialized)
eprosima::fastrtps::types::TypeDescriptor::get_element_type
RTPS_DllAPI DynamicType_ptr get_element_type() const
eprosima::fastrtps::types::TypeDescriptor::base_type_
DynamicType_ptr base_type_
Definition: TypeDescriptor.h:35
eprosima::fastrtps::types::TypeDescriptor::annotation_set_appendable
RTPS_DllAPI void annotation_set_appendable()
eprosima::fastrtps::types::TypeDescriptor::annotation_is_extensibility
RTPS_DllAPI bool annotation_is_extensibility() const
eprosima::fastrtps::types::TypeDescriptor::annotation_is_final
RTPS_DllAPI bool annotation_is_final() const
eprosima::fastrtps::types::DynamicType_ptr
Definition: DynamicTypePtr.h:26
eprosima
Definition: LibrarySettingsAttributes.h:23
eprosima::fastrtps::types::TypeDescriptor::annotation_get_key
RTPS_DllAPI bool annotation_get_key() const
eprosima::fastrtps::types::TypeDescriptor::clean
RTPS_DllAPI void clean()
eprosima::fastrtps::types::TypeDescriptor::get_kind
RTPS_DllAPI TypeKind get_kind() const
eprosima::fastrtps::types::TypeDescriptor::equals
RTPS_DllAPI bool equals(const TypeDescriptor *descriptor) const