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 
8 namespace 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
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
armarx::aron::ret
ReaderT::InputType T & ret
Definition: rw.h:13
skills
This file is part of ArmarX.
armarx::skills::FluxioProfile::toFluxioIdentificatorIce
manager::dto::FluxioIdentificator toFluxioIdentificatorIce() const
Definition: FluxioProfile.cpp:59
armarx::skills::FluxioProfile::FromFluxioIdentificatorAron
static std::experimental::observer_ptr< const FluxioProfile > FromFluxioIdentificatorAron(const manager::arondto::FluxioIdentificator &i, std::map< std::string, FluxioProfile > &profilesMap)
Definition: FluxioProfile.cpp:96
std::experimental::fundamentals_v2::make_observer
observer_ptr< _Tp > make_observer(_Tp *__p) noexcept
FluxioProfile.h
armarx::skills::FluxioProfile::name
std::string name
Definition: FluxioProfile.h:17
std::experimental::fundamentals_v2::observer_ptr
Definition: ManagedIceObject.h:53
armarx::skills::FluxioProfile::FromIce
static FluxioProfile FromIce(const manager::dto::FluxioProfile &i, std::map< std::string, FluxioProfile > &profilesMap)
Definition: FluxioProfile.cpp:111
armarx::skills::FluxioProfile::toFluxioIdentificatorAron
manager::arondto::FluxioIdentificator toFluxioIdentificatorAron() const
Definition: FluxioProfile.cpp:70
armarx::skills::FluxioProfile::id
std::string id
Definition: FluxioProfile.h:16
armarx::skills::FluxioProfile::toManagerIce
manager::dto::FluxioProfile toManagerIce() const
Definition: FluxioProfile.cpp:13
armarx::skills::FluxioProfile::description
std::string description
Definition: FluxioProfile.h:18
armarx::skills::FluxioProfile
Definition: FluxioProfile.h:14
armarx::skills::FluxioProfile::FromFluxioIdentificatorIce
static std::experimental::observer_ptr< const FluxioProfile > FromFluxioIdentificatorIce(const manager::dto::FluxioIdentificator &i, std::map< std::string, FluxioProfile > &profilesMap)
Definition: FluxioProfile.cpp:81
armarx::skills::FluxioProfile::toManagerAron
manager::arondto::FluxioProfile toManagerAron() const
Definition: FluxioProfile.cpp:36
Logging.h
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:193
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::skills::FluxioProfile::parentPtr
std::experimental::observer_ptr< const FluxioProfile > parentPtr
Definition: FluxioProfile.h:19