YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
Route.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <yarp/os/Route.h>
8
9#include <yarp/os/Contact.h>
10
11#include <string>
12#include <utility>
13
14
16using yarp::os::Route;
17
18#ifndef DOXYGEN_SHOULD_SKIP_THIS
19
20class Route::Private
21{
22public:
23 Private(std::string fromName,
24 std::string toName,
25 Contact toContact,
26 std::string carrierName) :
27 fromName(std::move(fromName)),
28 toName(std::move(toName)),
29 toContact(std::move(toContact)),
30 carrierName(std::move(carrierName))
31 {
32 }
33
34 std::string fromName;
35 std::string toName;
36 Contact toContact;
37 std::string carrierName;
38};
39
40#endif // DOXYGEN_SHOULD_SKIP_THIS
41
42
44 mPriv(new Private(std::string(),
45 std::string(),
46 Contact(),
47 std::string()))
48{
49}
50
51Route::Route(const std::string& fromName,
52 const std::string& toName,
53 const std::string& carrierName) :
54 mPriv(new Private(fromName,
55 toName,
56 Contact(),
57 carrierName))
58{
59}
60
62 mPriv(new Private(*(rhs.mPriv)))
63{
64}
65
67 mPriv(rhs.mPriv)
68{
69 rhs.mPriv = nullptr;
70}
71
73{
74 delete mPriv;
75}
76
78{
79 if (&rhs != this) {
80 *mPriv = *(rhs.mPriv);
81 }
82 return *this;
83}
84
86{
87 if (&rhs != this) {
88 std::swap(mPriv, rhs.mPriv);
89 }
90 return *this;
91}
92
93const std::string& Route::getFromName() const
94{
95 return mPriv->fromName;
96}
97
98void Route::setFromName(const std::string& fromName)
99{
100 mPriv->fromName = fromName;
101}
102
103const std::string& Route::getToName() const
104{
105 return mPriv->toName;
106}
107
108void Route::setToName(const std::string& toName)
109{
110 mPriv->toName = toName;
111}
112
114{
115 return mPriv->toContact;
116}
117
119{
120 mPriv->toContact = toContact;
121}
122
123const std::string& Route::getCarrierName() const
124{
125 return mPriv->carrierName;
126}
127
128void Route::setCarrierName(const std::string& carrierName)
129{
130 mPriv->carrierName = carrierName;
131}
132
134{
135 mPriv->fromName.swap(mPriv->toName);
136}
137
138std::string Route::toString() const
139{
140 return getFromName() + "->" + getCarrierName() + "->" + getToName();
141}
A mini-server for performing network communication in the background.
Represents how to reach a part of a YARP network.
Definition Contact.h:33
Information about a connection between two ports.
Definition Route.h:28
const std::string & getToName() const
Get the destination of the route.
Definition Route.cpp:103
Route()
Default constructor.
Definition Route.cpp:43
virtual ~Route()
Destructor.
Definition Route.cpp:72
const std::string & getCarrierName() const
Get the carrier type of the route.
Definition Route.cpp:123
void setToName(const std::string &toName)
Set the destination of the route.
Definition Route.cpp:108
std::string toString() const
Render a text form of the route, "source->carrier->dest".
Definition Route.cpp:138
Route & operator=(const Route &rhs)
Copy assignment operator.
Definition Route.cpp:77
const std::string & getFromName() const
Get the source of the route.
Definition Route.cpp:93
void swapNames()
Swap from and to names.
Definition Route.cpp:133
void setFromName(const std::string &fromName)
Set the source of the route.
Definition Route.cpp:98
void setCarrierName(const std::string &carrierName)
Set the carrier type of the route.
Definition Route.cpp:128
void setToContact(const Contact &toContact)
Set the destination contact of the route.
Definition Route.cpp:118
const Contact & getToContact() const
Get the destination contact of the route, if available.
Definition Route.cpp:113
STL namespace.