JsonSimoxShapeSerializer.h
Go to the documentation of this file.
1 #pragma once
2 
3 #ifdef MEMORYX_FOUND
4 
5 #include <memory>
6 
7 #include <SimoxUtility/json/json.hpp>
8 
9 namespace memoryx
10 {
11  class ObjectClassSegmentWrapper;
12 }
13 
14 namespace armarx::semantic
15 {
16  class SimoxObjectShape;
17 
18  /**
19  * @brief A serializer for `SimoxObjectShape` using the `memoryx::ObjectClassSegment`.
20  */
21  class JsonSimoxShapeSerializer
22  {
23  public:
24  JsonSimoxShapeSerializer(const memoryx::ObjectClassSegmentWrapper* classSegment = nullptr);
25 
26  void to_json(nlohmann::json& j, const SimoxObjectShape& object) const;
27  void from_json(const nlohmann::json& j, SimoxObjectShape& object) const;
28 
29 
30  /**
31  * @brief Register the given serializer in `semrel::json::ShapeSerializers`.
32  *
33  * The passed instance is held alive by capturing lambdas stored in
34  * `semrel::json::ShapeSerializers`.
35  *
36  * @see `semrel::json::ShapeSerializers::registerSerializer()`
37  */
38  static void registerSerializer(const std::shared_ptr<JsonSimoxShapeSerializer>& instance,
39  bool overwrite = false);
40 
41 
42  private:
43  const memoryx::ObjectClassSegmentWrapper* classSegment = nullptr;
44  };
45 
46 } // namespace armarx::semantic
47 
48 #endif
armarx::to_json
void to_json(nlohmann::json &j, const Vector2f &value)
memoryx::ObjectClassSegmentWrapper
Definition: ObjectClassSegmentWrapper.h:23
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
armarx::from_json
void from_json(const nlohmann::json &j, Vector2f &value)
armarx::semantic
Definition: ShapesSupportRelations.cpp:32