Go to the documentation of this file.
26 #include <type_traits>
28 #include "../../Descriptor.h"
64 throw error::AronException(__PRETTY_FUNCTION__,
"Unknown type in visitor. The element was NULL.");
68 throw error::AronException(__PRETTY_FUNCTION__,
"Unknown type in visitor. The element was set but descriptor was undefined.");
77 template <
class T1,
class T2>
86 using MapElements = std::map<std::string, std::pair<DataInputNonConst, TypeInputNonConst>>;
87 using ListElements = std::vector<std::pair<DataInputNonConst, TypeInputNonConst>>;
88 using PairElements = std::pair<std::pair<DataInputNonConst, TypeInputNonConst>, std::pair<DataInputNonConst, TypeInputNonConst>>;
89 using TupleElements = std::vector<std::pair<DataInputNonConst, TypeInputNonConst>>;
125 throw error::AronException(__PRETTY_FUNCTION__,
"Unknown type in visitor. The element was NULL.");
129 throw error::AronException(__PRETTY_FUNCTION__,
"Unknown type in visitor. The element was set but descriptor was undefined.");
135 template <
class T,
class Data>
138 template <
class T,
class Data,
class Type>
144 template <
class RecursiveVisitorImplementation>
145 requires isRecursiveVisitor<RecursiveVisitorImplementation, typename RecursiveVisitorImplementation::Input>
146 void visitRecursive(RecursiveVisitorImplementation&
v,
typename RecursiveVisitorImplementation::Input& o)
153 v.visitListOnEnter(o);
155 for (
auto&
value :
v.getListElements(o))
160 v.visitListOnExit(o);
165 v.visitDictOnEnter(o);
166 for (
auto& [key,
value] :
v.getDictElements(o))
170 v.visitDictOnExit(o);
174 return v.visitNDArray(o);
176 return v.visitInt(o);
178 return v.visitLong(o);
180 return v.visitFloat(o);
182 return v.visitDouble(o);
184 return v.visitString(o);
186 return v.visitBool(o);
188 return v.visitUnknown(o);
196 template <
class RecursiveVisitorImplementation>
197 requires isRecursiveTypedVisitor<RecursiveVisitorImplementation, typename RecursiveVisitorImplementation::DataInput, typename RecursiveVisitorImplementation::TypeInput>
198 void visitRecursive(RecursiveVisitorImplementation&
v,
typename RecursiveVisitorImplementation::DataInput& o,
typename RecursiveVisitorImplementation::TypeInput& t)
205 v.visitListOnEnter(o, t);
207 for (
auto& [
value, acceptedType] :
v.getListElements(o, t))
212 v.visitListOnExit(o, t);
217 v.visitPairOnEnter(o, t);
218 auto pair =
v.getPairElements(o, t);
219 auto first = pair.first;
220 auto second = pair.second;
223 v.visitPairOnExit(o, t);
228 v.visitTupleOnEnter(o, t);
230 for (
auto& [
value, acceptedType] :
v.getTupleElements(o, t))
235 v.visitTupleOnExit(o, t);
240 v.visitDictOnEnter(o, t);
241 for (
auto& [key, pair] :
v.getDictElements(o, t))
245 v.visitDictOnExit(o, t);
250 v.visitObjectOnEnter(o, t);
251 for (
auto& [key, pair] :
v.getObjectElements(o, t))
255 v.visitObjectOnExit(o, t);
259 return v.visitNDArray(o, t);
261 return v.visitMatrix(o, t);
263 return v.visitImage(o, t);
265 return v.visitPointCloud(o, t);
267 return v.visitQuaternion(o, t);
269 return v.visitInt(o, t);
271 return v.visitLong(o, t);
273 return v.visitFloat(o, t);
275 return v.visitDouble(o, t);
277 return v.visitString(o, t);
279 return v.visitBool(o, t);
281 return v.visitAnyObject(o, t);
283 return v.visitIntEnum(o, t);
285 return v.visitUnknown(o, t);
virtual void visitObjectOnExit(DataInput &elementData, TypeInput &elementType)
virtual PairElements getPairElements(DataInput &, TypeInput &)=0
A base class for aron exceptions.
virtual void visitListOnEnter(DataInput &elementData, TypeInput &elementType)
virtual ~RecursiveVisitor()=default
virtual void visitString(DataInput &elementData, TypeInput &elementType)
virtual void visitInt(Input &element)
virtual void visitTupleOnEnter(DataInput &elementData, TypeInput &elementType)
virtual void visitPointCloud(DataInput &elementData, TypeInput &elementType)
virtual TupleElements getTupleElements(DataInput &, TypeInput &)=0
virtual void visitPairOnEnter(DataInput &elementData, TypeInput &elementType)
typename std::remove_const< Input >::type InputNonConst
virtual void visitString(Input &element)
virtual void visitIntEnum(DataInput &elementData, TypeInput &elementType)
virtual void visitDouble(Input &element)
std::map< std::string, std::pair< DataInputNonConst, TypeInputNonConst > > MapElements
typename VisitorBase< data::VariantPtr >::Input Input
virtual void visitListOnExit(Input &element)
virtual void visitDictOnEnter(Input &element)
std::pair< std::pair< DataInputNonConst, TypeInputNonConst >, std::pair< DataInputNonConst, TypeInputNonConst > > PairElements
virtual ListElements getListElements(Input &)=0
virtual MapElements getObjectElements(DataInput &, TypeInput &)=0
virtual void visitPairOnExit(DataInput &elementData, TypeInput &elementType)
concept isRecursiveVisitor
concept isRecursiveTypedVisitor
virtual MapElements getDictElements(Input &)=0
std::shared_ptr< Value > value()
typename TypedVisitorBase< data::VariantPtr, const type::VariantPtr >::TypeInput TypeInput
virtual void visitObjectOnEnter(DataInput &elementData, TypeInput &elementType)
virtual void visitDouble(DataInput &elementData, TypeInput &elementType)
virtual ListElements getListElements(DataInput &, TypeInput &)=0
virtual void visitListOnExit(DataInput &elementData, TypeInput &elementType)
virtual void visitMatrix(DataInput &elementData, TypeInput &elementType)
requires(!aron::detail::DtoAndBoAreSame< DtoT, BoT >) void toAron(std
virtual void visitFloat(DataInput &elementData, TypeInput &elementType)
A convenience header to include all aron files (full include, not forward declared)
typename TypedVisitorBase< data::VariantPtr, const type::VariantPtr >::DataInput DataInput
virtual void visitDictOnExit(DataInput &elementData, TypeInput &elementType)
double v(double t, double v0, double a0, double j)
virtual void visitLong(Input &element)
virtual void visitImage(DataInput &elementData, TypeInput &elementType)
virtual void visitUnknown(Input &element)
virtual void visitTupleOnExit(DataInput &elementData, TypeInput &elementType)
virtual void visitUnknown(DataInput &elementData, TypeInput &elementType)
typename std::remove_const< TypeInput >::type TypeInputNonConst
requires isRecursiveVisitor< RecursiveVisitorImplementation, typename RecursiveVisitorImplementation::Input > void visitRecursive(RecursiveVisitorImplementation &v, typename RecursiveVisitorImplementation::Input &o)
virtual MapElements getDictElements(DataInput &, TypeInput &)=0
virtual void visitNDArray(DataInput &elementData, TypeInput &elementType)
std::vector< std::pair< DataInputNonConst, TypeInputNonConst > > ListElements
virtual void visitDictOnExit(Input &element)
virtual void visitNDArray(Input &element)
virtual ~RecursiveTypedVisitor()=default
std::vector< InputNonConst > ListElements
virtual void visitDictOnEnter(DataInput &elementData, TypeInput &elementType)
virtual void visitBool(DataInput &elementData, TypeInput &elementType)
virtual void visitFloat(Input &element)
virtual void visitListOnEnter(Input &element)
virtual void visitQuaternion(DataInput &elementData, TypeInput &elementType)
std::map< std::string, InputNonConst > MapElements
virtual void visitInt(DataInput &elementData, TypeInput &elementType)
virtual void visitLong(DataInput &elementData, TypeInput &elementType)
virtual void visitAnyObject(DataInput &elementData, TypeInput &elementType)
typename std::remove_const< DataInput >::type DataInputNonConst
virtual void visitBool(Input &element)
std::vector< std::pair< DataInputNonConst, TypeInputNonConst > > TupleElements