69 _out <<
"</proc>" << endl;
76 _out.open(xmlSchema.c_str(), ios::out);
79 string what =
"Impossible to open file for writing: " + xmlSchema;
82 _out <<
"<?xml version='1.0' encoding='iso-8859-1' ?>" << endl;
88 _out <<
"</proc>" << endl;
99 _out <<
" state=\"disabled\">" << endl;
103 node->ComposedNode::accept(
this);
134 _out <<
" state=\"disabled\"";
143 node->DynParaLoop::accept(
this);
146 _out <<
indent(depth) <<
"</foreach>" << endl;
159 _out <<
" state=\"disabled\"";
166 node->DynParaLoop::accept(
this);
169 _out <<
indent(depth) <<
"</foreachdyn>" << endl;
183 _out <<
" state=\"disabled\"";
192 node->DynParaLoop::accept(
this);
195 _out <<
indent(depth) <<
"</optimizer>" << endl;
206 _out <<
indent(depth+1) <<
"<initnode>" << endl;
208 _out <<
indent(depth+1) <<
"</initnode>" << endl;
216 _out <<
indent(depth+1) <<
"<finalizenode>" << endl;
218 _out <<
indent(depth+1) <<
"</finalizenode>" << endl;
231 _out <<
" state=\"disabled\"";
237 node->ComposedNode::accept(
this);
240 _out <<
indent(depth) <<
"</forloop>" << endl;
258 _out <<
" state=\"disabled\">" << endl;
261 _out <<
indent(depth+1) <<
"<script><code><![CDATA[";
263 _out <<
"]]></code></script>" << endl;
268 _out <<
indent(depth+1) <<
"<load container=\"" << cont->
getName() <<
"\"/>" << endl;
298 _out <<
" state=\"disabled\">" << endl;
304 _out <<
"]]></code>" << endl;
305 _out <<
indent(depth+1) <<
"</function>" << endl;
310 _out <<
indent(depth+1) <<
"<load container=\"" << cont->
getName() <<
"\"/>" << endl;
333 node->ComposedNode::accept(
this);
344 _out <<
"<proc name=\""<< node->
getName() <<
"\">" << endl;
350 node->ComposedNode::accept(
this);
366 _out <<
" state=\"disabled\">" << endl;
369 if (node->
getKind() ==
"xmlsh")
371 _out <<
indent(depth+1) <<
"<kind>xmlsh</kind>" << endl;
388 map<string, Container*>::const_iterator it;
391 if (it->second == cont)
break;
394 _out <<
indent(depth+1) <<
"<load container=\"" << it->first <<
"\"/>" << endl;
403 _out <<
indent(depth+1) <<
"<component>" <<
"UNKNOWN" <<
"</component>" << endl;
413 _out <<
indent(depth) <<
"</service>" << endl;
425 _out <<
" state=\"disabled\">" << endl;
429 map<string, Container*>::const_iterator it;
432 if (it->second == cont)
break;
435 _out <<
indent(depth+1) <<
"<loadcontainer>" << it->first <<
"</loadcontainer>" << endl;
441 _out <<
indent(depth+2) <<
"<script><code><![CDATA[";
443 _out <<
"]]></code></script>" << endl;
462 _out <<
" state=\"disabled\">" << endl;
473 _out <<
"]]></code>" << endl;
474 _out <<
indent(depth+1) <<
"</function>" << endl;
478 _out <<
indent(depth) <<
"</serviceInline>" << endl;
516 _out <<
" state=\"disabled\"";
522 node->ComposedNode::accept(
this);
538 _out <<
" state=\"disabled\">" << endl;
542 node->ComposedNode::accept(
this);
555 map<string,string>::const_iterator it;
556 for(it = properties.begin(); it != properties.end(); ++it)
558 _out <<
indent(depth) <<
"<property name=\"" << it->first
559 <<
"\" value=\"" << it->second <<
"\"/>" << endl;
566 string typeName = type->
name();
567 if (typeNames.find(typeName) != typeNames.end())
573 typeNames.insert(typeName);
574 _out <<
indent(depth) <<
"<type name=\"" << typeName <<
"\" kind=\"double\"/>" << endl;
579 typeNames.insert(typeName);
580 _out <<
indent(depth) <<
"<type name=\"" << typeName <<
"\" kind=\"int\"/>" << endl;
585 typeNames.insert(typeName);
586 _out <<
indent(depth) <<
"<type name=\"" << typeName <<
"\" kind=\"string\"/>" << endl;
591 typeNames.insert(typeName);
592 _out <<
indent(depth) <<
"<type name=\"" << typeName <<
"\" kind=\"bool\"/>" << endl;
600 for(std::list<TypeCodeObjref*>::iterator il=listOfBases.begin(); il != listOfBases.end(); ++il)
602 if (typeNames.find((*il)->name()) == typeNames.end())
606 typeNames.insert(typeName);
607 _out <<
indent(depth) <<
"<objref name=\"" << typeName <<
"\" id=\""
608 << objref->
id() <<
"\"";
609 if (listOfBases.empty())
610 _out <<
"/>" << endl;
614 for(std::list<TypeCodeObjref*>::iterator il=listOfBases.begin(); il != listOfBases.end(); ++il)
617 _out << (*il)->name();
618 _out <<
"</base>" << endl;
627 if (typeNames.find(content->
name()) == typeNames.end())
632 typeNames.insert(typeName);
633 _out <<
indent(depth) <<
"<sequence name=\"" << typeName <<
"\" content=\""
634 << content->
name() <<
"\"/>" << endl;
640 if (typeNames.find(content->
name()) == typeNames.end())
645 typeNames.insert(typeName);
646 _out <<
indent(depth) <<
"<array name=\"" << typeName <<
"\" content=\""
647 << content->
name() <<
"\"/>" << endl;
655 for (
int i=0;
i<mbCnt;
i++)
658 if (typeNames.find(member->
name()) == typeNames.end())
664 typeNames.insert(typeName);
665 _out <<
indent(depth) <<
"<struct name=\"" << typeName <<
"\">" << endl;
666 for (
int i=0;
i<mbCnt;
i++)
669 _out <<
indent(depth+1) <<
"<member name=\"" <<tcStruct->
memberName(
i) <<
"\" type=\"" << member->
name() <<
"\"/>" << endl;
676 string what =
"wrong TypeCode: ";
686 map<string, TypeCode*>::const_iterator it;
687 set<string> typeNames;
691 for (it = typeMap.begin(); it != typeMap.end(); it++)
700 std::map<std::string, ComponentInstance*>::const_iterator it;
703 string name = it->first;
712 _out <<
indent(depth+1) <<
"<load container=\"" << cont->
getName() <<
"\"/>" << endl;
714 std::map<std::string, std::string> properties = inst->
getProperties();
715 std::map<std::string, std::string>::const_iterator itm;
716 for(itm = properties.begin(); itm != properties.end(); ++itm)
717 _out <<
indent(depth+1) <<
"<property name=\"" << (*itm).first
718 <<
"\" value=\"" << (*itm).second <<
"\"/>" << endl;
720 _out <<
indent(depth) <<
"</componentinstance>" << endl;
729 map<string, Container*>::const_iterator it;
732 string name = it->first;
733 _out <<
indent(depth) <<
"<container name=\"" << name <<
"\">" << endl;
735 _out <<
indent(depth+1) <<
"<property name=\"" <<
Container::AOC_ENTRY <<
"\" value=\"" << (int)it->second->isAttachedOnCloning() <<
"\"/>" << endl;
736 map<string, string> properties = (it->second)->getProperties();
737 map<string, string>::iterator itm;
738 for(itm = properties.begin(); itm != properties.end(); ++itm)
746 _out <<
indent(depth+1) <<
"<property name=\"" << (*itm).first <<
"\" value=\"" << (*itm).second <<
"\"/>" << endl;
750 _out <<
indent(depth+1) <<
"<initializescriptkey><code><![CDATA[" << (*itm).second <<
"]]></code></initializescriptkey>" << endl;
753 _out <<
indent(depth) <<
"</container>" << endl;
762 for (list<InputPort*>::iterator it = listOfInputPorts.begin(); it != listOfInputPorts.end(); ++it)
764 _out <<
indent(depth) <<
"<inport name=\"" << (*it)->getName() <<
"\" type=\""
765 << (*it)->edGetType()->name() <<
"\"/>" << endl;
773 for (list<InputDataStreamPort*>::iterator it = listOfInputPorts.begin(); it != listOfInputPorts.end(); ++it)
775 std::map<std::string,std::string> aPropMap = (*it)->getProperties();
776 if ( aPropMap.empty() )
777 _out <<
indent(depth) <<
"<instream name=\"" << (*it)->getName() <<
"\" type=\""
778 << (*it)->edGetType()->name() <<
"\"/>" << endl;
781 _out <<
indent(depth) <<
"<instream name=\"" << (*it)->getName() <<
"\" type=\""
782 << (*it)->edGetType()->name() <<
"\">" << endl;
783 for (std::map<std::string,std::string>::iterator itP = aPropMap.begin(); itP != aPropMap.end(); itP++)
784 _out <<
indent(depth+1) <<
"<property name=\"" << (*itP).first <<
"\" value=\""
785 << (*itP).second <<
"\"/>" << endl;
786 _out <<
indent(depth) <<
"</instream>" << endl;
795 for (list<OutputPort*>::iterator it = listOfOutputPorts.begin(); it != listOfOutputPorts.end(); ++it)
797 _out <<
indent(depth) <<
"<outport name=\"" << (*it)->getName() <<
"\" type=\""
798 << (*it)->edGetType()->name() <<
"\"/>" << endl;
806 for (list<OutputDataStreamPort*>::iterator it = listOfOutputPorts.begin(); it != listOfOutputPorts.end(); ++it)
808 std::map<std::string,std::string> aPropMap = (*it)->getProperties();
809 if ( aPropMap.empty() )
810 _out <<
indent(depth) <<
"<outstream name=\"" << (*it)->getName() <<
"\" type=\""
811 << (*it)->edGetType()->name() <<
"\"/>" << endl;
814 _out <<
indent(depth) <<
"<outstream name=\"" << (*it)->getName() <<
"\" type=\""
815 << (*it)->edGetType()->name() <<
"\">" << endl;
816 for (std::map<std::string,std::string>::iterator itP = aPropMap.begin(); itP != aPropMap.end(); itP++)
817 _out <<
indent(depth+1) <<
"<property name=\"" << (*itP).first <<
"\" value=\""
818 << (*itP).second <<
"\"/>" << endl;
819 _out <<
indent(depth) <<
"</outstream>" << endl;
828 for (list<Node*>::iterator ic = setOfChildren.begin(); ic != setOfChildren.end(); ++ic)
831 list<InGate*> setOfInGates = (*ic)->getOutGate()->edSetInGate();
832 for (list<InGate*>::iterator ig = setOfInGates.begin(); ig != setOfInGates.end(); ++ig)
834 Node *to = (*ig)->getNode();
839 _out <<
"<tonode>" << node->
getChildName(to) <<
"</tonode> </control>" << endl;
844 list<OutGate*> listOfOutGates = (*ic)->getInGate()->getBackLinks();
845 for (list<OutGate*>::iterator ig = listOfOutGates.begin(); ig != listOfOutGates.end(); ++ig)
847 Node *from = (*ig)->getNode();
852 _out <<
"<tonode>" << node->
getChildName(to) <<
"</tonode> </control>" << endl;
870 list<Node*> setOfChildrenPlusSplitters = setOfChildren;
872 for (list<Node*>::iterator ic = setOfChildren.begin(); ic != setOfChildren.end(); ++ic)
877 if(find(setOfChildrenPlusSplitters.begin(),setOfChildrenPlusSplitters.end(),nodeToInsert)==setOfChildrenPlusSplitters.end())
878 setOfChildrenPlusSplitters.push_back(nodeToInsert);
883 for (list<Node*>::iterator ic = setOfChildrenPlusSplitters.begin(); ic != setOfChildrenPlusSplitters.end(); ++ic)
887 for (list<OutputPort*>::iterator io = listOP.begin(); io != listOP.end(); ++io)
891 for (set<InPort*>::iterator iip = setIP.begin(); iip != setIP.end(); ++iip)
914 _out <<
indent(depth) <<
"<datalink control=\"false\">" << endl;
915 _out <<
indent(depth+1) <<
"<fromnode>" << fromName <<
"</fromnode> ";
916 _out <<
"<fromport>" << anOP->
getName() <<
"</fromport>" << endl;
917 _out <<
indent(depth+1) <<
"<tonode>" << childName <<
"</tonode> ";
918 _out <<
"<toport>" << anIP->
getName() <<
"</toport>" << endl;
919 _out <<
indent(depth) <<
"</datalink>" << endl;
924 struct DataLinkInfo aLink = { from, to, anOP, anIP,
false };
933 if (!
dynamic_cast<Switch*
>(node))
935 std::multimap<int, DataLinkInfo>::iterator pos;
938 Node* to = (pos->second).to;
942 InPort* anIP = (pos->second).inp;
944 Node* from = (pos->second).from;
950 OutPort *anOP = (pos->second).outp;
951 (pos->second).toDelete =
true;
952 _out <<
indent(depth) <<
"<datalink control=\"false\">" << endl;
953 _out <<
indent(depth+1) <<
"<fromnode>" << childName <<
"</fromnode> ";
954 _out <<
"<fromport>" << anOP->
getName() <<
"</fromport>" << endl;
956 _out <<
"<toport>" << anIP->
getName() <<
"</toport>" << endl;
957 _out <<
indent(depth) <<
"</datalink>" << endl;
966 if ((pos->second).toDelete)
981 for (list<Node*>::iterator ic = setOfChildren.begin(); ic != setOfChildren.end(); ++ic)
986 for (list<OutputDataStreamPort*>::iterator io = listOP.begin(); io != listOP.end(); ++io)
990 for (set<InPort*>::iterator iip = setIP.begin(); iip != setIP.end(); ++iip)
1004 _out <<
"<fromport>" << anOP->
getName() <<
"</fromport>" << endl;
1005 _out <<
indent(depth+1) <<
"<tonode>" << childName <<
"</tonode> ";
1006 _out <<
"<toport>" << anIP->
getName() <<
"</toport>" << endl;
1008 std::map<std::string,std::string> aPropMap =
dynamic_cast<InputDataStreamPort*
>(anIP)->getProperties();
1009 for (std::map<std::string,std::string>::iterator itP = aPropMap.begin(); itP != aPropMap.end(); itP++)
1011 string notAlinkProperty =
"DependencyType";
1012 if (notAlinkProperty != (*itP).first)
1013 _out <<
indent(depth+1) <<
"<property name=\"" << (*itP).first <<
"\" value=\""
1014 << (*itP).second <<
"\"/>" << endl;
1016 _out <<
indent(depth) <<
"</stream>" << endl;
1030 if (!
dynamic_cast<Switch*
>(node))
1032 std::multimap<int, StreamLinkInfo>::iterator pos;
1035 Node* to = (pos->second).to;
1039 InPort* anIP = (pos->second).inp;
1041 Node* from = (pos->second).from;
1048 (pos->second).toDelete =
true;
1050 _out <<
indent(depth+1) <<
"<fromnode>" << childName <<
"</fromnode> ";
1051 _out <<
"<fromport>" << anOP->
getName() <<
"</fromport>" << endl;
1053 _out <<
"<toport>" << anIP->
getName() <<
"</toport>" << endl;
1055 std::map<std::string,std::string> aPropMap =
dynamic_cast<InputDataStreamPort*
>(anIP)->getProperties();
1056 for (std::map<std::string,std::string>::iterator itP = aPropMap.begin(); itP != aPropMap.end(); itP++)
1057 _out <<
indent(depth+1) <<
"<property name=\"" << (*itP).first <<
"\" value=\""
1058 << (*itP).second <<
"\"/>" << endl;
1060 _out <<
indent(depth) <<
"</stream>" << endl;
1069 if ((pos->second).toDelete)
1081 for(list<Node *>::iterator iter=setOfNode.begin();iter!=setOfNode.end();iter++)
1086 ret.insert(myCurrentSet.begin(),myCurrentSet.end());
1091 list<ElementaryNode *> myCurrentSet=(*iter)->getRecursiveConstituents();
1092 ret.insert(myCurrentSet.begin(),myCurrentSet.end());
1103 for (set<Node*>::iterator iter = nodeSet.begin(); iter != nodeSet.end(); ++iter)
1116 list<InputPort *>::iterator iter;
1117 for(iter = setOfInputPort.begin(); iter != setOfInputPort.end(); ++iter)
1119 if (!(*iter)->isEmpty())
1121 _out <<
indent(depth) <<
"<parameter>" << endl;
1123 _out <<
"<toport>" << (*iter)->getName() <<
"</toport>" <<endl;
1130 _out <<
"<value><error><![CDATA[" << e.
what() <<
"]]></error></value>" << endl;
1132 _out <<
indent(depth) <<
"</parameter>" << endl;
1145 _out <<
indent(depth) <<
"<default>" << endl;
1147 _out <<
indent(depth) <<
"<case id=\"" << myCase <<
"\">" << endl;
1159 _out <<
indent(depth) <<
"</default>" << endl;
1172 if (
dynamic_cast<Switch*
>(father)) depth +=1;
#define YASSERT(val)
YASSERT macro is always defined, used like assert, but throw a YACS::Exception instead of abort.
Composed node to group elementary and composed nodes.
double getElementaryWeight() const
double getSimpleLoopWeight() const
Base class for all component instances.
Container * getContainer() const
const std::string & getCompoName() const
virtual bool isAnonymous()
virtual std::string getFileRepr() const
For dump in file.
const std::string & getInstanceName() const
Base class for all composed nodes.
std::string getChildName(const Node *node) const
virtual std::list< Node * > edGetDirectDescendants() const =0
std::string getName() const
Node * isInMyDescendance(Node *nodeToTest) const
Returns the parent of a node that is the direct child of this node.
static const char KIND_ENTRY[]
static const char AOC_ENTRY[]
virtual std::string getName() const
Class for data parameters specification.
TypeCode * edGetType() const
std::string getName() const
Base class for dynamically (fully or semifully) built graphs.
OutputPort * edGetSamplePort()
InputPort * edGetNbOfBranchesPort()
ComplexWeight * getWeight()
Base class for all calculation nodes.
ComplexWeight * getWeight()
YACS::StatesForNode getState() const
static const char NAME_OF_SPLITTERNODE[]
Loop node for parametric calculation.
InputPort * edGetNbOfTimesInputPort()
static const char INITIALIZE_SCRIPT_KEY[]
Class for calculation node (function) inlined (and executed) in the schema.
virtual std::string getFname()
Class for calculation node (script) inlined (and executed) in the schema.
static const char LOCAL_STR[]
virtual Container * getContainer()
virtual std::string getExecutionMode()
virtual std::string getScript()
Base class for loop node.
Base class for all nodes.
virtual std::list< OutputPort * > getSetOfOutputPort() const =0
virtual std::list< InputDataStreamPort * > getSetOfInputDataStreamPort() const =0
virtual std::list< InputPort * > getLocalInputPorts() const =0
virtual std::list< OutputPort * > getLocalOutputPorts() const =0
virtual Node * getChildByName(const std::string &name) const =0
ComposedNode * getFather() const
virtual YACS::StatesForNode getState() const
virtual std::list< InputPort * > getSetOfInputPort() const =0
const std::string & getName() const
int getNumId()
return node instance identifiant, unique for each node instance
virtual void accept(Visitor *visitor)=0
virtual std::list< OutputDataStreamPort * > getSetOfOutputDataStreamPort() const =0
class to build optimization loops
virtual std::string getAlgLib() const
Return the name of the algorithm library.
virtual std::string getSymbol() const
std::set< InPort * > edSetInPort() const
std::set< InPort * > edSetInPort() const
Base class for all schema objects.
virtual void accept(Visitor *visitor)
std::map< std::string, ComponentInstance * > componentInstanceMap
std::map< std::string, std::string > getProperties() const
virtual void save(std::string xmlSchemaFile)
std::string getScript() const
Class for calculation node associated with a component service.
virtual std::string getKind() const
Return the service node kind.
virtual std::string getMethod()
virtual std::string getRef()
virtual ComponentInstance * getComponent()
Return the associated component instance.
Control node that emulates the C switch.
InputPort * edGetConditionPort()
static const int ID_FOR_DEFAULT_NODE
int getRankOfNode(Node *node) const
Class for reference objects.
const char * memberName(int index) const
TypeCode * memberType(int index) const
Base class for all type objects.
virtual const char * name() const
virtual const TypeCode * contentType() const
Base class for all visitors that save a schema.
int depthNode(Node *node)
virtual void writeParameters(Proc *proc)
virtual void visitInlineNode(InlineNode *node)
virtual void writeParametersNode(ComposedNode *proc, Node *node)
virtual void writeInputDataStreamPorts(Node *node)
std::multimap< int, DataLinkInfo > _mapOfDLtoCreate
virtual void writeTypeCodes(Proc *proc)
std::multimap< int, StreamLinkInfo > _mapOfSLtoCreate
virtual void visitForLoop(ForLoop *node)
virtual void writeOutputDataStreamPorts(Node *node)
virtual void visitDynParaLoop(DynParaLoop *node)
virtual void writeContainers(Proc *proc)
std::string indent(int val)
virtual void visitPresetNode(DataNode *node)
virtual void dumpTypeCode(TypeCode *type, std::set< std::string > &typeNames, std::map< std::string, TypeCode * > &typeMap, int depth)
virtual ~VisitorSaveSchema()
virtual void writeComponentInstances(Proc *proc)
virtual void writeSimpleDataLinks(ComposedNode *node)
virtual void endCase(Node *node)
void visitForEachLoop(ForEachLoop *node) override
virtual void writeProperties(Node *node)
virtual void writeSimpleStreamLinks(ComposedNode *node)
virtual void writeInputPorts(Node *node)
virtual void visitProc(Proc *node)
virtual void writeControls(ComposedNode *node)
virtual void beginCase(Node *node)
virtual void visitBloc(Bloc *node)
virtual void visitServerNode(ServerNode *node)
virtual void visitOutNode(DataNode *node)
void openFileSchema(std::string xmlDump)
virtual void visitStudyOutNode(DataNode *node)
virtual void visitStudyInNode(DataNode *node)
virtual void visitServiceNode(ServiceNode *node)
std::set< Node * > getAllNodes(ComposedNode *node)
virtual void visitServiceInlineNode(ServiceInlineNode *node)
virtual void visitLoop(Loop *node)
virtual void visitOptimizerLoop(OptimizerLoop *node)
VisitorSaveSchema(ComposedNode *root)
virtual void visitInlineFuncNode(InlineFuncNode *node)
virtual void writeOutputPorts(Node *node)
virtual void visitWhileLoop(WhileLoop *node)
virtual void visitElementaryNode(ElementaryNode *node)
std::map< std::string, Container * > _containerMap
virtual void visitSwitch(Switch *node)
void visitForEachLoopDyn(ForEachLoopDyn *node) override
std::map< ComponentInstance *, std::string > _componentInstanceMap
std::map< std::string, std::string > getNodeProperties(Node *node)
std::map< std::string, Container * > getContainerMap(Proc *proc)
std::list< TypeCodeObjref * > getListOfBases(TypeCodeObjref *objref)
std::map< std::string, TypeCode * > getTypeCodeMap(Proc *proc)
const char * what(void) const noexcept