Version: 8.3.0
LoadState.hxx
Go to the documentation of this file.
1 // Copyright (C) 2006-2016 CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 #ifndef __LOADSTATE_HXX_
21 #define __LOADSTATE_HXX_
22 
23 #include "YACSloaderExport.hxx"
24 #include "xmlParserBase.hxx"
25 #include "InputPort.hxx"
26 
27 #include "define.hxx"
28 #include "Exception.hxx"
29 #include <vector>
30 #include <list>
31 
32 namespace YACS
33 {
34  namespace ENGINE
35  {
36  class Proc;
37  class Runtime;
38  class SequenceAny;
39  class Any;
40  class TypeCode;
41 
43 
47  YACSLOADER_EXPORT void loadState(YACS::ENGINE::Proc *p,const std::string& xmlStateFile);
48 
54  {
55  public:
58  virtual void parse(std::string xmlState);
59  protected:
60  Proc* _p;
62  };
63 
64  typedef enum
65  {
68  XMLINNODE = 2,
69  XMLINPORT = 3,
71  XMLDONE = 5,
73  } XMLReadState;
74 
76 
81  {
82  public:
84  static std::string _what;
85 
86  static void setProc(Proc* p);
87  static void setRuntime(Runtime* runtime);
88 
89  public:
90  virtual void init(const xmlChar** p, xmlParserBase* father=0);
91 
92  protected:
93  virtual void onStart (const XML_Char* elem, const xmlChar** p);
94  virtual void onEnd (const XML_Char* name);
95  virtual void charData(std::string data);
96 
97  protected:
98  static std::stack<XMLReadState> _stackState;
99  static Proc* _p;
100  static Runtime* _runtime;
101  static std::map<std::string, YACS::StatesForNode> _nodeStateValue;
102  static std::map<std::string, YACS::StatesForNode> _nodeStates;
103  };
104 
105 #ifndef SWIG
107  {
108  public:
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  };
113 
114 
115  class loopPortParser;
117  {
118  public:
119  virtual void init(const xmlChar** p, xmlParserBase* father=0);
120  virtual void onStart (const XML_Char* elem, const xmlChar** p);
121  virtual void onEnd (const XML_Char* name);
122  Any* xmlToAny(const std::string& data, const TypeCode* tc)const;
123  std::string _nodeName;
124  std::string _nodeState;
125  private:
126  std::list<loopPortParser*> _loopSamples;
127  };
128 
130  {
131  public:
132  virtual void init(const xmlChar** p, xmlParserBase* father=0);
133  virtual void onStart (const XML_Char* elem, const xmlChar** p);
134  virtual void charData(std::string data);
135  virtual void onEnd (const XML_Char* name);
136  std::string _attrValue;
137  };
138 
139 
141  {
142  public:
143  virtual void init(const xmlChar** p, xmlParserBase* father=0);
144  virtual void onStart (const XML_Char* elem, const xmlChar** p);
145  virtual void onEnd (const XML_Char* name);
146  virtual void addData(std::string value);
147  };
148 
150  {
151  public:
152  virtual void init(const xmlChar** p, xmlParserBase* father=0);
153  virtual void onStart (const XML_Char* elem, const xmlChar** p);
154  virtual void onEnd (const XML_Char* name);
155  virtual void addData(std::string value);
156  };
157 
159  {
160  public:
161  virtual void init(const xmlChar** p, xmlParserBase* father=0);
162  virtual void onStart (const XML_Char* elem, const xmlChar** p);
163  virtual void onEnd (const XML_Char* name);
164  virtual void addData(std::string value);
165  };
166 
168  {
169  public:
170  virtual void init(const xmlChar** p, xmlParserBase* father=0);
171  virtual void onStart (const XML_Char* elem, const xmlChar** p);
172  virtual void onEnd (const XML_Char* name);
173  virtual void addData(std::string value);
174  std::list<std::string> _dataList;
175  };
176 
178  {
179  public:
180  virtual void init(const xmlChar** p, xmlParserBase* father=0);
181  virtual void onStart (const XML_Char* elem, const xmlChar** p);
182  virtual void onEnd (const XML_Char* name);
183  virtual void charData(std::string data);
184  };
185 
187  {
188  public:
189  virtual void init(const xmlChar** p, xmlParserBase* father=0);
190  virtual void onStart (const XML_Char* elem, const xmlChar** p);
191  virtual void onEnd (const XML_Char* name);
192  virtual void charData(std::string data);
193  void addSample(int index, const std::string data);
194  unsigned int getNbSamples()const;
195  unsigned int getSampleId(unsigned int i)const;
196  const std::string& getSampleData(unsigned int i)const;
197  const std::string& getPortName()const;
198  private:
199  std::vector<unsigned int> _ids;
200  std::vector<std::string> _sampleData;
201  };
202 
204  {
205  public:
206  sampleParser(loopPortParser* father);
207  virtual void init(const xmlChar** p, xmlParserBase* father=0);
208  virtual void onStart (const XML_Char* elem, const xmlChar** p);
209  virtual void onEnd (const XML_Char* name);
210  virtual void charData(std::string data);
211  //protected:
212  // Any* xmlToAny()throw(ConversionException);
213  private:
215  };
216 #endif
217  }
218 }
219 #endif