1 // Copyright (C) 2006-2020 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 std::vector< std::pair<std::string,int> > RuntimeForEngineIntegrationTest::getCatalogOfComputeNodes() const
39 throw Exception("RuntimeForEngineIntegrationTest not implemented !");
42 ElementaryNode* RuntimeForEngineIntegrationTest::createNode(const std::string& implementation, const std::string& name) throw (YACS::Exception)
44 if (implementation == ToyNode::MY_IMPL_NAME)
45 return new ToyNode(name);
46 else if(implementation == LimitNode::MY_IMPL_NAME)
47 return new LimitNode(name);
48 std::string what="RuntimeForEngineIntegrationTest does not handle this implementation: " + implementation;
49 throw YACS::Exception(what);
52 InputPort* RuntimeForEngineIntegrationTest::createInputPort(const std::string& name, const std::string& impl, Node * node, TypeCode * type)
54 if(impl == ToyNode::MY_IMPL_NAME)
56 if(type->kind()!=Double)
57 throw Exception("Invalid type");
58 return new InputToyPort(name, node);
60 else if(impl == LimitNode::MY_IMPL_NAME)
61 throw Exception("InputPort creation not allowed for LimitNode");
62 std::ostringstream msg;
63 msg << "Cannot create " << impl << " OutputPort" ;
64 throw YACS::Exception(msg.str());
67 OutputPort* RuntimeForEngineIntegrationTest::createOutputPort(const std::string& name, const std::string& impl, Node * node, TypeCode * type)
69 if(impl == ToyNode::MY_IMPL_NAME)
71 if(type->kind()!=Double && type->kind()!=Int)
72 throw Exception("Invalid type");
73 return new OutputToyPort(name, node, type);
75 else if(impl == LimitNode::MY_IMPL_NAME)
76 throw Exception("OutputPort creation not allowed for LimitNode");
77 std::stringstream msg;
78 msg << "Cannot create " << impl << " OutputPort" ;
79 throw Exception(msg.str());
82 InputPort* RuntimeForEngineIntegrationTest::adapt(InputPort* source, const std::string& impl,TypeCode * type,bool init) throw (ConversionException)
84 return new ProxyPort(source);
87 InputPort* RuntimeForEngineIntegrationTest::adapt(InPropertyPort* source, const std::string& impl, TypeCode * type, bool init) throw (ConversionException)
89 return adapt((InputPort *)source, impl, type, init);
92 ComponentInstance* RuntimeForEngineIntegrationTest::createComponentInstance(const std::string& name, const std::string& kind)
94 if(kind==ToyNode1S::KIND)
95 return new ComponentInstanceTest1(name);
96 else if(kind==ToyNode2S::KIND)
97 return new ComponentInstanceTest2(name);
100 std::string msg("RuntimeForEngineIntegrationTest::createComponentInstance : Unable to crate component with kind \"");
101 msg+=kind; msg+="\"";
102 throw Exception(msg);