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