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