XMLState.h
Go to the documentation of this file.
1/*
2* This file is part of ArmarX.
3*
4* Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5*
6* ArmarX is free software; you can redistribute it and/or modify
7* it under the terms of the GNU General Public License version 2 as
8* published by the Free Software Foundation.
9*
10* ArmarX is distributed in the hope that it will be useful, but
11* WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17*
18* @package ArmarX::
19* @author Mirko Waechter ( mirko.waechter at kit dot edu)
20* @date 2013
21* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22* GNU General Public License
23*/
24#pragma once
25
26
27#include <memory>
28
32
33namespace armarx
34{
35
36 class RapidXmlReader;
37 using RapidXmlReaderPtr = std::shared_ptr<RapidXmlReader>;
39 using RapidXmlReaderNodePtr = std::shared_ptr<RapidXmlReaderNode>;
40
41 using StringXMLNodeMap = std::map<std::string, RapidXmlReaderPtr>;
42 using StringXMLNodeMapPtr = std::shared_ptr<StringXMLNodeMap>;
43
45 using StatechartProfilePtr = std::shared_ptr<StatechartProfile>;
47 using StatechartProfilesPtr = std::shared_ptr<StatechartProfiles>;
48
62
65
67 virtual Ice::Object,
68 virtual public AbstractFactoryMethod<XMLStateFactoryBase,
69 XMLStateConstructorParams,
70 XMLStateFactoryBasePtr>
71 {
72 };
73
75 {
76 public:
79 StatechartProfilePtr selectedProfile);
80
81 std::string getName();
82 bool getOptional();
83 std::string getTypeStr();
84 ContainerTypePtr getTypePtr();
85 VariantContainerBasePtr getContainer();
86
87 protected:
88 std::string name;
90 std::string typeStr;
91 ContainerTypePtr typePtr;
92 VariantContainerBasePtr container;
93 };
94
95 VariantContainerBasePtr GetSelectedProfileValue(RapidXmlReaderNode parameterNode,
96 StatechartProfilePtr selectedProfile,
98 std::string defaultValueJsonString = "");
99
100
102 using PrivateXmlStateClassPtr = std::shared_ptr<PrivateXmlStateClass>;
103
104 class XMLState : virtual public State
105 {
106 public:
108 {
109 }
110
111 XMLState(const XMLStateConstructorParams& stateData);
112 ~XMLState() override;
113
115
116 protected:
117 StateParameterMap getParameters(RapidXmlReaderNode parametersNode);
118
120 void addXMLSubstates(RapidXmlReaderNode substatesNode, const std::string& parentStateName);
122 const std::string& parentStateName);
123
124 void defineParameters() override;
125 void defineSubstates() override;
126
127 private:
128 void setXMLStateData(const XMLStateConstructorParams& stateData);
129
130
131 void addTransitions(const RapidXmlReaderNode& transitionsNode);
132 void setStartState(const RapidXmlReaderNode& startNode);
133 ParameterMappingPtr getMapping(const RapidXmlReaderNode& mappingNode);
134 PrivateXmlStateClassPtr privateStateData;
135
136 template <typename type>
137 friend class XMLStateTemplate;
138 template <typename ContextType>
140 };
141
142 /**
143 * Class for legacy to stay compatible with old statecharts
144 */
145 template <typename StateType>
146 class XMLStateTemplate : virtual public XMLState
147 {
148 public:
150 {
151 setXMLStateData(params);
152 }
153 };
154
155 struct NoUserCodeState : virtual public XMLState, public virtual XMLStateFactoryBase
156 {
159 static std::string GetName();
160
161 StateBasePtr clone() const override;
162 static SubClassRegistry Registry;
163 };
164} // namespace armarx
A template that can be used as a superclass of a class hierarchy that wants to provide a factory meth...
VariantContainerBasePtr container
Definition XMLState.h:92
VariantContainerBasePtr getContainer()
Definition XMLState.cpp:170
StateParameterDeserialization(RapidXmlReaderNode const &parameterNode, Ice::CommunicatorPtr ic, StatechartProfilePtr selectedProfile)
Definition XMLState.cpp:130
XMLStateTemplate(const XMLStateConstructorParams &params)
Definition XMLState.h:149
void defineParameters() override
Virtual function, in which input/local/output parameters can be specified.
Definition XMLState.cpp:231
StateParameterMap getParameters(RapidXmlReaderNode parametersNode)
Definition XMLState.cpp:253
~XMLState() override
Definition XMLState.cpp:220
StatePtr addState(StatePtr state)
Definition XMLState.cpp:416
void addXMLSubstates(RapidXmlReaderNode substatesNode, const std::string &parentStateName)
Definition XMLState.cpp:310
friend class XMLRemoteStateOfferer
Definition XMLState.h:139
friend class XMLStateTemplate
Definition XMLState.h:137
void defineSubstates() override
Virtual function, in which substates, transition and mappings can be added.
Definition XMLState.cpp:290
StateBasePtr addXMLSubstate(RapidXmlReaderNode stateNode, const std::string &parentStateName)
Definition XMLState.cpp:326
StatechartProfilePtr getSelectedProfile() const
Definition XMLState.cpp:225
::IceInternal::Handle<::Ice::Communicator > CommunicatorPtr
Definition IceManager.h:49
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::shared_ptr< PrivateXmlStateClass > PrivateXmlStateClassPtr
Definition XMLState.h:102
std::shared_ptr< RapidXmlReaderNode > RapidXmlReaderNodePtr
Definition XMLState.h:39
VariantContainerBasePtr GetSelectedProfileValue(RapidXmlReaderNode parameterNode, StatechartProfilePtr selectedProfile, Ice::CommunicatorPtr ic, std::string defaultValueJsonString="")
Definition XMLState.cpp:74
std::shared_ptr< StringXMLNodeMap > StringXMLNodeMapPtr
Definition XMLState.h:42
std::shared_ptr< StatechartProfiles > StatechartProfilesPtr
std::shared_ptr< RapidXmlReader > RapidXmlReaderPtr
IceInternal::Handle< State > StatePtr
Definition State.h:44
std::shared_ptr< class StatechartProfile > StatechartProfilePtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition XMLState.h:64
IceInternal::Handle< StateBase > StateBasePtr
Definition StateBase.h:49
IceInternal::Handle< ParameterMapping > ParameterMappingPtr
std::map< std::string, RapidXmlReaderPtr > StringXMLNodeMap
Definition XMLState.h:41
StateBasePtr clone() const override
Pure virtual function to clone of the derived class type.
Definition XMLState.cpp:68
static SubClassRegistry Registry
Definition XMLState.h:162
static std::string GetName()
Definition XMLState.cpp:62
NoUserCodeState(XMLStateConstructorParams stateData)
Definition XMLState.cpp:50
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition XMLState.cpp:56
XMLStateConstructorParams(const std::string &xmlFilepath, RapidXmlReaderPtr reader, StatechartProfilePtr selectedProfile, StringXMLNodeMapPtr uuidToXMLMap, Ice::CommunicatorPtr ic)
Definition XMLState.cpp:550
StatechartProfilePtr selectedProfile
Definition XMLState.h:53
StringXMLNodeMapPtr uuidToXMLMap
Definition XMLState.h:54
Ice::CommunicatorPtr ic
Definition XMLState.h:55