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