SALOME documentation central

src/NamingService/SALOME_NamingService.hxx

00001 //  Copyright (C) 2007-2008  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 //  SALOME NamingService : wrapping NamingService services
00023 //  File   : SALOME_NamingService.hxx
00024 //  Author : Estelle Deville
00025 //  Module : SALOME
00026 //  $Header$
00027 //
00028 #ifndef SALOME_NAMINGSERVICE_H
00029 #define SALOME_NAMINGSERVICE_H
00030 
00031 #include <SALOMEconfig.h>
00032 #include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
00033 #include CORBA_CLIENT_HEADER(SALOME_Component)
00034 
00035 #include <vector>
00036 #include <string>
00037 #include "utilities.h"
00038 #include "Utils_Mutex.hxx"
00039 #include "ServiceUnreachable.hxx"
00040 
00041 #include "SALOME_NamingService_defs.hxx"
00042 
00043 class NAMINGSERVICE_EXPORT SALOME_NamingService
00044 {
00045 public:
00046   SALOME_NamingService();
00047   SALOME_NamingService(CORBA::ORB_ptr orb);
00048 
00049   virtual ~SALOME_NamingService();
00050 
00051   void init_orb(CORBA::ORB_ptr orb=0);
00052   void Register(CORBA::Object_ptr ObjRef,
00053           const char* Path) 
00054     throw(ServiceUnreachable);
00055   CORBA::Object_ptr Resolve(const char* Path)
00056     throw( ServiceUnreachable); 
00057   CORBA::Object_ptr ResolveFirst(const char* Path)
00058     throw( ServiceUnreachable); 
00059   CORBA::Object_ptr ResolveComponent(const char* hostname,
00060                          const char* containerName,
00061                          const char* componentName,
00062                          const int nbproc=0)
00063     throw(ServiceUnreachable);
00064   std::string ContainerName(const char *ContainerName);
00065   std::string ContainerName(const Engines::MachineParameters& params);
00066   std::string BuildContainerNameForNS(const char *ContainerName,
00067                           const char *hostname);
00068   std::string 
00069   BuildContainerNameForNS(const Engines::MachineParameters& params,
00070                  const char *hostname);
00071   int Find(const char* name)
00072     throw(ServiceUnreachable);
00073   bool Create_Directory(const char* Path)
00074     throw(ServiceUnreachable);
00075   bool Change_Directory(const char* Path)
00076     throw(ServiceUnreachable);
00077   char* Current_Directory()
00078     throw(ServiceUnreachable);
00079   void list()
00080     throw(ServiceUnreachable);
00081   std::vector<std::string> list_directory()
00082     throw(ServiceUnreachable);
00083   std::vector<std::string> list_subdirs()
00084     throw(ServiceUnreachable);
00085   std::vector<std::string> list_directory_recurs()
00086     throw(ServiceUnreachable);
00087   void Destroy_Name(const char* Path)
00088     throw(ServiceUnreachable);
00089   virtual void Destroy_Directory(const char* Path)
00090     throw(ServiceUnreachable);
00091   virtual void Destroy_FullDirectory(const char* Path)
00092     throw(ServiceUnreachable);
00093   char* getIORaddr();
00094   CORBA::ORB_ptr orb();
00095 
00096 protected:
00097   Utils_Mutex _myMutex;
00098   CORBA::ORB_var _orb;
00099   CosNaming::NamingContext_var _root_context, _current_context;
00100 
00101   void _initialize_root_context();
00102   int _createContextNameDir(std::string path,
00103                    CosNaming::Name& context_name,
00104                    std::vector<std::string>& splitPath,
00105                    bool onlyDir);
00106   void _Find(const char* name, CORBA::Long& occurence_number);
00107   void _current_directory(std::vector<std::string>& splitPath,
00108                  int& lengthResult,
00109                  CosNaming::NamingContext_var contextToFind,
00110                  bool& notFound);
00111   void _list_directory_recurs(std::vector<std::string>& myList,
00112                      std::string relativeSubDir,
00113                      std::string absCurDirectory);
00114 
00115 };
00116 
00117 #endif // SALOME_NAMINGSERVICE_H
00118