1 // Copyright (C) 2006-2008 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "RuntimeForEngineIntegrationTest.hxx"
20 #include "ComponentInstanceTest.hxx"
21 #include "ToyNode.hxx"
22 #include "TypeCode.hxx"
26 using namespace YACS::ENGINE;
28 void RuntimeForEngineIntegrationTest::setRuntime()
30 if (! Runtime::_singleton)
31 Runtime::_singleton = new RuntimeForEngineIntegrationTest;
34 ElementaryNode* RuntimeForEngineIntegrationTest::createNode(const string& implementation, const string& name) throw(Exception)
36 if (implementation == ToyNode::MY_IMPL_NAME)
37 return new ToyNode(name);
38 else if(implementation == LimitNode::MY_IMPL_NAME)
39 return new LimitNode(name);
40 string what="RuntimeForEngineIntegrationTest does not handle this implementation: " + implementation;
41 throw Exception(what);
44 InputPort* RuntimeForEngineIntegrationTest::createInputPort(const string& name, const string& impl, Node * node, TypeCode * type)
46 if(impl == ToyNode::MY_IMPL_NAME)
48 if(type->kind()!=Double)
49 throw Exception("Invalid type");
50 return new InputToyPort(name, node);
52 else if(impl == LimitNode::MY_IMPL_NAME)
53 throw Exception("InputPort creation not allowed for LimitNode");
55 msg << "Cannot create " << impl << " OutputPort" ;
56 throw Exception(msg.str());
59 OutputPort* RuntimeForEngineIntegrationTest::createOutputPort(const string& name, const string& impl, Node * node, TypeCode * type)
61 if(impl == ToyNode::MY_IMPL_NAME)
63 if(type->kind()!=Double && type->kind()!=Int)
64 throw Exception("Invalid type");
65 return new OutputToyPort(name, node, type);
67 else if(impl == LimitNode::MY_IMPL_NAME)
68 throw Exception("OutputPort creation not allowed for LimitNode");
70 msg << "Cannot create " << impl << " OutputPort" ;
71 throw Exception(msg.str());
74 InputPort* RuntimeForEngineIntegrationTest::adapt(InputPort* source, const string& impl,TypeCode * type,bool init) throw (ConversionException)
76 return new ProxyPort(source);
79 ComponentInstance* RuntimeForEngineIntegrationTest::createComponentInstance(const std::string& name, const std::string& kind)
81 if(kind==ToyNode1S::KIND)
82 return new ComponentInstanceTest1(name);
83 else if(kind==ToyNode2S::KIND)
84 return new ComponentInstanceTest2(name);
87 string msg("RuntimeForEngineIntegrationTest::createComponentInstance : Unable to crate component with kind \"");