DatatypeConverterVisitor.cpp
Go to the documentation of this file.
2 
4 {
5  void
6  AronDatatypeConverterVisitor::visitAronVariant(const type::ObjectPtr& el)
7  {
8  auto dict = aron::make_dict(el->getPath());
9  auto type = aron::make_string(el->getFullName(), Path(el->getPath(), {TYPE_MEMBER_NAME}));
10  dict->addElement(TYPE_MEMBER_NAME, type);
11 
12  for (const auto& [key, child] : el->getMemberTypes())
13  {
14  AronDatatypeConverterVisitor converter;
15  aron::type::visit(converter, child);
16 
17  dict->addElement(key, converter.latest);
18  }
19 
20  latest = dict;
21  }
22 
23  void
24  AronDatatypeConverterVisitor::visitAronVariant(const type::DictPtr& el)
25  {
26  auto dict = aron::make_dict(el->getPath());
27  auto type = aron::make_string(el->getFullName(), Path(el->getPath(), {TYPE_MEMBER_NAME}));
28  dict->addElement(TYPE_MEMBER_NAME, type);
29 
30  auto acceptedType = el->getAcceptedType();
31  AronDatatypeConverterVisitor converter;
32  aron::type::visit(converter, acceptedType);
33  dict->addElement(ACCEPTED_TYPE_MEMBER_NAME, converter.latest);
34 
35  latest = dict;
36  }
37 
38  void
39  AronDatatypeConverterVisitor::visitAronVariant(const type::ListPtr& el)
40  {
41  auto dict = aron::make_dict(el->getPath());
42  auto type = aron::make_string(el->getFullName(), Path(el->getPath(), {TYPE_MEMBER_NAME}));
43  dict->addElement(TYPE_MEMBER_NAME, type);
44 
45  auto acceptedType = el->getAcceptedType();
46  AronDatatypeConverterVisitor converter;
47  aron::type::visit(converter, acceptedType);
48  dict->addElement(ACCEPTED_TYPE_MEMBER_NAME, converter.latest);
49 
50  latest = dict;
51  }
52 
53  void
54  AronDatatypeConverterVisitor::visitAronVariant(const type::PairPtr& el)
55  {
56  auto dict = aron::make_dict(el->getPath());
57  auto type = aron::make_string(el->getFullName(), Path(el->getPath(), {TYPE_MEMBER_NAME}));
58  dict->addElement(TYPE_MEMBER_NAME, type);
59 
60  auto acceptedType1 = el->getFirstAcceptedType();
61  AronDatatypeConverterVisitor converter1;
62  aron::type::visit(converter1, acceptedType1);
63  dict->addElement(FIRST_ACCEPTED_TYPE_MEMBER_NAME, converter1.latest);
64 
65  auto acceptedType2 = el->getSecondAcceptedType();
66  AronDatatypeConverterVisitor converter2;
67  aron::type::visit(converter2, acceptedType2);
68  dict->addElement(SECOND_ACCEPTED_TYPE_MEMBER_NAME, converter2.latest);
69 
70  latest = dict;
71  }
72 
73  void
74  AronDatatypeConverterVisitor::visitAronVariant(const type::TuplePtr& el)
75  {
76  auto dict = aron::make_dict(el->getPath());
77  auto type = aron::make_string(el->getFullName(), Path(el->getPath(), {TYPE_MEMBER_NAME}));
78  dict->addElement(TYPE_MEMBER_NAME, type);
79 
80  int i = 0;
81  for (const auto& child : el->getAcceptedTypes())
82  {
83  AronDatatypeConverterVisitor converter;
84  aron::type::visit(converter, child);
85 
86  dict->addElement(std::string(ACCEPTED_TYPE_MEMBER_NAME) + "_" + std::to_string(i++),
87  converter.latest);
88  }
89 
90  latest = dict;
91  }
92 
93  void
94  AronDatatypeConverterVisitor::visitAronVariant(const type::MatrixPtr& el)
95  {
96  latest = aron::make_string(el->getFullName(), el->getPath());
97  }
98 
99  void
100  AronDatatypeConverterVisitor::visitAronVariant(const type::NDArrayPtr& el)
101  {
102  latest = aron::make_string(el->getFullName(), el->getPath());
103  }
104 
105  void
106  AronDatatypeConverterVisitor::visitAronVariant(const type::QuaternionPtr& el)
107  {
108  latest = aron::make_string(el->getFullName(), el->getPath());
109  }
110 
111  void
112  AronDatatypeConverterVisitor::visitAronVariant(const type::PointCloudPtr& el)
113  {
114  latest = aron::make_string(el->getFullName(), el->getPath());
115  }
116 
117  void
118  AronDatatypeConverterVisitor::visitAronVariant(const type::ImagePtr& el)
119  {
120  latest = aron::make_string(el->getFullName(), el->getPath());
121  }
122 
123  void
124  AronDatatypeConverterVisitor::visitAronVariant(const type::IntEnumPtr& el)
125  {
126  latest = aron::make_string(el->getFullName(), el->getPath());
127  }
128 
129  void
130  AronDatatypeConverterVisitor::visitAronVariant(const type::IntPtr& el)
131  {
132  latest = aron::make_string(el->getFullName(), el->getPath());
133  }
134 
135  void
136  AronDatatypeConverterVisitor::visitAronVariant(const type::LongPtr& el)
137  {
138  latest = aron::make_string(el->getFullName(), el->getPath());
139  }
140 
141  void
142  AronDatatypeConverterVisitor::visitAronVariant(const type::FloatPtr& el)
143  {
144  latest = aron::make_string(el->getFullName(), el->getPath());
145  }
146 
147  void
148  AronDatatypeConverterVisitor::visitAronVariant(const type::DoublePtr& el)
149  {
150  latest = aron::make_string(el->getFullName(), el->getPath());
151  }
152 
153  void
154  AronDatatypeConverterVisitor::visitAronVariant(const type::BoolPtr& el)
155  {
156  latest = aron::make_string(el->getFullName(), el->getPath());
157  }
158 
159  void
160  AronDatatypeConverterVisitor::visitAronVariant(const type::StringPtr& el)
161  {
162  latest = aron::make_string(el->getFullName(), el->getPath());
163  }
164 
165  void
166  AronDatatypeConverterVisitor::visitAronVariant(const type::AnyObjectPtr& el)
167  {
168  latest = aron::make_string(el->getFullName(), el->getPath());
169  }
170 } // namespace armarx::aron::type::converter
armarx::aron::type::MatrixPtr
std::shared_ptr< class Matrix > MatrixPtr
Definition: forward_declarations.h:20
armarx::aron::type::AnyObjectPtr
std::shared_ptr< class AnyObject > AnyObjectPtr
Definition: forward_declarations.h:34
armarx::aron::type::ImagePtr
std::shared_ptr< class Image > ImagePtr
Definition: forward_declarations.h:22
armarx::aron::type::NDArrayPtr
std::shared_ptr< class NDArray > NDArrayPtr
Definition: forward_declarations.h:19
armarx::aron::make_dict
aron::data::DictPtr make_dict(_Args &&... args)
Definition: Dict.h:107
armarx::aron::make_string
aron::data::StringPtr make_string(_Args &&... args)
Definition: String.h:76
armarx::aron::type::TuplePtr
std::shared_ptr< class Tuple > TuplePtr
Definition: forward_declarations.h:17
armarx::aron::type::PointCloudPtr
std::shared_ptr< class PointCloud > PointCloudPtr
Definition: forward_declarations.h:23
armarx::aron::type::FloatPtr
std::shared_ptr< class Float > FloatPtr
Definition: forward_declarations.h:29
armarx::aron::type::converter::AronDatatypeConverterVisitor::latest
aron::data::VariantPtr latest
Definition: DatatypeConverterVisitor.h:60
armarx::aron::type::ListPtr
std::shared_ptr< class List > ListPtr
Definition: forward_declarations.h:14
armarx::aron::type::LongPtr
std::shared_ptr< class Long > LongPtr
Definition: forward_declarations.h:28
armarx::aron::type::StringPtr
std::shared_ptr< class String > StringPtr
Definition: forward_declarations.h:31
armarx::aron::type::PairPtr
std::shared_ptr< class Pair > PairPtr
Definition: forward_declarations.h:16
armarx::aron::type::DictPtr
std::shared_ptr< class Dict > DictPtr
Definition: forward_declarations.h:13
DatatypeConverterVisitor.h
armarx::aron::type::converter
Definition: aron_conversions.cpp:9
armarx::aron::type::BoolPtr
std::shared_ptr< class Bool > BoolPtr
Definition: forward_declarations.h:32
armarx::to_string
const std::string & to_string(const std::string &s)
Definition: StringHelpers.h:40
armarx::armem::server::ltm::detail::mixin::Path
std::filesystem::path Path
Definition: DiskStorageMixin.h:17
armarx::aron::type::visit
void visit(VisitorImplementation &v, typename VisitorImplementation::Input &t)
The visit function.
Definition: Visitor.h:42
armarx::aron::type::IntEnumPtr
std::shared_ptr< IntEnum > IntEnumPtr
Definition: IntEnum.h:36
armarx::aron::type::ObjectPtr
std::shared_ptr< Object > ObjectPtr
Definition: Object.h:36
armarx::aron::type::QuaternionPtr
std::shared_ptr< class Quaternion > QuaternionPtr
Definition: forward_declarations.h:21
armarx::aron::type::IntPtr
std::shared_ptr< class Int > IntPtr
Definition: forward_declarations.h:27
armarx::aron::type::DoublePtr
std::shared_ptr< class Double > DoublePtr
Definition: forward_declarations.h:30