src
route_point.cpp
Go to the documentation of this file.
1
// *****************************************************************************
2
//
3
// Copyright (c) 2016, Southwest Research Institute® (SwRI®)
4
// All rights reserved.
5
//
6
// Redistribution and use in source and binary forms, with or without
7
// modification, are permitted provided that the following conditions are met:
8
// * Redistributions of source code must retain the above copyright
9
// notice, this list of conditions and the following disclaimer.
10
// * Redistributions in binary form must reproduce the above copyright
11
// notice, this list of conditions and the following disclaimer in the
12
// documentation and/or other materials provided with the distribution.
13
// * Neither the name of Southwest Research Institute® (SwRI®) nor the
14
// names of its contributors may be used to endorse or promote products
15
// derived from this software without specific prior written permission.
16
//
17
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
// ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
21
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
//
28
// *****************************************************************************
29
#include <
swri_route_util/route_point.h
>
30
31
namespace
swri_route_util
32
{
33
RoutePoint::RoutePoint
()
34
{
35
id_
=
"<not-initialized>"
;
36
stop_point_
=
false
;
37
}
38
39
std::vector<std::string>
RoutePoint::getPropertyNames
()
const
40
{
41
std::vector<std::string> names;
42
names.push_back(
"stop_point"
);
43
names.push_back(
"stop_point_delay"
);
44
45
for
(
auto
const
&it :
properties_
) {
46
names.push_back(it.first);
47
}
48
49
return
names;
50
}
51
52
std::string
RoutePoint::getProperty
(
const
std::string &name)
const
53
{
54
if
(
name
==
"stop_point"
) {
55
return
stop_point_
?
"true"
:
"false"
;
56
}
57
58
if
(
name
==
"stop_point_delay"
) {
59
return
boost::lexical_cast<std::string>(
stop_point_delay_
);
60
}
61
62
if
(
properties_
.count(
name
)) {
63
return
properties_
.at(
name
);
64
}
else
{
65
return
""
;
66
}
67
}
68
69
bool
RoutePoint::hasProperty
(
const
std::string &name)
const
70
{
71
if
(
name
==
"stop_point"
) {
return
true
; }
72
if
(
name
==
"stop_point_delay"
) {
return
true
; }
73
return
properties_
.count(
name
);
74
}
75
76
void
RoutePoint::setProperty
(
const
std::string &name,
const
std::string &value)
77
{
78
if
(
name
==
"stop_point"
) {
79
stop_point_
= (value ==
"1"
) || (value ==
"true"
);
80
}
else
if
(
name
==
"stop_point_delay"
) {
81
stop_point_delay_
= boost::lexical_cast<double>(value);
82
}
else
{
83
properties_
[
name
] = value;
84
}
85
}
86
87
void
RoutePoint::deleteProperty
(
const
std::string &name)
88
{
89
// If we add "native" properties that are erasable, we should check
90
// for those here first and mark them as deleted when appropriate.
91
92
// Otherwise, fall back to the generic properties.
93
// std::map::erase() ignores the call if the key is not found.
94
properties_
.erase(
name
);
95
}
96
}
// namespace swri_route_util
route_point.h
swri_route_util
Definition:
path_util.h:35
swri_route_util::RoutePoint::stop_point_delay_
double stop_point_delay_
Definition:
route_point.h:140
swri_route_util::RoutePoint::id_
std::string id_
Definition:
route_point.h:137
swri_route_util::RoutePoint::getPropertyNames
std::vector< std::string > getPropertyNames() const
Definition:
route_point.cpp:39
swri_route_util::RoutePoint::deleteProperty
void deleteProperty(const std::string &name)
Definition:
route_point.cpp:87
swri_route_util::RoutePoint::RoutePoint
RoutePoint()
Definition:
route_point.cpp:33
swri_route_util::RoutePoint::setProperty
void setProperty(const std::string &name, const std::string &value)
Definition:
route_point.cpp:76
swri_route_util::RoutePoint::hasProperty
bool hasProperty(const std::string &name) const
Definition:
route_point.cpp:69
swri_route_util::RoutePoint::getProperty
std::string getProperty(const std::string &name) const
Definition:
route_point.cpp:52
swri_route_util::RoutePoint::properties_
std::map< std::string, std::string > properties_
Definition:
route_point.h:142
name
string name
swri_route_util::RoutePoint::stop_point_
bool stop_point_
Definition:
route_point.h:139
swri_route_util
Author(s):
autogenerated on Fri Aug 2 2024 08:39:28