Initial Patch of Auction House bot rev. 135
[auctionmangos.git] / dep / ACE_wrappers / ace / Local_Name_Space_T.h
blob9822a22a6e735d7316cd602d844fdeea9bac503b
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Local_Name_Space_T.h
7 * $Id: Local_Name_Space_T.h 80826 2008-03-04 14:51:23Z wotte $
9 * @author Prashant Jain <pjain@cs.wustl.edu>
10 * @author Irfan Pyarali <irfan@wuerl.wustl.edu> and
11 * @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
13 //=============================================================================
15 #ifndef ACE_LOCAL_NAME_SPACE_T_H
16 #define ACE_LOCAL_NAME_SPACE_T_H
17 #include /**/ "ace/pre.h"
19 #include "ace/Name_Space.h"
21 #if !defined (ACE_LACKS_PRAGMA_ONCE)
22 # pragma once
23 #endif /* ACE_LACKS_PRAGMA_ONCE */
25 #include "ace/Naming_Context.h"
26 #include "ace/SString.h"
27 #include "ace/Local_Name_Space.h"
28 #include "ace/Null_Mutex.h"
30 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
32 /// A short-hand name for our set of name/value/type tuples passed back
33 /// to callers.
34 typedef ACE_Unbounded_Set<ACE_NS_WString> ACE_WSTRING_SET;
36 ACE_END_VERSIONED_NAMESPACE_DECL
38 // Simplify later usage by defining typedefs.
39 #if (1)
40 # include "ace/Hash_Map_Manager_T.h"
41 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
42 typedef ACE_Hash_Map_Manager_Ex<ACE_NS_String, ACE_NS_Internal, ACE_Hash<ACE_NS_String>, ACE_Equal_To<ACE_NS_String>, ACE_Null_Mutex> MAP_MANAGER;
43 ACE_END_VERSIONED_NAMESPACE_DECL
44 #else
45 # include "ace/Map_Manager.h"
46 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
47 typedef ACE_Map_Manager<ACE_NS_String, ACE_NS_Internal, ACE_Null_Mutex> MAP_MANAGER;
48 ACE_END_VERSIONED_NAMESPACE_DECL
49 #endif /* 0 */
51 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
53 /// @deprecated Deprecated typedefs. Use the map's traits instead.
54 typedef MAP_MANAGER::ITERATOR MAP_ITERATOR;
55 typedef MAP_MANAGER::ENTRY MAP_ENTRY;
58 /**
59 * @class ACE_Name_Space_Map
61 * @brief This class serves as a Proxy that ensures our process always
62 * has the appropriate allocator in place for every operation
63 * that accesses or updates the Map Manager.
65 * We need this class because otherwise the ALLOCATOR
66 * pointer will be stored in the Map_Manager that resides within
67 * shared memory. Naturally, this will cause horrible problems
68 * since only the first process to set that pointer will be
69 * guaranteed the address of the ALLOCATOR is meaningful!
71 template <class ALLOCATOR>
72 class ACE_Name_Space_Map : public MAP_MANAGER
74 public:
75 /// Constructor.
76 ACE_Name_Space_Map (ALLOCATOR *alloc);
78 // = The following methods are Proxies to the underlying methods
79 // provided by ACE_Hash_Map_Manager. When they are called, they
80 // acquire the lock, set the allocator to the one specific to this
81 // process, and then call down to perform the intended operation.
82 int bind (const ACE_NS_String &,
83 const ACE_NS_Internal &,
84 ALLOCATOR *alloc);
86 int unbind (const ACE_NS_String &,
87 ACE_NS_Internal &,
88 ALLOCATOR *alloc);
90 int rebind (const ACE_NS_String &,
91 const ACE_NS_Internal &,
92 ACE_NS_String &,
93 ACE_NS_Internal &,
94 ALLOCATOR *alloc);
96 int find (const ACE_NS_String &,
97 ACE_NS_Internal &,
98 ALLOCATOR *alloc);
100 int close (ALLOCATOR *alloc);
104 * @class ACE_Local_Name_Space
106 * @brief Maintaining accesses Local Name Server Database. Allows to
107 * add NameBindings, change them, remove them and resolve
108 * NameBindings.
110 * Manages a Naming Service for a local name space which
111 * includes bindings for node_local and host_local naming
112 * contexts. All strings are stored in wide character format.
113 * A Name Binding consists of a name (that's the key), a value
114 * string and an optional type string (no wide chars).
116 template <ACE_MEM_POOL_1, class ACE_LOCK>
117 class ACE_Local_Name_Space : public ACE_Name_Space
119 public:
120 // = Initialization and termination methods.
121 /// "Do-nothing" constructor.
122 ACE_Local_Name_Space (void);
125 * Specifies the scope of this namespace, opens and memory-maps the
126 * associated file (if accessible) or contacts the dedicated name
127 * server process for NET_LOCAL namespace.
129 ACE_Local_Name_Space (ACE_Naming_Context::Context_Scope_Type scope_in,
130 ACE_Name_Options *name_options);
133 * Specifies the scope of this namespace, opens and memory-maps the
134 * associated file (if accessible) or contacts the dedicated name
135 * server process for NET_LOCAL namespace.
137 int open (ACE_Naming_Context::Context_Scope_Type scope_in);
139 /// Destructor, do some cleanup :TBD: last dtor should "compress"
140 /// file
141 ~ACE_Local_Name_Space (void);
143 /// Bind a new name to a naming context (Wide character strings).
144 virtual int bind (const ACE_NS_WString &name,
145 const ACE_NS_WString &value,
146 const char *type = "");
149 * Overwrite the value or type of an existing name in a
150 * ACE_Local_Name_Space or bind a new name to the context, if it
151 * didn't exist yet. (Wide charcter strings interface).
153 virtual int rebind (const ACE_NS_WString &name,
154 const ACE_NS_WString &value,
155 const char *type = "");
157 /// Delete a name from a ACE_Local_Name_Space (Wide charcter strings
158 /// Interface).
159 virtual int unbind (const ACE_NS_WString &name);
160 virtual int unbind_i (const ACE_NS_WString &name);
162 /// Get value and type of a given name binding (Wide chars). The
163 /// caller is responsible for deleting @a type!
164 virtual int resolve (const ACE_NS_WString &name,
165 ACE_NS_WString &value,
166 char *&type);
167 virtual int resolve_i (const ACE_NS_WString &name,
168 ACE_NS_WString &value,
169 char *&type);
171 /// Get a set of names matching a specified pattern (wchars). Matching
172 /// means the names must begin with the pattern string.
173 virtual int list_names (ACE_WSTRING_SET &set,
174 const ACE_NS_WString &pattern);
175 virtual int list_names_i (ACE_WSTRING_SET &set,
176 const ACE_NS_WString &pattern);
178 /// Get a set of values matching a specified pattern (wchars). Matching
179 /// means the values must begin with the pattern string.
180 virtual int list_values (ACE_WSTRING_SET &set,
181 const ACE_NS_WString &pattern);
182 virtual int list_values_i (ACE_WSTRING_SET &set,
183 const ACE_NS_WString &pattern);
185 /// Get a set of types matching a specified pattern (wchars). Matching
186 /// means the types must begin with the pattern string.
187 virtual int list_types (ACE_WSTRING_SET &set,
188 const ACE_NS_WString &pattern);
189 virtual int list_types_i (ACE_WSTRING_SET &set,
190 const ACE_NS_WString &pattern);
193 * Get a set of names matching a specified pattern (wchars). Matching
194 * means the names must begin with the pattern string. Returns the
195 * complete binding associated each pattern match.
197 virtual int list_name_entries (ACE_BINDING_SET &set,
198 const ACE_NS_WString &pattern);
199 virtual int list_name_entries_i (ACE_BINDING_SET &set,
200 const ACE_NS_WString &pattern);
203 * Get a set of values matching a specified pattern (wchars). Matching
204 * means the values must begin with the pattern string. Returns the
205 * complete binding associated each pattern match.
207 virtual int list_value_entries (ACE_BINDING_SET &set,
208 const ACE_NS_WString &pattern);
209 virtual int list_value_entries_i (ACE_BINDING_SET &set,
210 const ACE_NS_WString &pattern);
213 * Get a set of types matching a specified pattern (wchars). Matching
214 * means the types must begin with the pattern string. Returns the
215 * complete binding associated each pattern match.
217 virtual int list_type_entries (ACE_BINDING_SET &set,
218 const ACE_NS_WString &pattern);
219 virtual int list_type_entries_i (ACE_BINDING_SET &set,
220 const ACE_NS_WString &pattern);
222 /// Dump the state of the object
223 virtual void dump (void) const;
224 virtual void dump_i (void) const;
226 // = I just know this is going to cause problems on some platform...
227 typedef ACE_Allocator_Adapter <ACE_Malloc <ACE_MEM_POOL_2, ACE_LOCK> >
228 ALLOCATOR;
230 private:
231 #if defined (ACE_WIN32)
232 /// Remap the backing store
233 int remap (EXCEPTION_POINTERS *ep);
234 #endif /* ACE_WIN32 */
236 /// Factor out code from bind() and rebind().
237 int shared_bind (const ACE_NS_WString &name,
238 const ACE_NS_WString &value,
239 const char *type, int rebind);
240 int shared_bind_i (const ACE_NS_WString &name,
241 const ACE_NS_WString &value,
242 const char *type, int rebind);
244 /// Allocate the appropriate type of map manager that stores the
245 /// key/value binding.
246 int create_manager (void);
247 int create_manager_i (void);
249 /// Pointer to the allocator
250 ALLOCATOR *allocator_;
252 /// Pointer to the allocated map manager.
253 ACE_Name_Space_Map <ALLOCATOR> *name_space_map_;
255 /// Scope of this naming context (e.g., PROC_LOCAL, NODE_LOCAL, or
256 /// NET_LOCAL).
257 ACE_Naming_Context::Context_Scope_Type ns_scope_;
259 /// Keep track of the options such as database name etc
260 ACE_Name_Options *name_options_;
262 /// Name of the file used as the backing store.
263 ACE_TCHAR context_file_[MAXPATHLEN + MAXNAMELEN];
265 /// Synchronization variable.
266 ACE_LOCK *lock_;
269 ACE_END_VERSIONED_NAMESPACE_DECL
271 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
272 #include "ace/Local_Name_Space_T.cpp"
273 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
275 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
276 #pragma implementation ("Local_Name_Space_T.cpp")
277 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
279 #include /**/ "ace/post.h"
280 #endif /* ACE_LOCAL_NAME_SPACE_T_H */