YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
ReturnValue.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2025-2025 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
9
10using namespace yarp::dev;
11using namespace yarp::os;
12
16
17#if !YARP_RETURNVALUE_DISABLE_BOOL_INPUT
18ReturnValue::ReturnValue(const bool& val)
19{
20 if (val)
21 {
23 }
24 else
25 {
27 }
28}
29#endif
30
32{
33 // THIS IS THE IMPLEMENTATION RULE:
34 // OP1 OP2 RESULT
35 // 1) True True True
36 // 2) FalseType1 FalseType1 FalseType1
37 // 3) FalseType1 FalseType2 FalseGeneric
38 // 4) True FalseType1 FalseGeneric
39 // 5) FalseType1 True FalseGeneric
40
41 if (this->value_b == other.value_b)
42 {
43 //cases 1 and 2
44 return *this;
45 }
46
48 return *this;
49}
50
52{
53 // THIS IS THE IMPLEMENTATION RULE:
54 // OP1 OP2 RESULT
55 // 1) True True True
56 // 2) FalseType1 FalseType1 FalseType1
57 // 3) FalseType1 FalseType2 FalseGeneric
58 // 4) True FalseType1 FalseGeneric
59 // 5) FalseType1 True FalseGeneric
60
61 if (this->value_b == other.value_b)
62 {
63 //cases 1 and 2
64 return *this;
65 }
66
68 return *this;
69}
70
71#if !YARP_RETURNVALUE_DISABLE_BOOL_INPUT
72ReturnValue& ReturnValue::operator=(const bool& bool_val)
73{
74 if (bool_val)
75 {
77 }
78 else
79 {
81 }
82 return *this;
83}
84#endif
85
87{
88 switch (value_b)
89 {
91 return std::string("ok");
93 return std::string("return_value_error_deprecated");
95 return std::string("return_value_error_generic");
97 return std::string("return_value_error_method_fail");
99 return std::string("return_value_error_not_implemented_by_device");
101 return std::string("return_value_error_nws_nwc_communication_error");
103 return std::string("return_value_error_not_ready");
104 default:
106 return std::string("unknown/uninitialized");
107 }
108}
109
110ReturnValue::operator bool() const
111{
112 return value_b == return_code::return_value_ok;
113}
114
116{
117 value_b = code;
118}
119
121{
122 if (code == this->value_b) return true;
123 return false;
124}
125
127{
128 if (value == this->value_b) return true;
129 return false;
130}
131
133{
134 connection.convertTextMode();
135 this->value_b = (ReturnValue::return_code)(connection.expectInt64());
136 return true;
137}
138
140{
141 connection.convertTextMode();
142 connection.appendInt64((int64_t)(this->value_b));
143 return true;
144}
bool operator==(const return_code &code) const
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
ReturnValue & operator&&(const ReturnValue &other)
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
ReturnValue & operator&=(const ReturnValue &other)
@ return_value_error_nws_nwc_communication_error
Method is not (yet) implemented.
@ return_value_error_deprecated
Command answer lost during network transmission. Status unknown.
@ return_value_error_generic
Method was successfully executed.
@ return_value_uninitialized
Method failed because some initialization is missing.
@ return_value_error_not_ready
Method failed due to invalid internal status/invalid request.
@ return_value_error_method_failed
Method is deprecated.
A mini-server for performing network communication in the background.
An interface for reading from a network connection.
An interface for writing to a network connection.
For streams capable of holding different kinds of content, check what they actually have.
Definition jointData.cpp:13
An interface to the operating system, including Port based communication.