Salome HOME
mergefrom branch BR_V511_PR tag mergeto_trunk_03feb09
[modules/yacs.git] / src / engine / Runtime.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 _RUNTIME_HXX_
20 #define _RUNTIME_HXX_
21
22 #include "ConversionException.hxx"
23
24 #include<string>
25 #include<set>
26 #include<map>
27 #include<vector>
28
29 namespace YACS
30 {
31   namespace ENGINE
32   {
33     class Runtime;
34     Runtime* getRuntime() throw(Exception);
35
36     class Any;
37     class InputPort;
38     class OutputPort;
39     class ForLoop;
40     class ForEachLoop;
41     class WhileLoop;
42     class Switch;
43     class InlineNode;
44     class InlineFuncNode;
45     class ServiceNode;
46     class DataNode;
47     class Container;
48     class ServiceInlineNode;
49     class ComponentInstance;
50     class Proc;
51     class Bloc;
52     class ElementaryNode;
53     class Node;
54     class TypeCode;
55     class InputDataStreamPort;
56     class OutputDataStreamPort;
57     class Catalog;
58     class CatalogLoader;
59
60     class Runtime
61     {
62       friend Runtime* getRuntime() throw(Exception);
63     public:
64       virtual void init() { }
65       virtual void fini() { }
66
67       virtual Catalog* loadCatalog(const std::string& sourceKind,const std::string& path);
68       virtual InlineFuncNode* createFuncNode(const std::string& kind,const std::string& name);
69       virtual InlineNode* createScriptNode(const std::string& kind,const std::string& name);
70
71       virtual ServiceNode* createRefNode(const std::string& kind,const std::string& name);
72       virtual ServiceNode* createCompoNode(const std::string& kind,const std::string& name);
73       virtual ServiceInlineNode *createSInlineNode(const std::string& kind, const std::string& name);
74       virtual DataNode* createInDataNode(const std::string& kind,const std::string& name);
75       virtual DataNode* createOutDataNode(const std::string& kind,const std::string& name);
76
77       virtual ComponentInstance* createComponentInstance(const std::string& name,
78                                                          const std::string& kind="");
79       virtual Container *createContainer(const std::string& kind="");
80       virtual Proc* createProc(const std::string& name);
81       virtual Bloc* createBloc(const std::string& name);
82       virtual WhileLoop* createWhileLoop(const std::string& name);
83       virtual ForLoop* createForLoop(const std::string& name);
84       virtual ForEachLoop* createForEachLoop(const std::string& name,TypeCode * type);
85       virtual Switch* createSwitch(const std::string& name);
86
87       
88       virtual InputPort* createInputPort(const std::string& name,
89                                          const std::string& impl,
90                                          Node * node,
91                                          TypeCode * type) = 0;
92
93       virtual OutputPort* createOutputPort(const std::string& name,
94                                            const std::string& impl,
95                                            Node * node,
96                                            TypeCode * type) = 0;
97
98       virtual InputDataStreamPort* createInputDataStreamPort(const std::string& name,
99                                                              Node * node,
100                                                              TypeCode * type);
101       virtual OutputDataStreamPort* createOutputDataStreamPort(const std::string& name,
102                                                                Node * node,
103                                                                TypeCode * type);
104
105       virtual InputPort* adapt(InputPort* source, const std::string& impl, TypeCode * type,
106                                bool init=false) throw (ConversionException) = 0;
107
108       virtual void* convertNeutral(TypeCode * type, Any *data);
109       virtual std::string convertNeutralAsString(TypeCode * type, Any *data);
110
111       virtual void removeRuntime();
112       virtual ~Runtime();
113     public:
114       static const char RUNTIME_ENGINE_INTERACTION_IMPL_NAME[];
115       static  YACS::ENGINE::TypeCode *_tc_double;
116       static  YACS::ENGINE::TypeCode *_tc_int;
117       static  YACS::ENGINE::TypeCode *_tc_bool;
118       static  YACS::ENGINE::TypeCode *_tc_string;
119       static  YACS::ENGINE::TypeCode *_tc_file;
120       virtual void setCatalogLoaderFactory(const std::string& name, CatalogLoader* factory);
121       std::map<std::string,CatalogLoader*> _catalogLoaderFactoryMap;
122       Catalog* getBuiltinCatalog();
123       virtual void addCatalog(Catalog* catalog);
124       virtual TypeCode* getTypeCode(const std::string& name);
125
126     protected:
127       static Runtime* _singleton;
128       Runtime();
129       std::set<std::string> _setOfImplementation;
130       Catalog* _builtinCatalog;
131       std::vector<Catalog*> _catalogs;
132     };
133
134   }
135 }
136 #endif