]> SALOME platform Git repositories - modules/yacs.git/blob - src/engine/VisitorSaveSchema.hxx
Salome HOME
mergefrom branch BR_V511_PR tag mergeto_trunk_03feb09
[modules/yacs.git] / src / engine / VisitorSaveSchema.hxx
1 //  Copyright (C) 2006-2008  CEA/DEN, EDF R&D
2 //
3 //  This library is free software; you can redistribute it and/or
4 //  modify it under the terms of the GNU Lesser General Public
5 //  License as published by the Free Software Foundation; either
6 //  version 2.1 of the License.
7 //
8 //  This library is distributed in the hope that it will be useful,
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 //  Lesser General Public License for more details.
12 //
13 //  You should have received a copy of the GNU Lesser General Public
14 //  License along with this library; if not, write to the Free Software
15 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 #ifndef __VISITOR_SAVESCHEMA_HXX__
20 #define __VISITOR_SAVESCHEMA_HXX__
21
22 #include "Visitor.hxx"
23 #include "Exception.hxx"
24
25 #include <fstream>
26 #include <string>
27 #include <map>
28 #include <set>
29
30 namespace YACS
31 {
32   namespace ENGINE
33   {
34     class OutputPort;
35     class OutputDataStreamPort;
36     class InPort;
37     class ComponentInstance;
38
39     struct DataLinkInfo
40     {
41       Node* from;
42       Node* to;
43       OutputPort* outp;
44       InPort* inp;
45       bool toDelete;
46     };
47
48     struct StreamLinkInfo
49     {
50       Node* from;
51       Node* to;
52       OutputDataStreamPort* outp;
53       InPort* inp;
54       bool toDelete;
55     };
56
57     class VisitorSaveSchema: public Visitor
58     {
59     public:
60       VisitorSaveSchema(ComposedNode *root);
61       virtual ~VisitorSaveSchema();
62       void openFileSchema(std::string xmlDump) throw(Exception);
63       void closeFileSchema();
64       virtual void visitBloc(Bloc *node);
65       virtual void visitElementaryNode(ElementaryNode *node);
66       virtual void visitForEachLoop(ForEachLoop *node);
67       virtual void visitForLoop(ForLoop *node);
68       virtual void visitInlineNode(InlineNode *node);
69       virtual void visitInlineFuncNode(InlineFuncNode *node);
70       virtual void visitLoop(Loop *node);
71       virtual void visitProc(Proc *node);
72       virtual void visitServiceNode(ServiceNode *node);
73       virtual void visitServiceInlineNode(ServiceInlineNode *node);
74       virtual void visitSwitch(Switch *node);
75       virtual void visitWhileLoop(WhileLoop *node);
76       virtual void visitPresetNode(DataNode *node);
77       virtual void visitOutNode(DataNode *node);
78       virtual void visitStudyInNode(DataNode *node);
79       virtual void visitStudyOutNode(DataNode *node);
80
81     protected:
82       virtual void writeProperties(Node *node);
83       virtual void dumpTypeCode(TypeCode* type, std::set<std::string>& typeNames,std::map<std::string, TypeCode*>& typeMap,int depth);
84       virtual void writeTypeCodes(Proc *proc);
85       virtual void writeContainers(Proc *proc);
86       virtual void writeInputPorts(Node *node);
87       virtual void writeInputDataStreamPorts(Node *node); // OCC : mkr : add possibility to write input data stream ports
88       virtual void writeOutputPorts(Node *node);
89       virtual void writeOutputDataStreamPorts(Node *node); // OCC : mkr : add possibility to write output data stream ports
90       virtual void writeControls(ComposedNode *node);
91       virtual void writeSimpleDataLinks(ComposedNode *node);
92       virtual void writeSimpleStreamLinks(ComposedNode *node); // OCC : mkr : add possibility to write stream links
93       virtual void writeParameters(Proc *proc);
94       virtual void writeParametersNode(ComposedNode *proc, Node *node);
95       virtual void beginCase(Node* node);
96       virtual void endCase(Node* node);
97       std::set<Node*> getAllNodes(ComposedNode *node);
98       int depthNode(Node* node);
99       inline std::string indent(int val)
100       {std::string white; white.append(3*val,' '); return white;};
101
102       std::ofstream _out;
103       std::map<int, std::string> _nodeStateName;
104       std::map<std::string, Container*> _containerMap;
105       std::map<ComponentInstance*, std::string> _componentInstanceMap;
106       ComposedNode *_root;
107       std::multimap<int, DataLinkInfo> _mapOfDLtoCreate;
108       std::multimap<int, StreamLinkInfo> _mapOfSLtoCreate;
109     };
110
111     class SchemaSave
112     {
113     public:
114       SchemaSave(Proc* proc);
115       virtual void save(std::string xmlSchemaFile);
116     protected:
117       Proc* _p;
118     };
119   }
120 }
121 #endif