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 
30 
31 #include <memory>
32 
33 
34 namespace armarx
35 {
36 
37  class RapidXmlReader;
38  using RapidXmlReaderPtr = std::shared_ptr<RapidXmlReader>;
39  class RapidXmlReaderNode;
40  using RapidXmlReaderNodePtr = std::shared_ptr<RapidXmlReaderNode>;
41 
42  using StringXMLNodeMap = std::map<std::string, RapidXmlReaderPtr>;
43  using StringXMLNodeMapPtr = std::shared_ptr<StringXMLNodeMap>;
44 
45  class StatechartProfile;
46  using StatechartProfilePtr = std::shared_ptr<StatechartProfile>;
47  class StatechartProfiles;
48  using StatechartProfilesPtr = std::shared_ptr<StatechartProfiles>;
49 
51  {
52  std::string xmlFilepath;
57  XMLStateConstructorParams(const std::string& xmlFilepath,
62  };
63 
64  struct XMLStateFactoryBase;
66  struct XMLStateFactoryBase : virtual Ice::Object,
67  virtual public AbstractFactoryMethod<XMLStateFactoryBase, XMLStateConstructorParams, XMLStateFactoryBasePtr >
68  {
69 
70  };
71 
73  {
74  public:
76 
77  std::string getName();
78  bool getOptional();
79  std::string getTypeStr();
80  ContainerTypePtr getTypePtr();
81  VariantContainerBasePtr getContainer();
82 
83  protected:
84  std::string name;
85  bool optional;
86  std::string typeStr;
87  ContainerTypePtr typePtr;
88  VariantContainerBasePtr container;
89  };
90 
91  VariantContainerBasePtr GetSelectedProfileValue(RapidXmlReaderNode parameterNode, StatechartProfilePtr selectedProfile, Ice::CommunicatorPtr ic, std::string defaultValueJsonString = "");
92 
93 
94  struct PrivateXmlStateClass;
95  using PrivateXmlStateClassPtr = std::shared_ptr<PrivateXmlStateClass>;
96  class XMLState :
97  virtual public State
98  {
99  public:
100 
101  XMLState() {}
102  XMLState(const XMLStateConstructorParams& stateData);
103  ~XMLState() override;
104 
106 
107  protected:
108 
110 
111  StatePtr addState(StatePtr state);
112  void addXMLSubstates(RapidXmlReaderNode substatesNode, const std::string& parentStateName);
113  StateBasePtr addXMLSubstate(RapidXmlReaderNode stateNode, const std::string& parentStateName);
114 
115  void defineParameters() override;
116  void defineSubstates() override;
117  private:
118  void setXMLStateData(const XMLStateConstructorParams& stateData);
119 
120 
121  void addTransitions(const RapidXmlReaderNode& transitionsNode);
122  void setStartState(const RapidXmlReaderNode& startNode);
123  ParameterMappingPtr getMapping(const RapidXmlReaderNode& mappingNode);
124  PrivateXmlStateClassPtr privateStateData;
125 
126  template <typename type>
127  friend class XMLStateTemplate;
128  template <typename ContextType>
129  friend class XMLRemoteStateOfferer;
130 
131  };
132 
133  /**
134  * Class for legacy to stay compatible with old statecharts
135  */
136  template <typename StateType>
138  virtual public XMLState
139  {
140  public:
142  {
143  setXMLStateData(params);
144  }
145 
146  };
147 
149  virtual public XMLState,
150  public virtual XMLStateFactoryBase
151  {
154  static std::string GetName();
155 
156  StateBasePtr clone() const override;
157  static SubClassRegistry Registry;
158 
159  };
160 }
161 
armarx::RapidXmlReaderPtr
std::shared_ptr< RapidXmlReader > RapidXmlReaderPtr
Definition: RapidXmlReader.h:66
armarx::NoUserCodeState::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: XMLState.cpp:62
cyberglove_with_calib_22dof.ic
ic
Definition: cyberglove_with_calib_22dof.py:22
armarx::StateParameterDeserialization::getTypePtr
ContainerTypePtr getTypePtr()
Definition: XMLState.cpp:157
armarx::AbstractFactoryMethod
A template that can be used as a superclass of a class hierarchy that wants to provide a factory meth...
Definition: AbstractFactoryMethod.h:46
armarx::StateParameterDeserialization::getTypeStr
std::string getTypeStr()
Definition: XMLState.cpp:152
armarx::XMLStateConstructorParams::selectedProfile
StatechartProfilePtr selectedProfile
Definition: XMLState.h:54
armarx::PrivateXmlStateClassPtr
std::shared_ptr< PrivateXmlStateClass > PrivateXmlStateClassPtr
Definition: XMLState.h:95
armarx::NoUserCodeState::GetName
static std::string GetName()
Definition: XMLState.cpp:67
armarx::StateParameterDeserialization::getName
std::string getName()
Definition: XMLState.cpp:142
armarx::XMLStateConstructorParams::XMLStateConstructorParams
XMLStateConstructorParams(const std::string &xmlFilepath, RapidXmlReaderPtr reader, StatechartProfilePtr selectedProfile, StringXMLNodeMapPtr uuidToXMLMap, Ice::CommunicatorPtr ic)
Definition: XMLState.cpp:523
armarx::StateParameterDeserialization::typePtr
ContainerTypePtr typePtr
Definition: XMLState.h:87
armarx::XMLState::addState
StatePtr addState(StatePtr state)
Definition: XMLState.cpp:400
armarx::StateParameterDeserialization::getContainer
VariantContainerBasePtr getContainer()
Definition: XMLState.cpp:162
armarx::XMLStateConstructorParams::ic
Ice::CommunicatorPtr ic
Definition: XMLState.h:56
armarx::XMLStateConstructorParams
Definition: XMLState.h:50
armarx::XMLState::defineSubstates
void defineSubstates() override
Virtual function, in which substates, transition and mappings can be added.
Definition: XMLState.cpp:284
armarx::XMLState::addXMLSubstate
StateBasePtr addXMLSubstate(RapidXmlReaderNode stateNode, const std::string &parentStateName)
Definition: XMLState.cpp:324
armarx::StatechartProfile
Definition: StatechartProfiles.h:41
armarx::StatechartProfilePtr
std::shared_ptr< class StatechartProfile > StatechartProfilePtr
Definition: StatechartContext.h:52
armarx::StateParameterDeserialization::StateParameterDeserialization
StateParameterDeserialization(RapidXmlReaderNode const &parameterNode, Ice::CommunicatorPtr ic, StatechartProfilePtr selectedProfile)
Definition: XMLState.cpp:130
armarx::NoUserCodeState::NoUserCodeState
NoUserCodeState(XMLStateConstructorParams stateData)
Definition: XMLState.cpp:53
armarx::NoUserCodeState::Registry
static SubClassRegistry Registry
Definition: XMLState.h:157
armarx::StateParameterDeserialization::container
VariantContainerBasePtr container
Definition: XMLState.h:88
armarx::StringXMLNodeMapPtr
std::shared_ptr< StringXMLNodeMap > StringXMLNodeMapPtr
Definition: XMLState.h:43
armarx::XMLStateConstructorParams::xmlFilepath
std::string xmlFilepath
Definition: XMLState.h:52
IceInternal::Handle< ::Ice::Communicator >
armarx::XMLState::~XMLState
~XMLState() override
Definition: XMLState.cpp:220
armarx::StatechartProfilesPtr
std::shared_ptr< StatechartProfiles > StatechartProfilesPtr
Definition: StatechartProfiles.h:35
armarx::NoUserCodeState
Definition: XMLState.h:148
armarx::StateParameterDeserialization::getOptional
bool getOptional()
Definition: XMLState.cpp:147
armarx::XMLState::getParameters
StateParameterMap getParameters(RapidXmlReaderNode parametersNode)
Definition: XMLState.cpp:252
armarx::XMLStateTemplate
Class for legacy to stay compatible with old statecharts.
Definition: XMLState.h:137
armarx::XMLState::XMLState
XMLState()
Definition: XMLState.h:101
armarx::XMLStateConstructorParams::reader
RapidXmlReaderPtr reader
Definition: XMLState.h:53
armarx::StatechartProfiles
Definition: StatechartProfiles.h:75
armarx::statechartmodel::StateParameterMap
QMap< QString, StateParameterPtr > StateParameterMap
Definition: StateParameter.h:46
State.h
armarx::XMLRemoteStateOfferer
Definition: XMLRemoteStateOfferer.h:51
armarx::GetSelectedProfileValue
VariantContainerBasePtr GetSelectedProfileValue(RapidXmlReaderNode parameterNode, StatechartProfilePtr selectedProfile, Ice::CommunicatorPtr ic, std::string defaultValueJsonString="")
Definition: XMLState.cpp:77
armarx::StateParameterDeserialization::typeStr
std::string typeStr
Definition: XMLState.h:86
armarx::RapidXmlReaderNode
Definition: RapidXmlReader.h:68
armarx::StringXMLNodeMap
std::map< std::string, RapidXmlReaderPtr > StringXMLNodeMap
Definition: XMLState.h:42
armarx::XMLStateConstructorParams::uuidToXMLMap
StringXMLNodeMapPtr uuidToXMLMap
Definition: XMLState.h:55
armarx::XMLState
Definition: XMLState.h:96
armarx::StateParameterDeserialization::optional
bool optional
Definition: XMLState.h:85
armarx::State
Definition: State.h:54
ExpressionException.h
armarx::StateParameterDeserialization::name
std::string name
Definition: XMLState.h:84
armarx::StateParameterDeserialization
Definition: XMLState.h:72
armarx::XMLStateFactoryBase
Definition: XMLState.h:66
armarx::XMLState::addXMLSubstates
void addXMLSubstates(RapidXmlReaderNode substatesNode, const std::string &parentStateName)
Definition: XMLState.cpp:306
armarx::NoUserCodeState::clone
StateBasePtr clone() const override
Generates a new copy of this state with the same statename, substates, transitions,...
Definition: XMLState.cpp:72
armarx::XMLStateTemplate::XMLStateTemplate
XMLStateTemplate(const XMLStateConstructorParams &params)
Definition: XMLState.h:141
AbstractFactoryMethod.h
armarx::XMLState::getSelectedProfile
StatechartProfilePtr getSelectedProfile() const
Definition: XMLState.cpp:225
armarx::RapidXmlReaderNodePtr
std::shared_ptr< RapidXmlReaderNode > RapidXmlReaderNodePtr
Definition: XMLState.h:40
armarx::XMLState::defineParameters
void defineParameters() override
Virtual function, in which input/local/output parameters can be specified.
Definition: XMLState.cpp:231
armarx::PrivateXmlStateClass
Definition: XMLState.cpp:171
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28