]> SALOME platform Git repositories - modules/yacs.git/blob - src/engine/Test/RuntimeForEngineTest.cxx
Salome HOME
copy tag mergefrom_BR_V0_1_CC_Salome_04oct07
[modules/yacs.git] / src / engine / Test / RuntimeForEngineTest.cxx
1 #include "RuntimeForEngineTest.hxx"
2 #include <iostream>
3 #include <sstream>
4
5 using namespace YACS::ENGINE;
6 using namespace std;
7
8 TestElemNode::TestElemNode(const TestElemNode& other, ComposedNode *father):ElementaryNode(other,father)
9 {
10 }
11
12 Node *TestElemNode::simpleClone(ComposedNode *father, bool editionOnly) const
13 {
14   return new TestElemNode(*this,father);
15 }
16
17 TestElemInputPort::TestElemInputPort(const std::string& name, Node *node, TypeCode* type):InputPort(name,node,type),DataPort(name,node,type),Port(node)
18 {
19 }
20
21 TestElemInputPort::TestElemInputPort(const TestElemInputPort& other, Node *newHelder):InputPort(other,newHelder),DataPort(other,newHelder),Port(other,newHelder)
22 {
23 }
24
25 void TestElemInputPort::put(const void *data) throw(ConversionException)
26 {
27   cerr << _name << endl;
28   stringstream msg;
29   msg << "Not implemented (" << __FILE__ << ":" << __LINE__ << ")";
30   throw Exception(msg.str());
31 }
32
33 InputPort *TestElemInputPort::clone(Node *newHelder) const
34 {
35   return new TestElemInputPort(*this,newHelder);
36 }
37
38 void *TestElemInputPort::get() const throw(Exception)
39 {
40   stringstream msg;
41   msg << "Not implemented (" << __FILE__ << ":" << __LINE__ << ")";
42   throw Exception(msg.str());
43 }
44
45 void TestElemInputPort::exRestoreInit()
46 {
47   if(!_initValue)
48     return;
49   if(_value)
50     _value->decrRef();
51   _value=_initValue;
52   _value->incrRef();
53 }
54
55 void TestElemInputPort::exSaveInit()
56 {
57   if(_initValue)
58     _initValue->decrRef();
59   _initValue=_value;
60   _initValue->incrRef();
61 }
62
63 TestElemOutputPort::TestElemOutputPort(const std::string& name, Node *node, TypeCode* type):OutputPort(name,node,type),DataPort(name,node,type),Port(node)
64 {
65 }
66
67 TestElemOutputPort::TestElemOutputPort(const TestElemOutputPort& other, Node *newHelder):OutputPort(other,newHelder),DataPort(other,newHelder),Port(other,newHelder)
68 {
69 }
70
71 OutputPort *TestElemOutputPort::clone(Node *newHelder) const
72 {
73   return new TestElemOutputPort(*this,newHelder);
74 }
75
76 void TestElemOutputPort::put(const void *data) throw(ConversionException)
77 {
78   cerr << _name << endl;
79   stringstream msg;
80   msg << "Not implemented (" << __FILE__ << ":" << __LINE__ << ")";
81   throw Exception(msg.str());
82 }
83
84 void RuntimeForEngineTest::setRuntime()
85 {
86   if (! Runtime::_singleton)
87     Runtime::_singleton = new RuntimeForEngineTest;
88 }
89
90 ElementaryNode* RuntimeForEngineTest::createNode(const string& implementation, const string& name) throw(Exception)
91 {
92   return new TestElemNode(name);
93 }
94
95 InputPort* RuntimeForEngineTest::createInputPort(const string& name, const string& impl, Node * node, TypeCode * type)
96 {
97   return new TestElemInputPort(name, node, type);
98 }
99
100 OutputPort* RuntimeForEngineTest::createOutputPort(const string& name, const string& impl, Node * node, TypeCode * type)
101 {
102   return new TestElemOutputPort(name, node, type);
103 }
104
105 InputPort* RuntimeForEngineTest::adapt(InputPort* source, const string& impl,TypeCode * type) throw (ConversionException)
106 {
107   return new ProxyPort(source);
108 }