Back to index

salome-kernel  6.5.0
SALOME_NamingService.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  SALOME NamingService : wrapping NamingService services
00024 //  File   : SALOME_NamingService.hxx
00025 //  Author : Estelle Deville
00026 //  Module : SALOME
00027 //  $Header: /home/server/cvs/KERNEL/KERNEL_SRC/src/NamingService/SALOME_NamingService.hxx,v 1.11.2.4.10.2.12.1 2012-04-12 14:05:18 vsr Exp $
00028 //
00029 #ifndef SALOME_NAMINGSERVICE_H
00030 #define SALOME_NAMINGSERVICE_H
00031 
00032 #include <SALOMEconfig.h>
00033 #include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
00034 #include CORBA_CLIENT_HEADER(SALOME_Component)
00035 
00036 #include <vector>
00037 #include <string>
00038 #include "utilities.h"
00039 #include "Utils_Mutex.hxx"
00040 #include "ServiceUnreachable.hxx"
00041 
00042 #include "SALOME_NamingService_defs.hxx"
00043 
00044 #ifdef WNT
00045 #pragma warning(disable:4290) // Warning Exception ...
00046 #endif
00047 
00048 class NAMINGSERVICE_EXPORT SALOME_NamingService
00049 {
00050 public:
00051   SALOME_NamingService();
00052   SALOME_NamingService(CORBA::ORB_ptr orb);
00053 
00054   virtual ~SALOME_NamingService();
00055 
00056   void init_orb(CORBA::ORB_ptr orb=0);
00057   void Register(CORBA::Object_ptr ObjRef,
00058                 const char* Path) 
00059     throw(ServiceUnreachable);
00060   CORBA::Object_ptr Resolve(const char* Path)
00061     throw( ServiceUnreachable); 
00062   CORBA::Object_ptr ResolveFirst(const char* Path)
00063     throw( ServiceUnreachable); 
00064   CORBA::Object_ptr ResolveComponent(const char* hostname,
00065                                      const char* containerName,
00066                                      const char* componentName,
00067                                      const int nbproc=0)
00068     throw(ServiceUnreachable);
00069   std::string ContainerName(const char *ContainerName);
00070   std::string ContainerName(const Engines::ContainerParameters& params);
00071   std::string BuildContainerNameForNS(const char *ContainerName,
00072                                       const char *hostname);
00073   std::string 
00074   BuildContainerNameForNS(const Engines::ContainerParameters& params,
00075                           const char *hostname);
00076 
00077   // Will Be deleted on SALOME 6
00078   std::string ContainerName(const Engines::MachineParameters& params);
00079   std::string 
00080   BuildContainerNameForNS(const Engines::MachineParameters& params,
00081                           const char *hostname);
00082   int Find(const char* name)
00083     throw(ServiceUnreachable);
00084   bool Create_Directory(const char* Path)
00085     throw(ServiceUnreachable);
00086   bool Change_Directory(const char* Path)
00087     throw(ServiceUnreachable);
00088   char* Current_Directory()
00089     throw(ServiceUnreachable);
00090   void list()
00091     throw(ServiceUnreachable);
00092   std::vector<std::string> list_directory()
00093     throw(ServiceUnreachable);
00094   std::vector<std::string> list_subdirs()
00095     throw(ServiceUnreachable);
00096   std::vector<std::string> list_directory_recurs()
00097     throw(ServiceUnreachable);
00098   void Destroy_Name(const char* Path)
00099     throw(ServiceUnreachable);
00100   virtual void Destroy_Directory(const char* Path)
00101     throw(ServiceUnreachable);
00102   virtual void Destroy_FullDirectory(const char* Path)
00103     throw(ServiceUnreachable);
00104   char* getIORaddr();
00105   CORBA::ORB_ptr orb();
00106 
00107 protected:
00108   Utils_Mutex _myMutex;
00109   CORBA::ORB_var _orb;
00110   CosNaming::NamingContext_var _root_context, _current_context;
00111 
00112   void _initialize_root_context();
00113   int _createContextNameDir(std::string path,
00114                             CosNaming::Name& context_name,
00115                             std::vector<std::string>& splitPath,
00116                             bool onlyDir);
00117   void _Find(const char* name, CORBA::Long& occurence_number);
00118   void _current_directory(std::vector<std::string>& splitPath,
00119                           int& lengthResult,
00120                           CosNaming::NamingContext_var contextToFind,
00121                           bool& notFound);
00122   void _list_directory_recurs(std::vector<std::string>& myList,
00123                               std::string relativeSubDir,
00124                               std::string absCurDirectory);
00125 
00126 };
00127 
00128 #endif // SALOME_NAMINGSERVICE_H
00129