Variant.cpp
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 // Header
25 #include "Variant.h"
26 
27 // ArmarX
28 #include "../../Exception.h"
29 #include "Factory.h"
30 #include "container/Dict.h"
31 
32 
33 namespace armarx::aron::data
34 {
35  // static data members
36  const VariantFactoryPtr Variant::FACTORY = VariantFactoryPtr(new VariantFactory());
37 
38  // static methods
39  VariantPtr Variant::FromAronDTO(const data::dto::GenericDataPtr& a, const Path& path)
40  {
41  return FACTORY->create(a, path);
42  }
43 
44  std::vector<VariantPtr> Variant::FromAronDTO(const std::vector<data::dto::GenericDataPtr>& a, const Path& path)
45  {
46  std::vector<VariantPtr> ret;
47  for (const auto& aron : a)
48  {
49  ret.push_back(Variant::FromAronDTO(aron, path));
50  }
51  return ret;
52  }
53 
54  std::vector<data::dto::GenericDataPtr> Variant::ToAronDTO(const std::vector<VariantPtr>& a)
55  {
56  std::vector<data::dto::GenericDataPtr> ret;
57  for (const auto& v : a)
58  {
59  if (v)
60  {
61  ret.push_back(v->toAronDTO());
62  }
63  else
64  {
65  ret.push_back(nullptr);
66  }
67  }
68  return ret;
69  }
70 }
armarx::aron::data::VariantFactoryPtr
std::unique_ptr< VariantFactory > VariantFactoryPtr
Definition: Variant.h:40
Variant.h
armarx::aron::ret
ReaderT::InputType T & ret
Definition: rw.h:21
armarx::aron::data::Variant::FromAronDTO
static VariantPtr FromAronDTO(const data::dto::GenericDataPtr &, const Path &=Path())
create a variant from a dto object
Definition: Variant.cpp:39
armarx::aron::data::Variant::path
const Path path
Definition: Variant.h:156
armarx::aron::Path
The Path class.
Definition: Path.h:36
armarx::aron::data::VariantPtr
std::shared_ptr< Variant > VariantPtr
Definition: forward_declarations.h:11
armarx::ctrlutil::a
double a(double t, double a0, double j)
Definition: CtrlUtil.h:45
armarx::aron::data
A convenience header to include all aron files (full include, not forward declared)
Definition: aron_conversions.cpp:3
armarx::aron::data::Variant::ToAronDTO
static std::vector< data::dto::GenericDataPtr > ToAronDTO(const std::vector< VariantPtr > &)
return a list of dto objects from a list of variant objects
Definition: Variant.cpp:54
armarx::ctrlutil::v
double v(double t, double v0, double a0, double j)
Definition: CtrlUtil.h:39
Factory.h