Salome HOME
Moved some functionality to VTKViewer_Utilities.h
[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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
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 "utilities.h"
33 #include <CORBA.h>
34 #include <vector>
35 #include <string>
36
37 //class ServiceUnreachable;
38 #include "ServiceUnreachable.hxx"
39
40 class SALOME_NamingService
41 {
42 public:
43   //! default constructor
44   SALOME_NamingService();
45
46   //! standard constructor
47   SALOME_NamingService(CORBA::ORB_ptr orb);
48
49   //! standard destructor
50   virtual ~SALOME_NamingService();
51
52   //! initialize ORB reference after default constructor
53   void init_orb(CORBA::ORB_ptr orb);
54  
55   //! method to create an association in the NamingService between an object reference and a path
56   void Register(CORBA::Object_ptr ObjRef, const char* Path) 
57     throw(ServiceUnreachable);
58
59   //! method to get the ObjRef of a symbolic name
60   CORBA::Object_ptr Resolve(const char* Path)
61     throw( ServiceUnreachable); 
62
63   //! method to research a name from the naming service's current directory 
64   int Find(const char* name)
65     throw(ServiceUnreachable);
66   
67   //! method to create a directory from the current directory
68   bool Create_Directory(const char* Path)
69     throw(ServiceUnreachable);
70   
71   //! method to change the current directory to the directory Path indicated in "in" Parameter
72   bool Change_Directory(const char* Path)
73     throw(ServiceUnreachable);
74  
75   //!method to get the current directory
76   char* Current_Directory()
77     throw(ServiceUnreachable);
78
79   //!method to print all the contexts contained from the current directory
80   void list()
81     throw(ServiceUnreachable);
82
83   //!method to get all the contexts contained in the current direcotry
84   // Get only objects, isn't iterative
85   std::vector<std::string> list_directory()
86     throw(ServiceUnreachable);
87
88   //!methods that lists all objects RECUSIVELY in the current directory
89   std::vector<std::string> list_directory_recurs()
90     throw(ServiceUnreachable);
91  
92   //! method to destroy an association Path-Object Reference
93   void Destroy_Name(const char* Path)
94     throw(ServiceUnreachable);
95  
96   //! method to destroy a directory if it is empty
97   virtual void Destroy_Directory(const char* Path)
98     throw(ServiceUnreachable);
99
100   //! get IORstring naming service address 
101   char * getIORaddr();
102
103 protected:
104   CORBA::ORB_ptr _orb;
105   CosNaming::NamingContext_var _root_context, _current_context;
106
107   //! method called by constructor to initialize _root_context
108   void _initialize_root_context();
109   
110   //! method to decompose a Path : /Kernel/Services/Sessions
111   char* _resolve_Path(char* Path);
112
113   //! method to decompose a Path : /Kernel/Services/Sessions
114   void _result_resolve_Path(const char* Path, int& j,
115                             char ** resultat_resolve_Path);
116
117   //! internal method called by Find to research a name from the naming service's current directory 
118   void _Find(const char* name, CORBA::Long& occurence_number);
119
120   //! internal method to create a context name from a Path
121   void _create_context_name_dir(char** resultat_resolve_Path,
122                                 int length_copy,
123                                 CosNaming::Name& _context_name);
124
125   //! internal method to create a parse the naming service tree 
126   void _current_directory(char** result_path,
127                           int& length_result,
128                           CosNaming::NamingContext_var context_to_found,
129                           CORBA::Boolean& _continue);
130
131   //! internal method to list all (recursively) the objects contains in absCurDirectory/relativeSubDir.
132   void _list_directory_recurs(std::vector<std::string>& myList, const char *relativeSubDir,const char *absCurDirectory);
133
134 };
135
136 #endif // SALOME_NAMINGSERVICE_H