Salome HOME
CCAR:
[modules/kernel.git] / src / NamingService / SALOME_NamingService.hxx
1 //  Copyright (C) 2007-2008  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.
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 //  SALOME NamingService : wrapping NamingService services
23 //  File   : SALOME_NamingService.hxx
24 //  Author : Estelle Deville
25 //  Module : SALOME
26 //  $Header$
27 //
28 #ifndef SALOME_NAMINGSERVICE_H
29 #define SALOME_NAMINGSERVICE_H
30
31 #include <SALOMEconfig.h>
32 #include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
33 #include CORBA_CLIENT_HEADER(SALOME_Component)
34
35 #include <vector>
36 #include <string>
37 #include "utilities.h"
38 #include "Utils_Mutex.hxx"
39 #include "ServiceUnreachable.hxx"
40
41 #include "SALOME_NamingService_defs.hxx"
42
43 class NAMINGSERVICE_EXPORT SALOME_NamingService
44 {
45 public:
46   SALOME_NamingService();
47   SALOME_NamingService(CORBA::ORB_ptr orb);
48
49   virtual ~SALOME_NamingService();
50
51   void init_orb(CORBA::ORB_ptr orb);
52   void Register(CORBA::Object_ptr ObjRef,
53                 const char* Path) 
54     throw(ServiceUnreachable);
55   CORBA::Object_ptr Resolve(const char* Path)
56     throw( ServiceUnreachable); 
57   CORBA::Object_ptr ResolveFirst(const char* Path)
58     throw( ServiceUnreachable); 
59   CORBA::Object_ptr ResolveComponent(const char* hostname,
60                                      const char* containerName,
61                                      const char* componentName,
62                                      const int nbproc=0)
63     throw(ServiceUnreachable);
64   std::string ContainerName(const char *ContainerName);
65   std::string ContainerName(const Engines::MachineParameters& params);
66   std::string BuildContainerNameForNS(const char *ContainerName,
67                                       const char *hostname);
68   std::string 
69   BuildContainerNameForNS(const Engines::MachineParameters& params,
70                           const char *hostname);
71   int Find(const char* name)
72     throw(ServiceUnreachable);
73   bool Create_Directory(const char* Path)
74     throw(ServiceUnreachable);
75   bool Change_Directory(const char* Path)
76     throw(ServiceUnreachable);
77   char* Current_Directory()
78     throw(ServiceUnreachable);
79   void list()
80     throw(ServiceUnreachable);
81   std::vector<std::string> list_directory()
82     throw(ServiceUnreachable);
83   std::vector<std::string> list_subdirs()
84     throw(ServiceUnreachable);
85   std::vector<std::string> list_directory_recurs()
86     throw(ServiceUnreachable);
87   void Destroy_Name(const char* Path)
88     throw(ServiceUnreachable);
89   virtual void Destroy_Directory(const char* Path)
90     throw(ServiceUnreachable);
91   virtual void Destroy_FullDirectory(const char* Path)
92     throw(ServiceUnreachable);
93   char* getIORaddr();
94
95 protected:
96   Utils_Mutex _myMutex;
97   CORBA::ORB_ptr _orb;
98   CosNaming::NamingContext_var _root_context, _current_context;
99
100   void _initialize_root_context();
101   int _createContextNameDir(std::string path,
102                             CosNaming::Name& context_name,
103                             std::vector<std::string>& splitPath,
104                             bool onlyDir);
105   void _Find(const char* name, CORBA::Long& occurence_number);
106   void _current_directory(std::vector<std::string>& splitPath,
107                           int& lengthResult,
108                           CosNaming::NamingContext_var contextToFind,
109                           bool& notFound);
110   void _list_directory_recurs(std::vector<std::string>& myList,
111                               std::string relativeSubDir,
112                               std::string absCurDirectory);
113
114 };
115
116 #endif // SALOME_NAMINGSERVICE_H
117