Salome HOME
CCAR: some corrections in :
[modules/kernel.git] / src / Container / Component_i.cxx
index cfeeefc9b10549266744c661ffb5d7af1dae41d4..885750da9ed96f7101f1e2158805677b304a1541 100644 (file)
@@ -106,6 +106,7 @@ Engines_Component_i::Engines_Component_i(CORBA::ORB_ptr orb,
   _poa = PortableServer::POA::_duplicate(poa);
   _contId = contId ;
   CORBA::Object_var o = _poa->id_to_reference(*contId); // container ior...
+  _container=Engines::Container::_narrow(o);
   const CORBA::String_var ior = _orb->object_to_string(o);
   _myConnexionToRegistry = new RegistryConnexion(0, 0, ior,"theSession",
                                                 _instanceName.c_str());
@@ -114,6 +115,56 @@ Engines_Component_i::Engines_Component_i(CORBA::ORB_ptr orb,
   //SCRUTE(pd_refCount);
 }
 
+//=============================================================================
+/*!
+ *  Standard Constructor for standalone Component, used in derived class
+ *  Connection to Registry and Notification
+ *  \param orb Object Request broker given by Container
+ *  \param poa Portable Object Adapter from Container (normally root_poa)
+ *  \param container container CORBA reference
+ *  \param instanceName unique instance name for this object (see Container_i)
+ *  \param interfaceName component class name
+ *  \param notif use of notification
+ */
+//=============================================================================
+
+Engines_Component_i::Engines_Component_i(CORBA::ORB_ptr orb,
+                                         PortableServer::POA_ptr poa,
+                                         Engines::Container_ptr container,
+                                         const char *instanceName,
+                                         const char *interfaceName,
+                                         bool notif) :
+  _instanceName(instanceName),
+  _interfaceName(interfaceName),
+  _myConnexionToRegistry(0),
+  _notifSupplier(0),
+  _ThreadId(0) ,
+  _ThreadCpuUsed(0) ,
+  _Executed(false) ,
+  _graphName("") ,
+  _nodeName(""),
+  _studyId(-1),
+  _CanceledThread(false)
+{
+  MESSAGE("Component constructor with instanceName "<< _instanceName);
+  _orb = CORBA::ORB::_duplicate(orb);
+  _poa = PortableServer::POA::_duplicate(poa);
+  _container=Engines::Container::_duplicate(container);
+  try
+    {
+      _contId=_poa->reference_to_id(container);
+    }
+  catch(PortableServer::POA::WrongAdapter)
+    {
+      //not created by this poa
+      _contId = 0;
+    }
+  const CORBA::String_var ior = _orb->object_to_string(_container);
+  _myConnexionToRegistry = new RegistryConnexion(0, 0, ior,"theSession", _instanceName.c_str());
+  _notifSupplier = new NOTIFICATION_Supplier(instanceName, notif);
+}
+
+
 //=============================================================================
 /*! 
  * Standard constructor for parallel component
@@ -244,8 +295,8 @@ void Engines_Component_i::destroy()
 
   delete _myConnexionToRegistry;
   _myConnexionToRegistry = 0 ;
-  _poa->deactivate_object(*_id) ;
-  delete(_id) ;
+  if(_id)
+    delete(_id) ;
   //SCRUTE(pd_refCount);
   _thisObj->_remove_ref();
   //SCRUTE(pd_refCount);
@@ -261,9 +312,7 @@ void Engines_Component_i::destroy()
 
 Engines::Container_ptr Engines_Component_i::GetContainerRef()
 {
-  //  MESSAGE("Engines_Component_i::GetContainerRef");
-  CORBA::Object_var o = _poa->id_to_reference(*_contId) ;
-  return Engines::Container::_narrow(o);
+  return Engines::Container::_duplicate(_container);
 }
 
 //=============================================================================