Factory.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 // STD/STL
25 
26 // Header
27 #include "Factory.h"
28 
29 // ArmarX
30 #include "All.h"
31 #include "enum/All.h"
32 
34 {
35  // Access method
36  std::unique_ptr<Generator>
37  GeneratorFactory::create(const type::Variant& n, const Path& path) const
38  {
39  auto desc = n.getDescriptor();
40  switch (desc)
41  {
43  return std::make_unique<generator::List>(dynamic_cast<const type::List&>(n));
45  return std::make_unique<generator::Dict>(dynamic_cast<const type::Dict&>(n));
47  return std::make_unique<generator::Object>(dynamic_cast<const type::Object&>(n));
49  return std::make_unique<generator::Tuple>(dynamic_cast<const type::Tuple&>(n));
51  return std::make_unique<generator::Pair>(dynamic_cast<const type::Pair&>(n));
53  return std::make_unique<generator::NDArray>(dynamic_cast<const type::NDArray&>(n));
55  return std::make_unique<generator::Matrix>(dynamic_cast<const type::Matrix&>(n));
57  return std::make_unique<generator::Quaternion>(
58  dynamic_cast<const type::Quaternion&>(n));
60  return std::make_unique<generator::Image>(dynamic_cast<const type::Image&>(n));
62  return std::make_unique<generator::PointCloud>(
63  dynamic_cast<const type::PointCloud&>(n));
65  return std::make_unique<generator::IntEnum>(dynamic_cast<const type::IntEnum&>(n));
67  return std::make_unique<generator::Int>(dynamic_cast<const type::Int&>(n));
69  return std::make_unique<generator::Long>(dynamic_cast<const type::Long&>(n));
71  return std::make_unique<generator::Float>(dynamic_cast<const type::Float&>(n));
73  return std::make_unique<generator::Double>(dynamic_cast<const type::Double&>(n));
75  return std::make_unique<generator::String>(dynamic_cast<const type::String&>(n));
77  return std::make_unique<generator::Bool>(dynamic_cast<const type::Bool&>(n));
79  return std::make_unique<generator::AnyObject>(
80  dynamic_cast<const type::AnyObject&>(n));
82  break;
83  }
84  throw error::AronEOFException(__PRETTY_FUNCTION__);
85  }
86 
87 } // namespace armarx::aron::codegenerator::cpp
armarx::aron::type::Descriptor::FLOAT
@ FLOAT
armarx::aron::type::AnyObject
The AnyObject class.
Definition: AnyObject.h:37
armarx::aron::type::Descriptor::DOUBLE
@ DOUBLE
armarx::aron::codegenerator::cpp
Definition: AnyObject.cpp:28
armarx::aron::type::Long
The Long class.
Definition: Long.h:37
armarx::aron::type::Descriptor::IMAGE
@ IMAGE
armarx::aron::type::NDArray
The NDArray class.
Definition: NDArray.h:37
armarx::aron::type::PointCloud
The PointCloud class.
Definition: PointCloud.h:39
All.h
armarx::aron::type::List
The List class.
Definition: List.h:39
armarx::aron::type::Int
The Int class.
Definition: Int.h:37
armarx::aron::type::Descriptor::PAIR
@ PAIR
armarx::aron::type::Descriptor::LIST
@ LIST
armarx::aron::type::Object
The Object class.
Definition: Object.h:42
armarx::aron::type::IntEnum
The IntEnum class.
Definition: IntEnum.h:42
armarx::aron::type::Descriptor::NDARRAY
@ NDARRAY
armarx::aron::type::Tuple
The Tuple class.
Definition: Tuple.h:38
armarx::aron::type::Quaternion
The Qaternion class.
Definition: Quaternion.h:39
armarx::aron::Path
The Path class.
Definition: Path.h:35
armarx::aron::type::Variant
The Variant class.
Definition: Variant.h:53
armarx::aron::type::Descriptor::BOOL
@ BOOL
armarx::aron::error::AronEOFException
Definition: Exception.h:49
armarx::aron::type::Dict
The Dict class.
Definition: Dict.h:39
armarx::aron::type::Variant::getDescriptor
type::Descriptor getDescriptor() const
Definition: Variant.cpp:62
armarx::aron::type::Descriptor::MATRIX
@ MATRIX
armarx::aron::type::Bool
The Bool class.
Definition: Bool.h:37
armarx::aron::type::Descriptor::QUATERNION
@ QUATERNION
armarx::aron::codegenerator::cpp::GeneratorFactory::create
std::unique_ptr< Generator > create(const type::Variant &, const Path &) const
Definition: Factory.cpp:37
armarx::aron::type::Pair
The Pair class.
Definition: Pair.h:38
armarx::aron::type::Descriptor::STRING
@ STRING
armarx::aron::type::Descriptor::LONG
@ LONG
armarx::aron::type::Descriptor::INT
@ INT
armarx::aron::type::Descriptor::INT_ENUM
@ INT_ENUM
armarx::aron::type::Descriptor::OBJECT
@ OBJECT
armarx::aron::type::Descriptor::UNKNOWN
@ UNKNOWN
armarx::aron::type::Descriptor::DICT
@ DICT
armarx::aron::type::Descriptor::TUPLE
@ TUPLE
armarx::aron::type::Float
The Float class.
Definition: Float.h:37
armarx::aron::type::Double
The Double class.
Definition: Double.h:37
armarx::aron::type::Descriptor::POINTCLOUD
@ POINTCLOUD
armarx::aron::type::Image
The Image class.
Definition: Image.h:38
Factory.h
armarx::aron::type::String
The String class.
Definition: String.h:37
armarx::aron::type::Descriptor::ANY_OBJECT
@ ANY_OBJECT
armarx::aron::type::Matrix
The Matrix class.
Definition: Matrix.h:39