AronGeneratedObject.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T),
5  * Karlsruhe Institute of Technology (KIT), all rights reserved.
6  *
7  * ArmarX is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10  *
11  * ArmarX is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  *
19  * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu)
20  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21  * GNU General Public License
22  */
23 
24 #pragma once
25 
26 #include "AronGeneratedClass.h"
27 
28 
29 namespace armarx::aron::cpp
30 {
31 
33  public AronGeneratedClass
34  {
35  public:
36  AronGeneratedObjectBase() = default;
37  virtual ~AronGeneratedObjectBase() = default;
38 
39  /// Convert the current bo to an aron variant data dict
40  virtual armarx::aron::data::DictPtr toAron() const = 0;
41 
42  /// Convert the current bo to the ice representation of an aron variant data dict
43  virtual armarx::aron::data::dto::DictPtr toAronDTO() const = 0;
44 
45  /// Set all members of the current bo according to the aron variant data dict
46  virtual void fromAron(const armarx::aron::data::DictPtr& input) = 0;
47 
48  /// Set all members of the current bo according to the ice representation of an aron variant data dict
49  virtual void fromAron(const armarx::aron::data::dto::DictPtr& input) = 0;
50  };
51 
52  template <class Derived>
55  {
56  public:
57  AronGeneratedObject() = default;
58  virtual ~AronGeneratedObject() = default;
59 
60  template <class T>
61  void to(T& t) const
62  {
63  const Derived* d = dynamic_cast<const Derived*>(this);
64  if (d)
65  {
66  t.fromAron(*d);
67  }
68  }
69 
70  template <class T>
71  void from(const T& t)
72  {
73  Derived* d = dynamic_cast<Derived*>(this);
74  if (d)
75  {
76  t.toAron(*d);
77  }
78  }
79 
80  template <class T>
81  void to(T& t, void(*fromAron)(const Derived&, T&)) const
82  {
83  const Derived* d = dynamic_cast<const Derived*>(this);
84  if (d)
85  {
86  fromAron(*d, t);
87  }
88  }
89 
90  template <class T>
91  void from(const T& t, void(*toAron)(Derived&, const T&))
92  {
93  Derived* d = dynamic_cast<Derived*>(this);
94  if (d)
95  {
96  toAron(*d, t);
97  }
98  }
99  };
100 
101  template <class T>
103 }
104 
106 {
108 
109  template <class Derived>
111 }
armarx::aron::codegenerator::cpp
Definition: AnyObject.cpp:29
armarx::aron::codegenerator::cpp::AronGeneratedObjectBase
aron::cpp::AronGeneratedObjectBase AronGeneratedObjectBase
Definition: AronGeneratedObject.h:107
armarx::aron::cpp::AronGeneratedObject::to
void to(T &t) const
Definition: AronGeneratedObject.h:61
armarx::aron::cpp::AronGeneratedObjectBase
Definition: AronGeneratedObject.h:32
armarx::aron::cpp
Definition: AronGeneratedClass.h:44
armarx::aron::cpp::isAronGeneratedObject
concept isAronGeneratedObject
Definition: AronGeneratedObject.h:102
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
armarx::aron::input
ReaderT::InputType & input
Definition: rw.h:19
armarx::aron::cpp::AronGeneratedObject::from
void from(const T &t)
Definition: AronGeneratedObject.h:71
armarx::aron::cpp::AronGeneratedObjectBase::~AronGeneratedObjectBase
virtual ~AronGeneratedObjectBase()=default
armarx::aron::cpp::AronGeneratedClass
Definition: AronGeneratedClass.h:46
armarx::aron::cpp::AronGeneratedObject::AronGeneratedObject
AronGeneratedObject()=default
armarx::aron::cpp::AronGeneratedObjectBase::AronGeneratedObjectBase
AronGeneratedObjectBase()=default
armarx::aron::cpp::AronGeneratedObject::~AronGeneratedObject
virtual ~AronGeneratedObject()=default
armarx::aron::cpp::AronGeneratedObject::from
void from(const T &t, void(*toAron)(Derived &, const T &))
Definition: AronGeneratedObject.h:91
armarx::aron::data::DictPtr
std::shared_ptr< Dict > DictPtr
Definition: Dict.h:41
armarx::aron::cpp::AronGeneratedObjectBase::fromAron
virtual void fromAron(const armarx::aron::data::DictPtr &input)=0
Set all members of the current bo according to the aron variant data dict.
armarx::aron::cpp::AronGeneratedObject::to
void to(T &t, void(*fromAron)(const Derived &, T &)) const
Definition: AronGeneratedObject.h:81
armarx::aron::cpp::AronGeneratedObjectBase::toAronDTO
virtual armarx::aron::data::dto::DictPtr toAronDTO() const =0
Convert the current bo to the ice representation of an aron variant data dict.
armarx::aron::cpp::AronGeneratedObject
Definition: AronGeneratedObject.h:53
armarx::aron::cpp::AronGeneratedObjectBase::toAron
virtual armarx::aron::data::DictPtr toAron() const =0
Convert the current bo to an aron variant data dict.
T
float T
Definition: UnscentedKalmanFilterTest.cpp:35
AronGeneratedClass.h