rad  4.0.0
DOMSCXMLReader.h
Go to the documentation of this file.
1 
10 /*
11  * scampl4cpp/parser
12  *
13  * Copyright by European Southern Observatory, 2012
14  * All rights reserved
15  *
16  * This library is free software; you can redistribute it and/or
17  * modify it under the terms of the GNU Lesser General Public
18  * License as published by the Free Software Foundation; either
19  * version 2.1 of the License, or (at your option) any later version.
20  *
21  * This library is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24  * Lesser General Public License for more details.
25  *
26  * You should have received a copy of the GNU Lesser General Public
27  * License along with this library; if not, write to the Free Software
28  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
29  * 02111-1307 USA.
30  */
31 
32 #ifndef SCXML4CPP_DOMSCXMLREADER_H
33 #define SCXML4CPP_DOMSCXMLREADER_H
34 
35 #ifndef __cplusplus
36 #error This is a C++ include file and cannot be used from plain C
37 #endif
38 
39 #ifndef SCXML4CPP_SCXMLREADER_H
40 #include "scxml4cpp/SCXMLReader.h"
41 #endif
42 
43 #include <stdio.h>
44 //#include <stdexcept>
45 
46 #include <xercesc/dom/DOM.hpp>
47 #include <xercesc/dom/DOMDocument.hpp>
48 #include <xercesc/dom/DOMDocumentType.hpp>
49 #include <xercesc/dom/DOMElement.hpp>
50 #include <xercesc/dom/DOMImplementation.hpp>
51 #include <xercesc/dom/DOMImplementationLS.hpp>
52 #include <xercesc/dom/DOMNodeIterator.hpp>
53 #include <xercesc/dom/DOMNodeList.hpp>
54 #include <xercesc/dom/DOMText.hpp>
55 #include <xercesc/sax/HandlerBase.hpp>
56 #include <xercesc/parsers/XercesDOMParser.hpp>
57 #include <xercesc/util/XMLUni.hpp>
58 
59 
60 using namespace xercesc;
61 
62 namespace scxml4cpp {
63 
64 class StateMachine;
65 class State;
66 class Action;
67 class Activity;
68 
74 {
75  public:
84 
91  ~DOMSCXMLReader();
92 
93 
104  bool read(const std::string& filename,
105  std::list<Action*>* actions,
106  std::list<Activity*>* activities,
107  StateMachine& sm);
108 
120  bool read(const std::string& input,
121  const std::string& id,
122  std::list<Action*>* actions,
123  std::list<Activity*>* activities,
124  StateMachine& sm);
125 
126  private:
127  std::list<DOMElement*> mStates;
128  std::list<Action*>* mActions;
129  std::list<Activity*>* mActivities;
130  std::list<Action*> mTraces;
131 
132  DOMDocument* mDoc;
133  XercesDOMParser* mDomParser;
134  ErrorHandler* mErrHandler;
135 
136  XMLCh* XML_SCXML;
137  XMLCh* XML_INITIAL;
138  XMLCh* XML_STATE;
139  XMLCh* XML_PARALLEL;
140  XMLCh* XML_FINAL;
141  XMLCh* XML_ONENTRY;
142  XMLCh* XML_ONEXIT;
143  XMLCh* XML_TRANSITION;
144  XMLCh* XML_HISTORY;
145  XMLCh* XML_INVOKE;
146 
147  // SCXML Element's attributes names
148  XMLCh* XML_ATTR_INITIAL;
149  XMLCh* XML_ATTR_NAME;
150  /*
151  XMLCh* XML_ATTR_XMLNS = "xmlns";
152  XMLCh* XML_ATTR_VERSION = "version";
153  XMLCh* XML_ATTR_PROFILE = "profile";
154  XMLCh* XML_ATTR_EXMODE = "exmode";
155  */
156  XMLCh* XML_ATTR_ID;
157  XMLCh* XML_ATTR_EVENT;
158  XMLCh* XML_ATTR_COND;
159  XMLCh* XML_ATTR_TARGET;
160  XMLCh* XML_ATTR_TYPE;
161  /*
162  XMLCh* XML_ATTR_LABEL = "label";
163  XMLCh* XML_ATTR_EXPR = "expr";
164  XMLCh* XML_ATTR_LEVEL = "level";
165  XMLCh* XML_ATTR_ANCHOR = "anchor";
166  */
167  // Custom Element name (extension to the SCXML Executable Content)
168  XMLCh* XML_ACTION;
169  XMLCh* XML_ATTR_ACTION_NAME;
170  XMLCh* XML_ATTR_ACTION_PARAM;
171 
172  XMLCh* SCXML_HISTORY_DEEP;
173  XMLCh* SCXML_HISTORY_SHALLOW;
174  XMLCh* USER_DATA_KEY_STATE;
175  XMLCh* DEFAULT_SCXML_NAME;
176 
177 
178  void addTraces(State* s);
179  void delTraces();
180 
181  void parseActivities();
182  void parseActions(const XMLCh*);
183  void resolveInitialStates(StateMachine& sm);
184  Action* findAction(const XMLCh*);
185  DOMNodeList* findCustomActionXMLElement(DOMElement* elementList);
186  Activity* findActivity(const XMLCh*);
187  State* findTargetState(const XMLCh*);
188  void parseTransitions(StateMachine& sm);
189  void resolveParents(StateMachine& sm);
190  void resolveHistory();
191  bool isStateCompound(DOMElement*);
192  void parseStates();
196  void parseDoc(StateMachine& sm);
197 
199  DOMSCXMLReader& operator= (const DOMSCXMLReader&);
200 };
201 
202 } // namespace scxml4cpp
203 
204 #endif // SCXML4CPP_DOMSCXMLREADER_H
scxml4cpp
Definition: Action.h:40
scxml4cpp::SCXMLReader
Definition: SCXMLReader.h:50
scxml4cpp::Activity
Definition: Activity.h:52
SCXMLReader.h
SCXMLReader header.
scxml4cpp::StateMachine
Definition: StateMachine.h:64
scxml4cpp::State
Definition: State.h:60
scxml4cpp::Action
Definition: Action.h:66
scxml4cpp::DOMSCXMLReader
Definition: DOMSCXMLReader.h:74