FluxioParameterNode.cpp
Go to the documentation of this file.
2
3#include <optional>
4
6
8#include <RobotAPI/interface/skills/SkillManagerInterface.h>
9#include <RobotAPI/libraries/skills/core/aron/FluxioNode.aron.generated.h>
10
11#include "FluxioParameter.h"
12
13namespace armarx
14{
15 namespace skills
16 {
17 std::optional<manager::dto::FluxioNode>
19 {
20 if (parameterPtr == nullptr)
21 {
22 ARMARX_WARNING << "Parameter for Parameternode with id " << nodeId << " not set";
23 return std::nullopt;
24 }
25
26 const auto& nt = FluxioNodeTypeToString(nodeType);
27 if (!nt.has_value())
28 {
29 return std::nullopt;
30 }
31
32 manager::dto::FluxioNode ret;
33 ret.nodeId = nodeId;
34 ret.nodeType = nt.value();
35 ret.name = name;
36 ret.xPos = xPos;
37 ret.yPos = yPos;
38 ret.parameterId = parameterPtr->toFluxioIdentificatorIce();
39
40 manager::dto::FluxioIdentificator subSId;
41 subSId.id = "";
42 subSId.hint = "";
43 ret.skillId = subSId;
44
45 return ret;
46 }
47
48 std::optional<manager::arondto::FluxioNode>
50 {
51 if (parameterPtr == nullptr)
52 {
53 ARMARX_WARNING << "Parameter for Parameternode with id " << nodeId << " not set";
54 return std::nullopt;
55 }
56
57 const auto& nt = FluxioNodeTypeToString(nodeType);
58 if (!nt.has_value())
59 {
60 return std::nullopt;
61 }
62
63 manager::arondto::FluxioNode ret;
64 ret.nodeId = nodeId;
65 ret.nodeType = nt.value();
66 ret.name = name;
67 ret.xPos = xPos;
68 ret.yPos = yPos;
69 ret.parameterId = parameterPtr->toFluxioIdentificatorAron();
70
71 manager::arondto::FluxioIdentificator subSId;
72 subSId.id = "";
73 subSId.hint = "";
74 ret.skillId = subSId;
75
76 return ret;
77 }
78
79 std::optional<FluxioParameterNode>
80 FluxioParameterNode::FromIce(const manager::dto::FluxioNode& i,
81 std::map<std::string, FluxioParameter>& parametersMap)
82 {
83 if (i.parameterId.id.empty())
84 {
85 ARMARX_WARNING << "Parameters id is dummy id in ParameterNode with id " << i.nodeId;
86 return std::nullopt;
87 }
88 const auto& parameterPtr =
89 FluxioParameter::FromFluxioIdentificatorIce(i.parameterId, parametersMap);
90
91 if (parameterPtr == nullptr)
92 {
93 return std::nullopt;
94 }
95
97
98 ret.nodeId = i.nodeId;
99 ret.nodeType = FluxioNodeTypeFromString(i.nodeType);
100 ret.name = i.name;
101 ret.xPos = i.xPos;
102 ret.yPos = i.yPos;
104
105 return ret;
106 }
107
108 std::optional<FluxioParameterNode>
109 FluxioParameterNode::FromAron(const manager::arondto::FluxioNode& i,
110 std::map<std::string, FluxioParameter>& parametersMap)
111 {
112 if (i.parameterId.id.empty())
113 {
114 ARMARX_WARNING << "Parameters id is dummy id in ParameterNode with id " << i.nodeId;
115 return std::nullopt;
116 }
117 const auto& parameterPtr =
118 FluxioParameter::FromFluxioIdentificatorAron(i.parameterId, parametersMap);
119
120 if (parameterPtr == nullptr)
121 {
122 return std::nullopt;
123 }
124
126
127 ret.nodeId = i.nodeId;
128 ret.nodeType = FluxioNodeTypeFromString(i.nodeType);
129 ret.name = i.name;
130 ret.xPos = i.xPos;
131 ret.yPos = i.yPos;
133
134 return ret;
135 }
136 } // namespace skills
137} // namespace armarx
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
Definition Logging.h:193
This file is part of ArmarX.
FluxioNodeType FluxioNodeTypeFromString(const std::string &type)
std::optional< std::string > FluxioNodeTypeToString(const FluxioNodeType &type)
This file offers overloads of toIce() and fromIce() functions for STL container types.
FluxioNodeType nodeType
Definition FluxioNode.h:26
static std::optional< FluxioParameterNode > FromIce(const manager::dto::FluxioNode &i, std::map< std::string, FluxioParameter > &parametersMap)
std::optional< manager::arondto::FluxioNode > toAron() const override
std::experimental::observer_ptr< const FluxioParameter > parameterPtr
std::optional< manager::dto::FluxioNode > toManagerIce() const override
static std::optional< FluxioParameterNode > FromAron(const manager::arondto::FluxioNode &i, std::map< std::string, FluxioParameter > &parametersMap)
static std::experimental::observer_ptr< const FluxioParameter > FromFluxioIdentificatorAron(const manager::arondto::FluxioIdentificator &i, const std::map< std::string, FluxioParameter > &parametersMap)
static std::experimental::observer_ptr< const FluxioParameter > FromFluxioIdentificatorIce(const manager::dto::FluxioIdentificator &i, const std::map< std::string, FluxioParameter > &parametersMap)