ConnectionManager_i::~ConnectionManager_i() {}
-/* Cette méthode connecte deux ports ensembles.
- * Elle permet de rendre plus simple l'utilisation du modèle de programmation
- * à base de ports.
- */
Engines::ConnectionManager::connectionId
ConnectionManager_i::connect(Engines::DSC_ptr uses_component,
const char* uses_port_name,
uses_component->connect_uses_port(uses_port_name, p_port);
provides_component->connect_provides_port(provides_port_name);
- // Ajout de l'id dans la map comme tout s'est bien passé
- //
- // Protection du current_id pour récupérer un id unique
+ // 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);
- // Creation de la structure et ajout dans la map
+ // 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_port_name = provides_port_name;
infos->provides_port = Ports::Port::_duplicate(p_port);
- // Ajout dans la map
+ // Adding the new connection into the map.
ids[rtn_id] = infos;
return rtn_id;
Engines::DSC::Message message)
throw (Engines::ConnectionManager::BadId)
{
- // Verification que l'id existe
+ // Connection id exist ?
ids_it = ids.find(id);
if (ids_it == ids.end())
throw Engines::ConnectionManager::BadId();
- // Recuperation des infos
+ // TODO
+ // We need to catch exceptions if one of these disconnect operation fails.
connection_infos * infos = ids[id];
infos->provides_component->disconnect_provides_port(infos->provides_port_name.c_str(),
message);
infos->uses_component->disconnect_uses_port(infos->uses_port_name.c_str(),
Ports::Port::_duplicate(infos->provides_port),
message);
- // Nettoyage
delete infos;
ids.erase(id);
}
~ConnectionManager_i();
/*!
+ * CORBA method : connect two ports of two components.
* \see Engines::ConnectionManager::connect
*/
Engines::ConnectionManager::connectionId connect(Engines::DSC_ptr uses_component,
Engines::DSC::NilPort);
/*!
+ * CORBA method : releases a connection performed with
+ * ConnectionManager_i::connect.
+ *
* \see Engines::ConnectionManager::disconnect
*/
void disconnect(const Engines::ConnectionManager::connectionId id,
PortableServer::POA_var root_poa;
PortableServer::POAManager_var pman;
CORBA::Object_var obj;
- CORBA::ORB_var orb = CORBA::ORB_init( argc , argv ) ;
+ CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
try{
obj = orb->resolve_initial_references("RootPOA");
if(!CORBA::is_nil(obj))
root_poa = PortableServer::POA::_narrow(obj);
if(!CORBA::is_nil(root_poa))
pman = root_poa->the_POAManager();
- ConnectionManager_i * serv = new ConnectionManager_i(orb);
+
+ // We create a ConnectionManager.
+ // It is automatically added to the RootPOA into its constructor.
+ new ConnectionManager_i(orb);
+
pman->activate();
orb->run();
}catch(CORBA::SystemException&){