Salome HOME
PR: merge from BR_DATACONV_PR tag "mergeto_trunk_25oct06"
[modules/yacs.git] / src / engine / Runtime.cxx
1 #include "Runtime.hxx"
2
3 #include<cassert>
4
5 using namespace YACS::ENGINE;
6 using namespace std;
7
8
9 Runtime* Runtime::_singleton = 0;
10
11 void Runtime::setRuntime() // singleton creation (not thread safe!)
12 {
13   if (! Runtime::_singleton) Runtime::_singleton = new Runtime();
14 }
15
16 // singleton creation must be done before by a derived class
17
18 Runtime* YACS::ENGINE::getRuntime() throw(Exception)
19 {
20   if ( !  Runtime::_singleton )
21     throw Exception("Runtime is not yet initialized");
22   return Runtime::_singleton;
23 }
24
25 ElementaryNode* Runtime::createNode(string implementation,
26                                     string name) throw(Exception)
27 {
28   return new TestElemNode(name);
29 }
30       
31 InputPort* Runtime::createInputPort(const string& name,
32                                     const string& impl,
33                                     Node * node,
34                                     TypeCode * type)
35 {
36   return new InputPort(name, node, type);
37 }
38
39 OutputPort* Runtime::createOutputPort(const string& name,
40                                       const string& impl,
41                                       Node * node,
42                                       TypeCode * type)
43 {
44   return new OutputPort(name, node, type);
45 }
46
47 InputPort* Runtime::adapt(const string& imp_source, 
48                           InputPort* source,
49                           const string& impl,TypeCode * type)
50   throw (ConversionException)
51 {
52   return source;
53 }