Salome HOME
Copyrights update 2015.
[modules/kernel.git] / src / NamingService / SALOME_NamingService.hxx
1 // Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  SALOME NamingService : wrapping NamingService services
24 //  File   : SALOME_NamingService.hxx
25 //  Author : Estelle Deville
26 //  Module : SALOME
27 //  $Header$
28 //
29 #ifndef SALOME_NAMINGSERVICE_H
30 #define SALOME_NAMINGSERVICE_H
31
32 #include <SALOMEconfig.h>
33 #include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
34 #include CORBA_CLIENT_HEADER(SALOME_Component)
35
36 #include <vector>
37 #include <string>
38 #include "Utils_Mutex.hxx"
39 #include "ServiceUnreachable.hxx"
40
41 #include "SALOME_NamingService_defs.hxx"
42
43 #ifdef WIN32
44 #pragma warning(disable:4290) // Warning Exception ...
45 #endif
46
47 class NAMINGSERVICE_EXPORT SALOME_NamingService
48 {
49 public:
50   SALOME_NamingService();
51   SALOME_NamingService(CORBA::ORB_ptr orb);
52
53   virtual ~SALOME_NamingService();
54
55   void init_orb(CORBA::ORB_ptr orb=0);
56   void Register(CORBA::Object_ptr ObjRef, const char* Path) throw(ServiceUnreachable);
57   CORBA::Object_ptr Resolve(const char* Path) throw( ServiceUnreachable); 
58   CORBA::Object_ptr ResolveFirst(const char* Path) throw( ServiceUnreachable); 
59   CORBA::Object_ptr ResolveComponent(const char* hostname,
60                                      const char* containerName,
61                                      const char* componentName,
62                                      const int nbproc=0) throw(ServiceUnreachable);
63   std::string ContainerName(const char *ContainerName);
64   std::string ContainerName(const Engines::ContainerParameters& params);
65   std::string BuildContainerNameForNS(const char *ContainerName, const char *hostname);
66   std::string BuildContainerNameForNS(const Engines::ContainerParameters& params, const char *hostname);
67
68   int Find(const char* name) throw(ServiceUnreachable);
69   bool Create_Directory(const char* Path) throw(ServiceUnreachable);
70   bool Change_Directory(const char* Path) throw(ServiceUnreachable);
71   char* Current_Directory() throw(ServiceUnreachable);
72   void list() throw(ServiceUnreachable);
73   std::vector<std::string> list_directory() throw(ServiceUnreachable);
74   std::vector<std::string> list_subdirs() throw(ServiceUnreachable);
75   std::vector<std::string> list_directory_recurs() throw(ServiceUnreachable);
76   void Destroy_Name(const char* Path) throw(ServiceUnreachable);
77   virtual void Destroy_Directory(const char* Path) throw(ServiceUnreachable);
78   virtual void Destroy_FullDirectory(const char* Path) throw(ServiceUnreachable);
79   char *getIORaddr();
80   CORBA::ORB_ptr orb();
81
82 protected:
83   Utils_Mutex _myMutex;
84   CORBA::ORB_var _orb;
85   CosNaming::NamingContext_var _root_context, _current_context;
86
87   void _initialize_root_context();
88   int _createContextNameDir(std::string path,
89                             CosNaming::Name& context_name,
90                             std::vector<std::string>& splitPath,
91                             bool onlyDir);
92   void _Find(const char* name, CORBA::Long& occurence_number);
93   void _current_directory(std::vector<std::string>& splitPath,
94                           int& lengthResult,
95                           CosNaming::NamingContext_var contextToFind,
96                           bool& notFound);
97   void _list_directory_recurs(std::vector<std::string>& myList,
98                               std::string relativeSubDir,
99                               std::string absCurDirectory);
100
101 };
102
103 #endif // SALOME_NAMINGSERVICE_H
104