YARP
Yet Another Robot Platform
Param.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
10 
11 #include <yarp/os/LogStream.h>
12 #include <yarp/os/Property.h>
13 
14 #include <string>
15 
16 
17 std::ostream& std::operator<<(std::ostream& oss, const yarp::robotinterface::experimental::Param& t)
18 {
19  oss << "(\"" << t.name() << "\"" << (t.isGroup() ? " [group]" : "") << " = \"" << t.value() << "\")";
20  return oss;
21 }
22 
23 
25 {
26 public:
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 
51 yarp::robotinterface::experimental::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 
59 yarp::robotinterface::experimental::Param::Param(const ::yarp::robotinterface::experimental::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 
94 {
95  return mPriv->name;
96 }
97 
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 }
float t
yarp::os::LogStream operator<<(yarp::os::LogStream dbg, const yarp::robotinterface::experimental::Param &t)
Definition: Param.cpp:37
A class for storing options and configuration information.
Definition: Property.h:37
void fromString(const std::string &txt, bool wipe=true)
Interprets a string as a list of properties.
Definition: Property.cpp:1046
Param & operator=(const Param &other)
Definition: Param.cpp:67
yarp::os::Property toProperty() const
Definition: Param.cpp:108