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
The Path class.
Definition Path.h:36
std::unique_ptr< Generator > create(const type::Variant &, const Path &) const
Definition Factory.cpp:37
The AnyObject class.
Definition AnyObject.h:38
The Bool class.
Definition Bool.h:38
The Dict class.
Definition Dict.h:40
The Double class.
Definition Double.h:38
The Float class.
Definition Float.h:38
The Image class.
Definition Image.h:39
The IntEnum class.
Definition IntEnum.h:43
The Int class.
Definition Int.h:38
The List class.
Definition List.h:40
The Long class.
Definition Long.h:38
The Matrix class.
Definition Matrix.h:40
The NDArray class.
Definition NDArray.h:38
The Object class.
Definition Object.h:43
The Pair class.
Definition Pair.h:39
The PointCloud class.
Definition PointCloud.h:40
The Qaternion class.
Definition Quaternion.h:40
The String class.
Definition String.h:38
The Tuple class.
Definition Tuple.h:39
The Variant class.
Definition Variant.h:54