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