YARP
Yet Another Robot Platform
Action.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 
12 
13 #include <yarp/os/LogStream.h>
14 
15 #include <string>
16 
17 
19 {
20 public:
21  Private(Action* /*parent*/) :
24  level(0)
25  {
26  }
27 
30  unsigned int level;
32 };
33 
34 std::ostream& std::operator<<(std::ostream& oss, const yarp::robotinterface::experimental::Action& t)
35 {
36  oss << "(\"" << ActionPhaseToString(t.phase()) << ":" << ActionTypeToString(t.type()) << ":" << t.level() << "\"";
37  if (!t.params().empty()) {
38  oss << ", params = [";
39  oss << t.params();
40  oss << "]";
41  }
42  oss << ")";
43  return oss;
44 }
45 
46 
48 {
49  std::ostringstream oss;
50  oss << t;
51  dbg << oss.str();
52  return dbg;
53 }
54 
56  mPriv(new Private(this))
57 {
58 }
59 
60 yarp::robotinterface::experimental::Action::Action(const std::string& phase, const std::string& type, unsigned int level) :
61  mPriv(new Private(this))
62 {
64  mPriv->type = StringToActionType(type);
65  mPriv->level = level;
66 }
67 
69  mPriv(new Private(this))
70 {
71  mPriv->phase = phase;
72  mPriv->type = type;
73  mPriv->level = level;
74 }
75 
77  mPriv(new Private(this))
78 {
79  mPriv->phase = other.mPriv->phase;
80  mPriv->type = other.mPriv->type;
81  mPriv->level = other.mPriv->level;
82  mPriv->params = other.mPriv->params;
83 }
84 
86 {
87  if (&other != this) {
88  mPriv->phase = other.mPriv->phase;
89  mPriv->type = other.mPriv->type;
90  mPriv->level = other.mPriv->level;
91 
92  mPriv->params.clear();
93  mPriv->params = other.mPriv->params;
94  }
95 
96  return *this;
97 }
98 
100 {
101  delete mPriv;
102 }
103 
105 {
106  return mPriv->phase;
107 }
108 
110 {
111  return mPriv->type;
112 }
113 
115 {
116  return mPriv->level;
117 }
118 
120 {
121  return mPriv->params;
122 }
123 
125 {
126  return mPriv->phase;
127 }
128 
130 {
131  return mPriv->type;
132 }
133 
135 {
136  return mPriv->level;
137 }
138 
140 {
141  return mPriv->params;
142 }
143 
144 bool yarp::robotinterface::experimental::Action::hasParam(const std::string& name) const
145 {
146  return yarp::robotinterface::experimental::hasParam(mPriv->params, name);
147 }
148 
149 std::string yarp::robotinterface::experimental::Action::findParam(const std::string& name) const
150 {
151  return yarp::robotinterface::experimental::findParam(mPriv->params, name);
152 }
yarp::os::LogStream operator<<(yarp::os::LogStream dbg, const yarp::robotinterface::experimental::Action &t)
Definition: Action.cpp:47
float t
Action & operator=(const Action &other)
Definition: Action.cpp:85
std::string findParam(const std::string &name) const
Definition: Action.cpp:149
bool hasParam(const std::string &name) const
Definition: Action.cpp:144
std::string findParam(const robotinterface::experimental::ParamList &list, const std::string &name)
Definition: Types.cpp:29
robotinterface::experimental::ActionType StringToActionType(const std::string &type)
Definition: Types.cpp:128
bool hasParam(const robotinterface::experimental::ParamList &list, const std::string &name)
Definition: Types.cpp:19
std::string ActionPhaseToString(robotinterface::experimental::ActionPhase actionphase)
Definition: Types.cpp:101
robotinterface::experimental::ActionPhase StringToActionPhase(const std::string &phase)
Definition: Types.cpp:83
std::string ActionTypeToString(robotinterface::experimental::ActionType actiontype)
Definition: Types.cpp:149
std::vector< robotinterface::experimental::Param > ParamList
Definition: Types.h:32