1 // Copyright (C) 2006-2015 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, or (at your option) any later version.
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 "Exception.hxx"
23 #include "ToyNode.hxx"
24 #include "TypeCode.hxx"
29 using namespace YACS::ENGINE;
31 void RuntimeForEngineIntegrationTest::setRuntime()
33 if (! Runtime::_singleton)
34 Runtime::_singleton = new RuntimeForEngineIntegrationTest;
37 ElementaryNode* RuntimeForEngineIntegrationTest::createNode(const std::string& implementation, const std::string& name) throw (YACS::Exception)
39 if (implementation == ToyNode::MY_IMPL_NAME)
40 return new ToyNode(name);
41 else if(implementation == LimitNode::MY_IMPL_NAME)
42 return new LimitNode(name);
43 std::string what="RuntimeForEngineIntegrationTest does not handle this implementation: " + implementation;
44 throw YACS::Exception(what);
47 InputPort* RuntimeForEngineIntegrationTest::createInputPort(const std::string& name, const std::string& impl, Node * node, TypeCode * type)
49 if(impl == ToyNode::MY_IMPL_NAME)
51 if(type->kind()!=Double)
52 throw Exception("Invalid type");
53 return new InputToyPort(name, node);
55 else if(impl == LimitNode::MY_IMPL_NAME)
56 throw Exception("InputPort creation not allowed for LimitNode");
57 std::ostringstream msg;
58 msg << "Cannot create " << impl << " OutputPort" ;
59 throw YACS::Exception(msg.str());
62 OutputPort* RuntimeForEngineIntegrationTest::createOutputPort(const std::string& name, const std::string& impl, Node * node, TypeCode * type)
64 if(impl == ToyNode::MY_IMPL_NAME)
66 if(type->kind()!=Double && type->kind()!=Int)
67 throw Exception("Invalid type");
68 return new OutputToyPort(name, node, type);
70 else if(impl == LimitNode::MY_IMPL_NAME)
71 throw Exception("OutputPort creation not allowed for LimitNode");
72 std::stringstream msg;
73 msg << "Cannot create " << impl << " OutputPort" ;
74 throw Exception(msg.str());
77 InputPort* RuntimeForEngineIntegrationTest::adapt(InputPort* source, const std::string& impl,TypeCode * type,bool init) throw (ConversionException)
79 return new ProxyPort(source);
82 InputPort* RuntimeForEngineIntegrationTest::adapt(InPropertyPort* source, const std::string& impl, TypeCode * type, bool init) throw (ConversionException)
84 return adapt((InputPort *)source, impl, type, init);
87 ComponentInstance* RuntimeForEngineIntegrationTest::createComponentInstance(const std::string& name, const std::string& kind)
89 if(kind==ToyNode1S::KIND)
90 return new ComponentInstanceTest1(name);
91 else if(kind==ToyNode2S::KIND)
92 return new ComponentInstanceTest2(name);
95 std::string msg("RuntimeForEngineIntegrationTest::createComponentInstance : Unable to crate component with kind \"");