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
12namespace 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
49 FluxioValue ret;
50
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
68 FluxioValue ret;
69
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
100 dict->addElement("content", content);
101 ret.content = dict;
102
103 return ret;
104 }
105
106 } // namespace skills
107} // namespace armarx
static VariantPtr FromAronDTO(const data::dto::GenericDataPtr &, const Path &=Path())
create a variant from a dto object
Definition Variant.cpp:39
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
Definition Logging.h:193
std::shared_ptr< Dict > DictPtr
Definition Dict.h:42
aron::data::DictPtr make_dict(_Args &&... args)
Definition Dict.h:107
This file is part of ArmarX.
This file offers overloads of toIce() and fromIce() functions for STL container types.
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)
std::optional< manager::dto::FluxioValue > toManagerIce() const
std::optional< manager::arondto::FluxioValue > toAron() const
armarx::aron::data::VariantPtr content
Definition FluxioValue.h:20
std::experimental::observer_ptr< const FluxioProfile > profilePtr
Definition FluxioValue.h:19
static std::optional< FluxioValue > FromAron(const manager::arondto::FluxioValue &i, std::map< std::string, FluxioProfile > &profilesMap)
static std::optional< FluxioValue > FromIce(const manager::dto::FluxioValue &i, std::map< std::string, FluxioProfile > &profilesMap)