Gazebo Math
API Reference
7.5.1
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-math
include
gz
math
graph
gz/math/graph/Vertex.hh
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2017 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
#ifndef GZ_MATH_GRAPH_VERTEX_HH_
18
#define GZ_MATH_GRAPH_VERTEX_HH_
19
20
// uint64_t
21
#include <cstdint>
22
#include <functional>
23
#include <map>
24
#include <ostream>
25
#include <string>
26
#include <utility>
27
28
#include <gz/math/config.hh>
29
#include <
gz/math/Helpers.hh
>
30
31
namespace
gz::math
32
{
33
// Inline bracket to help doxygen filtering.
34
inline
namespace
GZ_MATH_VERSION_NAMESPACE {
35
namespace
graph
36
{
39
using
VertexId
= uint64_t;
40
43
using
VertexId_P
=
std::pair<VertexId, VertexId>
;
44
46
static
const
VertexId
kNullId
=
MAX_UI64
;
47
51
template
<
typename
V>
52
class
Vertex
53
{
55
public
:
static
Vertex<V>
NullVertex
;
56
61
// cppcheck-suppress noExplicitConstructor
62
public
:
Vertex
(
const
std::string
&_name,
63
const
V &_data = V(),
64
const
VertexId
_id =
kNullId
)
65
: name(_name),
66
data(_data),
67
id(_id)
68
{
69
}
70
73
public
:
const
V &
Data
()
const
74
{
75
return
this->data;
76
}
77
80
public
: V &
Data
()
81
{
82
return
this->data;
83
}
84
87
public
:
VertexId
Id
()
const
88
{
89
return
this->id;
90
}
91
94
public
:
const
std::string
&
Name
()
const
95
{
96
return
this->name;
97
}
98
101
public
:
void
SetName
(
const
std::string
&_name)
102
{
103
this->name = _name;
104
}
105
108
public
:
bool
Valid
()
const
109
{
110
return
this->
id
!=
kNullId
;
111
}
112
118
public
:
friend
std::ostream
&
operator<<
(
std::ostream
&_out,
119
const
Vertex<V>
&_v)
120
{
121
_out <<
" "
<< _v.
Id
() <<
" [label=\""
<< _v.
Name
()
122
<<
" ("
<< _v.
Id
() <<
")\"];"
<<
std::endl
;
123
return
_out;
124
}
125
127
private
:
std::string
name =
""
;
128
130
private
: V data;
131
133
private
:
VertexId
id
=
kNullId
;
134
};
135
137
template
<
typename
V>
138
Vertex<V> Vertex<V>::NullVertex(
"__null__"
, V(),
kNullId
);
139
143
template
<
typename
V>
144
using
VertexRef_M
=
145
std::map<VertexId, std::reference_wrapper<const Vertex<V>
>>;
146
}
// namespace graph
147
}
// namespace GZ_MATH_VERSION_NAMESPACE
148
}
// namespace gz::math
149
#endif
// GZ_MATH_GRAPH_VERTEX_HH_