Salome HOME
updated copyright message
[modules/yacs.git] / src / engine / Test / RuntimeForEngineTest.cxx
1 // Copyright (C) 2006-2023  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 #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::releaseData()
45 {
46   stringstream msg;
47   msg << "Not implemented (" << __FILE__ << ":" << __LINE__ << ")";
48   throw Exception(msg.str());
49 }
50
51 void TestElemInputPort::put(const void *data)
52 {
53   cerr << _name << endl;
54   stringstream msg;
55   msg << "Not implemented (" << __FILE__ << ":" << __LINE__ << ")";
56   throw Exception(msg.str());
57 }
58
59 InputPort *TestElemInputPort::clone(Node *newHelder) const
60 {
61   return new TestElemInputPort(*this,newHelder);
62 }
63
64 void *TestElemInputPort::get() const
65 {
66   stringstream msg;
67   msg << "Not implemented (" << __FILE__ << ":" << __LINE__ << ")";
68   throw Exception(msg.str());
69 }
70
71 void TestElemInputPort::exRestoreInit()
72 {
73   if(!_initValue)
74     return;
75   if(_value)
76     _value->decrRef();
77   _value=_initValue;
78   _value->incrRef();
79 }
80
81 void TestElemInputPort::exSaveInit()
82 {
83   if(_initValue)
84     _initValue->decrRef();
85   _initValue=_value;
86   _initValue->incrRef();
87 }
88
89 TestElemOutputPort::TestElemOutputPort(const std::string& name, Node *node, TypeCode* type):OutputPort(name,node,type),DataPort(name,node,type),Port(node)
90 {
91 }
92
93 TestElemOutputPort::TestElemOutputPort(const TestElemOutputPort& other, Node *newHelder):OutputPort(other,newHelder),DataPort(other,newHelder),Port(other,newHelder)
94 {
95 }
96
97 OutputPort *TestElemOutputPort::clone(Node *newHelder) const
98 {
99   return new TestElemOutputPort(*this,newHelder);
100 }
101
102 void TestElemOutputPort::put(const void *data)
103 {
104   cerr << _name << endl;
105   stringstream msg;
106   msg << "Not implemented (" << __FILE__ << ":" << __LINE__ << ")";
107   throw Exception(msg.str());
108 }
109
110 void RuntimeForEngineTest::setRuntime()
111 {
112   if (! Runtime::_singleton)
113     Runtime::_singleton = new RuntimeForEngineTest;
114 }
115
116 std::vector< std::pair<std::string,int> > RuntimeForEngineTest::getCatalogOfComputeNodes() const
117 {
118   return std::vector< std::pair<std::string,int> >();
119 }
120
121 ElementaryNode* RuntimeForEngineTest::createNode(const string& implementation, const string& name)
122 {
123   return new TestElemNode(name);
124 }
125
126 InputPort* RuntimeForEngineTest::createInputPort(const string& name, const string& impl, Node * node, TypeCode * type)
127 {
128   return new TestElemInputPort(name, node, type);
129 }
130
131 OutputPort* RuntimeForEngineTest::createOutputPort(const string& name, const string& impl, Node * node, TypeCode * type)
132 {
133   return new TestElemOutputPort(name, node, type);
134 }
135
136 InputPort* RuntimeForEngineTest::adapt(InputPort* source, const string& impl,TypeCode * type,bool init)
137 {
138   return new ProxyPort(source);
139 }
140
141 InputPort* RuntimeForEngineTest::adapt(InPropertyPort* source, const std::string& impl, TypeCode * type, bool init)
142 {
143   return adapt((InputPort *)source,impl,type,init);
144 }