FluxioSubSkillNode.cpp
Go to the documentation of this file.
2
4
9#include <RobotAPI/interface/skills/SkillManagerInterface.h>
10#include <RobotAPI/libraries/skills/core/aron/FluxioNode.aron.generated.h>
11
12#include "FluxioSkill.h"
13
14namespace armarx
15{
16 namespace skills
17 {
18 std::optional<manager::dto::FluxioNode>
20 {
21 if (skillPtr == nullptr)
22 {
23 ARMARX_WARNING << "Skill for SubSkillNode with id " << nodeId << " not set";
24 return std::nullopt;
25 }
26
27 const auto& nt = FluxioNodeTypeToString(nodeType);
28 if (!nt.has_value())
29 {
30 return std::nullopt;
31 }
32
33 manager::dto::FluxioNode ret;
34 ret.nodeId = nodeId;
35 ret.nodeType = nt.value();
36 ret.name = name;
37 ret.xPos = xPos;
38 ret.yPos = yPos;
39
40 manager::dto::FluxioIdentificator paramId;
41 paramId.id = "";
42 paramId.hint = "";
43 ret.parameterId = paramId;
44
45 ret.skillId = skillPtr->toFluxioIdentificatorIce();
46
47 return ret;
48 }
49
50 std::optional<manager::arondto::FluxioNode>
52 {
53 if (skillPtr == nullptr)
54 {
55 ARMARX_WARNING << "Skill for SubSkillNode with id " << nodeId << " not set";
56 return std::nullopt;
57 }
58
59 const auto& nt = FluxioNodeTypeToString(nodeType);
60 if (!nt.has_value())
61 {
62 return std::nullopt;
63 }
64
65 manager::arondto::FluxioNode ret;
66 ret.nodeId = nodeId;
67 ret.nodeType = nt.value();
68 ret.name = name;
69 ret.xPos = xPos;
70 ret.yPos = yPos;
71
72 manager::arondto::FluxioIdentificator paramId;
73 paramId.id = "";
74 paramId.hint = "";
75 ret.parameterId = paramId;
76
77 ret.skillId = skillPtr->toFluxioIdentificatorAron();
78
79 return ret;
80 }
81
82 std::optional<FluxioSubSkillNode>
83 FluxioSubSkillNode::FromIce(const manager::dto::FluxioNode& i,
84 std::map<std::string, FluxioSkill>& skillsMap)
85 {
86 if (i.skillId.id.empty())
87 {
88 ARMARX_WARNING << "Skills id is dummy id in SubSkillNode with id " << i.nodeId;
89 return std::nullopt;
90 }
91 const auto& skillPtr = FluxioSkill::FromFluxioIdentificatorIce(i.skillId, skillsMap);
92
93 if (skillPtr == nullptr)
94 {
95 ARMARX_WARNING << "Skill for SubSkillNode with id " << i.nodeId << " not found";
96 return std::nullopt;
97 }
98
100 ret.nodeId = i.nodeId;
101 ret.nodeType = FluxioNodeTypeFromString(i.nodeType);
102 ret.name = i.name;
103 ret.xPos = i.xPos;
104 ret.yPos = i.yPos;
105 ret.skillPtr = skillPtr;
106
107 return ret;
108 }
109
110 std::optional<FluxioSubSkillNode>
111 FluxioSubSkillNode::FromAron(const manager::arondto::FluxioNode& i,
112 std::map<std::string, FluxioSkill>& skillsMap)
113 {
114 if (i.skillId.id.empty())
115 {
116 ARMARX_WARNING << "Skills id is dummy id in SubSkillNode with id " << i.nodeId;
117 return std::nullopt;
118 }
119 const auto& skillPtr = FluxioSkill::FromFluxioIdentificatorAron(i.skillId, skillsMap);
120
121 if (skillPtr == nullptr)
122 {
123 ARMARX_WARNING << "Skill for SubSkillNode with id " << i.nodeId << " not found";
124 return std::nullopt;
125 }
126
128 ret.nodeId = i.nodeId;
129 ret.nodeType = FluxioNodeTypeFromString(i.nodeType);
130 ret.name = i.name;
131 ret.xPos = i.xPos;
132 ret.yPos = i.yPos;
133 ret.skillPtr = skillPtr;
134
135 return ret;
136 }
137 } // namespace skills
138} // 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::experimental::observer_ptr< const FluxioSkill > FromFluxioIdentificatorIce(const manager::dto::FluxioIdentificator &i, std::map< std::string, FluxioSkill > &skillsMap)
static std::experimental::observer_ptr< const FluxioSkill > FromFluxioIdentificatorAron(const manager::arondto::FluxioIdentificator &i, std::map< std::string, FluxioSkill > &skillsMap)
static std::optional< FluxioSubSkillNode > FromIce(const manager::dto::FluxioNode &i, std::map< std::string, FluxioSkill > &skillsMap)
static std::optional< FluxioSubSkillNode > FromAron(const manager::arondto::FluxioNode &i, std::map< std::string, FluxioSkill > &skillsMap)
std::optional< manager::arondto::FluxioNode > toAron() const override
std::optional< manager::dto::FluxioNode > toManagerIce() const override
std::experimental::observer_ptr< const FluxioSkill > skillPtr