| Fast DDS Version 3.3.0 Fast DDS

Loading...
Searching...
No Matches
Token.hpp
1// Copyright 2016 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
18#ifndef FASTDDS_RTPS_COMMON__TOKEN_HPP
19#define FASTDDS_RTPS_COMMON__TOKEN_HPP
20
21#include <fastdds/fastdds_dll.hpp>
22#include <fastdds/rtps/common/Property.hpp>
23#include <fastdds/rtps/common/BinaryProperty.hpp>
24
25 namespace eprosima {
26 namespace fastdds {
27 namespace rtps {
28
29 class DataHolder
30{
31 public:
32
33 DataHolder()
34 {
35 }
36
37 DataHolder(
38 const DataHolder& data_holder)
39 : class_id_(data_holder.class_id_)
40 , properties_(data_holder.properties_)
41 , binary_properties_(data_holder.binary_properties_)
42 {
43 }
44
45 DataHolder(
46 DataHolder&& data_holder)
47 : class_id_(data_holder.class_id_)
48 , properties_(data_holder.properties_)
49 , binary_properties_(data_holder.binary_properties_)
50 {
51 }
52
53 DataHolder& operator =(
54 const DataHolder& data_holder)
55 {
56 class_id_ = data_holder.class_id_;
57 properties_ = data_holder.properties_;
58 binary_properties_ = data_holder.binary_properties_;
59
60 return *this;
61 }
62
63 DataHolder& operator =(
64 DataHolder&& data_holder)
65 {
66 class_id_ = std::move(data_holder.class_id_);
67 properties_ = std::move(data_holder.properties_);
68 binary_properties_ = std::move(data_holder.binary_properties_);
69
70 return *this;
71 }
72
73 bool is_nil() const
74 {
75 return class_id_.empty();
76 }
77
78 void class_id(
79 const std::string& class_id)
80 {
81 class_id_ = class_id;
82 }
83
84 void class_id(
85 std::string&& class_id)
86 {
87 class_id_ = std::move(class_id);
88 }
89
90 std::string& class_id()
91 {
92 return class_id_;
93 }
94
95 const std::string& class_id() const
96 {
97 return class_id_;
98 }
99
100 const PropertySeq& properties() const
101 {
102 return properties_;
103 }
104
105 PropertySeq& properties()
106 {
107 return properties_;
108 }
109
110 const BinaryPropertySeq& binary_properties() const
111 {
112 return binary_properties_;
113 }
114
115 BinaryPropertySeq& binary_properties()
116 {
117 return binary_properties_;
118 }
119
120 private:
121
122 std::string class_id_;
123
124 PropertySeq properties_;
125
126 BinaryPropertySeq binary_properties_;
127};
128
129 typedef std::vector<DataHolder> DataHolderSeq;
130 typedef DataHolder Token;
131 typedef Token IdentityToken;
132 typedef Token IdentityStatusToken;
133 typedef Token PermissionsToken;
134 typedef Token AuthenticatedPeerCredentialToken;
135 typedef Token PermissionsCredentialToken;
136
137 class DataHolderHelper
138{
139 public:
140
141 static std::string* find_property_value(
142 DataHolder& data_holder,
143 const std::string& name);
144
145 static const std::string* find_property_value(
146 const DataHolder& data_holder,
147 const std::string& name);
148
149 static Property* find_property(
150 DataHolder& data_holder,
151 const std::string& name);
152
153 static const Property* find_property(
154 const DataHolder& data_holder,
155 const std::string& name);
156
157 static std::vector<uint8_t>* find_binary_property_value(
158 DataHolder& data_holder,
159 const std::string& name);
160
161 static const std::vector<uint8_t>* find_binary_property_value(
162 const DataHolder& data_holder,
163 const std::string& name);
164
165 static BinaryProperty* find_binary_property(
166 DataHolder& data_holder,
167 const std::string& name);
168
169 static const BinaryProperty* find_binary_property(
170 const DataHolder& data_holder,
171 const std::string& name);
172
173 static size_t serialized_size(
174 const DataHolder& data_holder,
175 size_t current_alignment = 0);
176
177 static size_t serialized_size(
178 const DataHolderSeq& data_holders,
179 size_t current_alignment = 0);
180
181 private:
182
183 inline static size_t alignment(
184 size_t current_alignment,
185 size_t dataSize)
186 {
187 return (dataSize - (current_alignment % dataSize)) & (dataSize - 1);
188 }
189
190};
191
192} //namespace rtps
193} //namespace fastdds
194} //namespace eprosima
195
196#endif // FASTDDS_RTPS_COMMON__TOKEN_HPP
eprosima::fastdds::rtps::BinaryProperty
Definition BinaryProperty.hpp:32
eprosima::fastdds::rtps::DataHolderHelper
Definition Token.hpp:138
eprosima::fastdds::rtps::DataHolderHelper::find_binary_property_value
static const std::vector< uint8_t > * find_binary_property_value(const DataHolder &data_holder, const std::string &name)
eprosima::fastdds::rtps::DataHolderHelper::find_property_value
static std::string * find_property_value(DataHolder &data_holder, const std::string &name)
eprosima::fastdds::rtps::DataHolderHelper::serialized_size
static size_t serialized_size(const DataHolderSeq &data_holders, size_t current_alignment=0)
eprosima::fastdds::rtps::DataHolderHelper::serialized_size
static size_t serialized_size(const DataHolder &data_holder, size_t current_alignment=0)
eprosima::fastdds::rtps::DataHolderHelper::find_binary_property
static BinaryProperty * find_binary_property(DataHolder &data_holder, const std::string &name)
eprosima::fastdds::rtps::DataHolderHelper::find_property_value
static const std::string * find_property_value(const DataHolder &data_holder, const std::string &name)
eprosima::fastdds::rtps::DataHolderHelper::find_property
static Property * find_property(DataHolder &data_holder, const std::string &name)
eprosima::fastdds::rtps::DataHolderHelper::find_binary_property_value
static std::vector< uint8_t > * find_binary_property_value(DataHolder &data_holder, const std::string &name)
eprosima::fastdds::rtps::DataHolderHelper::find_property
static const Property * find_property(const DataHolder &data_holder, const std::string &name)
eprosima::fastdds::rtps::DataHolderHelper::find_binary_property
static const BinaryProperty * find_binary_property(const DataHolder &data_holder, const std::string &name)
eprosima::fastdds::rtps::DataHolder
Definition Token.hpp:30
eprosima::fastdds::rtps::DataHolder::class_id
std::string & class_id()
Definition Token.hpp:90
eprosima::fastdds::rtps::DataHolder::properties
const PropertySeq & properties() const
Definition Token.hpp:100
eprosima::fastdds::rtps::DataHolder::DataHolder
DataHolder(const DataHolder &data_holder)
Definition Token.hpp:37
eprosima::fastdds::rtps::DataHolder::DataHolder
DataHolder()
Definition Token.hpp:33
eprosima::fastdds::rtps::DataHolder::DataHolder
DataHolder(DataHolder &&data_holder)
Definition Token.hpp:45
eprosima::fastdds::rtps::DataHolder::class_id
const std::string & class_id() const
Definition Token.hpp:95
eprosima::fastdds::rtps::DataHolder::class_id
void class_id(const std::string &class_id)
Definition Token.hpp:78
eprosima::fastdds::rtps::DataHolder::binary_properties
BinaryPropertySeq & binary_properties()
Definition Token.hpp:115
eprosima::fastdds::rtps::DataHolder::binary_properties
const BinaryPropertySeq & binary_properties() const
Definition Token.hpp:110
eprosima::fastdds::rtps::DataHolder::properties
PropertySeq & properties()
Definition Token.hpp:105
eprosima::fastdds::rtps::DataHolder::class_id
void class_id(std::string &&class_id)
Definition Token.hpp:84
eprosima::fastdds::rtps::DataHolder::operator=
DataHolder & operator=(const DataHolder &data_holder)
Definition Token.hpp:53
eprosima::fastdds::rtps::DataHolder::is_nil
bool is_nil() const
Definition Token.hpp:73
eprosima::fastdds::rtps::Property
Definition Property.hpp:31
eprosima::fastdds::rtps
Contains the RTPS protocol implementation.
eprosima::fastdds::rtps::PropertySeq
std::vector< Property > PropertySeq
Definition Property.hpp:168
eprosima::fastdds::rtps::PermissionsToken
Token PermissionsToken
Definition Token.hpp:133
eprosima::fastdds::rtps::IdentityStatusToken
Token IdentityStatusToken
Definition Token.hpp:132
eprosima::fastdds::rtps::IdentityToken
Token IdentityToken
Definition Token.hpp:131
eprosima::fastdds::rtps::AuthenticatedPeerCredentialToken
Token AuthenticatedPeerCredentialToken
Definition Token.hpp:134
eprosima::fastdds::rtps::BinaryPropertySeq
std::vector< BinaryProperty > BinaryPropertySeq
Definition BinaryProperty.hpp:166
eprosima::fastdds::rtps::Token
DataHolder Token
Definition Token.hpp:130
eprosima::fastdds::rtps::DataHolderSeq
std::vector< DataHolder > DataHolderSeq
Definition Token.hpp:129
eprosima::fastdds::rtps::PermissionsCredentialToken
Token PermissionsCredentialToken
Definition Token.hpp:135
eprosima::fastdds
eprosima
eProsima namespace.