Version: 9.15.0
YACS::ENGINE::VisitorSaveState Class Reference

#include <VisitorSaveState.hxx>

Inheritance diagram for YACS::ENGINE::VisitorSaveState:
Collaboration diagram for YACS::ENGINE::VisitorSaveState:

Public Member Functions

 VisitorSaveState (ComposedNode *root)
 
virtual ~VisitorSaveState ()
 
void openFileDump (const std::string &xmlDump)
 
void closeFileDump ()
 
virtual void visitBloc (Bloc *node)
 
virtual void visitElementaryNode (ElementaryNode *node)
 
void visitForEachLoop (ForEachLoop *node) override
 
void visitForEachLoopDyn (ForEachLoopDyn *node) override
 
virtual void visitOptimizerLoop (OptimizerLoop *node)
 
virtual void visitDynParaLoop (DynParaLoop *node)
 
virtual void visitForLoop (ForLoop *node)
 
virtual void visitInlineNode (InlineNode *node)
 
virtual void visitInlineFuncNode (InlineFuncNode *node)
 
virtual void visitLoop (Loop *node)
 
virtual void visitProc (Proc *node)
 
virtual void visitServiceNode (ServiceNode *node)
 
virtual void visitServerNode (ServerNode *node)
 
virtual void visitServiceInlineNode (ServiceInlineNode *node)
 
virtual void visitSwitch (Switch *node)
 
virtual void visitWhileLoop (WhileLoop *node)
 
virtual void visitPresetNode (DataNode *node)
 
virtual void visitOutNode (DataNode *node)
 
virtual void visitStudyInNode (DataNode *node)
 
virtual void visitStudyOutNode (DataNode *node)
 
- Public Member Functions inherited from YACS::ENGINE::Visitor
 Visitor (ComposedNode *root)
 

Protected Attributes

std::ofstream _out
 
std::map< int, std::string > _nodeStateName
 
- Protected Attributes inherited from YACS::ENGINE::Visitor
ComposedNode_root
 

Additional Inherited Members

- Protected Member Functions inherited from YACS::ENGINE::Visitor
std::map< std::string, std::string > getNodeProperties (Node *node)
 
std::map< std::string, TypeCode * > getTypeCodeMap (Proc *proc)
 
std::map< std::string, Container * > getContainerMap (Proc *proc)
 
std::list< TypeCodeObjref * > getListOfBases (TypeCodeObjref *objref)
 

Detailed Description

Definition at line 35 of file VisitorSaveState.hxx.

Constructor & Destructor Documentation

◆ VisitorSaveState()

VisitorSaveState::VisitorSaveState ( ComposedNode root)

Definition at line 47 of file VisitorSaveState.cxx.

47  : Visitor(root)
48 {
49  _nodeStateName[YACS::READY] ="READY";
50  _nodeStateName[YACS::TOLOAD] ="TOLOAD";
51  _nodeStateName[YACS::LOADED] ="LOADED";
52  _nodeStateName[YACS::TOACTIVATE] ="TOACTIVATE";
53  _nodeStateName[YACS::ACTIVATED] ="ACTIVATED";
54  _nodeStateName[YACS::DESACTIVATED] ="DESACTIVATED";
55  _nodeStateName[YACS::DONE] ="DONE";
56  _nodeStateName[YACS::SUSPENDED] ="SUSPENDED";
57  _nodeStateName[YACS::LOADFAILED] ="LOADFAILED";
58  _nodeStateName[YACS::EXECFAILED] ="EXECFAILED";
59  _nodeStateName[YACS::PAUSE] ="PAUSE";
60  _nodeStateName[YACS::INTERNALERR] ="INTERNALERR";
61  _nodeStateName[YACS::DISABLED] ="DISABLED";
62  _nodeStateName[YACS::FAILED] ="FAILED";
63  _nodeStateName[YACS::ERROR] ="ERROR";
64 }
std::map< int, std::string > _nodeStateName
Visitor(ComposedNode *root)
Definition: Visitor.cxx:28
@ FAILED
Definition: define.hxx:51
@ DESACTIVATED
Definition: define.hxx:42
@ EXECFAILED
Definition: define.hxx:46
@ TOLOAD
Definition: define.hxx:38
@ LOADED
Definition: define.hxx:39
@ READY
Definition: define.hxx:37
@ ACTIVATED
Definition: define.hxx:41
@ INTERNALERR
Definition: define.hxx:49
@ DONE
Definition: define.hxx:43
@ TOACTIVATE
Definition: define.hxx:40
@ SUSPENDED
Definition: define.hxx:44
@ PAUSE
Definition: define.hxx:47
@ DISABLED
Definition: define.hxx:50
@ LOADFAILED
Definition: define.hxx:45
@ ERROR
Definition: define.hxx:52

References _nodeStateName, YACS::ACTIVATED, YACS::DESACTIVATED, YACS::DISABLED, YACS::DONE, YACS::ERROR, YACS::EXECFAILED, YACS::FAILED, YACS::INTERNALERR, YACS::LOADED, YACS::LOADFAILED, YACS::PAUSE, YACS::READY, YACS::SUSPENDED, YACS::TOACTIVATE, and YACS::TOLOAD.

◆ ~VisitorSaveState()

VisitorSaveState::~VisitorSaveState ( )
virtual

Definition at line 66 of file VisitorSaveState.cxx.

67 {
68  if (_out)
69  {
70  _out << "</graphState>" << endl;
71  _out.close();
72  }
73 }

References _out.

Member Function Documentation

◆ closeFileDump()

void VisitorSaveState::closeFileDump ( )

Definition at line 87 of file VisitorSaveState.cxx.

88 {
89  if (!_out) throw Exception("No file open for dump state");
90  _out << "</graphState>" << endl;
91  _out.close();
92 }

References _out.

Referenced by dumpState(), Handler(), main(), YACS::ENGINE::Executor::saveState(), YACS::ENGINE::Proc::saveState(), and YACS::ENGINE::schemaSaveStateUnsafe().

◆ openFileDump()

void VisitorSaveState::openFileDump ( const std::string &  xmlDump)

Definition at line 75 of file VisitorSaveState.cxx.

76 {
77  _out.open(xmlDump.c_str(), ios::out);
78  if (!_out)
79  {
80  string what = "Impossible to open file for writing: " + xmlDump;
81  throw Exception(what);
82  }
83  _out << "<?xml version='1.0'?>" << endl;
84  _out << "<graphState>" << endl;
85 }

References _out.

Referenced by dumpState(), Handler(), main(), YACS::ENGINE::Executor::saveState(), YACS::ENGINE::Proc::saveState(), and YACS::ENGINE::schemaSaveStateUnsafe().

◆ visitBloc()

void VisitorSaveState::visitBloc ( Bloc node)
virtual

Implements YACS::ENGINE::Visitor.

Definition at line 145 of file VisitorSaveState.cxx.

146 {
147  node->ComposedNode::accept(this);
148  if (!_out) throw Exception("No file open for dump state");
149  string name = _root->getName();
150  if (static_cast<ComposedNode*>(node) != _root) name = _root->getChildName(node);
151  DEBTRACE("VisitorSaveState::visitBloc ------------- " << name);
152  _out << " <node type='bloc'>" << endl;
153  _out << " <name>" << name << "</name>" << endl;
154  _out << " <state>" << _nodeStateName[node->getState()] << "</state>" << endl;
155 
156  _out << " </node>" << endl;
157 }
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
Base class for all composed nodes.
std::string getChildName(const Node *node) const
std::string getName() const
virtual YACS::StatesForNode getState() const
Definition: Node.hxx:118
ComposedNode * _root
Definition: Visitor.hxx:85

References _nodeStateName, _out, YACS::ENGINE::Visitor::_root, DEBTRACE, YACS::ENGINE::ComposedNode::getChildName(), YACS::ENGINE::ComposedNode::getName(), and YACS::ENGINE::Node::getState().

◆ visitDynParaLoop()

void VisitorSaveState::visitDynParaLoop ( DynParaLoop node)
virtual

Implements YACS::ENGINE::Visitor.

Definition at line 214 of file VisitorSaveState.cxx.

215 {
216  node->ComposedNode::accept(this);
217 }

◆ visitElementaryNode()

void VisitorSaveState::visitElementaryNode ( ElementaryNode node)
virtual

Implements YACS::ENGINE::Visitor.

Definition at line 94 of file VisitorSaveState.cxx.

95 {
96  if (!_out) throw Exception("No file open for dump state");
97  string name = _root->getChildName(node);
98  DEBTRACE("VisitorSaveState::visitElementaryNode --- " << name);
99  _out << " <node type='elementaryNode'>" << endl;
100  _out << " <name>" << name << "</name>" << endl;
101  int nodeState = node->getState();
102  _out << " <state>" << _nodeStateName[nodeState] << "</state>" << endl;
103 
104  list<InputPort *> setOfInputPort = node->getSetOfInputPort();
105  list<InputPort *>::iterator iter;
106  for(iter = setOfInputPort.begin(); iter != setOfInputPort.end(); iter++)
107  {
108  _out << " <inputPort>" << endl;
109  _out << " <name>" << (*iter)->getName() << "</name>" << endl;
110  try
111  {
112  _out << " ";
113  _out << (*iter)->dump();
114  }
115  catch (YACS::Exception &e)
116  {
117  DEBTRACE("caught YACS:Exception: " << e.what());
118  _out << "<value><error><![CDATA[" << e.what() << "]]></error></value>" << endl;
119  }
120  _out << " </inputPort>" << endl;
121  }
122 
123  list<OutputPort *> setOfOutputPort = node->getSetOfOutputPort();
124  list<OutputPort *>::iterator oiter;
125  for(oiter = setOfOutputPort.begin(); oiter != setOfOutputPort.end(); oiter++)
126  {
127  _out << " <outputPort>" << endl;
128  _out << " <name>" << (*oiter)->getName() << "</name>" << endl;
129  try
130  {
131  _out << " ";
132  _out << (*oiter)->dump();
133  }
134  catch (YACS::Exception &e)
135  {
136  DEBTRACE("caught YACS:Exception: " << e.what());
137  _out << "<value><error><![CDATA[" << e.what() << "]]></error></value>" << endl;
138  }
139  _out << " </outputPort>" << endl;
140  }
141 
142  _out << " </node>" << endl;
143 }
std::list< OutputPort * > getSetOfOutputPort() const
std::list< InputPort * > getSetOfInputPort() const
YACS::StatesForNode getState() const
const char * what(void) const noexcept
Definition: Exception.cxx:50

References _nodeStateName, _out, YACS::ENGINE::Visitor::_root, DEBTRACE, YACS::ENGINE::ComposedNode::getChildName(), YACS::ENGINE::ElementaryNode::getSetOfInputPort(), YACS::ENGINE::ElementaryNode::getSetOfOutputPort(), YACS::ENGINE::ElementaryNode::getState(), and YACS::Exception::what().

Referenced by visitInlineFuncNode(), visitInlineNode(), visitOutNode(), visitPresetNode(), visitServerNode(), visitServiceInlineNode(), visitServiceNode(), visitStudyInNode(), and visitStudyOutNode().

◆ visitForEachLoop()

void VisitorSaveState::visitForEachLoop ( ForEachLoop node)
overridevirtual

Implements YACS::ENGINE::Visitor.

Reimplemented in YACS::ENGINE::VisitorSalomeSaveState.

Definition at line 173 of file VisitorSaveState.cxx.

174 {
175  node->ComposedNode::accept(this);
176  if (!_out) throw Exception("No file open for dump state");
177  string name = _root->getName();
178  if (static_cast<ComposedNode*>(node) != _root) name = _root->getChildName(node);
179  DEBTRACE("VisitorSaveState::visitForEachLoop ------ " << name);
180  _out << " <node type='forEachLoop'>" << endl;
181  _out << " <name>" << name << "</name>" << endl;
182  _out << " <state>" << _nodeStateName[node->getState()] << "</state>" << endl;
183 
184  _out << " </node>" << endl;
185 }

References _nodeStateName, _out, YACS::ENGINE::Visitor::_root, DEBTRACE, YACS::ENGINE::ComposedNode::getChildName(), YACS::ENGINE::ComposedNode::getName(), and YACS::ENGINE::Node::getState().

◆ visitForEachLoopDyn()

void VisitorSaveState::visitForEachLoopDyn ( ForEachLoopDyn node)
overridevirtual

Implements YACS::ENGINE::Visitor.

Definition at line 187 of file VisitorSaveState.cxx.

188 {
189  node->ComposedNode::accept(this);
190  if (!_out) throw Exception("No file open for dump state");
191  string name = _root->getName();
192  if (static_cast<ComposedNode*>(node) != _root) name = _root->getChildName(node);
193  DEBTRACE("VisitorSaveState::visitForEachLoopDyn ------ " << name);
194  _out << " <node type='forEachLoopDyn'>" << endl;
195  _out << " <name>" << name << "</name>" << endl;
196  _out << " <state>" << _nodeStateName[node->getState()] << "</state>" << endl;
197  _out << " </node>" << endl;
198 }

References _nodeStateName, _out, YACS::ENGINE::Visitor::_root, DEBTRACE, YACS::ENGINE::ComposedNode::getChildName(), YACS::ENGINE::ComposedNode::getName(), and YACS::ENGINE::Node::getState().

◆ visitForLoop()

void VisitorSaveState::visitForLoop ( ForLoop node)
virtual

Implements YACS::ENGINE::Visitor.

Definition at line 234 of file VisitorSaveState.cxx.

235 {
236  node->ComposedNode::accept(this);
237  if (!_out) throw Exception("No file open for dump state");
238  string name = _root->getName();
239  if (static_cast<ComposedNode*>(node) != _root) name = _root->getChildName(node);
240  DEBTRACE("VisitorSaveState::visitForLoop ---------- " << name);
241  _out << " <node type='forLoop'>" << endl;
242  _out << " <name>" << name << "</name>" << endl;
243  _out << " <state>" << _nodeStateName[node->getState()] << "</state>" << endl;
244  _out << " <nbdone>" << node->getNbOfTurns() << "</nbdone>" << endl;
245  InputPort * ip = node->edGetNbOfTimesInputPort();
246  if (ip->isEmpty())
247  throw Exception("NbOfTimesInputPort in forLoop empty, case not handled yet...");
248  Any *val = static_cast<Any*>(ip->get());
249  int nsteps = val->getIntValue();
250  _out << " <nsteps>" << nsteps << "</nsteps>" << endl;
251 
252  _out << " </node>" << endl;
253 }
: Interface for management of storage of data formated dynamically in its TypeCode....
Definition: Any.hxx:79
virtual int getIntValue() const =0
InputPort * edGetNbOfTimesInputPort()
Definition: ForLoop.hxx:45
Base class for Input Ports.
Definition: InputPort.hxx:44
virtual bool isEmpty()
Definition: InputPort.cxx:70
virtual void * get() const =0
int getNbOfTurns() const
Definition: Loop.hxx:162

References _nodeStateName, _out, YACS::ENGINE::Visitor::_root, DEBTRACE, YACS::ENGINE::ForLoop::edGetNbOfTimesInputPort(), YACS::ENGINE::InputPort::get(), YACS::ENGINE::ComposedNode::getChildName(), YACS::ENGINE::Any::getIntValue(), YACS::ENGINE::ComposedNode::getName(), YACS::ENGINE::Loop::getNbOfTurns(), YACS::ENGINE::Node::getState(), and YACS::ENGINE::InputPort::isEmpty().

◆ visitInlineFuncNode()

void VisitorSaveState::visitInlineFuncNode ( InlineFuncNode node)
virtual

Implements YACS::ENGINE::Visitor.

Definition at line 303 of file VisitorSaveState.cxx.

304 {
305  visitElementaryNode(node);
306 }
virtual void visitElementaryNode(ElementaryNode *node)

References visitElementaryNode().

◆ visitInlineNode()

void VisitorSaveState::visitInlineNode ( InlineNode node)
virtual

Implements YACS::ENGINE::Visitor.

Definition at line 298 of file VisitorSaveState.cxx.

299 {
300  visitElementaryNode(node);
301 }

References visitElementaryNode().

◆ visitLoop()

void VisitorSaveState::visitLoop ( Loop node)
virtual

Implements YACS::ENGINE::Visitor.

Definition at line 219 of file VisitorSaveState.cxx.

220 {
221  node->ComposedNode::accept(this);
222  if (!_out) throw Exception("No file open for dump state");
223  string name = _root->getName();
224  if (static_cast<ComposedNode*>(node) != _root) name = _root->getChildName(node);
225  DEBTRACE("VisitorSaveState::visitLoop ------------- " << name);
226  _out << " <node type ='loop'>" << endl;
227  _out << " <name>" << name << "</name>" << endl;
228  _out << " <state>" << _nodeStateName[node->getState()] << "</state>" << endl;
229  _out << " <nbdone>" << node->getNbOfTurns() << "</nbdone>" << endl;
230 
231  _out << " </node>" << endl;
232 }

References _nodeStateName, _out, YACS::ENGINE::Visitor::_root, DEBTRACE, YACS::ENGINE::ComposedNode::getChildName(), YACS::ENGINE::ComposedNode::getName(), YACS::ENGINE::Loop::getNbOfTurns(), and YACS::ENGINE::Node::getState().

◆ visitOptimizerLoop()

void VisitorSaveState::visitOptimizerLoop ( OptimizerLoop node)
virtual

Implements YACS::ENGINE::Visitor.

Definition at line 200 of file VisitorSaveState.cxx.

201 {
202  node->ComposedNode::accept(this);
203  if (!_out) throw Exception("No file open for dump state");
204  string name = _root->getName();
205  if (static_cast<ComposedNode*>(node) != _root) name = _root->getChildName(node);
206  DEBTRACE("VisitorSaveState::visitOptimizerLoop ------ " << name);
207  _out << " <node type='optimizerLoop'>" << endl;
208  _out << " <name>" << name << "</name>" << endl;
209  _out << " <state>" << _nodeStateName[node->getState()] << "</state>" << endl;
210 
211  _out << " </node>" << endl;
212 }

References _nodeStateName, _out, YACS::ENGINE::Visitor::_root, DEBTRACE, YACS::ENGINE::ComposedNode::getChildName(), YACS::ENGINE::ComposedNode::getName(), and YACS::ENGINE::Node::getState().

◆ visitOutNode()

void VisitorSaveState::visitOutNode ( DataNode node)
virtual

Implements YACS::ENGINE::Visitor.

Definition at line 328 of file VisitorSaveState.cxx.

329 {
330  visitElementaryNode(node);
331 }

References visitElementaryNode().

◆ visitPresetNode()

void VisitorSaveState::visitPresetNode ( DataNode node)
virtual

Implements YACS::ENGINE::Visitor.

Definition at line 323 of file VisitorSaveState.cxx.

324 {
325  visitElementaryNode(node);
326 }

References visitElementaryNode().

◆ visitProc()

void VisitorSaveState::visitProc ( Proc node)
virtual

Implements YACS::ENGINE::Visitor.

Definition at line 159 of file VisitorSaveState.cxx.

160 {
161  node->ComposedNode::accept(this);
162  if (!_out) throw Exception("No file open for dump state");
163  string name = _root->getName();
164  if (static_cast<ComposedNode*>(node) != _root) name = _root->getChildName(node);
165  DEBTRACE("VisitorSaveState::visitProc ------------- " << name);
166  _out << " <node type='proc'>" << endl;
167  _out << " <name>" << name << "</name>" << endl;
168  _out << " <state>" << _nodeStateName[node->getState()] << "</state>" << endl;
169 
170  _out << " </node>" << endl;
171 }

References _nodeStateName, _out, YACS::ENGINE::Visitor::_root, DEBTRACE, YACS::ENGINE::ComposedNode::getChildName(), YACS::ENGINE::ComposedNode::getName(), and YACS::ENGINE::Node::getState().

◆ visitServerNode()

void VisitorSaveState::visitServerNode ( ServerNode node)
virtual

Implements YACS::ENGINE::Visitor.

Definition at line 313 of file VisitorSaveState.cxx.

314 {
315  visitElementaryNode(node);
316 }

References visitElementaryNode().

◆ visitServiceInlineNode()

void VisitorSaveState::visitServiceInlineNode ( ServiceInlineNode node)
virtual

Implements YACS::ENGINE::Visitor.

Definition at line 318 of file VisitorSaveState.cxx.

319 {
320  visitElementaryNode(node);
321 }

References visitElementaryNode().

◆ visitServiceNode()

void VisitorSaveState::visitServiceNode ( ServiceNode node)
virtual

Implements YACS::ENGINE::Visitor.

Definition at line 308 of file VisitorSaveState.cxx.

309 {
310  visitElementaryNode(node);
311 }

References visitElementaryNode().

◆ visitStudyInNode()

void VisitorSaveState::visitStudyInNode ( DataNode node)
virtual

Implements YACS::ENGINE::Visitor.

Definition at line 333 of file VisitorSaveState.cxx.

334 {
335  visitElementaryNode(node);
336 }

References visitElementaryNode().

◆ visitStudyOutNode()

void VisitorSaveState::visitStudyOutNode ( DataNode node)
virtual

Implements YACS::ENGINE::Visitor.

Definition at line 338 of file VisitorSaveState.cxx.

339 {
340  visitElementaryNode(node);
341 }

References visitElementaryNode().

◆ visitSwitch()

void VisitorSaveState::visitSwitch ( Switch node)
virtual

Implements YACS::ENGINE::Visitor.

Definition at line 278 of file VisitorSaveState.cxx.

279 {
280  node->ComposedNode::accept(this);
281  if (!_out) throw Exception("No file open for dump state");
282  string name = _root->getName();
283  if (static_cast<ComposedNode*>(node) != _root) name = _root->getChildName(node);
284  DEBTRACE("VisitorSaveState::visitSwitch ----------- " << name);
285  _out << " <node type='switch'>" << endl;
286  _out << " <name>" << name << "</name>" << endl;
287  _out << " <state>" << _nodeStateName[node->getState()] << "</state>" << endl;
288  InputPort * ip = node->edGetConditionPort();
289  if (ip->isEmpty())
290  throw Exception("condition in switch empty, case not handled yet...");
291  Any *val = static_cast<Any*>(ip->get());
292  int condition = val->getIntValue();
293  _out << " <condition>" << condition << "</condition>" << endl;
294 
295  _out << " </node>" << endl;
296 }
InputPort * edGetConditionPort()
Definition: Switch.hxx:115

References _nodeStateName, _out, YACS::ENGINE::Visitor::_root, DEBTRACE, YACS::ENGINE::Switch::edGetConditionPort(), YACS::ENGINE::InputPort::get(), YACS::ENGINE::ComposedNode::getChildName(), YACS::ENGINE::Any::getIntValue(), YACS::ENGINE::ComposedNode::getName(), YACS::ENGINE::Node::getState(), and YACS::ENGINE::InputPort::isEmpty().

◆ visitWhileLoop()

void VisitorSaveState::visitWhileLoop ( WhileLoop node)
virtual

Implements YACS::ENGINE::Visitor.

Definition at line 255 of file VisitorSaveState.cxx.

256 {
257  node->ComposedNode::accept(this);
258  if (!_out) throw Exception("No file open for dump state");
259  string name = _root->getName();
260  if (static_cast<ComposedNode*>(node) != _root) name = _root->getChildName(node);
261  DEBTRACE("VisitorSaveState::visitWhileLoop -------- " << name);
262  _out << " <node type='whileLoop'>" << endl;
263  _out << " <name>" << name << "</name>" << endl;
264  _out << " <state>" << _nodeStateName[node->getState()] << "</state>" << endl;
265  _out << " <nbdone>" << node->getNbOfTurns() << "</nbdone>" << endl;
266  InputPort * ip = node->edGetConditionPort();
267  if (ip->isEmpty())
268  throw Exception("condition in WhileLoop empty, case not handled yet...");
269  if ( ConditionInputPort* cip = dynamic_cast<ConditionInputPort*>(ip) )
270  {
271  bool condition = cip->getValue();
272  _out << " <condition>" << condition << "</condition>" << endl;
273  }
274 
275  _out << " </node>" << endl;
276 }
InputPort * edGetConditionPort()
Definition: WhileLoop.hxx:48

References _nodeStateName, _out, YACS::ENGINE::Visitor::_root, DEBTRACE, YACS::ENGINE::WhileLoop::edGetConditionPort(), YACS::ENGINE::ComposedNode::getChildName(), YACS::ENGINE::ComposedNode::getName(), YACS::ENGINE::Loop::getNbOfTurns(), YACS::ENGINE::Node::getState(), and YACS::ENGINE::InputPort::isEmpty().

Member Data Documentation

◆ _nodeStateName

◆ _out


The documentation for this class was generated from the following files: