TreeTypedJSONConverter.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <stack>
4 #include <utility>
5 
6 #include <SimoxUtility/json/json.hpp>
7 
9 
11 {
13  {
14  public:
16  ~TreeTypedJSONConverter() override = default;
17 
18  const nlohmann::json& getJSON();
19 
20  MapElements getObjectElements(DataInput& elementData, TypeInput& elementType) override;
21 
22  void visitObjectOnEnter(DataInput& elementData, TypeInput& elementType) override;
23  void visitObjectOnExit(DataInput& elementData, TypeInput& elementType) override;
24  void visitDictOnEnter(DataInput& elementData, TypeInput& elementType) override;
25  void visitDictOnExit(DataInput& elementData, TypeInput& elementType) override;
26  void visitPairOnEnter(DataInput& elementData, TypeInput& elementType) override;
27  void visitPairOnExit(DataInput& elementData, TypeInput& elementType) override;
28  void visitTupleOnEnter(DataInput& elementData, TypeInput& elementType) override;
29  void visitTupleOnExit(DataInput& elementData, TypeInput& elementType) override;
30  void visitListOnEnter(DataInput& elementData, TypeInput& elementType) override;
31  void visitListOnExit(DataInput& elementData, TypeInput& elementType) override;
32 
33  void visitMatrix(DataInput& elementData, TypeInput& elementType) override;
34  void visitNDArray(DataInput& elementData, TypeInput& elementType) override;
35  void visitQuaternion(DataInput& elementData, TypeInput& elementType) override;
36  void visitImage(DataInput& elementData, TypeInput& elementType) override;
37  void visitPointCloud(DataInput& elementData, TypeInput& elementType) override;
38  void visitIntEnum(DataInput& elementData, TypeInput& elementType) override;
39  void visitInt(DataInput& elementData, TypeInput& elementType) override;
40  void visitLong(DataInput& elementData, TypeInput& elementType) override;
41  void visitFloat(DataInput& elementData, TypeInput& elementType) override;
42  void visitDouble(DataInput& elementData, TypeInput& elementType) override;
43  void visitBool(DataInput& elementData, TypeInput& elementType) override;
44  void visitString(DataInput& elementData, TypeInput& elementType) override;
45 
46  private:
47  std::stack<std::pair<std::string, nlohmann::json>> jsonStack;
48 
49  template <typename ElementType>
50  void insertIntoJSON(const std::string& key, const ElementType& data);
51  void insertNULLIntoJSON(const std::string& key);
52 
53  static nlohmann::json handleGenericNDArray(const aron::data::NDArray& nd);
54  };
55 } // namespace armarx::armem::gui::instance
armarx::armem::gui::instance::TreeTypedJSONConverter
Definition: TreeTypedJSONConverter.h:12
armarx::armem::gui::instance::TreeTypedJSONConverter::visitLong
void visitLong(DataInput &elementData, TypeInput &elementType) override
Definition: TreeTypedJSONConverter.cpp:321
armarx::armem::gui::instance::TreeTypedJSONConverter::visitDictOnEnter
void visitDictOnEnter(DataInput &elementData, TypeInput &elementType) override
Definition: TreeTypedJSONConverter.cpp:89
armarx::aron::data::NDArray
Definition: NDArray.h:48
armarx::armem::gui::instance::TreeTypedJSONConverter::visitTupleOnExit
void visitTupleOnExit(DataInput &elementData, TypeInput &elementType) override
Definition: TreeTypedJSONConverter.cpp:119
armarx::armem::gui::instance::TreeTypedJSONConverter::visitDictOnExit
void visitDictOnExit(DataInput &elementData, TypeInput &elementType) override
Definition: TreeTypedJSONConverter.cpp:95
armarx::aron::data::RecursiveTypedVisitor< const data::VariantPtr, const type::VariantPtr >::MapElements
std::map< std::string, std::pair< DataInputNonConst, TypeInputNonConst > > MapElements
Definition: RecursiveVisitor.h:86
armarx::armem::gui::instance::TreeTypedJSONConverter::TreeTypedJSONConverter
TreeTypedJSONConverter()
Definition: TreeTypedJSONConverter.cpp:14
armarx::armem::gui::instance::TreeTypedJSONConverter::visitObjectOnExit
void visitObjectOnExit(DataInput &elementData, TypeInput &elementType) override
Definition: TreeTypedJSONConverter.cpp:80
armarx::armem::gui::instance::TreeTypedJSONConverter::visitImage
void visitImage(DataInput &elementData, TypeInput &elementType) override
Definition: TreeTypedJSONConverter.cpp:252
armarx::armem::gui::instance::TreeTypedJSONConverter::getObjectElements
MapElements getObjectElements(DataInput &elementData, TypeInput &elementType) override
Definition: TreeTypedJSONConverter.cpp:34
armarx::armem::gui::instance::TreeTypedJSONConverter::visitPointCloud
void visitPointCloud(DataInput &elementData, TypeInput &elementType) override
Definition: TreeTypedJSONConverter.cpp:273
armarx::armem::gui::instance::TreeTypedJSONConverter::visitIntEnum
void visitIntEnum(DataInput &elementData, TypeInput &elementType) override
Definition: TreeTypedJSONConverter.cpp:294
armarx::armem::gui::instance
Definition: AronDataView.cpp:2
armarx::aron::data::RecursiveTypedVisitor< const data::VariantPtr, const type::VariantPtr >::TypeInput
typename TypedVisitorBase< const data::VariantPtr, const type::VariantPtr >::TypeInput TypeInput
Definition: RecursiveVisitor.h:81
armarx::armem::gui::instance::TreeTypedJSONConverter::visitNDArray
void visitNDArray(DataInput &elementData, TypeInput &elementType) override
Definition: TreeTypedJSONConverter.cpp:207
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
armarx::armem::gui::instance::TreeTypedJSONConverter::visitPairOnExit
void visitPairOnExit(DataInput &elementData, TypeInput &elementType) override
Definition: TreeTypedJSONConverter.cpp:107
armarx::armem::gui::instance::TreeTypedJSONConverter::visitFloat
void visitFloat(DataInput &elementData, TypeInput &elementType) override
Definition: TreeTypedJSONConverter.cpp:342
armarx::armem::gui::instance::TreeTypedJSONConverter::visitDouble
void visitDouble(DataInput &elementData, TypeInput &elementType) override
Definition: TreeTypedJSONConverter.cpp:363
armarx::ElementTypes::ElementType
ElementType
Definition: AbstractObjectSerializer.h:32
armarx::armem::gui::instance::TreeTypedJSONConverter::visitListOnEnter
void visitListOnEnter(DataInput &elementData, TypeInput &elementType) override
Definition: TreeTypedJSONConverter.cpp:125
armarx::armem::gui::instance::TreeTypedJSONConverter::getJSON
const nlohmann::json & getJSON()
Definition: TreeTypedJSONConverter.cpp:20
armarx::armem::gui::instance::TreeTypedJSONConverter::visitBool
void visitBool(DataInput &elementData, TypeInput &elementType) override
Definition: TreeTypedJSONConverter.cpp:384
armarx::aron::data::RecursiveTypedVisitor< const data::VariantPtr, const type::VariantPtr >::DataInput
typename TypedVisitorBase< const data::VariantPtr, const type::VariantPtr >::DataInput DataInput
Definition: RecursiveVisitor.h:80
armarx::armem::gui::instance::TreeTypedJSONConverter::visitInt
void visitInt(DataInput &elementData, TypeInput &elementType) override
Definition: TreeTypedJSONConverter.cpp:300
armarx::armem::gui::instance::TreeTypedJSONConverter::~TreeTypedJSONConverter
~TreeTypedJSONConverter() override=default
armarx::armem::gui::instance::TreeTypedJSONConverter::visitPairOnEnter
void visitPairOnEnter(DataInput &elementData, TypeInput &elementType) override
Definition: TreeTypedJSONConverter.cpp:101
VariantVisitor.h
armarx::armem::gui::instance::TreeTypedJSONConverter::visitTupleOnEnter
void visitTupleOnEnter(DataInput &elementData, TypeInput &elementType) override
Definition: TreeTypedJSONConverter.cpp:113
armarx::aron::data::RecursiveConstTypedVariantVisitor
Definition: VariantVisitor.h:192
armarx::armem::gui::instance::TreeTypedJSONConverter::visitObjectOnEnter
void visitObjectOnEnter(DataInput &elementData, TypeInput &elementType) override
Definition: TreeTypedJSONConverter.cpp:40
armarx::armem::gui::instance::TreeTypedJSONConverter::visitMatrix
void visitMatrix(DataInput &elementData, TypeInput &elementType) override
Definition: TreeTypedJSONConverter.cpp:164
armarx::armem::gui::instance::TreeTypedJSONConverter::visitListOnExit
void visitListOnExit(DataInput &elementData, TypeInput &elementType) override
Definition: TreeTypedJSONConverter.cpp:156
armarx::armem::gui::instance::TreeTypedJSONConverter::visitQuaternion
void visitQuaternion(DataInput &elementData, TypeInput &elementType) override
Definition: TreeTypedJSONConverter.cpp:228
armarx::armem::gui::instance::TreeTypedJSONConverter::visitString
void visitString(DataInput &elementData, TypeInput &elementType) override
Definition: TreeTypedJSONConverter.cpp:405