27 #ifndef _SUPERV_COMPONENT_I_HXX_
28 #define _SUPERV_COMPONENT_I_HXX_
31 #include "base_port.hxx"
32 #include "uses_port.hxx"
33 #include "provides_port.hxx"
34 #include "port_factory.hxx"
36 #include "DSC_Exception.hxx"
55 virtual public POA_Engines::Superv_Component
59 PortableServer::POA_ptr poa,
60 PortableServer::ObjectId * contId,
65 PortableServer::POA_ptr poa,
66 Engines::Container_ptr container,
67 const char *instanceName,
68 const char *interfaceName,
145 virtual void add_port(
const char * port_fab_type,
146 const char * port_type,
147 const char * port_name)
148 throw (PortAlreadyDefined, BadFabType, BadType, BadProperty);
159 template <
typename SpecificPortType >
160 SpecificPortType *
add_port(
const char * port_fab_type,
161 const char * port_type,
162 const char * port_name)
163 throw (PortAlreadyDefined, BadFabType, BadType, BadCast, BadProperty);
172 const char* provides_port_name)
173 throw (PortAlreadyDefined, NilPort, BadProperty);
182 const char* uses_port_name)
183 throw (PortAlreadyDefined, NilPort, BadProperty);
192 const char* provides_port_name)
193 throw (PortNotDefined, PortNotConnected);
202 const char* uses_port_name)
203 throw (PortNotDefined, PortNotConnected);
214 const std::string servicename=
"")
const;
222 template <
typename SpecificPortType >
223 SpecificPortType *
get_port(
const char * port_name)
224 throw (PortNotDefined, PortNotConnected, BadCast, UnexpectedState);
262 static long dscTimeOut;
263 static void setTimeOut();
264 void beginService(
const char *serviceName);
269 virtual CORBA::Boolean init_service_with_multiple(
const char* service_name,
270 const Engines::Superv_Component::seq_multiple_param & params)
277 typedef std::map<std::string, port_factory*> factory_map_t;
278 static factory_map_t _factory_map;
282 struct superv_port_t {
283 superv_port_t():u_ref(NULL),p_ref(NULL){};
286 if(u_ref)
delete u_ref;
290 PortableServer::ServantBase* servant=
dynamic_cast<PortableServer::ServantBase*
>(p_ref);
293 PortableServer::POA_var poa =servant->_default_POA();
294 PortableServer::ObjectId_var oid = poa->servant_to_id(servant);
295 poa->deactivate_object(oid);
296 servant->_remove_ref();
306 typedef std::map<std::string, superv_port_t *> superv_ports;
311 superv_ports my_superv_ports;
312 superv_ports::iterator my_superv_ports_it;
317 template <
typename SpecificPortType > SpecificPortType *
319 const char * port_type,
320 const char * port_name)
321 throw (PortAlreadyDefined, BadFabType, BadType, BadCast, BadProperty)
323 assert(port_fab_type);
326 SpecificPortType * retPort;
329 std::cout <<
"---- Superv_Component_i::add_port : Mark 0 ---- " << port_name <<
"----" << std::endl;
332 std::string s_port_type(port_type);
333 if (s_port_type ==
"provides") {
334 provides_port * port = create_provides_data_port(port_fab_type);
335 add_port(port, port_name);
336 retPort =
dynamic_cast<SpecificPortType *
>(port);
337 if ( retPort == NULL ) {
delete port;
338 throw BadCast( LOC(
"Can't cast to asked port type " ));
341 else if (s_port_type ==
"uses") {
342 uses_port * port = create_uses_data_port(port_fab_type);
343 add_port(port, port_name);
345 std::cout <<
"---- Superv_Component_i::add_port : Mark 1 ---- " << port <<
"----" << std::endl;
346 std::cout <<
"---- Superv_Component_i::add_port : Mark 1 ---- get_repository_id()" << port->
get_repository_id() << std::endl;
348 retPort =
dynamic_cast<SpecificPortType *
>(port);
350 std::cout <<
"---- Superv_Component_i::add_port : Mark 2 ---- " << retPort <<
"----" << std::endl;
352 if ( retPort == NULL ) {
delete port;
353 throw BadCast( LOC(
"Can't cast to asked port type " ));
357 throw BadType(LOC(
OSS()<<
"port_type must be either 'provides' either 'uses' not "
364 template <
typename SpecificPortType > SpecificPortType *
370 SpecificPortType * retPort;
373 my_superv_ports_it = my_superv_ports.find(port_name);
374 if (my_superv_ports_it == my_superv_ports.end())
379 superv_port_t * superv_port = my_superv_ports[port_name];
381 if ( superv_port->p_ref != NULL ) {
382 port = superv_port->p_ref;
385 else if ( superv_port->u_ref != NULL ) {
386 port = superv_port->u_ref;
390 throw UnexpectedState( LOC(
OSS()<<
"Internal Error superv_port struct is inconsistent "));
395 << port_name <<
" does not exist."));
398 <<
" is not connected."));
401 retPort =
dynamic_cast<SpecificPortType *
>(port);
402 if ( retPort == NULL ) {
403 throw BadCast( LOC(
"Can't cast to required port type " ));