Version: 8.3.0
YACS::ENGINE::VisitorSaveSchema Class Reference

Base class for all visitors that save a schema. More...

#include <VisitorSaveSchema.hxx>

Inheritance diagram for YACS::ENGINE::VisitorSaveSchema:
Collaboration diagram for YACS::ENGINE::VisitorSaveSchema:

Public Member Functions

 VisitorSaveSchema (ComposedNode *root)
 
virtual ~VisitorSaveSchema ()
 
void openFileSchema (std::string xmlDump) throw (Exception)
 
void closeFileSchema ()
 
virtual void visitBloc (Bloc *node)
 
virtual void visitElementaryNode (ElementaryNode *node)
 
virtual void visitForEachLoop (ForEachLoop *node)
 
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 Member Functions

virtual void writeProperties (Node *node)
 
virtual void dumpTypeCode (TypeCode *type, std::set< std::string > &typeNames, std::map< std::string, TypeCode * > &typeMap, int depth)
 
virtual void writeTypeCodes (Proc *proc)
 
virtual void writeContainers (Proc *proc)
 
virtual void writeComponentInstances (Proc *proc)
 
virtual void writeInputPorts (Node *node)
 
virtual void writeInputDataStreamPorts (Node *node)
 
virtual void writeOutputPorts (Node *node)
 
virtual void writeOutputDataStreamPorts (Node *node)
 
virtual void writeControls (ComposedNode *node)
 
virtual void writeSimpleDataLinks (ComposedNode *node)
 
virtual void writeSimpleStreamLinks (ComposedNode *node)
 
virtual void writeParameters (Proc *proc)
 
virtual void writeParametersNode (ComposedNode *proc, Node *node)
 
virtual void beginCase (Node *node)
 
virtual void endCase (Node *node)
 
std::set< Node * > getAllNodes (ComposedNode *node)
 
int depthNode (Node *node)
 
std::string indent (int val)
 
- 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)
 

Protected Attributes

std::ofstream _out
 
std::map< int, std::string > _nodeStateName
 
std::map< std::string,
Container * > 
_containerMap
 
std::map< ComponentInstance
*, std::string > 
_componentInstanceMap
 
ComposedNode_root
 
std::multimap< int, DataLinkInfo_mapOfDLtoCreate
 
std::multimap< int,
StreamLinkInfo
_mapOfSLtoCreate
 
- Protected Attributes inherited from YACS::ENGINE::Visitor
ComposedNode_root
 

Detailed Description

Base class for all visitors that save a schema.

Can be specialized in runtime.

Definition at line 59 of file VisitorSaveSchema.hxx.

Constructor & Destructor Documentation

VisitorSaveSchema::VisitorSaveSchema ( ComposedNode root)

Definition at line 61 of file VisitorSaveSchema.cxx.

61  : _root(root), Visitor(root)
62 {
63 }
VisitorSaveSchema::~VisitorSaveSchema ( )
virtual

Definition at line 65 of file VisitorSaveSchema.cxx.

References _out.

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

Member Function Documentation

void VisitorSaveSchema::beginCase ( Node node)
protectedvirtual
void VisitorSaveSchema::closeFileSchema ( )

Definition at line 85 of file VisitorSaveSchema.cxx.

References _out.

Referenced by main(), YACS::HMI::GenericGui::onExportSchema(), YACS::HMI::GenericGui::onExportSchemaAs(), YACS::ENGINE::SchemaSave::save(), YACS::ENGINE::SalomeProc::saveSchema(), and YACS::ENGINE::Proc::saveSchema().

86 {
87  if (!_out) throw Exception("No file open for save schema");
88  _out << "</proc>" << endl;
89  _out.close();
90 }
int VisitorSaveSchema::depthNode ( Node node)
protected
void VisitorSaveSchema::dumpTypeCode ( TypeCode type,
std::set< std::string > &  typeNames,
std::map< std::string, TypeCode * > &  typeMap,
int  depth 
)
protectedvirtual

Definition at line 532 of file VisitorSaveSchema.cxx.

References _out, YACS::ENGINE::Array, YACS::ENGINE::Bool, YACS::ENGINE::TypeCode::contentType(), YACS::ENGINE::Double, YACS::ENGINE::Visitor::getListOfBases(), CORBAEngineTest::i, YACS::ENGINE::TypeCodeObjref::id(), indent(), YACS::ENGINE::Int, YACS::ENGINE::TypeCode::kind(), YACS::ENGINE::TypeCodeStruct::memberCount(), YACS::ENGINE::TypeCodeStruct::memberName(), YACS::ENGINE::TypeCodeStruct::memberType(), YACS::ENGINE::TypeCode::name(), YACS::ENGINE::Objref, YACS::ENGINE::Sequence, YACS::ENGINE::String, YACS::ENGINE::Struct, and YASSERT.

Referenced by writeTypeCodes().

533 {
534  DynType kind = type->kind();
535  string typeName = type->name();
536  if (typeNames.find(typeName) != typeNames.end())
537  return;
538  switch(kind)
539  {
541  {
542  typeNames.insert(typeName);
543  _out << indent(depth) << "<type name=\"" << typeName << "\" kind=\"double\"/>" << endl;
544  break;
545  }
546  case YACS::ENGINE::Int:
547  {
548  typeNames.insert(typeName);
549  _out << indent(depth) << "<type name=\"" << typeName << "\" kind=\"int\"/>" << endl;
550  break;
551  }
553  {
554  typeNames.insert(typeName);
555  _out << indent(depth) << "<type name=\"" << typeName << "\" kind=\"string\"/>" << endl;
556  break;
557  }
558  case YACS::ENGINE::Bool:
559  {
560  typeNames.insert(typeName);
561  _out << indent(depth) << "<type name=\"" << typeName << "\" kind=\"bool\"/>" << endl;
562  break;
563  }
565  {
566  TypeCodeObjref *objref = dynamic_cast<TypeCodeObjref*>(type);
567  std::list<TypeCodeObjref*> listOfBases = getListOfBases(objref);
568  //try to dump base classes
569  for(std::list<TypeCodeObjref*>::iterator il=listOfBases.begin(); il != listOfBases.end(); ++il)
570  {
571  if (typeNames.find((*il)->name()) == typeNames.end())
572  dumpTypeCode((*il),typeNames,typeMap,depth);
573  }
574  //effective dump
575  typeNames.insert(typeName);
576  _out << indent(depth) << "<objref name=\"" << typeName << "\" id=\""
577  << objref->id() << "\"";
578  if (listOfBases.empty())
579  _out << "/>" << endl;
580  else
581  {
582  _out << ">" << endl;
583  for(std::list<TypeCodeObjref*>::iterator il=listOfBases.begin(); il != listOfBases.end(); ++il)
584  {
585  _out << indent(depth+1) << "<base>";
586  _out << (*il)->name();
587  _out << "</base>" << endl;
588  }
589  _out << indent(depth) << "</objref>" << endl;
590  }
591  break;
592  }
594  {
595  TypeCode* content = (TypeCode*)type->contentType();
596  if (typeNames.find(content->name()) == typeNames.end())
597  {
598  //content type not dumped
599  dumpTypeCode(content,typeNames,typeMap,depth);
600  }
601  typeNames.insert(typeName);
602  _out << indent(depth) << "<sequence name=\"" << typeName << "\" content=\""
603  << content->name() << "\"/>" << endl;
604  break;
605  }
606  case YACS::ENGINE::Array:
607  {
608  TypeCode* content = (TypeCode*)type->contentType();
609  if (typeNames.find(content->name()) == typeNames.end())
610  {
611  //content type not dumped
612  dumpTypeCode(content,typeNames,typeMap,depth);
613  }
614  typeNames.insert(typeName);
615  _out << indent(depth) << "<array name=\"" << typeName << "\" content=\""
616  << content->name() << "\"/>" << endl;
617  break;
618  }
620  {
621  TypeCodeStruct* tcStruct = dynamic_cast<TypeCodeStruct*>(type);
622  YASSERT(tcStruct);
623  int mbCnt = tcStruct->memberCount();
624  for (int i=0; i<mbCnt; i++)
625  {
626  TypeCode* member = tcStruct->memberType(i);
627  if (typeNames.find(member->name()) == typeNames.end())
628  {
629  //content type not dumped
630  dumpTypeCode(member,typeNames,typeMap,depth);
631  }
632  }
633  typeNames.insert(typeName);
634  _out << indent(depth) << "<struct name=\"" << typeName << "\">" << endl;
635  for (int i=0; i<mbCnt; i++)
636  {
637  TypeCode* member = tcStruct->memberType(i);
638  _out << indent(depth+1) << "<member name=\"" <<tcStruct->memberName(i) << "\" type=\"" << member->name() << "\"/>" << endl;
639  }
640  _out << indent(depth) << "</struct>" << endl;
641  break;
642  }
643  default:
644  {
645  string what = "wrong TypeCode: ";
646  throw Exception(what);
647  }
648  }
649 }
std::set< Node * > VisitorSaveSchema::getAllNodes ( ComposedNode node)
protected

Definition at line 1046 of file VisitorSaveSchema.cxx.

References YACS::ENGINE::ComposedNode::edGetDirectDescendants(), and PMMLBasicsTestLauncher::ret.

Referenced by writeParameters(), and YACS::HMI::VisitorSaveGuiSchema::writePresentation().

1047 {
1048  set<Node *> ret;
1049  list< Node *> setOfNode = node->edGetDirectDescendants();
1050  for(list<Node *>::iterator iter=setOfNode.begin();iter!=setOfNode.end();iter++)
1051  {
1052  if ( dynamic_cast<ComposedNode*> (*iter) )
1053  {
1054  set<Node *> myCurrentSet = getAllNodes(dynamic_cast<ComposedNode*> (*iter));
1055  ret.insert(myCurrentSet.begin(),myCurrentSet.end());
1056  ret.insert(*iter);
1057  }
1058  else
1059  {
1060  list<ElementaryNode *> myCurrentSet=(*iter)->getRecursiveConstituents();
1061  ret.insert(myCurrentSet.begin(),myCurrentSet.end());
1062  ret.insert(*iter);
1063  }
1064  }
1065  return ret;
1066 }
void VisitorSaveSchema::openFileSchema ( std::string  xmlDump) throw (Exception)

Definition at line 74 of file VisitorSaveSchema.cxx.

Referenced by main(), YACS::HMI::GenericGui::onExportSchema(), YACS::HMI::GenericGui::onExportSchemaAs(), YACS::ENGINE::SchemaSave::save(), YACS::ENGINE::SalomeProc::saveSchema(), and YACS::ENGINE::Proc::saveSchema().

75 {
76  _out.open(xmlSchema.c_str(), ios::out);
77  if (!_out)
78  {
79  string what = "Impossible to open file for writing: " + xmlSchema;
80  throw Exception(what);
81  }
82  _out << "<?xml version='1.0' encoding='iso-8859-1' ?>" << endl;
83 }
void VisitorSaveSchema::visitBloc ( Bloc node)
virtual

Implements YACS::ENGINE::Visitor.

Definition at line 92 of file VisitorSaveSchema.cxx.

References _out, _root, beginCase(), DEBTRACE, depthNode(), YACS::DISABLED, endCase(), YACS::ENGINE::ComposedNode::getChildName(), YACS::ENGINE::ComposedNode::getName(), YACS::ENGINE::Node::getState(), indent(), writeControls(), writeProperties(), writeSimpleDataLinks(), and writeSimpleStreamLinks().

93 {
94  DEBTRACE("START visitBloc " << _root->getChildName(node));
95  beginCase(node);
96  int depth = depthNode(node);
97  _out << indent(depth) << "<bloc name=\"" << node->getName() << "\"";
98  if (node->getState() == YACS::DISABLED)
99  _out << " state=\"disabled\">" << endl;
100  else
101  _out << ">" << endl;
102  writeProperties(node);
103  node->ComposedNode::accept(this);
104  writeControls(node);
105  writeSimpleDataLinks(node);
107  _out << indent(depth) << "</bloc>" << endl;
108  endCase(node);
109  DEBTRACE("END visitBloc " << _root->getChildName(node));
110 }
void VisitorSaveSchema::visitDynParaLoop ( DynParaLoop node)
virtual

Implements YACS::ENGINE::Visitor.

Definition at line 175 of file VisitorSaveSchema.cxx.

References _out, _root, YACS::ENGINE::Node::accept(), DEBTRACE, depthNode(), YACS::ENGINE::ComposedNode::getChildName(), YACS::ENGINE::DynParaLoop::getExecNode(), YACS::ENGINE::DynParaLoop::getFinalizeNode(), YACS::ENGINE::DynParaLoop::getInitNode(), and indent().

176 {
177  DEBTRACE("START visitDynParaLoop " << _root->getChildName(node));
178  int depth = depthNode(node);
179  if (node->getInitNode() != NULL)
180  {
181  _out << indent(depth+1) << "<initnode>" << endl;
182  node->getInitNode()->accept(this);
183  _out << indent(depth+1) << "</initnode>" << endl;
184  }
185  if (node->getExecNode() != NULL)
186  {
187  node->getExecNode()->accept(this);
188  }
189  if (node->getFinalizeNode() != NULL)
190  {
191  _out << indent(depth+1) << "<finalizenode>" << endl;
192  node->getFinalizeNode()->accept(this);
193  _out << indent(depth+1) << "</finalizenode>" << endl;
194  }
195  DEBTRACE("END visitDynParaLoop " << _root->getChildName(node));
196 }
void VisitorSaveSchema::visitElementaryNode ( ElementaryNode node)
virtual

Implements YACS::ENGINE::Visitor.

Definition at line 112 of file VisitorSaveSchema.cxx.

References _root, beginCase(), DEBTRACE, endCase(), YACS::ENGINE::ComposedNode::getChildName(), writeInputDataStreamPorts(), writeInputPorts(), writeOutputDataStreamPorts(), writeOutputPorts(), and writeProperties().

113 {
114  DEBTRACE("START visitElementaryNode " << _root->getChildName(node));
115  beginCase(node);
116  writeProperties(node);
117  writeInputPorts(node);
119  writeOutputPorts(node);
121  endCase(node);
122  DEBTRACE("END visitElementaryNode " << _root->getChildName(node));
123 }
void VisitorSaveSchema::visitForEachLoop ( ForEachLoop node)
virtual

Implements YACS::ENGINE::Visitor.

Definition at line 125 of file VisitorSaveSchema.cxx.

References _out, _root, beginCase(), DEBTRACE, depthNode(), YACS::DISABLED, YACS::ENGINE::DynParaLoop::edGetNbOfBranchesPort(), YACS::ENGINE::DynParaLoop::edGetSamplePort(), YACS::ENGINE::DataPort::edGetType(), endCase(), YACS::ENGINE::ComposedNode::getChildName(), YACS::ENGINE::AnyInputPort::getIntValue(), YACS::ENGINE::ComposedNode::getName(), YACS::ENGINE::Node::getState(), indent(), YACS::ENGINE::AnyInputPort::isEmpty(), YACS::ENGINE::TypeCode::name(), writeProperties(), writeSimpleDataLinks(), and writeSimpleStreamLinks().

126 {
127  DEBTRACE("START visitForEachLoop " << _root->getChildName(node));
128  beginCase(node);
129  int depth = depthNode(node);
130 
131  _out << indent(depth) << "<foreach name=\"" << node->getName() << "\"";
132  AnyInputPort *nbranch = static_cast<AnyInputPort*>(node->edGetNbOfBranchesPort());
133  if (node->getState() == YACS::DISABLED)
134  _out << " state=\"disabled\"";
135  if (!nbranch->isEmpty())
136  _out << " nbranch=\"" << nbranch->getIntValue() << "\"";
137  if (node->edGetSamplePort())
138  _out << " type=\"" << node->edGetSamplePort()->edGetType()->name() << "\"";
139  _out << ">" << endl;
140 
141  writeProperties(node);
142  node->DynParaLoop::accept(this);
143  writeSimpleDataLinks(node);
145  _out << indent(depth) << "</foreach>" << endl;
146  endCase(node);
147  DEBTRACE("END visitForEachLoop " << _root->getChildName(node));
148 }
void VisitorSaveSchema::visitForLoop ( ForLoop node)
virtual

Implements YACS::ENGINE::Visitor.

Definition at line 198 of file VisitorSaveSchema.cxx.

References _out, _root, beginCase(), DEBTRACE, depthNode(), YACS::DISABLED, YACS::ENGINE::ForLoop::edGetNbOfTimesInputPort(), endCase(), YACS::ENGINE::ComposedNode::getChildName(), YACS::ENGINE::AnyInputPort::getIntValue(), YACS::ENGINE::ComposedNode::getName(), YACS::ENGINE::Node::getState(), indent(), YACS::ENGINE::AnyInputPort::isEmpty(), writeProperties(), writeSimpleDataLinks(), and writeSimpleStreamLinks().

199 {
200  DEBTRACE("START visitForLoop " << _root->getChildName(node));
201  beginCase(node);
202  int depth = depthNode(node);
203  AnyInputPort *nsteps = static_cast<AnyInputPort*>(node->edGetNbOfTimesInputPort());
204  _out << indent(depth) << "<forloop name=\"" << node->getName() << "\"";
205  if (node->getState() == YACS::DISABLED)
206  _out << " state=\"disabled\"";
207  if (nsteps->isEmpty())
208  _out << ">" << endl;
209  else
210  _out << " nsteps=\"" << nsteps->getIntValue() << "\">" << endl;
211  writeProperties(node);
212  node->ComposedNode::accept(this);
213  writeSimpleDataLinks(node);
215  _out << indent(depth) << "</forloop>" << endl;
216  endCase(node);
217  DEBTRACE("END visitForLoop " << _root->getChildName(node));
218 }
void VisitorSaveSchema::visitInlineFuncNode ( InlineFuncNode node)
virtual

Implements YACS::ENGINE::Visitor.

Definition at line 257 of file VisitorSaveSchema.cxx.

References _out, _root, beginCase(), DEBTRACE, depthNode(), YACS::DISABLED, endCase(), YACS::ENGINE::ComposedNode::getChildName(), YACS::ENGINE::InlineNode::getContainer(), YACS::ENGINE::InlineNode::getExecutionMode(), YACS::ENGINE::InlineFuncNode::getFname(), YACS::ENGINE::Container::getName(), YACS::ENGINE::Node::getName(), YACS::ENGINE::InlineNode::getScript(), YACS::ENGINE::ElementaryNode::getState(), indent(), YACS::ENGINE::InlineNode::LOCAL_STR, writeInputDataStreamPorts(), writeInputPorts(), writeOutputDataStreamPorts(), writeOutputPorts(), and writeProperties().

258 {
259  DEBTRACE("START visitInlineFuncNode " << _root->getChildName(node));
260  beginCase(node);
261  int depth = depthNode(node);
263  _out << indent(depth) << "<inline name=\"" << node->getName() << "\"";
264  else
265  _out << indent(depth) << "<remote name=\"" << node->getName() << "\"";
266  if (node->getState() == YACS::DISABLED)
267  _out << " state=\"disabled\">" << endl;
268  else
269  _out << ">" << endl;
270  _out << indent(depth+1) << "<function name=\"" << node->getFname() << "\">" << endl;
271  _out << indent(depth+2) << "<code><![CDATA[";
272  _out << node->getScript();
273  _out << "]]></code>" << endl;
274  _out << indent(depth+1) << "</function>" << endl;
275 
276  //add load container if node is remote
277  Container *cont = node->getContainer();
278  if (cont)
279  _out << indent(depth+1) << "<load container=\"" << cont->getName() << "\"/>" << endl;
280 
281  writeProperties(node);
282  writeInputPorts(node);
284  writeOutputPorts(node);
286 
288  _out << indent(depth) << "</inline>" << endl;
289  else
290  _out << indent(depth) << "</remote>" << endl;
291 
292  endCase(node);
293  DEBTRACE("END visitInlineFuncNode " << _root->getChildName(node));
294 }
void VisitorSaveSchema::visitInlineNode ( InlineNode node)
virtual

Implements YACS::ENGINE::Visitor.

Definition at line 220 of file VisitorSaveSchema.cxx.

References _out, _root, beginCase(), DEBTRACE, depthNode(), YACS::DISABLED, endCase(), YACS::ENGINE::ComposedNode::getChildName(), YACS::ENGINE::InlineNode::getContainer(), YACS::ENGINE::InlineNode::getExecutionMode(), YACS::ENGINE::Container::getName(), YACS::ENGINE::Node::getName(), YACS::ENGINE::InlineNode::getScript(), YACS::ENGINE::ElementaryNode::getState(), indent(), YACS::ENGINE::InlineNode::LOCAL_STR, writeInputDataStreamPorts(), writeInputPorts(), writeOutputDataStreamPorts(), writeOutputPorts(), and writeProperties().

221 {
222  DEBTRACE("START visitInlineNode " << _root->getChildName(node));
223  beginCase(node);
224  int depth = depthNode(node);
226  _out << indent(depth) << "<inline name=\"" << node->getName() << "\"";
227  else
228  _out << indent(depth) << "<remote name=\"" << node->getName() << "\"";
229  if (node->getState() == YACS::DISABLED)
230  _out << " state=\"disabled\">" << endl;
231  else
232  _out << ">" << endl;
233  _out << indent(depth+1) << "<script><code><![CDATA[";
234  _out << node->getScript();
235  _out << "]]></code></script>" << endl;
236 
237  //add load container if node is remote
238  Container *cont = node->getContainer();
239  if (cont)
240  _out << indent(depth+1) << "<load container=\"" << cont->getName() << "\"/>" << endl;
241 
242  writeProperties(node);
243  writeInputPorts(node);
245  writeOutputPorts(node);
247 
249  _out << indent(depth) << "</inline>" << endl;
250  else
251  _out << indent(depth) << "</remote>" << endl;
252 
253  endCase(node);
254  DEBTRACE("END visitInlineNode " << _root->getChildName(node));
255 }
void VisitorSaveSchema::visitLoop ( Loop node)
virtual

Implements YACS::ENGINE::Visitor.

Definition at line 296 of file VisitorSaveSchema.cxx.

References _root, beginCase(), DEBTRACE, depthNode(), endCase(), YACS::ENGINE::ComposedNode::getChildName(), writeControls(), writeProperties(), writeSimpleDataLinks(), and writeSimpleStreamLinks().

297 {
298  DEBTRACE("START visitLoop " << _root->getChildName(node));
299  beginCase(node);
300  int depth = depthNode(node);
301  writeProperties(node);
302  node->ComposedNode::accept(this);
303  writeControls(node);
304  writeSimpleDataLinks(node);
306  endCase(node);
307  DEBTRACE("END visitLoop " << _root->getChildName(node));
308 }
void VisitorSaveSchema::visitOptimizerLoop ( OptimizerLoop node)
virtual

Implements YACS::ENGINE::Visitor.

Definition at line 150 of file VisitorSaveSchema.cxx.

References _out, _root, beginCase(), DEBTRACE, depthNode(), YACS::DISABLED, YACS::ENGINE::DynParaLoop::edGetNbOfBranchesPort(), endCase(), YACS::ENGINE::OptimizerLoop::getAlgLib(), YACS::ENGINE::ComposedNode::getChildName(), YACS::ENGINE::AnyInputPort::getIntValue(), YACS::ENGINE::ComposedNode::getName(), YACS::ENGINE::Node::getState(), YACS::ENGINE::OptimizerLoop::getSymbol(), indent(), YACS::ENGINE::AnyInputPort::isEmpty(), writeProperties(), writeSimpleDataLinks(), and writeSimpleStreamLinks().

151 {
152  DEBTRACE("START visitOptimizerLoop " << _root->getChildName(node));
153  beginCase(node);
154  int depth = depthNode(node);
155 
156  _out << indent(depth) << "<optimizer name=\"" << node->getName() << "\"";
157  AnyInputPort *nbranch = static_cast<AnyInputPort*>(node->edGetNbOfBranchesPort());
158  if (node->getState() == YACS::DISABLED)
159  _out << " state=\"disabled\"";
160  if (!nbranch->isEmpty())
161  _out << " nbranch=\"" << nbranch->getIntValue() << "\"";
162  _out << " lib=\"" << node->getAlgLib() << "\"";
163  _out << " entry=\"" << node->getSymbol() << "\"";
164  _out << ">" << endl;
165 
166  writeProperties(node);
167  node->DynParaLoop::accept(this);
168  writeSimpleDataLinks(node);
170  _out << indent(depth) << "</optimizer>" << endl;
171  endCase(node);
172  DEBTRACE("END visitOptimizerLoop " << _root->getChildName(node));
173 }
void VisitorSaveSchema::visitOutNode ( DataNode node)
virtual

Implements YACS::ENGINE::Visitor.

Reimplemented in YACS::ENGINE::VisitorSaveSalomeSchema.

Definition at line 458 of file VisitorSaveSchema.cxx.

References _root, DEBTRACE, and YACS::ENGINE::ComposedNode::getChildName().

459 {
460  DEBTRACE("START visitOutNode " << _root->getChildName(node));
461  DEBTRACE("END visitOutNode " << _root->getChildName(node));
462 }
void VisitorSaveSchema::visitPresetNode ( DataNode node)
virtual

Implements YACS::ENGINE::Visitor.

Reimplemented in YACS::ENGINE::VisitorSaveSalomeSchema.

Definition at line 452 of file VisitorSaveSchema.cxx.

References _root, DEBTRACE, and YACS::ENGINE::ComposedNode::getChildName().

453 {
454  DEBTRACE("START visitPresetNode " << _root->getChildName(node));
455  DEBTRACE("END visitPresetNode " << _root->getChildName(node));
456 }
void VisitorSaveSchema::visitProc ( Proc node)
virtual

Implements YACS::ENGINE::Visitor.

Definition at line 310 of file VisitorSaveSchema.cxx.

References _out, beginCase(), DEBTRACE, endCase(), YACS::ENGINE::ComposedNode::getName(), writeComponentInstances(), writeContainers(), writeControls(), writeParameters(), writeProperties(), writeSimpleDataLinks(), writeSimpleStreamLinks(), and writeTypeCodes().

311 {
312  DEBTRACE("START visitProc " << node->getName());
313  _out << "<proc name=\""<< node->getName() << "\">" << endl;
314  beginCase(node);
315  writeProperties(node);
316  writeTypeCodes(node);
317  writeContainers(node);
319  node->ComposedNode::accept(this);
320  writeControls(node);
321  writeSimpleDataLinks(node);
323  writeParameters(node);
324  endCase(node);
325  DEBTRACE("END visitProc " << node->getName());
326 }
void VisitorSaveSchema::visitServerNode ( ServerNode node)
virtual

Implements YACS::ENGINE::Visitor.

Definition at line 387 of file VisitorSaveSchema.cxx.

References _containerMap, _out, _root, beginCase(), DEBTRACE, depthNode(), YACS::DISABLED, endCase(), YACS::ENGINE::ComposedNode::getChildName(), YACS::ENGINE::InlineNode::getContainer(), YACS::ENGINE::InlineFuncNode::getFname(), YACS::ENGINE::Node::getName(), YACS::ENGINE::InlineNode::getScript(), YACS::ENGINE::ElementaryNode::getState(), indent(), writeInputDataStreamPorts(), writeInputPorts(), writeOutputDataStreamPorts(), writeOutputPorts(), and writeProperties().

388 {
389  DEBTRACE("START visitServerNode " << _root->getChildName(node));
390  beginCase(node);
391  int depth = depthNode(node);
392  _out << indent(depth) << "<server name=\"" << node->getName() << "\"";
393  if (node->getState() == YACS::DISABLED)
394  _out << " state=\"disabled\">" << endl;
395  else
396  _out << ">" << endl;
397  Container *cont = node->getContainer();
398  map<string, Container*>::const_iterator it;
399  for (it = _containerMap.begin(); it != _containerMap.end(); ++it)
400  {
401  if (it->second == cont) break;
402  }
403  if (it != _containerMap.end())
404  _out << indent(depth+1) << "<loadcontainer>" << it->first << "</loadcontainer>" << endl;
405  /*else
406  {
407  _out << indent(depth+1) << "<node>" << _contnentInstanceMap[cont] << "</node>" << endl;
408  }*/
409  _out << indent(depth+1) << "<method>" << node->getFname() << "</method>" << endl;
410  _out << indent(depth+2) << "<script><code><![CDATA[";
411  _out << node->getScript();
412  _out << "]]></code></script>" << endl;
413  //_out << indent(depth+1) << "</function>" << endl;
414  writeProperties(node);
415  writeInputPorts(node);
417  writeOutputPorts(node);
419  _out << indent(depth) << "</server>" << endl;
420  endCase(node);
421  DEBTRACE("END visitServerNode " << _root->getChildName(node));
422 }
void VisitorSaveSchema::visitServiceInlineNode ( ServiceInlineNode node)
virtual

Implements YACS::ENGINE::Visitor.

Definition at line 424 of file VisitorSaveSchema.cxx.

References _out, _root, beginCase(), DEBTRACE, depthNode(), YACS::DISABLED, endCase(), YACS::ENGINE::ComposedNode::getChildName(), YACS::ENGINE::ServiceNode::getComponent(), YACS::ENGINE::ComponentInstance::getFileRepr(), YACS::ENGINE::ServiceNode::getMethod(), YACS::ENGINE::Node::getName(), YACS::ENGINE::ServiceInlineNode::getScript(), YACS::ENGINE::ElementaryNode::getState(), indent(), writeInputPorts(), writeOutputPorts(), and writeProperties().

425 {
426  DEBTRACE("START visitServiceInlineNode " << _root->getChildName(node));
427  beginCase(node);
428  int depth = depthNode(node);
429  _out << indent(depth) << "<serviceInline name=\"" << node->getName() << "\"";
430  if (node->getState() == YACS::DISABLED)
431  _out << " state=\"disabled\">" << endl;
432  else
433  _out << ">" << endl;
434 
435  ComponentInstance *compo = node->getComponent();
436  if (compo)
437  _out << indent(depth+1) << compo->getFileRepr() << endl;
438 
439  _out << indent(depth+1) << "<function name=\"" << node->getMethod() << "\">" << endl;
440  _out << indent(depth+2) << "<code><![CDATA[";
441  _out << node->getScript();
442  _out << "]]></code>" << endl;
443  _out << indent(depth+1) << "</function>" << endl;
444  writeProperties(node);
445  writeInputPorts(node);
446  writeOutputPorts(node);
447  _out << indent(depth) << "</serviceInline>" << endl;
448  endCase(node);
449  DEBTRACE("END visitServiceInlineNode " << _root->getChildName(node));
450 }
void VisitorSaveSchema::visitServiceNode ( ServiceNode node)
virtual

Implements YACS::ENGINE::Visitor.

Definition at line 328 of file VisitorSaveSchema.cxx.

References _componentInstanceMap, _containerMap, _out, _root, beginCase(), DEBTRACE, depthNode(), YACS::DISABLED, endCase(), YACS::ENGINE::ComposedNode::getChildName(), YACS::ENGINE::ServiceNode::getComponent(), YACS::ENGINE::ComponentInstance::getContainer(), YACS::ENGINE::ComponentInstance::getFileRepr(), YACS::ENGINE::ComponentInstance::getInstanceName(), YACS::ENGINE::ServiceNode::getKind(), YACS::ENGINE::ServiceNode::getMethod(), YACS::ENGINE::Node::getName(), YACS::ENGINE::ServiceNode::getRef(), YACS::ENGINE::ElementaryNode::getState(), indent(), YACS::ENGINE::ComponentInstance::isAnonymous(), writeInputDataStreamPorts(), writeInputPorts(), writeOutputDataStreamPorts(), writeOutputPorts(), and writeProperties().

329 {
330  DEBTRACE("START visitServiceNode " << _root->getChildName(node));
331  beginCase(node);
332  int depth = depthNode(node);
333  _out << indent(depth) << "<service name=\"" << node->getName() << "\"";
334  if (node->getState() == YACS::DISABLED)
335  _out << " state=\"disabled\">" << endl;
336  else
337  _out << ">" << endl;
338  if (node->getKind() == "xmlsh")
339  {
340  _out << indent(depth+1) << "<kind>xmlsh</kind>" << endl;
341  _out << indent(depth+1) << "<ref>" << node->getRef() << "</ref>" << endl;
342  }
343  else
344  {
345  ComponentInstance *compo = node->getComponent();
346  if (compo && !compo->isAnonymous())
347  {
348  _out << indent(depth+1) << "<componentinstance>" << compo->getInstanceName() << "</componentinstance>" << endl;
349  }
350  else if (compo && (_componentInstanceMap.find(compo) == _componentInstanceMap.end()))
351  {
352  _out << indent(depth+1) << compo->getFileRepr() << endl;
353  _componentInstanceMap[compo] = _root->getChildName(node);
354  Container *cont = compo->getContainer();
355  if (cont)
356  {
357  map<string, Container*>::const_iterator it;
358  for (it = _containerMap.begin(); it != _containerMap.end(); ++it)
359  {
360  if (it->second == cont) break;
361  }
362  if (it != _containerMap.end())
363  _out << indent(depth+1) << "<load container=\"" << it->first << "\"/>" << endl;
364  }
365  }
366  else if(compo)
367  {
368  _out << indent(depth+1) << "<node>" << _componentInstanceMap[compo] << "</node>" << endl;
369  }
370  else
371  {
372  _out << indent(depth+1) << "<component>" << "UNKNOWN" << "</component>" << endl;
373  }
374  }
375  _out << indent(depth+1) << "<method>" << node->getMethod() << "</method>" << endl;
376 
377  writeProperties(node);
378  writeInputPorts(node);
380  writeOutputPorts(node);
382  _out << indent(depth) << "</service>" << endl;
383  endCase(node);
384  DEBTRACE("END visitServiceNode " << _root->getChildName(node));
385 }
void VisitorSaveSchema::visitStudyInNode ( DataNode node)
virtual

Implements YACS::ENGINE::Visitor.

Reimplemented in YACS::ENGINE::VisitorSaveSalomeSchema.

Definition at line 464 of file VisitorSaveSchema.cxx.

References _root, DEBTRACE, and YACS::ENGINE::ComposedNode::getChildName().

465 {
466  DEBTRACE("START visitStudyInNode " << _root->getChildName(node));
467  DEBTRACE("END visitStudyInNode " << _root->getChildName(node));
468 }
void VisitorSaveSchema::visitStudyOutNode ( DataNode node)
virtual

Implements YACS::ENGINE::Visitor.

Reimplemented in YACS::ENGINE::VisitorSaveSalomeSchema.

Definition at line 470 of file VisitorSaveSchema.cxx.

References _root, DEBTRACE, and YACS::ENGINE::ComposedNode::getChildName().

471 {
472  DEBTRACE("START visitStudyOutNode " << _root->getChildName(node));
473  DEBTRACE("END visitStudyOutNode " << _root->getChildName(node));
474 }
void VisitorSaveSchema::visitSwitch ( Switch node)
virtual

Implements YACS::ENGINE::Visitor.

Definition at line 477 of file VisitorSaveSchema.cxx.

References _out, _root, beginCase(), DEBTRACE, depthNode(), YACS::DISABLED, YACS::ENGINE::Switch::edGetConditionPort(), endCase(), YACS::ENGINE::ComposedNode::getChildName(), YACS::ENGINE::AnyInputPort::getIntValue(), YACS::ENGINE::ComposedNode::getName(), YACS::ENGINE::Node::getState(), indent(), YACS::ENGINE::AnyInputPort::isEmpty(), writeControls(), writeProperties(), writeSimpleDataLinks(), and writeSimpleStreamLinks().

478 {
479  DEBTRACE("START visitSwitch " << _root->getChildName(node));
480  beginCase(node);
481  int depth = depthNode(node);
482  AnyInputPort *condition = static_cast<AnyInputPort*>(node->edGetConditionPort());
483  _out << indent(depth) << "<switch name=\"" << node->getName() << "\"";
484  if (node->getState() == YACS::DISABLED)
485  _out << " state=\"disabled\"";
486  if (condition->isEmpty())
487  _out << ">" << endl;
488  else
489  _out << " select=\"" << condition->getIntValue() << "\">" << endl;
490  writeProperties(node);
491  node->ComposedNode::accept(this);
492  writeControls(node);
493  writeSimpleDataLinks(node);
495  _out << indent(depth) << "</switch>" << endl;
496  endCase(node);
497  DEBTRACE("END visitSwitch " << _root->getChildName(node));
498 }
void VisitorSaveSchema::visitWhileLoop ( WhileLoop node)
virtual

Implements YACS::ENGINE::Visitor.

Definition at line 500 of file VisitorSaveSchema.cxx.

References _out, _root, beginCase(), DEBTRACE, depthNode(), YACS::DISABLED, endCase(), YACS::ENGINE::ComposedNode::getChildName(), YACS::ENGINE::ComposedNode::getName(), YACS::ENGINE::Node::getState(), indent(), writeProperties(), writeSimpleDataLinks(), and writeSimpleStreamLinks().

501 {
502  DEBTRACE("START visitWhileLoop " << _root->getChildName(node));
503  beginCase(node);
504  int depth = depthNode(node);
505  _out << indent(depth) << "<while name=\"" << node->getName() << "\"";
506  if (node->getState() == YACS::DISABLED)
507  _out << " state=\"disabled\">" << endl;
508  else
509  _out << ">" << endl;
510  writeProperties(node);
511  node->ComposedNode::accept(this);
512  writeSimpleDataLinks(node);
514  _out << indent(depth) << "</while>" << endl;
515  endCase(node);
516  DEBTRACE("END visitWhileLoop " << _root->getChildName(node));
517 }
void VisitorSaveSchema::writeComponentInstances ( Proc proc)
protectedvirtual

Definition at line 666 of file VisitorSaveSchema.cxx.

References _out, YACS::ENGINE::Proc::componentInstanceMap, depthNode(), YACS::ENGINE::ComponentInstance::getCompoName(), YACS::ENGINE::ComponentInstance::getContainer(), YACS::ENGINE::ComponentInstance::getInstanceName(), YACS::ENGINE::Container::getName(), YACS::ENGINE::PropertyInterface::getProperties(), indent(), and YACS::ENGINE::ComponentInstance::isAnonymous().

Referenced by visitProc().

667 {
668  int depth = depthNode(proc)+1;
669  std::map<std::string, ComponentInstance*>::const_iterator it;
670  for (it = proc->componentInstanceMap.begin(); it != proc->componentInstanceMap.end(); it++)
671  {
672  string name = it->first;
673  ComponentInstance* inst=it->second;
674  if(!inst->isAnonymous())
675  {
676  _out << indent(depth) << "<componentinstance name=\"" << inst->getInstanceName() << "\">" << endl;
677  _out << indent(depth+1) << "<component>" << inst->getCompoName() << "</component>" << endl;
678 
679  Container *cont = inst->getContainer();
680  if (cont)
681  _out << indent(depth+1) << "<load container=\"" << cont->getName() << "\"/>" << endl;
682 
683  std::map<std::string, std::string> properties = inst->getProperties();
684  std::map<std::string, std::string>::const_iterator itm;
685  for(itm = properties.begin(); itm != properties.end(); ++itm)
686  _out << indent(depth+1) << "<property name=\"" << (*itm).first
687  << "\" value=\"" << (*itm).second << "\"/>" << endl;
688 
689  _out << indent(depth) << "</componentinstance>" << endl;
690  }
691  }
692 }
void VisitorSaveSchema::writeContainers ( Proc proc)
protectedvirtual

Definition at line 694 of file VisitorSaveSchema.cxx.

References _containerMap, _out, YACS::ENGINE::Container::AOC_ENTRY, depthNode(), YACS::ENGINE::Visitor::getContainerMap(), indent(), YACS::ENGINE::HomogeneousPoolContainer::INITIALIZE_SCRIPT_KEY, and YACS::ENGINE::Container::KIND_ENTRY.

Referenced by visitProc().

695 {
696  int depth = depthNode(proc)+1;
698  map<string, Container*>::const_iterator it;
699  for (it = _containerMap.begin(); it != _containerMap.end(); it++)
700  {
701  string name = it->first;
702  _out << indent(depth) << "<container name=\"" << name << "\">" << endl;
703  _out << indent(depth+1) << "<property name=\"" << Container::KIND_ENTRY << "\" value=\"" << it->second->getKind() << "\"/>" << endl;
704  _out << indent(depth+1) << "<property name=\"" << Container::AOC_ENTRY << "\" value=\"" << (int)it->second->isAttachedOnCloning() << "\"/>" << endl;
705  map<string, string> properties = (it->second)->getProperties();
706  map<string, string>::iterator itm;
707  for(itm = properties.begin(); itm != properties.end(); ++itm)
708  {
709  if((*itm).first==Container::KIND_ENTRY)
710  continue;
711  if((*itm).first==Container::AOC_ENTRY)
712  continue;
714  {
715  _out << indent(depth+1) << "<property name=\"" << (*itm).first << "\" value=\"" << (*itm).second << "\"/>" << endl;
716  }
717  else
718  {
719  _out << indent(depth+1) << "<initializescriptkey><code><![CDATA[" << (*itm).second << "]]></code></initializescriptkey>" << endl;
720  }
721  }
722  _out << indent(depth) << "</container>" << endl;
723  }
724 }
void VisitorSaveSchema::writeControls ( ComposedNode node)
protectedvirtual

Definition at line 793 of file VisitorSaveSchema.cxx.

References _out, depthNode(), YACS::ENGINE::ComposedNode::edGetDirectDescendants(), YACS::ENGINE::ComposedNode::getChildName(), YACS::ENGINE::Node::getFather(), YACS::ENGINE::Node::getNumId(), indent(), and YACS::ENGINE::ComposedNode::isInMyDescendance().

Referenced by visitBloc(), visitLoop(), visitProc(), and visitSwitch().

794 {
795  int depth = depthNode(node)+1;
796  list<Node*> setOfChildren = node->edGetDirectDescendants();
797  for (list<Node*>::iterator ic = setOfChildren.begin(); ic != setOfChildren.end(); ++ic)
798  {
799  // --- Control links from direct descendant to nodes inside the bloc
800  list<InGate*> setOfInGates = (*ic)->getOutGate()->edSetInGate();
801  for (list<InGate*>::iterator ig = setOfInGates.begin(); ig != setOfInGates.end(); ++ig)
802  {
803  Node *to = (*ig)->getNode();
804  if (node->isInMyDescendance(to))
805  {
806  Node *from = (*ic);
807  _out << indent(depth) << "<control> <fromnode>" << node->getChildName(from) << "</fromnode> ";
808  _out << "<tonode>" << node->getChildName(to) << "</tonode> </control>" << endl;
809  }
810  }
811  // --- Control links from nodes inside the bloc to direct descendant
812  // avoid links between direct descendants (already done above)
813  list<OutGate*> listOfOutGates = (*ic)->getInGate()->getBackLinks();
814  for (list<OutGate*>::iterator ig = listOfOutGates.begin(); ig != listOfOutGates.end(); ++ig)
815  {
816  Node *from = (*ig)->getNode();
817  if ((node->isInMyDescendance(from)) && (from->getFather()->getNumId() != node->getNumId()))
818  {
819  Node *to = *ic;
820  _out << indent(depth) << "<control> <fromnode>" << node->getChildName(from) << "</fromnode> ";
821  _out << "<tonode>" << node->getChildName(to) << "</tonode> </control>" << endl;
822  }
823  }
824  }
825 }
void VisitorSaveSchema::writeInputDataStreamPorts ( Node node)
protectedvirtual

Definition at line 738 of file VisitorSaveSchema.cxx.

References _out, depthNode(), YACS::ENGINE::Node::getSetOfInputDataStreamPort(), and indent().

Referenced by visitElementaryNode(), visitInlineFuncNode(), visitInlineNode(), visitServerNode(), and visitServiceNode().

739 {
740  int depth = depthNode(node)+1;
741  list<InputDataStreamPort*> listOfInputPorts = node->getSetOfInputDataStreamPort();
742  for (list<InputDataStreamPort*>::iterator it = listOfInputPorts.begin(); it != listOfInputPorts.end(); ++it)
743  {
744  std::map<std::string,std::string> aPropMap = (*it)->getProperties();
745  if ( aPropMap.empty() )
746  _out << indent(depth) << "<instream name=\"" << (*it)->getName() << "\" type=\""
747  << (*it)->edGetType()->name() << "\"/>" << endl;
748  else
749  {
750  _out << indent(depth) << "<instream name=\"" << (*it)->getName() << "\" type=\""
751  << (*it)->edGetType()->name() << "\">" << endl;
752  for (std::map<std::string,std::string>::iterator itP = aPropMap.begin(); itP != aPropMap.end(); itP++)
753  _out << indent(depth+1) << "<property name=\"" << (*itP).first << "\" value=\""
754  << (*itP).second << "\"/>" << endl;
755  _out << indent(depth) << "</instream>" << endl;
756  }
757  }
758 }
void VisitorSaveSchema::writeInputPorts ( Node node)
protectedvirtual

Definition at line 727 of file VisitorSaveSchema.cxx.

References _out, depthNode(), YACS::ENGINE::Node::getSetOfInputPort(), and indent().

Referenced by visitElementaryNode(), visitInlineFuncNode(), visitInlineNode(), visitServerNode(), visitServiceInlineNode(), and visitServiceNode().

728 {
729  int depth = depthNode(node)+1;
730  list<InputPort*> listOfInputPorts = node->getSetOfInputPort();
731  for (list<InputPort*>::iterator it = listOfInputPorts.begin(); it != listOfInputPorts.end(); ++it)
732  {
733  _out << indent(depth) << "<inport name=\"" << (*it)->getName() << "\" type=\""
734  << (*it)->edGetType()->name() << "\"/>" << endl;
735  }
736 }
void VisitorSaveSchema::writeOutputDataStreamPorts ( Node node)
protectedvirtual

Definition at line 771 of file VisitorSaveSchema.cxx.

References _out, depthNode(), YACS::ENGINE::Node::getSetOfOutputDataStreamPort(), and indent().

Referenced by visitElementaryNode(), visitInlineFuncNode(), visitInlineNode(), visitServerNode(), and visitServiceNode().

772 {
773  int depth = depthNode(node)+1;
774  list<OutputDataStreamPort*> listOfOutputPorts = node->getSetOfOutputDataStreamPort();
775  for (list<OutputDataStreamPort*>::iterator it = listOfOutputPorts.begin(); it != listOfOutputPorts.end(); ++it)
776  {
777  std::map<std::string,std::string> aPropMap = (*it)->getProperties();
778  if ( aPropMap.empty() )
779  _out << indent(depth) << "<outstream name=\"" << (*it)->getName() << "\" type=\""
780  << (*it)->edGetType()->name() << "\"/>" << endl;
781  else
782  {
783  _out << indent(depth) << "<outstream name=\"" << (*it)->getName() << "\" type=\""
784  << (*it)->edGetType()->name() << "\">" << endl;
785  for (std::map<std::string,std::string>::iterator itP = aPropMap.begin(); itP != aPropMap.end(); itP++)
786  _out << indent(depth+1) << "<property name=\"" << (*itP).first << "\" value=\""
787  << (*itP).second << "\"/>" << endl;
788  _out << indent(depth) << "</outstream>" << endl;
789  }
790  }
791 }
void VisitorSaveSchema::writeOutputPorts ( Node node)
protectedvirtual

Definition at line 760 of file VisitorSaveSchema.cxx.

References _out, depthNode(), YACS::ENGINE::Node::getSetOfOutputPort(), and indent().

Referenced by visitElementaryNode(), visitInlineFuncNode(), visitInlineNode(), visitServerNode(), visitServiceInlineNode(), and visitServiceNode().

761 {
762  int depth = depthNode(node)+1;
763  list<OutputPort*> listOfOutputPorts = node->getSetOfOutputPort();
764  for (list<OutputPort*>::iterator it = listOfOutputPorts.begin(); it != listOfOutputPorts.end(); ++it)
765  {
766  _out << indent(depth) << "<outport name=\"" << (*it)->getName() << "\" type=\""
767  << (*it)->edGetType()->name() << "\"/>" << endl;
768  }
769 }
void VisitorSaveSchema::writeParameters ( Proc proc)
protectedvirtual

Definition at line 1068 of file VisitorSaveSchema.cxx.

References getAllNodes(), and writeParametersNode().

Referenced by visitProc().

1069 {
1070  // set<Node*> nodeSet = proc->getAllRecursiveConstituents();
1071  set<Node*> nodeSet = getAllNodes(proc);
1072  for (set<Node*>::iterator iter = nodeSet.begin(); iter != nodeSet.end(); ++iter)
1073  {
1074  // ElementaryNode *node = dynamic_cast<ElementaryNode*>(*iter);
1075  // if (node)
1076  // writeParametersNode(proc,node);
1077  writeParametersNode(proc,(*iter));
1078  }
1079 }
void VisitorSaveSchema::writeParametersNode ( ComposedNode proc,
Node node 
)
protectedvirtual

Definition at line 1081 of file VisitorSaveSchema.cxx.

References _out, YACS::ENGINE::ComposedNode::getChildName(), YACS::ENGINE::Node::getLocalInputPorts(), indent(), and YACS::Exception::what().

Referenced by writeParameters().

1082 {
1083  int depth = 1;
1084  list<InputPort *> setOfInputPort = node->getLocalInputPorts();
1085  list<InputPort *>::iterator iter;
1086  for(iter = setOfInputPort.begin(); iter != setOfInputPort.end(); ++iter)
1087  {
1088  if (!(*iter)->isEmpty())
1089  {
1090  _out << indent(depth) << "<parameter>" << endl;
1091  _out << indent(depth+1) << "<tonode>" << proc->getChildName(node) << "</tonode>";
1092  _out << "<toport>" << (*iter)->getName() << "</toport>" <<endl;
1093  try
1094  {
1095  _out << indent(depth+1) << (*iter)->dump();
1096  }
1097  catch (YACS::Exception &e)
1098  {
1099  _out << "<value><error><![CDATA[" << e.what() << "]]></error></value>" << endl;
1100  }
1101  _out << indent(depth) << "</parameter>" << endl;
1102  }
1103  }
1104 }
void VisitorSaveSchema::writeProperties ( Node node)
protectedvirtual

Definition at line 520 of file VisitorSaveSchema.cxx.

References _out, depthNode(), YACS::ENGINE::Visitor::getNodeProperties(), and indent().

Referenced by visitBloc(), visitElementaryNode(), visitForEachLoop(), visitForLoop(), visitInlineFuncNode(), visitInlineNode(), visitLoop(), visitOptimizerLoop(), YACS::ENGINE::VisitorSaveSalomeSchema::visitOutNode(), YACS::ENGINE::VisitorSaveSalomeSchema::visitPresetNode(), visitProc(), visitServerNode(), visitServiceInlineNode(), visitServiceNode(), YACS::ENGINE::VisitorSaveSalomeSchema::visitStudyInNode(), YACS::ENGINE::VisitorSaveSalomeSchema::visitStudyOutNode(), visitSwitch(), and visitWhileLoop().

521 {
522  int depth = depthNode(node)+1;
523  map<string,string> properties = getNodeProperties(node);
524  map<string,string>::const_iterator it;
525  for(it = properties.begin(); it != properties.end(); ++it)
526  {
527  _out << indent(depth) << "<property name=\"" << it->first
528  << "\" value=\"" << it->second << "\"/>" << endl;
529  }
530 }
void VisitorSaveSchema::writeSimpleDataLinks ( ComposedNode node)
protectedvirtual

Write simple data links from and to direct children of node (grand children already done). First, for all output ports of direct children, write links where the input port is inside the node scope. Keep in memory the links where the input port is outside the node scope. Second, retreive links where the output port is inside the scope, using the links kept in memory and not yet written.

Definition at line 834 of file VisitorSaveSchema.cxx.

References _mapOfDLtoCreate, _out, DEBTRACE, depthNode(), YACS::ENGINE::ComposedNode::edGetDirectDescendants(), YACS::ENGINE::OutputPort::edSetInPort(), YACS::ENGINE::Node::getChildByName(), YACS::ENGINE::ComposedNode::getChildName(), YACS::ENGINE::Node::getFather(), YACS::ENGINE::Node::getLocalOutputPorts(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::ComposedNode::getName(), YACS::ENGINE::Node::getName(), YACS::ENGINE::Port::getNode(), YACS::ENGINE::Port::getNumId(), YACS::ENGINE::Node::getNumId(), indent(), YACS::ENGINE::ComposedNode::isInMyDescendance(), and YACS::ENGINE::ForEachLoop::NAME_OF_SPLITTERNODE.

Referenced by visitBloc(), visitForEachLoop(), visitForLoop(), visitLoop(), visitOptimizerLoop(), visitProc(), visitSwitch(), and visitWhileLoop().

835 {
836  int depth = depthNode(node)+1;
837  list<Node*> setOfChildren = node->edGetDirectDescendants();
838 
839  list<Node*> setOfChildrenPlusSplitters = setOfChildren;
840 
841  for (list<Node*>::iterator ic = setOfChildren.begin(); ic != setOfChildren.end(); ++ic)
842  // add "splitter" node of ForEachLoop nodes to the set of children
843  if ( dynamic_cast<ForEachLoop*>( *ic ) )
844  {
846  if(find(setOfChildrenPlusSplitters.begin(),setOfChildrenPlusSplitters.end(),nodeToInsert)==setOfChildrenPlusSplitters.end())
847  setOfChildrenPlusSplitters.push_back(nodeToInsert);
848  }
849 
850  // --- first pass, write links where the input port is inside the node scope. Keep in memory others.
851 
852  for (list<Node*>::iterator ic = setOfChildrenPlusSplitters.begin(); ic != setOfChildrenPlusSplitters.end(); ++ic)
853  {
854  Node* from = *ic;
855  list<OutputPort*> listOP = from->getLocalOutputPorts();
856  for (list<OutputPort*>::iterator io = listOP.begin(); io != listOP.end(); ++io)
857  {
858  OutputPort* anOP = *io;
859  set<InPort*> setIP = anOP->edSetInPort();
860  for (set<InPort*>::iterator iip = setIP.begin(); iip != setIP.end(); ++iip)
861  {
862  InPort *anIP = *iip;
863  Node* to = anIP->getNode();
864  DEBTRACE("from " << from->getName() << " outputPort " << anOP->getName()
865  << " to " << to->getName() << " inputPort " << anIP->getName() );
866  Node* child = node->isInMyDescendance(to);
867  if (child && (child->getNumId() != node->getNumId())
868  && (from->getNumId() != to->getNumId()))
869  {
870  DEBTRACE( "BINGO!" );
871 
872  string fromName;
873  if ( dynamic_cast<SplitterNode*>(from) && dynamic_cast<ForEachLoop*>(from->getFather()) )
874  fromName = from->getFather()->getName();
875  else
876  fromName = node->getChildName(from);
877 
878  string childName;
879  if ( dynamic_cast<SplitterNode*>(to) && dynamic_cast<ForEachLoop*>(to->getFather()) )
880  childName = node->getChildName(to->getFather());
881  else
882  childName = node->getChildName(to);
883  _out << indent(depth) << "<datalink control=\"false\">" << endl;
884  _out << indent(depth+1) << "<fromnode>" << fromName << "</fromnode> ";
885  _out << "<fromport>" << anOP->getName() << "</fromport>" << endl;
886  _out << indent(depth+1) << "<tonode>" << childName << "</tonode> ";
887  _out << "<toport>" << anIP->getName() << "</toport>" << endl;
888  _out << indent(depth) << "</datalink>" << endl;
889  }
890  else
891  { // --- store info to create the link later, given the input port
892  DEBTRACE( "For later" );
893  struct DataLinkInfo aLink = { from, to, anOP, anIP, false };
894  _mapOfDLtoCreate.insert(make_pair(anIP->getNumId(), aLink));
895  }
896  }
897  }
898  }
899 
900  // --- second pass, retreive links where the output port is inside the scope.
901 
902  if (!dynamic_cast<Switch*>(node)) // xml parser does not take into account datalinks in a switch context
903  {
904  std::multimap<int, DataLinkInfo>::iterator pos;
905  for (pos = _mapOfDLtoCreate.begin(); pos != _mapOfDLtoCreate.end(); ++pos)
906  {
907  Node* to = (pos->second).to;
908  Node* child = node->isInMyDescendance(to);
909  if (child && (child->getNumId() != node->getNumId()))
910  {
911  InPort* anIP = (pos->second).inp;
912  int portId = anIP->getNumId();
913  Node* from = (pos->second).from;
914  child = node->isInMyDescendance(from);
915  if (child && (child->getNumId() != node->getNumId()))
916  if((from->getNumId() != to->getNumId()) || dynamic_cast<Loop*>(node))
917  {
918  string childName = node->getChildName(from);
919  OutPort *anOP = (pos->second).outp;
920  (pos->second).toDelete = true;
921  _out << indent(depth) << "<datalink control=\"false\">" << endl;
922  _out << indent(depth+1) << "<fromnode>" << childName << "</fromnode> ";
923  _out << "<fromport>" << anOP->getName() << "</fromport>" << endl;
924  _out << indent(depth+1) << "<tonode>" << node->getChildName(to) << "</tonode> ";
925  _out << "<toport>" << anIP->getName() << "</toport>" << endl;
926  _out << indent(depth) << "</datalink>" << endl;
927  }
928  }
929  }
930 
931  // --- remove the link written from the multimap
932 
933  for (pos = _mapOfDLtoCreate.begin(); pos != _mapOfDLtoCreate.end();)
934  {
935  if ((pos->second).toDelete)
936  _mapOfDLtoCreate.erase(pos++); // be careful not to saw off the branch on which you are sitting!
937  else
938  ++pos;
939  }
940  }
941 }
void VisitorSaveSchema::writeSimpleStreamLinks ( ComposedNode node)
protectedvirtual

Definition at line 943 of file VisitorSaveSchema.cxx.

References _mapOfSLtoCreate, _out, DEBTRACE, depthNode(), YACS::ENGINE::ComposedNode::edGetDirectDescendants(), YACS::ENGINE::OutputDataStreamPort::edSetInPort(), YACS::ENGINE::ComposedNode::getChildName(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::Node::getName(), YACS::ENGINE::Port::getNode(), YACS::ENGINE::Port::getNumId(), YACS::ENGINE::Node::getNumId(), YACS::ENGINE::Node::getSetOfOutputDataStreamPort(), indent(), and YACS::ENGINE::ComposedNode::isInMyDescendance().

Referenced by visitBloc(), visitForEachLoop(), visitForLoop(), visitLoop(), visitOptimizerLoop(), visitProc(), visitSwitch(), and visitWhileLoop().

944 {
945  int depth = depthNode(node)+1;
946  list<Node*> setOfChildren = node->edGetDirectDescendants();
947 
948  // --- first pass, write links where the input port is inside the node scope. Keep in memory others.
949 
950  for (list<Node*>::iterator ic = setOfChildren.begin(); ic != setOfChildren.end(); ++ic)
951  {
952  Node* from = *ic;
953  if ( dynamic_cast<ComposedNode*>(from) ) continue;
954  list<OutputDataStreamPort*> listOP = from->getSetOfOutputDataStreamPort();
955  for (list<OutputDataStreamPort*>::iterator io = listOP.begin(); io != listOP.end(); ++io)
956  {
957  OutputDataStreamPort* anOP = *io;
958  set<InPort*> setIP = anOP->edSetInPort();
959  for (set<InPort*>::iterator iip = setIP.begin(); iip != setIP.end(); ++iip)
960  {
961  InPort *anIP = *iip;
962  Node* to = anIP->getNode();
963  DEBTRACE("from " << from->getName() << " outputPort " << anOP->getName()
964  << " to " << to->getName() << " inputPort " << anIP->getName() );
965  Node* child = node->isInMyDescendance(to);
966  if (child && (child->getNumId() != node->getNumId())
967  && (from->getNumId() != to->getNumId()))
968  {
969  DEBTRACE( "BINGO!" );
970  string childName = node->getChildName(to);
971  _out << indent(depth) << "<stream>" << endl;
972  _out << indent(depth+1) << "<fromnode>" << node->getChildName(from) << "</fromnode> ";
973  _out << "<fromport>" << anOP->getName() << "</fromport>" << endl;
974  _out << indent(depth+1) << "<tonode>" << childName << "</tonode> ";
975  _out << "<toport>" << anIP->getName() << "</toport>" << endl;
976 
977  std::map<std::string,std::string> aPropMap = dynamic_cast<InputDataStreamPort*>(anIP)->getProperties();
978  for (std::map<std::string,std::string>::iterator itP = aPropMap.begin(); itP != aPropMap.end(); itP++)
979  {
980  string notAlinkProperty = "DependencyType";
981  if (notAlinkProperty != (*itP).first)
982  _out << indent(depth+1) << "<property name=\"" << (*itP).first << "\" value=\""
983  << (*itP).second << "\"/>" << endl;
984  }
985  _out << indent(depth) << "</stream>" << endl;
986  }
987  else
988  { // --- store info to create the link later, given the input port
989  DEBTRACE("For later" );
990  struct StreamLinkInfo aLink = { from, to, anOP, anIP, false };
991  _mapOfSLtoCreate.insert(make_pair(anIP->getNumId(), aLink));
992  }
993  }
994  }
995  }
996 
997  // --- second pass, retreive links where the output port is inside the scope.
998 
999  if (!dynamic_cast<Switch*>(node)) // xml parser does not take into account datalinks in a switch context
1000  {
1001  std::multimap<int, StreamLinkInfo>::iterator pos;
1002  for (pos = _mapOfSLtoCreate.begin(); pos != _mapOfSLtoCreate.end(); ++pos)
1003  {
1004  Node* to = (pos->second).to;
1005  Node* child = node->isInMyDescendance(to);
1006  if (child && (child->getNumId() != node->getNumId()))
1007  {
1008  InPort* anIP = (pos->second).inp;
1009  int portId = anIP->getNumId();
1010  Node* from = (pos->second).from;
1011  child = node->isInMyDescendance(from);
1012  if (child && (child->getNumId() != node->getNumId()))
1013  if((from->getNumId() != to->getNumId()) || dynamic_cast<Loop*>(node))
1014  {
1015  string childName = node->getChildName(from);
1016  OutputDataStreamPort *anOP = (pos->second).outp;
1017  (pos->second).toDelete = true;
1018  _out << indent(depth) << "<stream>" << endl;
1019  _out << indent(depth+1) << "<fromnode>" << childName << "</fromnode> ";
1020  _out << "<fromport>" << anOP->getName() << "</fromport>" << endl;
1021  _out << indent(depth+1) << "<tonode>" << node->getChildName(to) << "</tonode> ";
1022  _out << "<toport>" << anIP->getName() << "</toport>" << endl;
1023 
1024  std::map<std::string,std::string> aPropMap = dynamic_cast<InputDataStreamPort*>(anIP)->getProperties();
1025  for (std::map<std::string,std::string>::iterator itP = aPropMap.begin(); itP != aPropMap.end(); itP++)
1026  _out << indent(depth+1) << "<property name=\"" << (*itP).first << "\" value=\""
1027  << (*itP).second << "\"/>" << endl;
1028 
1029  _out << indent(depth) << "</stream>" << endl;
1030  }
1031  }
1032  }
1033 
1034  // --- remove the link written from the multimap
1035 
1036  for (pos = _mapOfSLtoCreate.begin(); pos != _mapOfSLtoCreate.end();)
1037  {
1038  if ((pos->second).toDelete)
1039  _mapOfSLtoCreate.erase(pos++); // be careful not to saw off the branch on which you are sitting!
1040  else
1041  ++pos;
1042  }
1043  }
1044 }
void VisitorSaveSchema::writeTypeCodes ( Proc proc)
protectedvirtual

Definition at line 651 of file VisitorSaveSchema.cxx.

References depthNode(), dumpTypeCode(), and YACS::ENGINE::Visitor::getTypeCodeMap().

Referenced by visitProc().

652 {
653  int depth = depthNode(proc)+1;
654  map<string, TypeCode*> typeMap = getTypeCodeMap(proc);
655  map<string, TypeCode*>::const_iterator it;
656  set<string> typeNames;
657 
658  // --- force definition of simple types first
659 
660  for (it = typeMap.begin(); it != typeMap.end(); it++)
661  {
662  dumpTypeCode(it->second,typeNames,typeMap,depth);
663  }
664 }

Member Data Documentation

std::map<ComponentInstance*, std::string> YACS::ENGINE::VisitorSaveSchema::_componentInstanceMap
protected

Definition at line 111 of file VisitorSaveSchema.hxx.

Referenced by visitServiceNode().

std::map<std::string, Container*> YACS::ENGINE::VisitorSaveSchema::_containerMap
protected

Definition at line 110 of file VisitorSaveSchema.hxx.

Referenced by visitServerNode(), visitServiceNode(), and writeContainers().

std::multimap<int, DataLinkInfo> YACS::ENGINE::VisitorSaveSchema::_mapOfDLtoCreate
protected

Definition at line 113 of file VisitorSaveSchema.hxx.

Referenced by writeSimpleDataLinks().

std::multimap<int, StreamLinkInfo> YACS::ENGINE::VisitorSaveSchema::_mapOfSLtoCreate
protected

Definition at line 114 of file VisitorSaveSchema.hxx.

Referenced by writeSimpleStreamLinks().

std::map<int, std::string> YACS::ENGINE::VisitorSaveSchema::_nodeStateName
protected

Definition at line 109 of file VisitorSaveSchema.hxx.


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