Back to index

salome-kernel  6.5.0
Classes | Public Member Functions | Protected Attributes | Private Types | Private Attributes
ConnectionManager_i Class Reference

This class implements the interface Engines::ConnectionManager. More...

#include <ConnectionManager_i.hxx>

Collaboration diagram for ConnectionManager_i:
Collaboration graph
[legend]

List of all members.

Classes

struct  connection_infos

Public Member Functions

 ConnectionManager_i (CORBA::ORB_ptr orb)
virtual ~ConnectionManager_i ()
Engines::ConnectionManager::connectionId connect (Engines::DSC_ptr uses_component, const char *uses_port_name, Engines::DSC_ptr provides_component, const char *provides_port_name)
 CORBA method : connect two ports of two components.
void disconnect (Engines::ConnectionManager::connectionId id, Engines::DSC::Message message)
 CORBA method : releases a connection performed with ConnectionManager_i::connect.
void ShutdownWithExit ()
 Shutdown the ConnectionManager process.
CORBA::Long getPID ()
 Returns the PID of the connection manager.

Protected Attributes

CORBA::ORB_var _orb

Private Types

typedef std::map
< Engines::ConnectionManager::connectionId,
connection_infos * > 
ids_type
typedef std::map
< Engines::ConnectionManager::connectionId,
connection_infos * >::iterator 
ids_it_type

Private Attributes

ids_type ids
ids_it_type ids_it
int current_id
pthread_mutex_t mutex

Detailed Description

This class implements the interface Engines::ConnectionManager.

Definition at line 42 of file ConnectionManager_i.hxx.


Class Documentation

struct ConnectionManager_i::connection_infos

Definition at line 79 of file ConnectionManager_i.hxx.

Collaboration diagram for ConnectionManager_i::connection_infos:
Class Members
DSC_var provides_component
Port_var provides_port
string provides_port_name
DSC_var uses_component
string uses_port_name

Member Typedef Documentation

Definition at line 90 of file ConnectionManager_i.hxx.

Definition at line 88 of file ConnectionManager_i.hxx.


Constructor & Destructor Documentation

Definition at line 34 of file ConnectionManager_i.cxx.

                                                         {
  _orb = CORBA::ORB::_duplicate(orb) ;
  SALOME_NamingService * ns = new SALOME_NamingService(orb);
  const char * ConnectionManagerNameInNS = "/ConnectionManager";
  CORBA::Object_var obref = _this();
  _remove_ref();
  ns->Register(obref, ConnectionManagerNameInNS);
  delete ns;

  current_id = 0;
  pthread_mutex_init(&mutex, NULL);
}

Definition at line 47 of file ConnectionManager_i.cxx.

{}

Member Function Documentation

Engines::ConnectionManager::connectionId ConnectionManager_i::connect ( Engines::DSC_ptr  uses_component,
const char *  uses_port_name,
Engines::DSC_ptr  provides_component,
const char *  provides_port_name 
)

CORBA method : connect two ports of two components.

See also:
Engines::ConnectionManager::connect

Definition at line 50 of file ConnectionManager_i.cxx.

{

  Ports::Port_var p_port = provides_component->get_provides_port(provides_port_name, false);
  uses_component->connect_uses_port(uses_port_name, p_port);
  provides_component->connect_provides_port(provides_port_name);

  // Creating a new connection id.
  // We use a mutex for multithreaded applications.
  pthread_mutex_lock(&mutex);
  Engines::ConnectionManager::connectionId rtn_id = current_id;
  current_id += 1;
  pthread_mutex_unlock(&mutex);

  // Creating a new structure containing connection's infos.
  connection_infos * infos = new connection_infos();
  infos->uses_component = Engines::DSC::_duplicate(uses_component);
  infos->uses_port_name = uses_port_name;
  infos->provides_component = Engines::DSC::_duplicate(provides_component);
  infos->provides_port_name = provides_port_name;
  infos->provides_port = Ports::Port::_duplicate(p_port);

  // Adding the new connection into the map.
  ids[rtn_id] = infos;

  return rtn_id;
}

CORBA method : releases a connection performed with ConnectionManager_i::connect.

See also:
Engines::ConnectionManager::disconnect

Definition at line 82 of file ConnectionManager_i.cxx.

{
  int err=0;
  // Connection id exist ?
  ids_it = ids.find(id);
  if (ids_it == ids.end())
    throw Engines::ConnectionManager::BadId();

  // TODO
  // We need to catch exceptions if one of these disconnect operation fails.
  connection_infos * infos = ids[id];
  try
    {
      infos->provides_component->disconnect_provides_port(infos->provides_port_name.c_str(), message);
    }
  catch(CORBA::SystemException& ex)
    {
      std::cerr << "Problem in disconnect(CORBA::SystemException) provides port: " << infos->provides_port_name << std::endl;
      err=1;
    }
  try
    {
      infos->uses_component->disconnect_uses_port(infos->uses_port_name.c_str(),
                                                  infos->provides_port, message);
    }
  catch(CORBA::SystemException& ex)
    {
      std::cerr << "Problem in disconnect(CORBA::SystemException) uses port: " << infos->uses_port_name << std::endl;
      err=1;
    }
  delete infos;
  ids.erase(id);

  if(err)
    throw Engines::DSC::BadPortReference();
}

Here is the caller graph for this function:

CORBA::Long ConnectionManager_i::getPID ( )

Returns the PID of the connection manager.

Definition at line 136 of file ConnectionManager_i.cxx.

{
    return
#ifndef WIN32
    (CORBA::Long)getpid();
#else
    (CORBA::Long)_getpid();
#endif
}

Shutdown the ConnectionManager process.

Definition at line 121 of file ConnectionManager_i.cxx.

{
  ids_it = ids.begin();
  while(ids_it != ids.end())
    {
      disconnect(ids_it->first, Engines::DSC::RemovingConnection);
      ids_it = ids.begin();
    }

  if(!CORBA::is_nil(_orb))
    _orb->shutdown(0);

}

Here is the call graph for this function:


Member Data Documentation

CORBA::ORB_var ConnectionManager_i::_orb [protected]

Definition at line 98 of file ConnectionManager_i.hxx.

Definition at line 95 of file ConnectionManager_i.hxx.

Definition at line 92 of file ConnectionManager_i.hxx.

Definition at line 93 of file ConnectionManager_i.hxx.

pthread_mutex_t ConnectionManager_i::mutex [private]

Definition at line 96 of file ConnectionManager_i.hxx.


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