1 // Copyright (C) 2006-2016 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, or (at your option) any later version.
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
20 #ifndef __LOADSTATE_HXX_
21 #define __LOADSTATE_HXX_
23 #include "YACSloaderExport.hxx"
24 #include "xmlParserBase.hxx"
27 #include "Exception.hxx"
36 //! Load state from a file into a Proc
39 * \param xmlStateFile: the file name
41 YACSLOADER_EXPORT void loadState(YACS::ENGINE::Proc *p,const std::string& xmlStateFile);
43 /*! \brief class for parse an xml file, use a dedicated parser, to load a
44 * saved state of a SALOME execution.
47 class YACSLOADER_EXPORT stateLoader: public xmlReader
50 stateLoader(xmlParserBase* parser,
51 YACS::ENGINE::Proc* p);
52 virtual void parse(std::string xmlState);
69 //! \brief specialized parser to load SALOME execution saved states.
70 /*! this base class must be derived to build specific parsers for each tag
71 * defined in the xml file
74 class YACSLOADER_EXPORT stateParser: public xmlParserBase
77 static XMLReadState _state;
78 static std::string _what;
80 static void setProc(Proc* p);
81 static void setRuntime(Runtime* runtime);
84 virtual void init(const xmlChar** p, xmlParserBase* father=0);
87 virtual void onStart (const XML_Char* elem, const xmlChar** p);
88 virtual void onEnd (const XML_Char* name);
89 virtual void charData(std::string data);
92 static std::stack<XMLReadState> _stackState;
94 static Runtime* _runtime;
95 static std::map<std::string, YACS::StatesForNode> _nodeStateValue;
96 static std::map<std::string, YACS::StatesForNode> _nodeStates;
99 class YACSLOADER_EXPORT graphParser: public stateParser
102 virtual void init(const xmlChar** p, xmlParserBase* father=0);
103 virtual void onStart (const XML_Char* elem, const xmlChar** p);
104 virtual void onEnd (const XML_Char* name);
108 class YACSLOADER_EXPORT nodeParser: public stateParser
111 virtual void init(const xmlChar** p, xmlParserBase* father=0);
112 virtual void onStart (const XML_Char* elem, const xmlChar** p);
113 virtual void onEnd (const XML_Char* name);
114 std::string _nodeName;
115 std::string _nodeState;
118 class YACSLOADER_EXPORT attrParser: public stateParser
121 virtual void init(const xmlChar** p, xmlParserBase* father=0);
122 virtual void onStart (const XML_Char* elem, const xmlChar** p);
123 virtual void charData(std::string data);
124 virtual void onEnd (const XML_Char* name);
125 std::string _attrValue;
129 class YACSLOADER_EXPORT portParser: public stateParser
132 virtual void init(const xmlChar** p, xmlParserBase* father=0);
133 virtual void onStart (const XML_Char* elem, const xmlChar** p);
134 virtual void onEnd (const XML_Char* name);
135 virtual void addData(std::string value);
138 class YACSLOADER_EXPORT valueParser: public stateParser
141 virtual void init(const xmlChar** p, xmlParserBase* father=0);
142 virtual void onStart (const XML_Char* elem, const xmlChar** p);
143 virtual void onEnd (const XML_Char* name);
144 virtual void addData(std::string value);
147 class YACSLOADER_EXPORT arrayParser: public stateParser
150 virtual void init(const xmlChar** p, xmlParserBase* father=0);
151 virtual void onStart (const XML_Char* elem, const xmlChar** p);
152 virtual void onEnd (const XML_Char* name);
153 virtual void addData(std::string value);
156 class YACSLOADER_EXPORT dataParser: public stateParser
159 virtual void init(const xmlChar** p, xmlParserBase* father=0);
160 virtual void onStart (const XML_Char* elem, const xmlChar** p);
161 virtual void onEnd (const XML_Char* name);
162 virtual void addData(std::string value);
163 std::list<std::string> _dataList;
166 class YACSLOADER_EXPORT simpleTypeParser: public stateParser
169 virtual void init(const xmlChar** p, xmlParserBase* father=0);
170 virtual void onStart (const XML_Char* elem, const xmlChar** p);
171 virtual void onEnd (const XML_Char* name);
172 virtual void charData(std::string data);