1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include "Calcium.hxx"
23 #include "CalciumInterface.hxx"
31 PySupervCompo::PySupervCompo( CORBA::ORB_ptr orb,
32 PortableServer::POA_ptr poa,
33 Engines::Container_ptr contain,
34 const char *instanceName,
35 const char *interfaceName,
37 Superv_Component_i(orb, poa,contain, instanceName, interfaceName,false,false)
41 PySupervCompo::~PySupervCompo()
50 throw CalciumException(err,LOC("Abort coupling"));
53 void setDependency(provides_port * port,char* type,CalciumTypes::DependencyType depend)
55 if(std::string(type)=="CALCIUM_real")
57 dynamic_cast<calcium_real_port_provides *>(port)->setDependencyType(depend);
59 else if(std::string(type)=="CALCIUM_double")
61 dynamic_cast<calcium_double_port_provides *>(port)->setDependencyType(depend);
63 else if(std::string(type)=="CALCIUM_integer")
65 dynamic_cast<calcium_integer_port_provides *>(port)->setDependencyType(depend);
67 else if(std::string(type)=="CALCIUM_string")
69 dynamic_cast<calcium_string_port_provides *>(port)->setDependencyType(depend);
71 else if(std::string(type)=="CALCIUM_logical")
73 dynamic_cast<calcium_logical_port_provides *>(port)->setDependencyType(depend);
75 else if(std::string(type)=="CALCIUM_complex")
77 dynamic_cast<calcium_complex_port_provides *>(port)->setDependencyType(depend);
81 std::cerr << "unknown type:" << std::endl;
85 void create_calcium_port(Superv_Component_i* compo,char* name,char* type,char *mode,char* depend)
88 std::cerr << "create_calcium_port: " << name << " " << type << " " << mode << " " << depend << std::endl;
91 if(std::string(mode) == "IN")
93 provides_port * port ;
97 port = compo->create_provides_data_port(type);
98 compo->add_port(port, name);
99 if(std::string(depend) == "I")
100 setDependency(port,type,CalciumTypes::ITERATION_DEPENDENCY);
101 else if(std::string(depend) == "T")
102 setDependency(port,type,CalciumTypes::TIME_DEPENDENCY);
105 std::cerr << "create_calcium_port:unknown dependency: " << depend << std::endl;
108 catch(const Superv_Component_i::PortAlreadyDefined& ex)
110 //Port already defined : we use the old one
112 std::cerr << "create_calcium_port: " << ex.what() << std::endl;
116 std::cerr << "create_calcium_port: unknown exception" << std::endl;
119 else if(std::string(mode) == "OUT")
124 uport = compo->create_uses_data_port(type);
125 compo->add_port(uport, name);
127 catch(const Superv_Component_i::PortAlreadyDefined& ex)
129 //Port already defined : we use the old one
131 std::cerr << "create_calcium_port: " << ex.what() << std::endl;
135 std::cerr << "create_calcium_port: unknown exception" << std::endl;
141 std::cerr << "create_calcium_port:Unknown mode: " << mode << std::endl;