FluxioProfile.cpp
Go to the documentation of this file.
1#include "FluxioProfile.h"
2
4
5#include <RobotAPI/interface/skills/SkillManagerInterface.h>
6#include <RobotAPI/libraries/skills/core/aron/FluxioIdentificator.aron.generated.h>
7
8namespace armarx
9{
10 namespace skills
11 {
12 manager::dto::FluxioProfile
14 {
15 manager::dto::FluxioProfile ret;
16
17 ret.id = id;
18 ret.name = name;
19 ret.description = description;
20 if (parentPtr == nullptr)
21 {
22 ret.parentIdHasValue = false;
23 ret.parentId.id = "";
24 ret.parentId.hint = "";
25 }
26 else
27 {
28 ret.parentIdHasValue = true;
29 ret.parentId = parentPtr->toFluxioIdentificatorIce();
30 }
31
32 return ret;
33 }
34
35 manager::arondto::FluxioProfile
37 {
38 manager::arondto::FluxioProfile ret;
39
40 ret.id = id;
41 ret.name = name;
42 ret.description = description;
43 if (parentPtr == nullptr)
44 {
45 ret.parentIdHasValue = false;
46 ret.parentId.id = "";
47 ret.parentId.hint = "";
48 }
49 else
50 {
51 ret.parentIdHasValue = true;
52 ret.parentId = parentPtr->toFluxioIdentificatorAron();
53 }
54
55 return ret;
56 }
57
58 manager::dto::FluxioIdentificator
60 {
61 manager::dto::FluxioIdentificator ret;
62
63 ret.id = id;
64 ret.hint = name;
65
66 return ret;
67 }
68
69 manager::arondto::FluxioIdentificator
71 {
72 manager::arondto::FluxioIdentificator ret;
73
74 ret.id = id;
75 ret.hint = name;
76
77 return ret;
78 }
79
81 FluxioProfile::FromFluxioIdentificatorIce(const manager::dto::FluxioIdentificator& i,
82 std::map<std::string, FluxioProfile>& profilesMap)
83 {
84 const auto& profilesEntry = profilesMap.find(i.id);
85
86 if (profilesEntry == profilesMap.end())
87 {
88 ARMARX_WARNING << "Profile with id " << i.id << " not found";
89 return nullptr;
90 }
91
92 return std::experimental::make_observer(&(profilesMap[profilesEntry->second.id]));
93 }
94
96 FluxioProfile::FromFluxioIdentificatorAron(const manager::arondto::FluxioIdentificator& i,
97 std::map<std::string, FluxioProfile>& profilesMap)
98 {
99 const auto& profilesEntry = profilesMap.find(i.id);
100
101 if (profilesEntry == profilesMap.end())
102 {
103 ARMARX_WARNING << "Profile with id " << i.id << " not found";
104 return nullptr;
105 }
106
107 return std::experimental::make_observer(&(profilesMap[profilesEntry->second.id]));
108 }
109
111 FluxioProfile::FromIce(const manager::dto::FluxioProfile& i,
112 std::map<std::string, FluxioProfile>& profilesMap)
113 {
114 // TODO: find a way to manage a list of import, so that the sorting of the list will not be problematic
115 FluxioProfile ret;
116
117 ret.id = i.id;
118 ret.name = i.name;
119 ret.description = i.description;
120 if (!i.parentIdHasValue)
121 {
122 ret.parentPtr = nullptr;
123 }
124 else
125 {
126 ret.parentPtr = FromFluxioIdentificatorIce(i.parentId, profilesMap);
127 }
128
129 return ret;
130 }
131 } // namespace skills
132} // 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.
This file offers overloads of toIce() and fromIce() functions for STL container types.
observer_ptr< _Tp > make_observer(_Tp *__p) noexcept
manager::arondto::FluxioIdentificator toFluxioIdentificatorAron() const
manager::dto::FluxioProfile toManagerIce() const
std::experimental::observer_ptr< const FluxioProfile > parentPtr
manager::arondto::FluxioProfile toManagerAron() const
static std::experimental::observer_ptr< const FluxioProfile > FromFluxioIdentificatorIce(const manager::dto::FluxioIdentificator &i, std::map< std::string, FluxioProfile > &profilesMap)
static std::experimental::observer_ptr< const FluxioProfile > FromFluxioIdentificatorAron(const manager::arondto::FluxioIdentificator &i, std::map< std::string, FluxioProfile > &profilesMap)
static FluxioProfile FromIce(const manager::dto::FluxioProfile &i, std::map< std::string, FluxioProfile > &profilesMap)
manager::dto::FluxioIdentificator toFluxioIdentificatorIce() const