Gazebo Transport
API Reference
15.1.0
insert_drive_file
Tutorials
library_books
Classes
toc
Namespaces
insert_drive_file
Files
launch
Gazebo Website
Index
List
Hierarchy
Members: All
Members: Functions
Members: Variables
Members: Typedefs
Members: Enumerations
Members: Enumerator
List
Members
Functions
Typedefs
Variables
Enumerations
Enumerator
src
gz-transport
include
gz
transport
TopicUtils.hh
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2014 Open Source Robotics Foundation
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*
16
*/
17
18
#ifndef GZ_TRANSPORT_TOPICUTILS_HH_
19
#define GZ_TRANSPORT_TOPICUTILS_HH_
20
21
#include <cstdint>
22
#include <string>
23
#include <optional>
24
#include <utility>
25
#include <vector>
26
27
#include "gz/transport/config.hh"
28
#include "gz/transport/Export.hh"
29
30
namespace
gz::transport
31
{
32
// Inline bracket to help doxygen filtering.
33
inline
namespace
GZ_TRANSPORT_VERSION_NAMESPACE {
34
//
37
class
GZ_TRANSPORT_VISIBLE
TopicUtils
38
{
45
public
:
static
bool
IsValidNamespace
(
const
std::string
&_ns);
46
54
public
:
static
bool
IsValidPartition
(
const
std::string
&_partition);
55
65
public
:
static
bool
IsValidTopic
(
const
std::string
&_topic);
66
103
public
:
static
bool
FullyQualifiedName
(
const
std::string
&_partition,
104
const
std::string
&_ns,
105
const
std::string
&_topic,
106
std::string
&_name);
107
128
public
:
static
bool
DecomposeFullyQualifiedTopic
(
129
const
std::string
&_fullyQualifiedName,
130
std::string
&_partition,
131
std::string
&_namespaceAndTopic);
132
164
public
:
static
bool
DecomposeLivelinessTokenHelper
(
165
const
std::string
&_token,
166
std::string
&_prefix,
167
std::string
&_partition,
168
std::string
&_namespaceAndTopic,
169
std::string
&_pUUID,
170
std::string
&_nUUID,
171
std::string
&_entityType,
172
std::string
&_remainingToken);
173
208
public
:
static
bool
DecomposeLivelinessToken
(
209
const
std::string
&_token,
210
std::string
&_prefix,
211
std::string
&_partition,
212
std::string
&_namespaceAndTopic,
213
std::string
&_pUUID,
214
std::string
&_nUUID,
215
std::string
&_entityType,
216
std::string
&_typeName);
217
253
public
:
static
bool
DecomposeLivelinessToken
(
254
const
std::string
&_token,
255
std::string
&_prefix,
256
std::string
&_partition,
257
std::string
&_namespaceAndTopic,
258
std::string
&_pUUID,
259
std::string
&_nUUID,
260
std::string
&_entityType,
261
std::string
&_reqType,
262
std::string
&_repType);
263
277
public
:
static
std::string
CreateLivelinessTokenHelper
(
278
const
std::string
&_fullyQualifiedTopic,
279
const
std::string
&_pUuid,
280
const
std::string
&_nUuid,
281
const
std::string
&_entityType);
282
297
public
:
static
std::string
CreateLivelinessToken
(
298
const
std::string
&_fullyQualifiedTopic,
299
const
std::string
&_pUuid,
300
const
std::string
&_nUuid,
301
const
std::string
&_entityType,
302
const
std::string
&_typeName);
303
319
public
:
static
std::string
CreateLivelinessToken
(
320
const
std::string
&_fullyQualifiedTopic,
321
const
std::string
&_pUuid,
322
const
std::string
&_nUuid,
323
const
std::string
&_entityType,
324
const
std::string
&_reqTypeName,
325
const
std::string
&_repTypeName);
326
333
public
:
static
std::string
AsValidTopic
(
const
std::string
&_topic);
334
338
public
:
static
std::string
MangleName
(
const
std::string
&_input);
339
343
public
:
static
std::string
DemangleName
(
const
std::string
&_input);
344
349
public
:
static
bool
MangleType
(
const
std::vector<std::string>
&_input,
350
std::string
&_output);
351
356
public
:
static
bool
DemangleType
(
const
std::string
&_input,
357
std::vector<std::string>
&_output);
358
362
public
:
static
const
uint16_t kMaxNameLength = 65535;
363
365
public
:
static
const
char
kTokenSeparator[];
366
368
public
:
static
const
char
kTypeSeparator[];
369
371
public
:
static
const
char
kTokenPrefix[];
372
374
public
:
static
const
char
kSlashReplacement
;
375
};
376
377
379
class
FullyQualifiedTopic
380
{
386
public
:
FullyQualifiedTopic
(
const
std::string
&_partition,
387
const
std::string
&_ns,
388
const
std::string
&_topic)
389
: partition(_partition), ns(_ns), topic(_topic)
390
{
391
// Avoid emplace+reset on fullTopic: GCC -Wmaybe-uninitialized
392
// false-positives the reset path through inlined readers.
393
std::string
fullName;
394
if
(TopicUtils::FullyQualifiedName(_partition, _ns, _topic, fullName))
395
this->fullTopic =
std::move
(fullName);
396
}
399
const
std::string
&
Partition
()
const
400
{
401
return
this->partition;
402
}
405
const
std::string
&
Namespace
()
const
406
{
407
return
this->ns;
408
}
411
const
std::string
&
Topic
()
const
412
{
413
return
this->topic;
414
}
417
std::optional<std::string>
FullTopic
()
const
418
{
419
return
this->fullTopic;
420
}
421
423
private
:
const
std::string
partition;
424
426
private
:
const
std::string
ns;
427
429
private
:
const
std::string
topic;
430
433
private
: std::optional<std::string> fullTopic;
434
};
435
}
436
}
437
438
#endif