FluxioValue.cpp
Go to the documentation of this file.
1 #include "FluxioValue.h"
2 
3 #include <optional>
4 
6 
8 #include <RobotAPI/libraries/skills/core/aron/FluxioValue.aron.generated.h>
9 
10 #include "FluxioProfile.h"
11 
12 namespace armarx
13 {
14  namespace skills
15  {
16  std::optional<manager::dto::FluxioValue>
18  {
19  manager::dto::FluxioValue ret;
20 
21  if (profilePtr == nullptr)
22  {
23  ARMARX_WARNING << "Profile not set.";
24  return std::nullopt;
25  }
26 
27  ret.profileId = profilePtr->toFluxioIdentificatorIce();
28  if (content == nullptr)
29  {
30  // ARMARX_WARNING << "Content not set.";
31  return std::nullopt;
32  }
33  ret.content = content->toAronDTO();
34 
35  return ret;
36  }
37 
38  std::optional<FluxioValue>
39  FluxioValue::FromIce(const manager::dto::FluxioValue& i,
40  std::map<std::string, FluxioProfile>& profilesMap)
41  {
42  auto profilePtr = FluxioProfile::FromFluxioIdentificatorIce(i.profileId, profilesMap);
43 
44  if (profilePtr == nullptr)
45  {
46  return std::nullopt;
47  }
48 
50 
51  ret.profilePtr = profilePtr;
52  ret.content = armarx::aron::data::Variant::FromAronDTO(i.content);
53 
54  return ret;
55  }
56 
57  std::optional<FluxioValue>
58  FluxioValue::FromAron(const manager::arondto::FluxioValue& i,
59  std::map<std::string, FluxioProfile>& profilesMap)
60  {
61  auto profilePtr = FluxioProfile::FromFluxioIdentificatorAron(i.profileId, profilesMap);
62 
63  if (profilePtr == nullptr)
64  {
65  return std::nullopt;
66  }
67 
69 
70  ret.profilePtr = profilePtr;
71  if (!i.content->hasElement("content")) {
72  ARMARX_WARNING << "Error while converting FluxioValue from Aron for profile: '" << i.profileId.id << "': content not found";
73  return std::nullopt;
74  }
75  ret.content = i.content->getElement("content");
76 
77  return ret;
78  }
79 
80  std::optional<manager::arondto::FluxioValue>
82  {
83  manager::arondto::FluxioValue ret;
84 
85 
86  if (profilePtr == nullptr)
87  {
88  ARMARX_WARNING << "Profile not set.";
89  return std::nullopt;
90  }
91 
92  ret.profileId = profilePtr->toFluxioIdentificatorAron();
93  if (content == nullptr)
94  {
95  // ARMARX_WARNING << "Content not set.";
96  return std::nullopt;
97  }
98 
99  const aron::data::DictPtr& dict = aron::make_dict();
100  dict->addElement("content", content);
101  ret.content = dict;
102 
103  return ret;
104  }
105 
106  } // namespace skills
107 } // namespace armarx
armarx::aron::ret
ReaderT::InputType T & ret
Definition: rw.h:13
skills
This file is part of ArmarX.
armarx::skills::FluxioValue::FromIce
static std::optional< FluxioValue > FromIce(const manager::dto::FluxioValue &i, std::map< std::string, FluxioProfile > &profilesMap)
Definition: FluxioValue.cpp:39
armarx::skills::FluxioValue::toManagerIce
std::optional< manager::dto::FluxioValue > toManagerIce() const
Definition: FluxioValue.cpp:17
armarx::aron::data::Variant::FromAronDTO
static VariantPtr FromAronDTO(const data::dto::GenericDataPtr &, const Path &=Path())
create a variant from a dto object
Definition: Variant.cpp:39
armarx::aron::make_dict
aron::data::DictPtr make_dict(_Args &&... args)
Definition: Dict.h:107
FluxioValue.h
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
FluxioProfile.h
Dict.h
armarx::skills::FluxioValue::toAron
std::optional< manager::arondto::FluxioValue > toAron() const
Definition: FluxioValue.cpp:81
armarx::aron::data::DictPtr
std::shared_ptr< Dict > DictPtr
Definition: Dict.h:41
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::FluxioValue::profilePtr
std::experimental::observer_ptr< const FluxioProfile > profilePtr
Definition: FluxioValue.h:19
Logging.h
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:193
armarx::skills::FluxioValue::FromAron
static std::optional< FluxioValue > FromAron(const manager::arondto::FluxioValue &i, std::map< std::string, FluxioProfile > &profilesMap)
Definition: FluxioValue.cpp:58
armarx::skills::FluxioValue::content
armarx::aron::data::VariantPtr content
Definition: FluxioValue.h:20
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::skills::FluxioValue
Definition: FluxioValue.h:17