rad 6.2.0
Loading...
Searching...
No Matches
DOMSCXMLReaderImpl.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_DOMSCXMLREADERIMPL_H
33#define SCXML4CPP_DOMSCXMLREADERIMPL_H
34
36
37#include <xercesc/dom/DOM.hpp>
38#include <xercesc/dom/DOMDocument.hpp>
39#include <xercesc/dom/DOMDocumentType.hpp>
40#include <xercesc/dom/DOMElement.hpp>
41#include <xercesc/dom/DOMImplementation.hpp>
42#include <xercesc/dom/DOMImplementationLS.hpp>
43#include <xercesc/dom/DOMNodeIterator.hpp>
44#include <xercesc/dom/DOMNodeList.hpp>
45#include <xercesc/dom/DOMText.hpp>
46#include <xercesc/sax/HandlerBase.hpp>
47#include <xercesc/parsers/XercesDOMParser.hpp>
48#include <xercesc/util/XMLUni.hpp>
49
50#include "scxml4cpp/Action.h"
51#include "scxml4cpp/Activity.h"
52#include "scxml4cpp/State.h"
54
55namespace scxml4cpp {
56
62{
63 public:
71 Impl();
72
79 ~Impl();
80
84 Impl(const Impl&) = delete;
85 Impl& operator=(const Impl&) = delete;
86
87 Impl(Impl&&) = default;
88 Impl& operator=(Impl&&) = default;
89
100 bool read(const std::string& filename,
101 std::list<Action*>* actions,
102 std::list<Activity*>* activities,
103 StateMachine& sm);
104
116 bool read(const std::string& input,
117 const std::string& id,
118 std::list<Action*>* actions,
119 std::list<Activity*>* activities,
120 StateMachine& sm);
121
122#if 0
123 void addReplaceRule(const ReplaceRules::ElementType elementType,
124 const std::string& srcId,
125 const std::string& dstId);
126#endif
127 void setReplaceRules(const ReplaceRules& replaceRules);
128 void clearReplaceRules();
129
130 const std::vector<std::string>& getWarnings() const;
131 void resetWarnings();
132
133 private:
134 ReplaceRules mReplaceRules;
135
136 std::vector<std::string> mWarnings;
137
138 std::list<xercesc::DOMElement*> mStates;
139 std::list<Action*>* mActions;
140 std::list<Activity*>* mActivities;
141 std::list<Action*> mTraces;
142
143 xercesc::DOMDocument* mDoc;
144 xercesc::XercesDOMParser* mDomParser;
145 xercesc::ErrorHandler* mErrHandler;
146
147 XMLCh* XML_SCXML;
148 XMLCh* XML_INITIAL;
149 XMLCh* XML_STATE;
150 XMLCh* XML_PARALLEL;
151 XMLCh* XML_FINAL;
152 XMLCh* XML_ONENTRY;
153 XMLCh* XML_ONEXIT;
154 XMLCh* XML_TRANSITION;
155 XMLCh* XML_HISTORY;
156 XMLCh* XML_INVOKE;
157
158 // SCXML Element's attributes names
159 XMLCh* XML_ATTR_INITIAL;
160 XMLCh* XML_ATTR_NAME;
161 /*
162 XMLCh* XML_ATTR_XMLNS = "xmlns";
163 XMLCh* XML_ATTR_VERSION = "version";
164 XMLCh* XML_ATTR_PROFILE = "profile";
165 XMLCh* XML_ATTR_EXMODE = "exmode";
166 */
167 XMLCh* XML_ATTR_ID;
168 XMLCh* XML_ATTR_EVENT;
169 XMLCh* XML_ATTR_COND;
170 XMLCh* XML_ATTR_TARGET;
171 XMLCh* XML_ATTR_TYPE;
172 /*
173 XMLCh* XML_ATTR_LABEL = "label";
174 XMLCh* XML_ATTR_EXPR = "expr";
175 XMLCh* XML_ATTR_LEVEL = "level";
176 XMLCh* XML_ATTR_ANCHOR = "anchor";
177 */
178 // Custom Element name (extension to the SCXML Executable Content)
179 XMLCh* XML_ACTION;
180 XMLCh* XML_ATTR_ACTION_NAME;
181 XMLCh* XML_ATTR_ACTION_PARAM;
182 XMLCh* XML_ALL;
183
184 XMLCh* SCXML_HISTORY_DEEP;
185 XMLCh* SCXML_HISTORY_SHALLOW;
186 XMLCh* USER_DATA_KEY_STATE;
187 XMLCh* DEFAULT_SCXML_NAME;
188
189 std::string buildWarningMsg(const std::string& str, const XMLCh* id);
190 void addWarning(const std::string& msg);
191
192 void addTraces(State* s);
193 void delTraces();
194
195 void parseActivities();
196 void parseActions(const XMLCh*);
197 void resolveInitialStates(StateMachine& sm);
198 Action* findAction(const XMLCh*);
199 Action* findGuard(const XMLCh*);
200 xercesc::DOMNodeList* findCustomActionXMLElement(xercesc::DOMElement* elementList);
201 Activity* findActivity(const XMLCh*);
202 State* findTargetState(const XMLCh*);
203 void parseTransitions(StateMachine& sm);
204 void resolveParents(StateMachine& sm);
205 void resolveHistory();
206 bool isStateCompound(xercesc::DOMElement*);
207 void parseStates();
211 void parseDoc(StateMachine& sm);
212};
213
214} // namespace scxml4cpp
215
216#endif // SCXML4CPP_DOMSCXMLREADERIMPL_H
Action header.
Activity header.
SCXMLReader header.
StateMachine header.
State header.
Definition Action.h:66
Definition Activity.h:52
Definition DOMSCXMLReaderImpl.h:62
void setReplaceRules(const ReplaceRules &replaceRules)
Definition DOMSCXMLReaderImpl.cpp:285
void resetWarnings()
Definition DOMSCXMLReaderImpl.cpp:317
Impl(const Impl &)=delete
bool read(const std::string &filename, std::list< Action * > *actions, std::list< Activity * > *activities, StateMachine &sm)
Definition DOMSCXMLReaderImpl.cpp:960
Impl & operator=(Impl &&)=default
void clearReplaceRules()
Definition DOMSCXMLReaderImpl.cpp:290
Impl()
Definition DOMSCXMLReaderImpl.cpp:84
~Impl()
Definition DOMSCXMLReaderImpl.cpp:196
const std::vector< std::string > & getWarnings() const
Definition DOMSCXMLReaderImpl.cpp:312
Impl & operator=(const Impl &)=delete
Definition ReplaceRules.h:53
ElementType
Definition ReplaceRules.h:55
Definition StateMachine.h:64
Definition State.h:60
Definition Action.cpp:36