Back to index

salome-kernel  6.5.0
Public Member Functions | Static Public Member Functions | Static Public Attributes
PySupervCompo Class Reference

#include <Calcium.hxx>

Inheritance diagram for PySupervCompo:
Inheritance graph
[legend]
Collaboration diagram for PySupervCompo:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 PySupervCompo (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, Engines::Container_ptr contain, const char *instanceName, const char *interfaceName, bool notif=false)
virtual ~PySupervCompo ()
CORBA::Boolean init_service (const char *service_name)
 DSC_EXCEPTION (BadFabType)
 DSC_EXCEPTION (BadType)
 DSC_EXCEPTION (BadCast)
 DSC_EXCEPTION (UnexpectedState)
 DSC_EXCEPTION (PortAlreadyDefined)
 DSC_EXCEPTION (PortNotDefined)
 DSC_EXCEPTION (PortNotConnected)
 DSC_EXCEPTION (NilPort)
 DSC_EXCEPTION (BadProperty)
virtual provides_portcreate_provides_control_port ()
virtual provides_portcreate_provides_data_and_control_port (const char *port_type)
virtual uses_portcreate_uses_control_port ()
virtual uses_portcreate_uses_data_and_control_port (const char *port_type)
virtual provides_portcreate_provides_data_port (const std::string &port_fab_type) throw (BadFabType)
 This method permits to create a provides port provided by the platform.
virtual uses_portcreate_uses_data_port (const std::string &port_fab_type) throw (BadFabType)
 This method permits to create a uses port provided by the platform.
virtual void add_port (const char *port_fab_type, const char *port_type, const char *port_name) throw (PortAlreadyDefined, BadFabType, BadType, BadProperty)
 Adds a port to the component.
template<typename SpecificPortType >
SpecificPortType * add_port (const char *port_fab_type, const char *port_type, const char *port_name) throw (PortAlreadyDefined, BadFabType, BadType, BadCast, BadProperty)
 Adds a port to the component.
virtual void add_port (provides_port *port, const char *provides_port_name) throw (PortAlreadyDefined, NilPort, BadProperty)
 Adds a created provides port to the component.
virtual void add_port (uses_port *port, const char *uses_port_name) throw (PortAlreadyDefined, NilPort, BadProperty)
 Adds a created uses port to the component.
virtual void get_port (provides_port *&port, const char *provides_port_name) throw (PortNotDefined, PortNotConnected)
 Gets the provides port already added in the component.
virtual void get_port (uses_port *&port, const char *uses_port_name) throw (PortNotDefined, PortNotConnected)
 Gets the uses port already added in the component.
template<typename SpecificPortType >
SpecificPortType * get_port (const char *port_name) throw (PortNotDefined, PortNotConnected, BadCast, UnexpectedState)
 Gets a port already added in the component.
virtual void get_uses_port_names (std::vector< std::string > &port_names, const std::string servicename="") const
 Gets the list of the ports of a service.
virtual void provides_port_changed (const char *provides_port_name, int connection_nbr, const Engines::DSC::Message message)
virtual void uses_port_changed (const char *uses_port_name, Engines::DSC::uses_port *new_uses_port, const Engines::DSC::Message message)
virtual port_factoryget_factory (const std::string &factory_name)
 Get a factory from the component.
void beginService (const char *serviceName)

Static Public Member Functions

static void register_factory (const std::string &factory_name, port_factory *factory_ptr)
 Add a factory the component.
static void setTimeOut ()

Static Public Attributes

static long dscTimeOut = 0
 


Detailed Description

Definition at line 22 of file Calcium.hxx.


Constructor & Destructor Documentation

PySupervCompo::PySupervCompo ( CORBA::ORB_ptr  orb,
PortableServer::POA_ptr  poa,
Engines::Container_ptr  contain,
const char *  instanceName,
const char *  interfaceName,
bool  notif = false 
)

Definition at line 28 of file Calcium.cxx.

                                          :
  Superv_Component_i(orb, poa,contain, instanceName, interfaceName,false,false)
{
}

Definition at line 38 of file Calcium.cxx.

{
}

Member Function Documentation

SpecificPortType * Superv_Component_i::add_port ( const char *  port_fab_type,
const char *  port_type,
const char *  port_name 
) throw (PortAlreadyDefined, BadFabType, BadType, BadProperty) [virtual, inherited]

Adds a port to the component.

With this method only Salomé's provided DSC ports can be added.

Parameters:
port_fab_typetype of the port.
port_typeuses or provides.
port_namethe name of the port in the component.

Definition at line 156 of file Superv_Component_i.cxx.

{
  assert(port_fab_type);
  assert(port_type);
  assert(port_name);

  std::string s_port_type(port_type);
  if (s_port_type == "provides") {
    provides_port * port = create_provides_data_port(port_fab_type);
    add_port(port, port_name);
  }
  else if (s_port_type == "uses") {
#ifdef MYDEBUG
    std::cerr << "---- Superv_Component_i::add_port : MARK 1 ---- "  << std::endl;
#endif
    uses_port * port = create_uses_data_port(port_fab_type);
#ifdef MYDEBUG
    std::cerr << "---- Superv_Component_i::add_port : MARK 2 ---- "  << std::endl;
#endif
    add_port(port, port_name);
  }
  else
    throw BadType( LOC(OSS()<< "port_type must be either 'provides' either 'uses' not "
                       << port_type));

}

Here is the caller graph for this function:

template<typename SpecificPortType >
SpecificPortType* Superv_Component_i::add_port ( const char *  port_fab_type,
const char *  port_type,
const char *  port_name 
) throw (PortAlreadyDefined, BadFabType, BadType, BadCast, BadProperty) [inherited]

Adds a port to the component.

With this method only Salomé's provided DSC ports can be added.

Parameters:
port_fab_typetype of the port.
port_typeuses or provides.
port_namethe name of the port in the component.
Returns:
the created port.
void Superv_Component_i::add_port ( provides_port port,
const char *  provides_port_name 
) throw (PortAlreadyDefined, NilPort, BadProperty) [virtual, inherited]

Adds a created provides port to the component.

Parameters:
portthe provides port.
provides_port_namethe name of the port in the component.

Definition at line 187 of file Superv_Component_i.cxx.

{
  assert(port);
  assert(provides_port_name);

  try {

    Ports::PortProperties_var portproperties=port->get_port_properties();
    Ports::Port_var portref=port->get_port_ref();
    Engines_DSC_interface::add_provides_port(portref, 
                                             provides_port_name,
                                             portproperties);

    superv_port_t * new_superv_port = new superv_port_t();
    new_superv_port->p_ref = port;
    my_superv_ports[provides_port_name] = new_superv_port;

  } 
  catch (const Engines::DSC::PortAlreadyDefined&) {
    throw PortAlreadyDefined( LOC(OSS()<< "provides port "
                                  << provides_port_name <<" already exist."));
  } 
  catch (const Engines::DSC::NilPort&) {
    throw NilPort( LOC(OSS()<< "provides port pointer is nul."));
  }
  catch (const Engines::DSC::BadProperty&) {
    throw BadProperty( LOC(OSS()<< "Property is not well defined"));
  }
}

Here is the call graph for this function:

void Superv_Component_i::add_port ( uses_port port,
const char *  uses_port_name 
) throw (PortAlreadyDefined, NilPort, BadProperty) [virtual, inherited]

Adds a created uses port to the component.

Parameters:
portthe uses port.
uses_port_namethe name of the port in the component.

Definition at line 220 of file Superv_Component_i.cxx.

{
  assert(port);
  assert(uses_port_name);

  try {
    Ports::PortProperties_var portproperties=port->get_port_properties();
    Engines_DSC_interface::add_uses_port(port->get_repository_id(), 
                                         uses_port_name,
                                         portproperties);
    superv_port_t * new_superv_port = new superv_port_t();
    new_superv_port->u_ref = port;
    my_superv_ports[uses_port_name] = new_superv_port;
  } 
  catch (const Engines::DSC::PortAlreadyDefined&) {
    throw PortAlreadyDefined( LOC(OSS()<< "uses port " 
                                  << uses_port_name <<" already exists."));
  } 
  catch (const Engines::DSC::NilPort&) {
    throw NilPort( LOC(OSS()<< "uses port pointer is nul."));
  }
  catch (const Engines::DSC::BadProperty&) {
    throw BadProperty( LOC(OSS()<< "Property is not well defined"));
  }
}

Here is the call graph for this function:

void Superv_Component_i::beginService ( const char *  serviceName) [inherited]

Definition at line 340 of file Superv_Component_i.cxx.

Here is the call graph for this function:

virtual provides_port* Superv_Component_i::create_provides_control_port ( ) [inline, virtual, inherited]
Warning:
currently disabled.

Definition at line 89 of file Superv_Component_i.hxx.

  {return NULL;}
virtual provides_port* Superv_Component_i::create_provides_data_and_control_port ( const char *  port_type) [inline, virtual, inherited]
Warning:
currently disabled.

Definition at line 95 of file Superv_Component_i.hxx.

  {return NULL;}
provides_port * Superv_Component_i::create_provides_data_port ( const std::string &  port_fab_type) throw (BadFabType) [virtual, inherited]

This method permits to create a provides port provided by the platform.

(See documentation of DSC for knoing these ports).

Parameters:
port_fab_typetype provides port.
Returns:
the provides port.
Note:
It's user repsonsability to destroy the provides port.

Definition at line 106 of file Superv_Component_i.cxx.

{ 
  provides_port * rtn_port = NULL;
  std::string factory_name;
  std::string type_name;
  int search_result;

  search_result = port_fab_type.find("_");
  factory_name = port_fab_type.substr(0,search_result);
  type_name = port_fab_type.substr(search_result+1, port_fab_type.length());

  port_factory * factory = get_factory(factory_name);
  if (factory) {
    rtn_port = factory->create_data_servant(type_name);
  }

  if (rtn_port == NULL)
    throw  BadFabType( LOC(OSS()<< "No way to get the port factory "
                           <<port_fab_type));

  return rtn_port;
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual uses_port* Superv_Component_i::create_uses_control_port ( ) [inline, virtual, inherited]
Warning:
currently disabled.

Definition at line 101 of file Superv_Component_i.hxx.

  {return NULL;}
virtual uses_port* Superv_Component_i::create_uses_data_and_control_port ( const char *  port_type) [inline, virtual, inherited]
Warning:
currently disabled.

Definition at line 107 of file Superv_Component_i.hxx.

  {return NULL;}
uses_port * Superv_Component_i::create_uses_data_port ( const std::string &  port_fab_type) throw (BadFabType) [virtual, inherited]

This method permits to create a uses port provided by the platform.

(See documentation of DSC for knoing these ports).

Parameters:
port_fab_typetype uses port.
Returns:
the uses port.
Note:
It's user repsonsability to destroy the uses port.

Definition at line 131 of file Superv_Component_i.cxx.

{
  uses_port * rtn_proxy = NULL;
  std::string factory_name;
  std::string type_name;
  int search_result;

  search_result = port_fab_type.find("_");
  factory_name = port_fab_type.substr(0,search_result);
  type_name = port_fab_type.substr(search_result+1, port_fab_type.length());

  port_factory * factory = get_factory(factory_name);
  if (factory) {
    rtn_proxy = factory->create_data_proxy(type_name);
  }
  
  if (rtn_proxy == NULL)
   throw BadFabType( LOC(OSS()<< "No way to get the port factory "
                          <<port_fab_type));

  return rtn_proxy;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Superv_Component_i::DSC_EXCEPTION ( BadFabType  ) [inherited]
Superv_Component_i::DSC_EXCEPTION ( BadType  ) [inherited]
Superv_Component_i::DSC_EXCEPTION ( BadCast  ) [inherited]
Superv_Component_i::DSC_EXCEPTION ( UnexpectedState  ) [inherited]
Superv_Component_i::DSC_EXCEPTION ( PortAlreadyDefined  ) [inherited]
Superv_Component_i::DSC_EXCEPTION ( PortNotDefined  ) [inherited]
Superv_Component_i::DSC_EXCEPTION ( PortNotConnected  ) [inherited]
Superv_Component_i::DSC_EXCEPTION ( NilPort  ) [inherited]
Superv_Component_i::DSC_EXCEPTION ( BadProperty  ) [inherited]
port_factory * Superv_Component_i::get_factory ( const std::string &  factory_name) [virtual, inherited]

Get a factory from the component.

Parameters:
factory_namename of the factory.
Returns:
factory pointer, NULL if the factory doesn't exist.

Definition at line 92 of file Superv_Component_i.cxx.

{
  port_factory * rtn_factory = NULL;
  factory_map_t::iterator it = _factory_map.find(factory_name);

  if (it != _factory_map.end() )
  {
    rtn_factory = _factory_map[factory_name];
  }

  return rtn_factory;
}
void Superv_Component_i::get_port ( provides_port *&  port,
const char *  provides_port_name 
) throw (PortNotDefined, PortNotConnected) [virtual, inherited]

Gets the provides port already added in the component.

Parameters:
portthe provides port pointer.
provides_port_namethe name of the port.

Definition at line 249 of file Superv_Component_i.cxx.

{
  assert(provides_port_name);

  try {
    Ports::Port_var portref=Engines_DSC_interface::get_provides_port(provides_port_name, false);
    port = my_superv_ports[provides_port_name]->p_ref;
  } catch (const Engines::DSC::PortNotDefined&) {
    throw PortNotDefined( LOC(OSS()<< "provides  port "
                              << provides_port_name <<" does not exist."));
  } catch (const Engines::DSC::PortNotConnected&) {
    throw PortNotConnected( LOC(OSS()<< "provides port " << provides_port_name 
                                << " is not connected."));
  }
}

Here is the call graph for this function:

void Superv_Component_i::get_port ( uses_port *&  port,
const char *  uses_port_name 
) throw (PortNotDefined, PortNotConnected) [virtual, inherited]

Gets the uses port already added in the component.

Parameters:
portthe uses port pointer.
uses_port_namethe name of the port.

Definition at line 268 of file Superv_Component_i.cxx.

{
  assert(uses_port_name);

  try {
    Engines::DSC::uses_port * portseq=Engines_DSC_i::get_uses_port(uses_port_name);
    delete portseq;
    port = my_superv_ports[uses_port_name]->u_ref;
  } catch (const Engines::DSC::PortNotDefined&) {    
    throw PortNotDefined( LOC(OSS()<< "uses port "
                              << uses_port_name <<" does not exist."));
  } catch (const Engines::DSC::PortNotConnected&) {
    throw PortNotConnected( LOC(OSS()<< "uses port " << uses_port_name 
                                << " is not connected."));
  }
}
template<typename SpecificPortType >
SpecificPortType * Superv_Component_i::get_port ( const char *  port_name) throw (PortNotDefined, PortNotConnected, BadCast, UnexpectedState) [inherited]

Gets a port already added in the component.

Parameters:
port_namethe name of the port.
Returns:
a port's pointer.

Definition at line 356 of file Superv_Component_i.hxx.

{
  assert(port_name);
    
  SpecificPortType * retPort;
  base_port        * port;

  my_superv_ports_it = my_superv_ports.find(port_name);
  if (my_superv_ports_it == my_superv_ports.end())
  {
    throw PortNotDefined( LOC(OSS()<< "Port " << port_name <<" does not exist"));
  }

  superv_port_t * superv_port =  my_superv_ports[port_name];
  try {
    if ( superv_port->p_ref != NULL ) {
      port = superv_port->p_ref;
      Ports::Port_var portref=Engines_DSC_interface::get_provides_port(port_name, false); 
    } 
    else if ( superv_port->u_ref != NULL ) {
      port = superv_port->u_ref;
      Engines::DSC::uses_port * portseq=Engines_DSC_i::get_uses_port(port_name);
      delete portseq;
    } else {
      throw UnexpectedState( LOC(OSS()<< "Internal Error superv_port struct is inconsistent "));
    
    }
  } catch (const Engines::DSC::PortNotDefined&) {
    throw PortNotDefined( LOC(OSS()<< "port "
                              << port_name <<" does not exist."));
  } catch (const Engines::DSC::PortNotConnected&) {
    throw PortNotConnected( LOC(OSS()<< "port " << port_name 
                                << " is not connected."));
  }
  
  retPort = dynamic_cast<SpecificPortType *>(port);
  if ( retPort == NULL ) {
    throw BadCast( LOC("Can't cast to required port type " ));
  }

  return retPort;
};

Here is the call graph for this function:

void Superv_Component_i::get_uses_port_names ( std::vector< std::string > &  port_names,
const std::string  servicename = "" 
) const [virtual, inherited]

Gets the list of the ports of a service.

If servicename is not set, all the ports of the component are returned.

Parameters:
port_namesthe ports's list.
servicenameservice's name.

Definition at line 316 of file Superv_Component_i.cxx.

                                                                           {

  port_names.reserve(my_superv_ports.size());

  superv_ports::const_iterator it;

  for (it=my_superv_ports.begin(); it!=my_superv_ports.end();++it)
    if( (*it).second->p_ref == NULL ) port_names.push_back((*it).first);
}

Here is the caller graph for this function:

CORBA::Boolean PySupervCompo::init_service ( const char *  service_name) [inline]

Definition at line 32 of file Calcium.hxx.

{return true;};
void Superv_Component_i::provides_port_changed ( const char *  provides_port_name,
int  connection_nbr,
const Engines::DSC::Message  message 
) [virtual, inherited]
See also:
DSC_Callbacks::provides_port_changed

Definition at line 290 of file Superv_Component_i.cxx.

{
  my_superv_ports_it = my_superv_ports.find(provides_port_name);
  if (my_superv_ports_it !=  my_superv_ports.end())
    my_superv_ports[provides_port_name]->p_ref->provides_port_changed(connection_nbr,
                                                                      message);
}
void Superv_Component_i::register_factory ( const std::string &  factory_name,
port_factory factory_ptr 
) [static, inherited]

Add a factory the component.

If the factory_name is already used, the new library is not added.

Parameters:
factory_namename of the factory (used by Superv_Component_i::create_provides_data_port and Superv_Component_i::create_uses_data_port)
factory_ptrfactory pointer (destroyed by the component)

Definition at line 80 of file Superv_Component_i.cxx.

{
  factory_map_t::iterator it = _factory_map.find(factory_name);

  if (it == _factory_map.end() )
  {
    _factory_map[factory_name] = factory_ptr;
  }
}

Here is the caller graph for this function:

void Superv_Component_i::setTimeOut ( ) [static, inherited]

Definition at line 327 of file Superv_Component_i.cxx.

{
  char* valenv=getenv("DSC_TIMEOUT");
  if(valenv)
    {
      std::istringstream iss(valenv);
      long temp;
      if (iss >> temp)
        if(temp >=0)
          Superv_Component_i::dscTimeOut=temp;
    }
}

Here is the caller graph for this function:

void Superv_Component_i::uses_port_changed ( const char *  uses_port_name,
Engines::DSC::uses_port new_uses_port,
const Engines::DSC::Message  message 
) [virtual, inherited]
See also:
DSC_Callbacks::uses_port_changed

Definition at line 301 of file Superv_Component_i.cxx.

{
  my_superv_ports_it = my_superv_ports.find(uses_port_name);
  if (my_superv_ports_it !=  my_superv_ports.end())
    my_superv_ports[uses_port_name]->u_ref->uses_port_changed(new Engines::DSC::uses_port(*new_uses_port),
                                                              message);
  //delete the copy made by the caller
  delete new_uses_port;
}

Member Data Documentation

long Superv_Component_i::dscTimeOut = 0 [static, inherited]

Definition at line 262 of file Superv_Component_i.hxx.


The documentation for this class was generated from the following files: