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 
33 namespace armarx
34 {
35 
36  class RapidXmlReader;
37  using RapidXmlReaderPtr = std::shared_ptr<RapidXmlReader>;
38  class RapidXmlReaderNode;
39  using RapidXmlReaderNodePtr = std::shared_ptr<RapidXmlReaderNode>;
40 
41  using StringXMLNodeMap = std::map<std::string, RapidXmlReaderPtr>;
42  using StringXMLNodeMapPtr = std::shared_ptr<StringXMLNodeMap>;
43 
44  class StatechartProfile;
45  using StatechartProfilePtr = std::shared_ptr<StatechartProfile>;
46  class StatechartProfiles;
47  using StatechartProfilesPtr = std::shared_ptr<StatechartProfiles>;
48 
50  {
51  std::string xmlFilepath;
56  XMLStateConstructorParams(const std::string& xmlFilepath,
61  };
62 
63  struct XMLStateFactoryBase;
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;
89  bool optional;
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 
101  struct PrivateXmlStateClass;
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:
118 
119  StatePtr addState(StatePtr state);
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>
139  friend class XMLRemoteStateOfferer;
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
armarx::RapidXmlReaderPtr
std::shared_ptr< RapidXmlReader > RapidXmlReaderPtr
Definition: RapidXmlReader.h:67
armarx::NoUserCodeState::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: XMLState.cpp:56
cyberglove_with_calib_22dof.ic
ic
Definition: cyberglove_with_calib_22dof.py:22
armarx::StateParameterDeserialization::getTypePtr
ContainerTypePtr getTypePtr()
Definition: XMLState.cpp:164
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:49
armarx::StateParameterDeserialization::getTypeStr
std::string getTypeStr()
Definition: XMLState.cpp:158
armarx::XMLStateConstructorParams::selectedProfile
StatechartProfilePtr selectedProfile
Definition: XMLState.h:53
armarx::PrivateXmlStateClassPtr
std::shared_ptr< PrivateXmlStateClass > PrivateXmlStateClassPtr
Definition: XMLState.h:102
armarx::NoUserCodeState::GetName
static std::string GetName()
Definition: XMLState.cpp:62
armarx::StateParameterDeserialization::getName
std::string getName()
Definition: XMLState.cpp:146
armarx::XMLStateConstructorParams::XMLStateConstructorParams
XMLStateConstructorParams(const std::string &xmlFilepath, RapidXmlReaderPtr reader, StatechartProfilePtr selectedProfile, StringXMLNodeMapPtr uuidToXMLMap, Ice::CommunicatorPtr ic)
Definition: XMLState.cpp:550
armarx::StateParameterDeserialization::typePtr
ContainerTypePtr typePtr
Definition: XMLState.h:91
armarx::XMLState::addState
StatePtr addState(StatePtr state)
Definition: XMLState.cpp:416
armarx::StateParameterDeserialization::getContainer
VariantContainerBasePtr getContainer()
Definition: XMLState.cpp:170
armarx::XMLStateConstructorParams::ic
Ice::CommunicatorPtr ic
Definition: XMLState.h:55
armarx::XMLStateConstructorParams
Definition: XMLState.h:49
armarx::XMLState::defineSubstates
void defineSubstates() override
Virtual function, in which substates, transition and mappings can be added.
Definition: XMLState.cpp:290
armarx::XMLState::addXMLSubstate
StateBasePtr addXMLSubstate(RapidXmlReaderNode stateNode, const std::string &parentStateName)
Definition: XMLState.cpp:326
armarx::StatechartProfile
Definition: StatechartProfiles.h:42
armarx::StatechartProfilePtr
std::shared_ptr< class StatechartProfile > StatechartProfilePtr
Definition: StatechartContext.h:51
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:50
armarx::NoUserCodeState::Registry
static SubClassRegistry Registry
Definition: XMLState.h:162
armarx::StateParameterDeserialization::container
VariantContainerBasePtr container
Definition: XMLState.h:92
armarx::StringXMLNodeMapPtr
std::shared_ptr< StringXMLNodeMap > StringXMLNodeMapPtr
Definition: XMLState.h:42
armarx::XMLStateConstructorParams::xmlFilepath
std::string xmlFilepath
Definition: XMLState.h:51
IceInternal::Handle<::Ice::Communicator >
armarx::XMLState::~XMLState
~XMLState() override
Definition: XMLState.cpp:220
armarx::StatechartProfilesPtr
std::shared_ptr< StatechartProfiles > StatechartProfilesPtr
Definition: StatechartProfiles.h:36
armarx::NoUserCodeState
Definition: XMLState.h:155
armarx::StateParameterDeserialization::getOptional
bool getOptional()
Definition: XMLState.cpp:152
armarx::XMLState::getParameters
StateParameterMap getParameters(RapidXmlReaderNode parametersNode)
Definition: XMLState.cpp:253
armarx::XMLStateTemplate
Class for legacy to stay compatible with old statecharts.
Definition: XMLState.h:146
armarx::XMLState::XMLState
XMLState()
Definition: XMLState.h:107
armarx::XMLStateConstructorParams::reader
RapidXmlReaderPtr reader
Definition: XMLState.h:52
armarx::StatechartProfiles
Definition: StatechartProfiles.h:74
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:74
armarx::StateParameterDeserialization::typeStr
std::string typeStr
Definition: XMLState.h:90
armarx::RapidXmlReaderNode
Definition: RapidXmlReader.h:69
armarx::StringXMLNodeMap
std::map< std::string, RapidXmlReaderPtr > StringXMLNodeMap
Definition: XMLState.h:41
armarx::XMLStateConstructorParams::uuidToXMLMap
StringXMLNodeMapPtr uuidToXMLMap
Definition: XMLState.h:54
armarx::XMLState
Definition: XMLState.h:104
armarx::StateParameterDeserialization::optional
bool optional
Definition: XMLState.h:89
armarx::State
Definition: State.h:53
ExpressionException.h
armarx::StateParameterDeserialization::name
std::string name
Definition: XMLState.h:88
armarx::StateParameterDeserialization
Definition: XMLState.h:74
armarx::XMLStateFactoryBase
Definition: XMLState.h:66
armarx::XMLState::addXMLSubstates
void addXMLSubstates(RapidXmlReaderNode substatesNode, const std::string &parentStateName)
Definition: XMLState.cpp:310
armarx::NoUserCodeState::clone
StateBasePtr clone() const override
Generates a new copy of this state with the same statename, substates, transitions,...
Definition: XMLState.cpp:68
armarx::XMLStateTemplate::XMLStateTemplate
XMLStateTemplate(const XMLStateConstructorParams &params)
Definition: XMLState.h:149
AbstractFactoryMethod.h
armarx::XMLState::getSelectedProfile
StatechartProfilePtr getSelectedProfile() const
Definition: XMLState.cpp:225
armarx::RapidXmlReaderNodePtr
std::shared_ptr< RapidXmlReaderNode > RapidXmlReaderNodePtr
Definition: XMLState.h:39
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:178
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27