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
13
14std::ostream& std::operator<<(std::ostream& oss, const yarp::robotinterface::Param& t)
15{
16 oss << "(\"" << t.name() << "\"" << (t.isGroup() ? " [group]" : "") << " = \"" << t.value() << "\")";
17 return oss;
18}
19
20
22{
23public:
24 Private(Param* /*parent*/) :
25 isGroup(false)
26 {
27 }
28
29 std::string name;
30 std::string value;
31 bool isGroup;
32};
33
35{
36 std::ostringstream oss;
37 oss << t;
38 dbg << oss.str();
39 return dbg;
40}
41
43 mPriv(new Private(this))
44{
45 mPriv->isGroup = isGroup;
46}
47
48yarp::robotinterface::Param::Param(const std::string& name, const std::string& value, bool isGroup) :
49 mPriv(new Private(this))
50{
51 mPriv->name = name;
52 mPriv->value = value;
53 mPriv->isGroup = isGroup;
54}
55
56yarp::robotinterface::Param::Param(const ::yarp::robotinterface::Param& other) :
57 mPriv(new Private(this))
58{
59 mPriv->name = other.mPriv->name;
60 mPriv->value = other.mPriv->value;
61 mPriv->isGroup = other.mPriv->isGroup;
62}
63
65{
66 if (&other != this) {
67 mPriv->name = other.mPriv->name;
68 mPriv->value = other.mPriv->value;
69 mPriv->isGroup = other.mPriv->isGroup;
70 }
71
72 return *this;
73}
74
76{
77 delete mPriv;
78}
79
81{
82 return mPriv->name;
83}
84
86{
87 return mPriv->value;
88}
89
90const std::string& yarp::robotinterface::Param::name() const
91{
92 return mPriv->name;
93}
94
95const std::string& yarp::robotinterface::Param::value() const
96{
97 return mPriv->value;
98}
99
101{
102 return mPriv->isGroup;
103}
104
106{
108 std::string s = "(" + mPriv->name + " " + mPriv->value + ")";
109 p.fromString(s);
110 return p;
111}
float t
yarp::os::LogStream operator<<(yarp::os::LogStream dbg, const yarp::robotinterface::Param &t)
Definition Param.cpp:34
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:80
yarp::os::Property toProperty() const
Definition Param.cpp:105
Param & operator=(const Param &other)
Definition Param.cpp:64
std::string & value()
Definition Param.cpp:85
Param(bool isGroup=false)
Definition Param.cpp:42