1 // Copyright (C) 2006-2008 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #ifndef __LOADSTATE_HXX_
20 #define __LOADSTATE_HXX_
22 #include "xmlParserBase.hxx"
25 #include "Exception.hxx"
34 //! Load state from a file into a Proc
37 * \param xmlStateFile: the file name
39 void loadState(YACS::ENGINE::Proc *p,const std::string& xmlStateFile);
41 /*! \brief class for parse an xml file, use a dedicated parser, to load a
42 * saved state of a SALOME execution.
45 class stateLoader: public xmlReader
48 stateLoader(xmlParserBase* parser,
49 YACS::ENGINE::Proc* p);
50 virtual void parse(std::string xmlState);
67 //! \brief specialized parser to load SALOME execution saved states.
68 /*! this base class must be derived to build specific parsers for each tag
69 * defined in the xml file
72 class stateParser: public xmlParserBase
75 static XMLReadState _state;
76 static std::string _what;
78 static void setProc(Proc* p);
79 static void setRuntime(Runtime* runtime);
82 virtual void init(const xmlChar** p, xmlParserBase* father=0);
85 virtual void onStart (const XML_Char* elem, const xmlChar** p);
86 virtual void onEnd (const XML_Char* name);
87 virtual void charData(std::string data);
90 static std::stack<XMLReadState> _stackState;
92 static Runtime* _runtime;
93 static std::map<std::string, YACS::StatesForNode> _nodeStateValue;
94 static std::map<std::string, YACS::StatesForNode> _nodeStates;
97 class graphParser: public stateParser
100 virtual void init(const xmlChar** p, xmlParserBase* father=0);
101 virtual void onStart (const XML_Char* elem, const xmlChar** p);
102 virtual void onEnd (const XML_Char* name);
106 class nodeParser: public stateParser
109 virtual void init(const xmlChar** p, xmlParserBase* father=0);
110 virtual void onStart (const XML_Char* elem, const xmlChar** p);
111 virtual void onEnd (const XML_Char* name);
112 std::string _nodeName;
113 std::string _nodeState;
116 class attrParser: public stateParser
119 virtual void init(const xmlChar** p, xmlParserBase* father=0);
120 virtual void onStart (const XML_Char* elem, const xmlChar** p);
121 virtual void charData(std::string data);
122 virtual void onEnd (const XML_Char* name);
123 std::string _attrValue;
127 class portParser: public stateParser
130 virtual void init(const xmlChar** p, xmlParserBase* father=0);
131 virtual void onStart (const XML_Char* elem, const xmlChar** p);
132 virtual void onEnd (const XML_Char* name);
133 virtual void addData(std::string value);
136 class valueParser: public stateParser
139 virtual void init(const xmlChar** p, xmlParserBase* father=0);
140 virtual void onStart (const XML_Char* elem, const xmlChar** p);
141 virtual void onEnd (const XML_Char* name);
142 virtual void addData(std::string value);
145 class arrayParser: public stateParser
148 virtual void init(const xmlChar** p, xmlParserBase* father=0);
149 virtual void onStart (const XML_Char* elem, const xmlChar** p);
150 virtual void onEnd (const XML_Char* name);
151 virtual void addData(std::string value);
154 class dataParser: public stateParser
157 virtual void init(const xmlChar** p, xmlParserBase* father=0);
158 virtual void onStart (const XML_Char* elem, const xmlChar** p);
159 virtual void onEnd (const XML_Char* name);
160 virtual void addData(std::string value);
161 std::list<std::string> _dataList;
164 class simpleTypeParser: public stateParser
167 virtual void init(const xmlChar** p, xmlParserBase* father=0);
168 virtual void onStart (const XML_Char* elem, const xmlChar** p);
169 virtual void onEnd (const XML_Char* name);
170 virtual void charData(std::string data);