Factory.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
// STD/STL
27
#include <memory>
28
#include <map>
29
#include <vector>
30
#include <stack>
31
32
// ArmarX
33
#include <
ArmarXCore/core/rapidxml/wrapper/RapidXmlReader.h
>
34
#include <
RobotAPI/libraries/aron/codegeneration/typereader/helper/GenerateTypeInfo.h
>
35
#include <
RobotAPI/libraries/aron/codegeneration/typereader/helper/GenerateIntEnumInfo.h
>
36
#include <
RobotAPI/libraries/aron/core/type/variant/Variant.h
>
37
38
39
namespace
armarx::aron::typereader::xml
40
{
41
/**
42
* @brief The ReaderFactory class. It takes a xml-node and generates a type object representing the description in the xml node
43
*/
44
class
ReaderFactory
45
{
46
public
:
47
ReaderFactory
() =
default
;
48
49
/// the creation methods to return the types. Basically does a switch-case over the xml tag names converted to a descriptor object.
50
type::VariantPtr
create
(
const
RapidXmlReaderNode
&,
const
Path
&);
51
52
private
:
53
54
/// check, whether a given name corresponds to an already created object name.
55
type::VariantPtr
findExistingObject(
const
std::string& n,
const
Path
& path)
const
;
56
57
/// check, if the type should be a maybe type
58
type::Maybe getMaybe(
const
RapidXmlReaderNode
&)
const
;
59
60
/// check, if the member name matches the requirements
61
void
checkObjectMemberName(
const
std::string&)
const
;
62
63
64
type::VariantPtr
createObject(
const
RapidXmlReaderNode
& node,
const
Path
& path);
65
type::VariantPtr
createList(
const
RapidXmlReaderNode
& node,
const
Path
& path);
66
type::VariantPtr
createDict(
const
RapidXmlReaderNode
& node,
const
Path
& path);
67
type::VariantPtr
createTuple(
const
RapidXmlReaderNode
& node,
const
Path
& path);
68
type::VariantPtr
createPair(
const
RapidXmlReaderNode
& node,
const
Path
& path);
69
type::VariantPtr
createIntEnum(
const
RapidXmlReaderNode
& node,
const
Path
& path);
70
71
type::VariantPtr
createNDArray(
const
RapidXmlReaderNode
& node,
const
Path
& path)
const
;
72
type::VariantPtr
createMatrix(
const
RapidXmlReaderNode
& node,
const
Path
& path)
const
;
73
type::VariantPtr
createQuaternion(
const
RapidXmlReaderNode
& node,
const
Path
& path)
const
;
74
type::VariantPtr
createImage(
const
RapidXmlReaderNode
& node,
const
Path
& path)
const
;
75
type::VariantPtr
createPointCloud(
const
RapidXmlReaderNode
& node,
const
Path
& path)
const
;
76
type::VariantPtr
createPosition(
const
RapidXmlReaderNode
& node,
const
Path
& path)
const
;
77
type::VariantPtr
createOrientation(
const
RapidXmlReaderNode
& node,
const
Path
& path)
const
;
78
type::VariantPtr
createPose(
const
RapidXmlReaderNode
& node,
const
Path
& path)
const
;
79
80
type::VariantPtr
createInt(
const
RapidXmlReaderNode
& node,
const
Path
& path)
const
;
81
type::VariantPtr
createLong(
const
RapidXmlReaderNode
& node,
const
Path
& path)
const
;
82
type::VariantPtr
createFloat(
const
RapidXmlReaderNode
& node,
const
Path
& path)
const
;
83
type::VariantPtr
createDouble(
const
RapidXmlReaderNode
& node,
const
Path
& path)
const
;
84
type::VariantPtr
createString(
const
RapidXmlReaderNode
& node,
const
Path
& path)
const
;
85
type::VariantPtr
createBool(
const
RapidXmlReaderNode
& node,
const
Path
& path)
const
;
86
87
type::VariantPtr
createAnyObject(
const
RapidXmlReaderNode
& node,
const
Path
& path)
const
;
88
89
public
:
90
/// static map of all generated objects. Since this factory may be called recursively, it must be static
91
std::map<std::string, typereader::GenerateObjectInfo>
allGeneratedPublicObjects
;
92
93
/// same for int enums
94
std::map<std::string, typereader::GenerateIntEnumInfo>
allGeneratedPublicIntEnums
;
95
96
/// previously known types
97
std::vector<std::string>
allPreviouslyKnownPublicTypes
;
98
99
private
:
100
std::vector<std::string> allPreviouslyKnownPrivateTypes;
101
};
102
}
armarx::aron::type::VariantPtr
std::shared_ptr< Variant > VariantPtr
Definition:
forward_declarations.h:11
armarx::aron::typereader::xml::ReaderFactory::allPreviouslyKnownPublicTypes
std::vector< std::string > allPreviouslyKnownPublicTypes
previously known types
Definition:
Factory.h:97
armarx::aron::typereader::xml
All constantes for the aron XML parser, in addition to some utility functions wrapping around the arm...
Definition:
Data.cpp:30
armarx::aron::typereader::xml::ReaderFactory::allGeneratedPublicObjects
std::map< std::string, typereader::GenerateObjectInfo > allGeneratedPublicObjects
static map of all generated objects. Since this factory may be called recursively,...
Definition:
Factory.h:91
armarx::aron::Path
The Path class.
Definition:
Path.h:36
Variant.h
armarx::RapidXmlReaderNode
Definition:
RapidXmlReader.h:68
GenerateTypeInfo.h
armarx::aron::typereader::xml::ReaderFactory::ReaderFactory
ReaderFactory()=default
GenerateIntEnumInfo.h
RapidXmlReader.h
armarx::aron::typereader::xml::ReaderFactory
The ReaderFactory class.
Definition:
Factory.h:44
armarx::aron::typereader::xml::ReaderFactory::allGeneratedPublicIntEnums
std::map< std::string, typereader::GenerateIntEnumInfo > allGeneratedPublicIntEnums
same for int enums
Definition:
Factory.h:94
armarx::aron::typereader::xml::ReaderFactory::create
type::VariantPtr create(const RapidXmlReaderNode &, const Path &)
the creation methods to return the types. Basically does a switch-case over the xml tag names convert...
Definition:
Factory.cpp:60
RobotAPI
libraries
aron
codegeneration
typereader
xml
Factory.h
Generated on Sat Oct 12 2024 09:14:09 for armarx_documentation by
1.8.17