YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
Param.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
7
8#include <yarp/os/LogStream.h>
9#include <yarp/os/Property.h>
10
11#include <string>
12
13namespace {
14YARP_LOG_COMPONENT(YRI_PARAM, "yarp.yri.Param")
15}
16
17std::ostream& std::operator<<(std::ostream& oss, const yarp::robotinterface::Param& t)
18{
19 oss << "(\"" << t.name() << "\"" << (t.isGroup() ? " [group]" : "") << " = \"" << t.value() << "\")";
20 return oss;
21}
22
23
25{
26public:
27 Private(Param* /*parent*/) :
28 isGroup(false)
29 {
30 }
31
32 std::string name;
33 std::string value;
34 bool isGroup;
35};
36
38{
39 std::ostringstream oss;
40 oss << t;
41 dbg << oss.str();
42 return dbg;
43}
44
46 mPriv(new Private(this))
47{
48 mPriv->isGroup = isGroup;
49}
50
51yarp::robotinterface::Param::Param(const std::string& name, const std::string& value, bool isGroup) :
52 mPriv(new Private(this))
53{
54 mPriv->name = name;
55 mPriv->value = value;
56 mPriv->isGroup = isGroup;
57}
58
59yarp::robotinterface::Param::Param(const ::yarp::robotinterface::Param& other) :
60 mPriv(new Private(this))
61{
62 mPriv->name = other.mPriv->name;
63 mPriv->value = other.mPriv->value;
64 mPriv->isGroup = other.mPriv->isGroup;
65}
66
68{
69 if (&other != this) {
70 mPriv->name = other.mPriv->name;
71 mPriv->value = other.mPriv->value;
72 mPriv->isGroup = other.mPriv->isGroup;
73 }
74
75 return *this;
76}
77
79{
80 delete mPriv;
81}
82
84{
85 return mPriv->name;
86}
87
89{
90 return mPriv->value;
91}
92
93const std::string& yarp::robotinterface::Param::name() const
94{
95 return mPriv->name;
96}
97
98const std::string& yarp::robotinterface::Param::value() const
99{
100 return mPriv->value;
101}
102
104{
105 return mPriv->isGroup;
106}
107
109{
111 std::string s = "(" + mPriv->name + " " + mPriv->value + ")";
112 p.fromString(s);
113 return p;
114}
yarp::os::LogStream operator<<(yarp::os::LogStream dbg, const yarp::robotinterface::Param &t)
Definition Param.cpp:37
A class for storing options and configuration information.
Definition Property.h:33
void fromString(const std::string &txt, bool wipe=true)
Interprets a string as a list of properties.
std::string & name()
Definition Param.cpp:83
yarp::os::Property toProperty() const
Definition Param.cpp:108
Param & operator=(const Param &other)
Definition Param.cpp:67
std::string & value()
Definition Param.cpp:88
Param(bool isGroup=false)
Definition Param.cpp:45
#define YARP_LOG_COMPONENT(name,...)