Salome HOME
BugID: IPAL19426 Fixed methods Save/Load
[modules/kernel.git] / src / NamingService / SALOME_NamingService.hxx
1 //  SALOME NamingService : wrapping NamingService services
2 //
3 //  Copyright (C) 2003  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 //
23 //
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 "utilities.h"
39 #include "Utils_Mutex.hxx"
40 #include "ServiceUnreachable.hxx"
41
42 #if defined NAMINGSERVICE_EXPORTS
43 #if defined WIN32
44 #define NAMINGSERVICE_EXPORT __declspec( dllexport )
45 #else
46 #define NAMINGSERVICE_EXPORT
47 #endif
48 #else
49 #if defined WNT
50 #define NAMINGSERVICE_EXPORT __declspec( dllimport )
51 #else
52 #define NAMINGSERVICE_EXPORT
53 #endif
54 #endif
55
56 class NAMINGSERVICE_EXPORT SALOME_NamingService
57 {
58 public:
59   SALOME_NamingService();
60   SALOME_NamingService(CORBA::ORB_ptr orb);
61
62   virtual ~SALOME_NamingService();
63
64   void init_orb(CORBA::ORB_ptr orb);
65   void Register(CORBA::Object_ptr ObjRef,
66                 const char* Path) 
67     throw(ServiceUnreachable);
68   CORBA::Object_ptr Resolve(const char* Path)
69     throw( ServiceUnreachable); 
70   CORBA::Object_ptr ResolveFirst(const char* Path)
71     throw( ServiceUnreachable); 
72   CORBA::Object_ptr ResolveComponent(const char* hostname,
73                                      const char* containerName,
74                                      const char* componentName,
75                                      const int nbproc=0)
76     throw(ServiceUnreachable);
77   std::string ContainerName(const char *ContainerName);
78   std::string ContainerName(const Engines::MachineParameters& params);
79   std::string BuildContainerNameForNS(const char *ContainerName,
80                                       const char *hostname);
81   std::string 
82   BuildContainerNameForNS(const Engines::MachineParameters& params,
83                           const char *hostname);
84   int Find(const char* name)
85     throw(ServiceUnreachable);
86   bool Create_Directory(const char* Path)
87     throw(ServiceUnreachable);
88   bool Change_Directory(const char* Path)
89     throw(ServiceUnreachable);
90   char* Current_Directory()
91     throw(ServiceUnreachable);
92   void list()
93     throw(ServiceUnreachable);
94   std::vector<std::string> list_directory()
95     throw(ServiceUnreachable);
96   std::vector<std::string> list_subdirs()
97     throw(ServiceUnreachable);
98   std::vector<std::string> list_directory_recurs()
99     throw(ServiceUnreachable);
100   void Destroy_Name(const char* Path)
101     throw(ServiceUnreachable);
102   virtual void Destroy_Directory(const char* Path)
103     throw(ServiceUnreachable);
104   virtual void Destroy_FullDirectory(const char* Path)
105     throw(ServiceUnreachable);
106   char* getIORaddr();
107
108 protected:
109   Utils_Mutex _myMutex;
110   CORBA::ORB_ptr _orb;
111   CosNaming::NamingContext_var _root_context, _current_context;
112
113   void _initialize_root_context();
114   int _createContextNameDir(std::string path,
115                             CosNaming::Name& context_name,
116                             std::vector<std::string>& splitPath,
117                             bool onlyDir);
118   void _Find(const char* name, CORBA::Long& occurence_number);
119   void _current_directory(std::vector<std::string>& splitPath,
120                           int& lengthResult,
121                           CosNaming::NamingContext_var contextToFind,
122                           bool& notFound);
123   void _list_directory_recurs(std::vector<std::string>& myList,
124                               std::string relativeSubDir,
125                               std::string absCurDirectory);
126
127 };
128
129 #endif // SALOME_NAMINGSERVICE_H
130