Version: 9.15.0
Runtime.hxx
Go to the documentation of this file.
1 // Copyright (C) 2006-2025 CEA, EDF
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() ;
38 
39  class Any;
40  class InputPort;
41  class OutputPort;
42  class InPropertyPort;
43  class ForLoop;
44  class ForEachLoop;
45  class ForEachLoopDyn;
46  class OptimizerLoop;
47  class WhileLoop;
48  class Switch;
49  class InlineNode;
50  class InlineFuncNode;
51  class ServiceNode;
52  class DataNode;
53  class Container;
54  class ServiceInlineNode;
55  class ComponentInstance;
56  class Proc;
57  class Bloc;
58  class ElementaryNode;
59  class Node;
60  class TypeCode;
61  class TypeCodeStruct;
62  class TypeCodeObjref;
63  class InputDataStreamPort;
64  class OutputDataStreamPort;
65  class Catalog;
66  class CatalogLoader;
67 
69  {
70  friend Runtime* getRuntime() ;
71  public:
72  virtual void init() { }
73  virtual void fini() { }
74  virtual std::vector< std::pair<std::string,int> > getCatalogOfComputeNodes() const = 0;
75  virtual Catalog* loadCatalog(const std::string& sourceKind,const std::string& path);
76  virtual InlineFuncNode* createFuncNode(const std::string& kind,const std::string& name);
77  virtual InlineNode* createScriptNode(const std::string& kind,const std::string& name);
78 
79  virtual ServiceNode* createRefNode(const std::string& kind,const std::string& name);
80  virtual ServiceNode* createCompoNode(const std::string& kind,const std::string& name);
81  virtual ServiceInlineNode *createSInlineNode(const std::string& kind, const std::string& name);
82  virtual DataNode* createInDataNode(const std::string& kind,const std::string& name);
83  virtual DataNode* createOutDataNode(const std::string& kind,const std::string& name);
84 
85  virtual ComponentInstance* createComponentInstance(const std::string& name,
86  const std::string& kind="");
87  virtual Container *createContainer(const std::string& kind="");
88  virtual Proc* createProc(const std::string& name);
89  virtual Bloc* createBloc(const std::string& name);
90  virtual WhileLoop* createWhileLoop(const std::string& name);
91  virtual ForLoop* createForLoop(const std::string& name);
92  virtual ForEachLoop* createForEachLoop(const std::string& name,TypeCode * type);
93  virtual ForEachLoopDyn* createForEachLoopDyn(const std::string& name,TypeCode * type);
94  virtual OptimizerLoop* createOptimizerLoop(const std::string& name,const std::string& algLib,
95  const std::string& factoryName,bool algInitOnFile,
96  const std::string& kind="", Proc * procForTypes = NULL);
97  virtual Switch* createSwitch(const std::string& name);
98 
99  virtual TypeCode * createInterfaceTc(const std::string& id, const std::string& name,
100  std::list<TypeCodeObjref *> ltc);
101  virtual TypeCode * createSequenceTc(const std::string& id, const std::string& name, TypeCode *content);
102  virtual TypeCodeStruct * createStructTc(const std::string& id, const std::string& name);
103 
104  virtual InputPort* createInputPort(const std::string& name,
105  const std::string& impl,
106  Node * node,
107  TypeCode * type) = 0;
108 
109  virtual OutputPort* createOutputPort(const std::string& name,
110  const std::string& impl,
111  Node * node,
112  TypeCode * type) = 0;
113 
114  virtual InputDataStreamPort* createInputDataStreamPort(const std::string& name,
115  Node * node,
116  TypeCode * type);
117  virtual OutputDataStreamPort* createOutputDataStreamPort(const std::string& name,
118  Node * node,
119  TypeCode * type);
120 
121  virtual InputPort* adapt(InputPort* source, const std::string& impl, TypeCode * type,
122  bool init=false) = 0;
123 
124  virtual InputPort* adapt(InPropertyPort* source,
125  const std::string& impl,
126  TypeCode * type,
127  bool init=false) = 0;
128 
129  virtual void* convertNeutral(TypeCode * type, Any *data);
130  virtual std::string convertNeutralAsString(TypeCode * type, Any *data);
131 
132  virtual void removeRuntime();
133  virtual ~Runtime();
134  public:
135  static const char RUNTIME_ENGINE_INTERACTION_IMPL_NAME[];
143  virtual void setCatalogLoaderFactory(const std::string& name, CatalogLoader* factory);
144  std::map<std::string,CatalogLoader*> _catalogLoaderFactoryMap;
145  Catalog* getBuiltinCatalog();
146  virtual void addCatalog(Catalog* catalog);
147  virtual TypeCode* getTypeCode(const std::string& name);
148 
149  protected:
151  Runtime();
152  std::set<std::string> _setOfImplementation;
154  std::vector<Catalog*> _catalogs;
155  };
156 
157  }
158 }
159 #endif
#define YACSLIBENGINE_EXPORT
: Interface for management of storage of data formated dynamically in its TypeCode....
Definition: Any.hxx:79
Composed node to group elementary and composed nodes.
Definition: Bloc.hxx:36
class for YACS catalog loader.
Definition: Catalog.hxx:63
class for YACS catalogs.
Definition: Catalog.hxx:42
Base class for all component instances.
Class for data parameters specification.
Definition: DataNode.hxx:38
Loop node for parametric calculation.
Class for for loop node.
Definition: ForLoop.hxx:33
class for Input Property Ports
Class for calculation node (function) inlined (and executed) in the schema.
Definition: InlineNode.hxx:93
Class for calculation node (script) inlined (and executed) in the schema.
Definition: InlineNode.hxx:44
Base class for Input Ports.
Definition: InputPort.hxx:44
Base class for all nodes.
Definition: Node.hxx:70
class to build optimization loops
Base class for all schema objects.
Definition: Proc.hxx:44
virtual InputPort * createInputPort(const std::string &name, const std::string &impl, Node *node, TypeCode *type)=0
virtual void init()
Definition: Runtime.hxx:72
virtual InputPort * adapt(InPropertyPort *source, const std::string &impl, TypeCode *type, bool init=false)=0
virtual OutputPort * createOutputPort(const std::string &name, const std::string &impl, Node *node, TypeCode *type)=0
static YACS::ENGINE::TypeCode * _tc_double
Definition: Runtime.hxx:136
virtual std::vector< std::pair< std::string, int > > getCatalogOfComputeNodes() const =0
static YACS::ENGINE::TypeCode * _tc_bool
Definition: Runtime.hxx:138
Catalog * _builtinCatalog
Definition: Runtime.hxx:153
friend Runtime * getRuntime()
virtual InputPort * adapt(InputPort *source, const std::string &impl, TypeCode *type, bool init=false)=0
static YACS::ENGINE::TypeCode * _tc_file
Definition: Runtime.hxx:140
std::vector< Catalog * > _catalogs
Definition: Runtime.hxx:154
static Runtime * _singleton
Definition: Runtime.hxx:150
std::set< std::string > _setOfImplementation
Definition: Runtime.hxx:152
virtual void fini()
Definition: Runtime.hxx:73
static YACS::ENGINE::TypeCode * _tc_propvec
Definition: Runtime.hxx:142
std::map< std::string, CatalogLoader * > _catalogLoaderFactoryMap
Definition: Runtime.hxx:144
static YACS::ENGINE::TypeCode * _tc_int
Definition: Runtime.hxx:137
static YACS::ENGINE::TypeCode * _tc_stringpair
Definition: Runtime.hxx:141
static YACS::ENGINE::TypeCode * _tc_string
Definition: Runtime.hxx:139
Class for calculation node associated with a component service.
Definition: ServiceNode.hxx:35
Control node that emulates the C switch.
Definition: Switch.hxx:85
Class for struct type.
Definition: TypeCode.hxx:228
Base class for all type objects.
Definition: TypeCode.hxx:68
Class for a while loop.
Definition: WhileLoop.hxx:39
YACSLIBENGINE_EXPORT Runtime * getRuntime()
Definition: Runtime.cxx:61