1 // Copyright (C) 2006-2019 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 std::vector< std::pair<std::string,int> > result(1);
40 std::pair<std::string,int> localhost;
41 localhost.first = "localhost";
43 result[0] = localhost;
45 // throw Exception("RuntimeForEngineTest::getCatalogOfComputeNodes : not implemented !");
48 ElementaryNode* RuntimeForEngineIntegrationTest::createNode(const std::string& implementation, const std::string& name) throw (YACS::Exception)
50 if (implementation == ToyNode::MY_IMPL_NAME)
51 return new ToyNode(name);
52 else if(implementation == LimitNode::MY_IMPL_NAME)
53 return new LimitNode(name);
54 std::string what="RuntimeForEngineIntegrationTest does not handle this implementation: " + implementation;
55 throw YACS::Exception(what);
58 InputPort* RuntimeForEngineIntegrationTest::createInputPort(const std::string& name, const std::string& impl, Node * node, TypeCode * type)
60 if(impl == ToyNode::MY_IMPL_NAME)
62 if(type->kind()!=Double)
63 throw Exception("Invalid type");
64 return new InputToyPort(name, node);
66 else if(impl == LimitNode::MY_IMPL_NAME)
67 throw Exception("InputPort creation not allowed for LimitNode");
68 std::ostringstream msg;
69 msg << "Cannot create " << impl << " OutputPort" ;
70 throw YACS::Exception(msg.str());
73 OutputPort* RuntimeForEngineIntegrationTest::createOutputPort(const std::string& name, const std::string& impl, Node * node, TypeCode * type)
75 if(impl == ToyNode::MY_IMPL_NAME)
77 if(type->kind()!=Double && type->kind()!=Int)
78 throw Exception("Invalid type");
79 return new OutputToyPort(name, node, type);
81 else if(impl == LimitNode::MY_IMPL_NAME)
82 throw Exception("OutputPort creation not allowed for LimitNode");
83 std::stringstream msg;
84 msg << "Cannot create " << impl << " OutputPort" ;
85 throw Exception(msg.str());
88 InputPort* RuntimeForEngineIntegrationTest::adapt(InputPort* source, const std::string& impl,TypeCode * type,bool init) throw (ConversionException)
90 return new ProxyPort(source);
93 InputPort* RuntimeForEngineIntegrationTest::adapt(InPropertyPort* source, const std::string& impl, TypeCode * type, bool init) throw (ConversionException)
95 return adapt((InputPort *)source, impl, type, init);
98 ComponentInstance* RuntimeForEngineIntegrationTest::createComponentInstance(const std::string& name, const std::string& kind)
100 if(kind==ToyNode1S::KIND)
101 return new ComponentInstanceTest1(name);
102 else if(kind==ToyNode2S::KIND)
103 return new ComponentInstanceTest2(name);
106 std::string msg("RuntimeForEngineIntegrationTest::createComponentInstance : Unable to crate component with kind \"");
107 msg+=kind; msg+="\"";
108 throw Exception(msg);