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