1 // Copyright (C) 2006-2013 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
20 #include "RuntimeForEngineIntegrationTest.hxx"
21 #include "ComponentInstanceTest.hxx"
22 #include "ToyNode.hxx"
23 #include "TypeCode.hxx"
27 using namespace YACS::ENGINE;
29 void RuntimeForEngineIntegrationTest::setRuntime()
31 if (! Runtime::_singleton)
32 Runtime::_singleton = new RuntimeForEngineIntegrationTest;
35 ElementaryNode* RuntimeForEngineIntegrationTest::createNode(const string& implementation, const string& name) throw(Exception)
37 if (implementation == ToyNode::MY_IMPL_NAME)
38 return new ToyNode(name);
39 else if(implementation == LimitNode::MY_IMPL_NAME)
40 return new LimitNode(name);
41 string what="RuntimeForEngineIntegrationTest does not handle this implementation: " + implementation;
42 throw Exception(what);
45 InputPort* RuntimeForEngineIntegrationTest::createInputPort(const string& name, const string& impl, Node * node, TypeCode * type)
47 if(impl == ToyNode::MY_IMPL_NAME)
49 if(type->kind()!=Double)
50 throw Exception("Invalid type");
51 return new InputToyPort(name, node);
53 else if(impl == LimitNode::MY_IMPL_NAME)
54 throw Exception("InputPort creation not allowed for LimitNode");
56 msg << "Cannot create " << impl << " OutputPort" ;
57 throw Exception(msg.str());
60 OutputPort* RuntimeForEngineIntegrationTest::createOutputPort(const string& name, const string& impl, Node * node, TypeCode * type)
62 if(impl == ToyNode::MY_IMPL_NAME)
64 if(type->kind()!=Double && type->kind()!=Int)
65 throw Exception("Invalid type");
66 return new OutputToyPort(name, node, type);
68 else if(impl == LimitNode::MY_IMPL_NAME)
69 throw Exception("OutputPort creation not allowed for LimitNode");
71 msg << "Cannot create " << impl << " OutputPort" ;
72 throw Exception(msg.str());
75 InputPort* RuntimeForEngineIntegrationTest::adapt(InputPort* source, const string& impl,TypeCode * type,bool init) throw (ConversionException)
77 return new ProxyPort(source);
80 InputPort* RuntimeForEngineIntegrationTest::adapt(InPropertyPort* source, const std::string& impl, TypeCode * type, bool init) throw (ConversionException)
82 return adapt((InputPort *)source, impl, type, init);
85 ComponentInstance* RuntimeForEngineIntegrationTest::createComponentInstance(const std::string& name, const std::string& kind)
87 if(kind==ToyNode1S::KIND)
88 return new ComponentInstanceTest1(name);
89 else if(kind==ToyNode2S::KIND)
90 return new ComponentInstanceTest2(name);
93 string msg("RuntimeForEngineIntegrationTest::createComponentInstance : Unable to crate component with kind \"");