1 // SALOME NamingService : wrapping NamingService services
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SALOME_NamingService.hxx
25 // Author : Estelle Deville
29 #ifndef SALOME_NAMINGSERVICE_H
30 #define SALOME_NAMINGSERVICE_H
32 #include "utilities.h"
36 #include "Utils_Mutex.hxx"
38 //class ServiceUnreachable;
39 #include "ServiceUnreachable.hxx"
41 class SALOME_NamingService
44 //! default constructor
45 SALOME_NamingService();
47 //! standard constructor
48 SALOME_NamingService(CORBA::ORB_ptr orb);
50 //! standard destructor
51 virtual ~SALOME_NamingService();
53 //! initialize ORB reference after default constructor
54 void init_orb(CORBA::ORB_ptr orb);
56 //! method to create an association in the NamingService between an object reference and a path
57 void Register(CORBA::Object_ptr ObjRef, const char* Path)
58 throw(ServiceUnreachable);
60 //! method to get the ObjRef of a symbolic name
61 CORBA::Object_ptr Resolve(const char* Path)
62 throw( ServiceUnreachable);
64 //! method to get an ObjRef, given a symbolic name without instance suffix "/Path/Name*.kind"
65 CORBA::Object_ptr ResolveFirst(const char* Path)
66 throw( ServiceUnreachable);
68 //! method to research a name from the naming service's current directory
69 int Find(const char* name)
70 throw(ServiceUnreachable);
72 //! method to create a directory from the current directory
73 bool Create_Directory(const char* Path)
74 throw(ServiceUnreachable);
76 //! method to change the current directory to the directory Path indicated in "in" Parameter
77 bool Change_Directory(const char* Path)
78 throw(ServiceUnreachable);
80 //!method to get the current directory
81 char* Current_Directory()
82 throw(ServiceUnreachable);
84 //!method to print all the contexts contained from the current directory
86 throw(ServiceUnreachable);
88 //!method to get all the contexts contained in the current direcotry
89 // Get only objects, isn't iterative
90 std::vector<std::string> list_directory()
91 throw(ServiceUnreachable);
93 //!methods that lists all objects RECUSIVELY in the current directory
94 std::vector<std::string> list_directory_recurs()
95 throw(ServiceUnreachable);
97 //! method to destroy an association Path-Object Reference
98 void Destroy_Name(const char* Path)
99 throw(ServiceUnreachable);
101 //! method to destroy a directory if it is empty
102 virtual void Destroy_Directory(const char* Path)
103 throw(ServiceUnreachable);
105 //! get IORstring naming service address
109 Utils_Mutex _myMutex;
111 CosNaming::NamingContext_var _root_context, _current_context;
113 //! method called by constructor to initialize _root_context
114 void _initialize_root_context();
116 //! method to decompose a Path : /Kernel/Services/Sessions
117 char* _resolve_Path(char* Path);
119 //! method to decompose a Path : /Kernel/Services/Sessions
120 void _result_resolve_Path(const char* Path, int& j,
121 char ** resultat_resolve_Path);
123 //! internal method called by Find to research a name from the naming service's current directory
124 void _Find(const char* name, CORBA::Long& occurence_number);
126 //! internal method to create a context name from a Path
127 void _create_context_name_dir(char** resultat_resolve_Path,
129 CosNaming::Name& _context_name);
131 //! internal method to create a parse the naming service tree
132 void _current_directory(char** result_path,
134 CosNaming::NamingContext_var context_to_found,
135 CORBA::Boolean& _continue);
137 //! internal method to list all (recursively) the objects contains in absCurDirectory/relativeSubDir.
138 void _list_directory_recurs(std::vector<std::string>& myList, const char *relativeSubDir,const char *absCurDirectory);
142 #endif // SALOME_NAMINGSERVICE_H