Salome HOME
Typo and whitespace fixes by Kunda
[modules/kernel.git] / src / NamingService / SALOME_NamingService.cxx
index a8c213b03a47f8604dfeff249cb5f0c0e7d21a8b..797edefdf07b7cc13d73761970d2cebaa97e0288 100644 (file)
@@ -50,7 +50,7 @@
  *
  *  After Default Constructor, one needs to initialize ORB.
  *  \sa init_orb(CORBA::ORB_ptr orb), SALOME_NamingService(CORBA::ORB_ptr orb)
- */ 
+ */
 // ============================================================================
 
 SALOME_NamingService::SALOME_NamingService()
@@ -60,11 +60,11 @@ SALOME_NamingService::SALOME_NamingService()
 }
 
 // ============================================================================
-/*! \brief Standard Constructor, with ORB reference. 
- * 
+/*! \brief Standard Constructor, with ORB reference.
+ *
  * Initializes the naming service root context
  * \param orb CORBA::ORB_ptr arguments
- */ 
+ */
 // ============================================================================
 
 SALOME_NamingService::SALOME_NamingService(CORBA::ORB_ptr orb)
@@ -77,7 +77,7 @@ SALOME_NamingService::SALOME_NamingService(CORBA::ORB_ptr orb)
 /*! \brief Standard destructor.
  *
  *  The standard destructor does nothing special.
- */ 
+ */
 // ============================================================================
 
 SALOME_NamingService::~SALOME_NamingService()
@@ -89,12 +89,12 @@ SALOME_NamingService::~SALOME_NamingService()
 
 // ============================================================================
 /*! \brief initializes ORB reference and naming service root context.
- * 
+ *
  *  Initializes ORB reference and naming service root context.
  *  For use after default constructor.
  *  If param orb is null, the orb is initialized
  *  \param orb CORBA::ORB_ptr arguments
- */ 
+ */
 // ============================================================================
 
 void SALOME_NamingService::init_orb(CORBA::ORB_ptr orb)
@@ -124,12 +124,12 @@ void SALOME_NamingService::init_orb(CORBA::ORB_ptr orb)
  *               as an absolute pathname. Else, pathname is taken as a relative
  *               path, to current context. Prefer absolute pathname, relative
  *               pathname are not safe, when SALOME_NamingService object is
- *               shared or use in multithreaded context. 
+ *               shared or use in multithreaded context.
  *               If the path ends with '/', only a directory is created.
  * \sa           Change_Directory(const char* Path),
  *               Create_Directory(const char* Path)
  *               CORBA::Object_ptr Resolve(const char* Path)
- */ 
+ */
 // ============================================================================
 
 void SALOME_NamingService::Register(CORBA::Object_ptr ObjRef,
@@ -161,7 +161,7 @@ void SALOME_NamingService::Register(CORBA::Object_ptr ObjRef,
     // A directory is treated (not only an object name)
     // test if the directory where ObjRef should be recorded already exists
     // If not, create the new context
-    
+
     try{
       CORBA::Object_var obj = _current_context->resolve(context_name);
       _current_context = CosNaming::NamingContext::_narrow(obj);
@@ -313,9 +313,9 @@ void SALOME_NamingService::Register(CORBA::Object_ptr ObjRef,
 
 // ============================================================================
 /*! \brief get the CORBA object reference associated to a name.
- * 
+ *
  *  get the CORBA object reference associated to a complete name with a path.
- *  If the NamingService is out, the exception ServiceUnreachable is thrown 
+ *  If the NamingService is out, the exception ServiceUnreachable is thrown
  * \param Path pathname. If the pathname begins with a '/', pathname is taken
  *             as an absolute pathname. Else, pathname is taken as a relative
  *             path, to current context. Prefer absolute pathname, relative
@@ -325,7 +325,7 @@ void SALOME_NamingService::Register(CORBA::Object_ptr ObjRef,
  *             or nil reference in other cases.
  * \sa         Register(CORBA::Object_ptr ObjRef, const char* Path),
  *             Change_Directory(const char* Path)
- */ 
+ */
 // ============================================================================
 
 CORBA::Object_ptr SALOME_NamingService::Resolve(const char* Path)
@@ -404,7 +404,7 @@ CORBA::Object_ptr SALOME_NamingService::Resolve(const char* Path)
  *
  *  get the CORBA object reference associated to an incomplete name with a
  *  path. Look for the first occurrence of name*.
- *  If the NamingService is out, the exception ServiceUnreachable is thrown 
+ *  If the NamingService is out, the exception ServiceUnreachable is thrown
  * \param Path pathname under the form "/path/name" (Absolute reference !)
  *             search the fist reference like "/path(.dir)/name*(.kind)"
  * \return     the object reference if found, or nil reference.
@@ -438,19 +438,19 @@ CORBA::Object_ptr SALOME_NamingService::ResolveFirst(const char* Path)
     isOk =true;
   else
     isOk = Change_Directory(basePath.c_str());
-  
+
   if (isOk)
     {
       std::vector<std::string> listElem = list_directory();
       std::vector<std::string>::iterator its = listElem.begin();
-      
+
       while (its != listElem.end())
         {
           if ((*its).find(name) == 0)
             {
               return Resolve((*its).c_str());
             }
-          
+
           its++;
         }
     }
@@ -468,12 +468,12 @@ CORBA::Object_ptr SALOME_NamingService::ResolveFirst(const char* Path)
  * \param hostname      name of the machine on which the component is searched.
  * \param containerName name of the container in which the component is
                         instantiated.
- * \param componentName name of the component we are looking for an existing 
+ * \param componentName name of the component we are looking for an existing
                         instance.
  * \param nbproc        in case of multi processor machine, container name is
  *                      suffixed with _nbproc.
  * \return the object reference
- */ 
+ */
 // ============================================================================
 
 CORBA::Object_ptr
@@ -664,7 +664,7 @@ std::string SALOME_NamingService::BuildContainerNameForNS(const Engines::Contain
  * \param  name the name to search.
  * \return number of occurrences found.
  * \sa Change_Directory(const char* Path)
- */ 
+ */
 // ============================================================================
 
 int SALOME_NamingService::Find(const char* name)
@@ -692,7 +692,7 @@ throw(ServiceUnreachable)
 // ============================================================================
 /*! \brief Creates a directory (context_name)
  *
- *  Creates a directory (context_name) relative to the current directory 
+ *  Creates a directory (context_name) relative to the current directory
  *  (current context) or relative to the root directory (root context), if
  *  the path given begins with a '/'.
  *  If the NamingService is out, the exception ServiceUnreachable is thrown.
@@ -701,13 +701,13 @@ throw(ServiceUnreachable)
  *               as an absolute pathname. Else, pathname is taken as a relative
  *               path, to current context. Prefer absolute pathname, relative
  *               pathname are not safe, when SALOME_NamingService object is
- *               shared or use in multithreaded context.   
+ *               shared or use in multithreaded context.
  *  \return true if successful
  *          (creation not strictly guaranteed if true, because Register may
  *           catch some specific unlikely exception without throw anything
  *           --- to be corrected ---)
  *  \sa RegisterCORBA::Object_ptr ObjRef, const char* Path)
- */ 
+ */
 // ============================================================================
 
 bool SALOME_NamingService::Create_Directory(const char* Path) throw(ServiceUnreachable)
@@ -730,7 +730,7 @@ bool SALOME_NamingService::Create_Directory(const char* Path) throw(ServiceUnrea
     }
 
   // --- path must end with '/'
-  
+
   if (path[path.length()-1] != '/') path += '/';
 
   Register(CORBA::Object::_nil(), path.c_str());
@@ -748,7 +748,7 @@ bool SALOME_NamingService::Create_Directory(const char* Path) throw(ServiceUnrea
  *  If the NamingService is out, the exception ServiceUnreachable is thrown.
  * \param  Path the new current directory
  * \return true if the change succeeded
- */ 
+ */
 // ============================================================================
 
 bool SALOME_NamingService::Change_Directory(const char* Path) throw(ServiceUnreachable)
@@ -781,7 +781,7 @@ bool SALOME_NamingService::Change_Directory(const char* Path) throw(ServiceUnrea
   // --- need to resolve directory path
 
   ASSERT(!CORBA::is_nil(current_context));
-  
+
   if (path[path.length()-1] != '/') path += '/';
 //   SCRUTE(path);
   CosNaming::Name context_name;
@@ -790,9 +790,9 @@ bool SALOME_NamingService::Change_Directory(const char* Path) throw(ServiceUnrea
                                                  context_name,
                                                  splitPath,
                                                  true);
-  
+
   // --- Context creation
-  
+
   try
     {
       CORBA::Object_var obj = current_context->resolve(context_name);
@@ -801,11 +801,11 @@ bool SALOME_NamingService::Change_Directory(const char* Path) throw(ServiceUnrea
       _current_context = current_context;
       changeOK = true;
     }
-  
+
   catch (CosNaming::NamingContext::NotFound& ex)
     {
       CosNaming::Name n = ex.rest_of_name;
-      
+
       if (ex.why == CosNaming::NamingContext::missing_node)
         MESSAGE( "Change_Directory() : " << (char *) n[0].id
                << " (" << (char *) n[0].kind << ") not found");
@@ -818,17 +818,17 @@ bool SALOME_NamingService::Change_Directory(const char* Path) throw(ServiceUnrea
                << " (" << (char *) n[0].kind
                << ") is not an object" );
     }
-  
+
   catch (CosNaming::NamingContext::CannotProceed&)
     {
       INFOS("Change_Directory(): CosNaming::NamingContext::CannotProceed");
     }
-  
+
   catch (CosNaming::NamingContext::InvalidName&)
     {
       INFOS("Change_Directory(): CosNaming::NamingContext::InvalidName");
     }
-  
+
   catch (CORBA::SystemException&)
     {
       INFOS("Change_Directory():CORBA::SystemException : unable to contact"
@@ -846,7 +846,7 @@ bool SALOME_NamingService::Change_Directory(const char* Path) throw(ServiceUnrea
  *  If the NamingService is out, the exception ServiceUnreachable is thrown.
  * \return the path of the current_context
  * \sa  _current_directory
- */ 
+ */
 // ============================================================================
 
 char *SALOME_NamingService::Current_Directory() throw(ServiceUnreachable)
@@ -896,7 +896,7 @@ char *SALOME_NamingService::Current_Directory() throw(ServiceUnreachable)
  *  List and print via trace all directories and objects in the current
  *  context. Trace must be activated: compile option _DEBUG_
  *  If the NamingService is out, the exception ServiceUnreachable is thrown
- */ 
+ */
 // ============================================================================
 
 void SALOME_NamingService::list() throw(ServiceUnreachable)
@@ -956,7 +956,7 @@ void SALOME_NamingService::list() throw(ServiceUnreachable)
  *  If the NamingService is out, the exception ServiceUnreachable is thrown.
  * \return list of strings with objects found.
  * \sa vector<string> list_directory_recurs()
- */ 
+ */
 // ============================================================================
 
 std::vector<std::string> SALOME_NamingService::list_directory() throw(ServiceUnreachable)
@@ -1009,7 +1009,7 @@ std::vector<std::string> SALOME_NamingService::list_directory() throw(ServiceUnr
  *  If the NamingService is out, the exception ServiceUnreachable is thrown.
  * \return list of strings with directories found.
  * \sa vector<string> list_directory()
- */ 
+ */
 // ============================================================================
 
 std::vector<std::string> SALOME_NamingService::list_subdirs() throw(ServiceUnreachable)
@@ -1058,7 +1058,7 @@ std::vector<std::string> SALOME_NamingService::list_subdirs() throw(ServiceUnrea
  *  If the NamingService is out, the exception ServiceUnreachable is thrown.
  * \return list of strings with objects found.
  * \sa vector<string> list_directory()
- */ 
+ */
 // ============================================================================
 
 std::vector<std::string> SALOME_NamingService::list_directory_recurs()
@@ -1081,9 +1081,9 @@ throw(ServiceUnreachable)
 /*! \brief destroy an entry in naming service.
  *
  *  Destroy an association Path - Object Reference.
- *  If the NamingService is out, the exception ServiceUnreachable is thrown 
+ *  If the NamingService is out, the exception ServiceUnreachable is thrown
  * \param Path object path
- */ 
+ */
 // ============================================================================
 
 void SALOME_NamingService::Destroy_Name(const char* Path)
@@ -1190,7 +1190,7 @@ throw(ServiceUnreachable)
             CORBA::string_dup(splitPath[dimension_resultat].c_str());
           context_name[0].kind = CORBA::string_dup("object");
           //SCRUTE(context_name[0].id);
+
           _current_context->unbind(context_name);
           //MESSAGE("The object " << context_name[0].id << " has been deleted");
         }
@@ -1237,7 +1237,7 @@ throw(ServiceUnreachable)
  *  Destroy an empty directory in Naming Service.
  *  If the NamingService is out, the exception ServiceUnreachable is thrown.
  * \param Path directory path
- */ 
+ */
 // ============================================================================
 
 void SALOME_NamingService::Destroy_Directory(const char* Path) throw(ServiceUnreachable)
@@ -1402,10 +1402,10 @@ void SALOME_NamingService::Destroy_Directory(const char* Path) throw(ServiceUnre
 /*! \brief Destroy a directory with its contents.
  *
  *  Destroy the objects associations in a directory, and the directory itself,
- *  if there is no subdirectories. 
+ *  if there is no subdirectories.
  *  If the NamingService is out, the exception ServiceUnreachable is thrown.
  * \param Path the directory path.
- */ 
+ */
 // ============================================================================
 
 void SALOME_NamingService::Destroy_FullDirectory(const char* Path) throw(ServiceUnreachable)
@@ -1417,7 +1417,7 @@ void SALOME_NamingService::Destroy_FullDirectory(const char* Path) throw(Service
 
       for (unsigned int ind = 0; ind < contList.size(); ind++)
         Destroy_Name(contList[ind].c_str());
-      
+
       Destroy_Directory(Path);
     }
 }
@@ -1426,8 +1426,8 @@ void SALOME_NamingService::Destroy_FullDirectory(const char* Path) throw(Service
 /*! \brief  initialize root context (root directory)
  *
  * the root context initialisation must be done when the SALOME_NamingService
- * instance is created and before any othe call. See constructors.
- */ 
+ * instance is created and before any other call. See constructors.
+ */
 // ============================================================================
 
 void SALOME_NamingService::_initialize_root_context()
@@ -1469,7 +1469,7 @@ void SALOME_NamingService::_initialize_root_context()
  *                      if false, final object (if any) is included in
  *                      context_name.
  *  \return             dimension of context_name
- */ 
+ */
 // ============================================================================
 
 int
@@ -1504,7 +1504,7 @@ SALOME_NamingService::_createContextNameDir(std::string path,
   if (onlyDir)                  // only directory part
     {
       dim = splitPath.size()-1; // omit final object
-      if (endWithDelim)         // unless the path ends with a delimiter 
+      if (endWithDelim)         // unless the path ends with a delimiter
         dim++;
       endWithDelim = true;
     }
@@ -1540,7 +1540,7 @@ SALOME_NamingService::_createContextNameDir(std::string path,
  *
  * \param  name the name to search.
  * \param  occurence_number number of occurrence already found (incremented)
- */ 
+ */
 // ============================================================================
 
 void SALOME_NamingService::_Find(const char* name,
@@ -1563,37 +1563,37 @@ void SALOME_NamingService::_Find(const char* name,
       while (binding_iterator->next_one(binding))
         {
           CosNaming::Name bindingName = binding->binding_name;
-          
+
           if (binding->binding_type == CosNaming::ncontext)
             {
               // --- We work on a directory,
               //     the search should be done in this directory
-              
+
               Change_Directory(bindingName[0].id);
               _Find(name, occurence_number);
-              
+
               // --- We'll go back to the initial context
-              
+
               _current_context = ref_context ;
             }
-          
+
           else if (binding->binding_type == CosNaming::nobject)
             {
               // --- We work on an object...
-              
+
               if (!strcmp( bindingName[0].id, name))
                 {
                   //MESSAGE("One occurrence was found");
                   occurence_number++;
-                  
+
                   // --- We keep in memory the directory where
                   //     one occurrence was found
-                  
+
                   found_context = _current_context ;
                 }
             }
         }
-      
+
       binding_iterator->destroy();
     }
   // --- We go to the last directory where an occurrence was found
@@ -1605,14 +1605,14 @@ void SALOME_NamingService::_Find(const char* name,
 
 // ============================================================================
 /*! \brief find the current directory path.
- * 
+ *
  *  Parse the naming service tree to find the current context and give the
  *  associated directory path (relative to root context).
- * \param splitPath 
+ * \param splitPath
  * \param lengthResult
  * \param contextToFind
  * \param notFound
- */ 
+ */
 // ============================================================================
 
 void
@@ -1703,7 +1703,7 @@ _current_directory(std::vector<std::string>& splitPath,
  *  \param relativeSubDir  The directory relative to absCurDirectory in which
  *                         the objects are found.
  *  \param absCurDirectory The current directory, absolute path
- */ 
+ */
 // ============================================================================
 
 void SALOME_NamingService::_list_directory_recurs(std::vector<std::string>& myList,
@@ -1782,4 +1782,3 @@ CORBA::ORB_ptr SALOME_NamingService::orb()
 {
   return _orb;
 }
-