1 // $Id: Local_Name_Space_T.cpp 80826 2008-03-04 14:51:23Z wotte $
3 #ifndef ACE_LOCAL_NAME_SPACE_T_CPP
4 #define ACE_LOCAL_NAME_SPACE_T_CPP
8 #if !defined (ACE_LACKS_PRAGMA_ONCE)
10 #endif /* ACE_LACKS_PRAGMA_ONCE */
12 #include "ace/Local_Name_Space.h"
13 #include "ace/Auto_Ptr.h"
14 #include "ace/Guard_T.h"
15 #include "ace/OS_NS_regex.h"
16 #include "ace/OS_NS_string.h"
17 #include "ace/OS_NS_unistd.h"
19 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
21 template <class ALLOCATOR
>
22 ACE_Name_Space_Map
<ALLOCATOR
>::ACE_Name_Space_Map (ALLOCATOR
*alloc
)
25 ACE_TRACE ("ACE_Name_Space_Map::ACE_Name_Space_Map");
28 template <class ALLOCATOR
> int
29 ACE_Name_Space_Map
<ALLOCATOR
>::close (ALLOCATOR
*alloc
)
31 ACE_TRACE ("ACE_Name_Space_Map::close");
33 this->table_allocator_
= alloc
;
34 this->entry_allocator_
= alloc
;
35 return this->close_i ();
38 template <class ALLOCATOR
> int
39 ACE_Name_Space_Map
<ALLOCATOR
>::bind (const ACE_NS_String
&ext_id
,
40 const ACE_NS_Internal
&int_id
,
43 ACE_TRACE ("ACE_Name_Space_Map::bind");
45 this->table_allocator_
= alloc
;
46 this->entry_allocator_
= alloc
;
47 return this->bind_i (ext_id
, int_id
);
50 template <class ALLOCATOR
> int
51 ACE_Name_Space_Map
<ALLOCATOR
>::unbind (const ACE_NS_String
&ext_id
,
52 ACE_NS_Internal
&int_id
,
55 ACE_TRACE ("ACE_Name_Space_Map::unbind");
57 this->table_allocator_
= alloc
;
58 this->entry_allocator_
= alloc
;
59 return this->unbind_i (ext_id
, int_id
);
62 template <class ALLOCATOR
> int
63 ACE_Name_Space_Map
<ALLOCATOR
>::rebind (const ACE_NS_String
&ext_id
,
64 const ACE_NS_Internal
&int_id
,
65 ACE_NS_String
&old_ext_id
,
66 ACE_NS_Internal
&old_int_id
,
69 ACE_TRACE ("ACE_Name_Space_Map::rebind");
71 this->table_allocator_
= alloc
;
72 this->entry_allocator_
= alloc
;
73 return this->rebind_i (ext_id
, int_id
, old_ext_id
, old_int_id
);
76 template <class ALLOCATOR
> int
77 ACE_Name_Space_Map
<ALLOCATOR
>::find (const ACE_NS_String
&ext_id
,
78 ACE_NS_Internal
&int_id
,
81 ACE_TRACE ("ACE_Name_Space_Map::find");
83 this->table_allocator_
= alloc
;
84 this->entry_allocator_
= alloc
;
85 return this->find_i (ext_id
, int_id
);
88 #if defined (ACE_WIN32)
89 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
90 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::remap (EXCEPTION_POINTERS
*ep
)
92 ACE_TRACE ("ACE_Local_Name_Space::remap");
94 void *addr
= (void *) ep
->ExceptionRecord
->ExceptionInformation
[1];
96 // The following requires Memory Pool to have ::remap()
97 // defined. Thus currently this will only work for
98 // ACE_MMap_Memory_Pool.
99 if (this->allocator_
->alloc ().memory_pool ().remap (addr
) == -1)
100 // Kick it upstairs...
101 return EXCEPTION_CONTINUE_SEARCH
;
104 // This is 80x86-specific.
105 ep
->ContextRecord
->Edi
= (DWORD
) addr
;
107 ep
->ContextRecord
->IntA0
=
108 ep
->ContextRecord
->IntV0
= (DWORD
) addr
;
109 ep
->ContextRecord
->IntT5
= ep
->ContextRecord
->IntA0
+ 3;
111 // Resume execution at the original point of "failure."
112 return EXCEPTION_CONTINUE_EXECUTION
;
114 #endif /* ACE_WIN32 */
116 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
117 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::shared_bind (
118 const ACE_NS_WString
&name
,
119 const ACE_NS_WString
&value
,
123 // Note that we *must* use structured exception handling here
124 // because (1) we may need to commit virtual memory pages and (2)
125 // C++ exception handling doesn't support resumption.
129 result
= this->shared_bind_i (name
, value
, type
, rebind
);
131 ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
137 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
138 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::shared_bind_i (
139 const ACE_NS_WString
&name
,
140 const ACE_NS_WString
&value
,
145 ACE_TRACE ("ACE_Local_Name_Space::shared_bind_i");
146 const size_t name_len
= (name
.length () + 1) * sizeof (ACE_WCHAR_T
);
147 const size_t value_len
= (value
.length () + 1) * sizeof (ACE_WCHAR_T
);
148 const size_t type_len
= ACE_OS::strlen (type
) + 1;
149 const size_t total_len
= name_len
+ value_len
+ type_len
;
150 char *ptr
= (char *) this->allocator_
->malloc (total_len
);
156 // Note that the value_rep *must* come first to make sure we can
157 // retrieve this pointer later on in unbind().
158 ACE_WCHAR_T
*value_rep
= (ACE_WCHAR_T
*) (ptr
);
159 ACE_WCHAR_T
*name_rep
= (ACE_WCHAR_T
*) (ptr
+ value_len
);
160 char *new_type
= (char *) (ptr
+ value_len
+ name_len
);
162 ACE_Auto_Basic_Array_Ptr
<ACE_WCHAR_T
> name_urep (name
.rep ());
163 ACE_Auto_Basic_Array_Ptr
<ACE_WCHAR_T
> value_urep (value
.rep ());
164 ACE_NS_String
new_name (name_rep
, name_urep
.get (), name_len
);
165 ACE_NS_String
new_value (value_rep
, value_urep
.get (), value_len
);
167 ACE_OS::strcpy (new_type
, type
);
168 ACE_NS_Internal
new_internal (new_value
, new_type
);
173 // Do a normal bind. This will fail if there's already an
174 // <new_internal> with the same name.
175 result
= this->name_space_map_
->bind (new_name
,
181 // Entry already existed so bind failed. Free our
182 // dynamically allocated memory.
183 this->allocator_
->free ((void *) ptr
);
189 // Do a rebind. If there's already any entry, this will
190 // return the existing <new_name> and <new_internal> and
191 // overwrite the existing name binding.
192 ACE_NS_String old_name
;
193 ACE_NS_Internal old_internal
;
195 result
= this->name_space_map_
->rebind (new_name
, new_internal
,
196 old_name
, old_internal
,
200 // Free up the memory we allocated in shared_bind().
201 // Note that this assumes that the "value" pointer comes
202 // first and that the value, name, and type are
203 // contiguously allocated (see above for details)
204 this->allocator_
->free ((void *) (old_internal
.value ()).fast_rep ());
209 // Free our dynamically allocated memory.
210 this->allocator_
->free ((void *) ptr
);
212 // If bind() or rebind() succeed, they will automatically sync
213 // up the map manager entry. However, we must sync up our
214 // name/value memory.
215 this->allocator_
->sync (ptr
, total_len
);
221 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
222 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::unbind (
223 const ACE_NS_WString
&name
)
225 // Note that we *must* use structured exception handling here
226 // because (1) we may need to commit virtual memory pages and (2)
227 // C++ exception handling doesn't support resumption.
231 result
= this->unbind_i (name
);
233 ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
240 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
241 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::unbind_i (
242 const ACE_NS_WString
&name
)
244 ACE_TRACE ("ACE_Local_Name_Space::unbind_i");
246 ACE_WRITE_GUARD_RETURN (ACE_LOCK
, ace_mon
, *this->lock_
, -1);
247 ACE_NS_String
ns_name (name
);
248 ACE_NS_Internal ns_internal
;
249 if (this->name_space_map_
->unbind (ns_name
,
251 this->allocator_
) != 0)
254 // Free up the memory we allocated in shared_bind(). Note that this
255 // assumes that the "value" pointer comes first and that the value,
256 // name and type are contiguously allocated (see shared_bind() for
258 this->allocator_
->free ((void *) (ns_internal
.value ()).fast_rep ());
262 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
263 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::bind (
264 const ACE_NS_WString
&name
,
265 const ACE_NS_WString
&value
,
268 ACE_TRACE ("ACE_Local_Name_Space::bind");
269 ACE_WRITE_GUARD_RETURN (ACE_LOCK
, ace_mon
, *this->lock_
, -1);
271 return this->shared_bind (name
, value
, type
, 0);
274 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
275 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::rebind (
276 const ACE_NS_WString
&name
,
277 const ACE_NS_WString
&value
,
280 ACE_TRACE ("ACE_Local_Name_Space::rebind");
281 ACE_WRITE_GUARD_RETURN (ACE_LOCK
, ace_mon
, *this->lock_
, -1);
283 return this->shared_bind (name
, value
, type
, 1);
286 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
287 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::resolve (
288 const ACE_NS_WString
&name
,
289 ACE_NS_WString
&value
,
292 // Note that we *must* use structured exception handling here
293 // because (1) we may need to commit virtual memory pages and (2)
294 // C++ exception handling doesn't support resumption.
298 result
= this->resolve_i (name
, value
, type
);
300 ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
307 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
308 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::resolve_i (
309 const ACE_NS_WString
&name
,
310 ACE_NS_WString
&value
,
313 ACE_TRACE ("ACE_Local_Name_Space::resolve_i");
314 ACE_READ_GUARD_RETURN (ACE_LOCK
, ace_mon
, *this->lock_
, -1);
316 ACE_NS_String
ns_name (name
);
317 ACE_NS_Internal ns_internal
;
318 ACE_NS_String nbc_string
; // Note the classy variable name! :)
320 if (this->name_space_map_
->find (ns_name
,
322 this->allocator_
) != 0)
325 // Calls conversion operator and then calls the ACE_NS_WString
326 // assignment operator to get a fresh copy. (*#*(@#&!*@!!*@&( HP
327 // compiler causes us to add an extra copy explicitly !! :)
328 nbc_string
= ns_internal
.value ();
331 // Gets type and then the actual reprsentation which is a
333 const char *temp
= ns_internal
.type ();
335 size_t len
= ACE_OS::strlen (ns_internal
.type ());
336 // Makes a copy here. Caller needs to call delete to free up
339 ACE_NEW_RETURN (new_type
,
343 ACE_OS::strsncpy (new_type
, temp
, len
+ 1);
348 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
349 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::open (
350 ACE_Naming_Context::Context_Scope_Type scope_in
)
352 ACE_TRACE ("ACE_Local_Name_Space::open");
353 this->ns_scope_
= scope_in
;
355 return this->create_manager ();
358 template <ACE_MEM_POOL_1
, class ACE_LOCK
>
359 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::ACE_Local_Name_Space (void)
364 ACE_TRACE ("ACE_Local_Name_Space::ACE_Local_Name_Space");
367 template <ACE_MEM_POOL_1
, class ACE_LOCK
>
368 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::ACE_Local_Name_Space (
369 ACE_Naming_Context::Context_Scope_Type scope_in
,
370 ACE_Name_Options
*name_options
)
371 : name_options_ (name_options
)
373 ACE_TRACE ("ACE_Local_Name_Space::ACE_Local_Name_Space");
374 if (this->open (scope_in
) == -1)
375 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_Local_Name_Space::ACE_Local_Name_Space")));
378 template <ACE_MEM_POOL_1
, class ACE_LOCK
>
379 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::~ACE_Local_Name_Space (void)
381 ACE_TRACE ("ACE_Local_Name_Space::~ACE_Local_Name_Space");
384 delete this->allocator_
;
388 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
389 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::create_manager (void)
391 // Note that we *must* use structured exception handling here
392 // because (1) we may need to commit virtual memory pages and (2)
393 // C++ exception handling doesn't support resumption.
397 result
= this->create_manager_i ();
399 ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
406 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
407 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::create_manager_i (void)
409 ACE_TRACE ("ACE_Local_Name_Space::create_manager_i");
410 // Get directory name
411 const ACE_TCHAR
*dir
= this->name_options_
->namespace_dir ();
412 const ACE_TCHAR
*database
= this->name_options_
->database ();
414 // Use process name as the file name.
415 size_t len
= ACE_OS::strlen (dir
);
416 len
+= ACE_OS::strlen (ACE_DIRECTORY_SEPARATOR_STR
);
417 len
+= ACE_OS::strlen (database
) + 1;
419 if (len
>= MAXNAMELEN
+ MAXPATHLEN
)
421 errno
= ENAMETOOLONG
;
425 ACE_OS::strcpy (this->context_file_
, dir
);
426 ACE_OS::strcat (this->context_file_
, ACE_DIRECTORY_SEPARATOR_STR
);
427 ACE_OS::strcat (this->context_file_
, database
);
429 ACE_MEM_POOL_OPTIONS
options (this->name_options_
->base_address ());
431 ACE_TCHAR lock_name_for_local_name_space
[MAXNAMELEN
+ MAXPATHLEN
];
432 ACE_TCHAR lock_name_for_backing_store
[MAXPATHLEN
+ MAXNAMELEN
];
433 const ACE_TCHAR
*postfix
= database
;
436 length
= sizeof lock_name_for_local_name_space
/ sizeof (ACE_TCHAR
);
437 ACE_OS::strsncpy (lock_name_for_local_name_space
,
441 ACE_OS::strncat (lock_name_for_local_name_space
,
442 ACE_DIRECTORY_SEPARATOR_STR
,
443 length
- ACE_OS::strlen (lock_name_for_local_name_space
));
444 ACE_OS::strncat (lock_name_for_local_name_space
,
445 ACE_TEXT ("name_space_"),
446 length
- ACE_OS::strlen (lock_name_for_local_name_space
));
447 ACE_OS::strncat (lock_name_for_local_name_space
,
449 length
- ACE_OS::strlen (lock_name_for_local_name_space
));
451 length
= sizeof lock_name_for_backing_store
/ sizeof (ACE_TCHAR
);
452 ACE_OS::strsncpy (lock_name_for_backing_store
,
455 ACE_OS::strncat (lock_name_for_backing_store
,
456 ACE_DIRECTORY_SEPARATOR_STR
,
457 length
- ACE_OS::strlen (lock_name_for_backing_store
));
458 ACE_OS::strncat (lock_name_for_backing_store
,
459 ACE_TEXT ("backing_store_"),
460 length
- ACE_OS::strlen (lock_name_for_backing_store
));
461 ACE_OS::strncat (lock_name_for_backing_store
,
463 length
- ACE_OS::strlen (ACE_TEXT ("backing_store_")));
465 // Create the allocator with the appropriate options.
466 ACE_NEW_RETURN (this->allocator_
,
467 ALLOCATOR (this->context_file_
,
468 lock_name_for_backing_store
,
471 if (ACE_LOG_MSG
->op_status ())
472 ACE_ERROR_RETURN ((LM_ERROR
,
473 ACE_TEXT ("Allocator::Allocator\n")),
476 ACE_NEW_RETURN (this->lock_
,
477 ACE_LOCK (lock_name_for_local_name_space
),
480 #if !defined (ACE_LACKS_ACCESS)
481 // Now check if the backing store has been created successfully
482 if (ACE_OS::access (this->context_file_
, F_OK
) != 0)
483 ACE_ERROR_RETURN ((LM_ERROR
,
484 ACE_TEXT ("create_manager\n")),
486 #endif /* ACE_LACKS_ACCESS */
490 // This is the easy case since if we find the Name Server Map
491 // Manager we know it's already initialized.
492 if (this->allocator_
->find (ACE_NAME_SERVER_MAP
, ns_map
) == 0)
494 this->name_space_map_
= (ACE_Name_Space_Map
<ALLOCATOR
> *) ns_map
;
496 ACE_DEBUG ((LM_DEBUG
,
497 ACE_TEXT ("name_space_map_ = %@, ns_map = %@\n"),
498 this->name_space_map_
, ns_map
));
501 // This is the hard part since we have to avoid potential race
502 // conditions... We will use the double check here
505 ACE_GUARD_RETURN (ACE_LOCK
, ace_mon
, *this->lock_
, -1);
507 // This is the easy case since if we find the Name Server Map
508 // Manager we know it's already initialized.
509 if (this->allocator_
->find (ACE_NAME_SERVER_MAP
, ns_map
) == 0)
511 this->name_space_map_
= (ACE_Name_Space_Map
<ALLOCATOR
> *) ns_map
;
513 ACE_DEBUG ((LM_DEBUG
,
514 ACE_TEXT ("name_space_map_ = %@, ns_map = %@\n"),
515 this->name_space_map_
, ns_map
));
519 size_t map_size
= sizeof *this->name_space_map_
;
520 ns_map
= this->allocator_
->malloc (map_size
);
522 // Initialize the map into its memory location (e.g., shared memory).
523 this->name_space_map_
=
524 new (ns_map
) ACE_Name_Space_Map
<ALLOCATOR
> (this->allocator_
);
526 if (this->allocator_
->bind (ACE_NAME_SERVER_MAP
, ns_map
) == -1)
527 ACE_ERROR_RETURN ((LM_ERROR
,
528 ACE_TEXT ("create_manager\n")), -1);
532 ACE_DEBUG ((LM_DEBUG
,
533 ACE_TEXT ("name_space_map_ = %@, ns_map = %@\n"),
534 this->name_space_map_
, ns_map
));
540 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
541 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::list_names_i (
542 ACE_WSTRING_SET
&set
,
543 const ACE_NS_WString
&pattern
)
545 ACE_TRACE ("ACE_Local_Name_Space::list_names_i");
546 ACE_READ_GUARD_RETURN (ACE_LOCK
, ace_mon
, *this->lock_
, -1);
548 MAP_MANAGER::ITERATOR
map_iterator (*this->name_space_map_
);
549 MAP_MANAGER::ENTRY
*map_entry
;
554 map_iterator
.next (map_entry
) != 0;
555 map_iterator
.advance())
557 if (map_entry
->ext_id_
.strstr (pattern
) != -1)
559 ACE_NS_WString
entry (map_entry
->ext_id_
);
561 if (set
.insert (entry
) == -1)
574 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
575 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::list_values_i (
576 ACE_WSTRING_SET
&set
,
577 const ACE_NS_WString
&pattern
)
579 ACE_TRACE ("ACE_Local_Name_Space::list_values_i");
580 ACE_READ_GUARD_RETURN (ACE_LOCK
, ace_mon
, *this->lock_
, -1);
582 MAP_MANAGER::ITERATOR
map_iterator (*this->name_space_map_
);
583 MAP_MANAGER::ENTRY
*map_entry
;
588 map_iterator
.next (map_entry
) != 0;
589 map_iterator
.advance ())
591 if (map_entry
->int_id_
.value ().strstr (pattern
) != -1)
593 ACE_NS_WString
entry (map_entry
->int_id_
.value ());
595 if (set
.insert (entry
) == -1)
608 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
609 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::list_types_i (
610 ACE_WSTRING_SET
&set
,
611 const ACE_NS_WString
&pattern
)
613 ACE_TRACE ("ACE_Local_Name_Space::list_types_i");
614 ACE_READ_GUARD_RETURN (ACE_LOCK
, ace_mon
, *this->lock_
, -1);
616 MAP_MANAGER::ITERATOR
map_iterator (*this->name_space_map_
);
617 MAP_MANAGER::ENTRY
*map_entry
;
619 char *compiled_regexp
= 0;
621 // Note that char_rep() allocates memory so we need to delete it
622 char *pattern_rep
= pattern
.char_rep ();
624 // Check for wildcard case first.
625 if (ACE_OS::strcmp ("", pattern_rep
) == 0)
626 ACE_ALLOCATOR_RETURN (compiled_regexp
,
630 // Compile the regular expression (the 0's cause ACE_OS::compile
631 // to allocate space).
632 #if defined (ACE_HAS_REGEX)
633 compiled_regexp
= ACE_OS::compile (pattern_rep
, 0, 0);
635 // If we don't have regular expressions just use the pattern
637 compiled_regexp
= pattern_rep
;
638 #endif /* ACE_HAS_REGEX */
643 map_iterator
.next (map_entry
) != 0;
644 map_iterator
.advance ())
647 const char *type
= map_entry
->int_id_
.type ();
649 // Everything matches the wildcard.
650 if (ACE_OS::strcmp ("", pattern_rep
) == 0
651 #if defined (ACE_HAS_REGEX)
652 || ACE_OS::step (type
, compiled_regexp
) != 0)
654 // If we don't have regular expressions just use strstr() for
655 // substring matching.
656 || ACE_OS::strstr (type
, compiled_regexp
) != 0)
657 #endif /* ACE_HAS_REGEX */
660 ACE_NS_WString
entry (type
);
662 if (set
.insert (entry
) == -1)
671 #if defined (ACE_HAS_REGEX)
673 ACE_OS::free ((void *) compiled_regexp
);
674 #endif /* ACE_HAS_REGEX */
675 delete [] pattern_rep
; // delete pattern_rep;
679 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
680 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::list_name_entries_i (
681 ACE_BINDING_SET
&set
,
682 const ACE_NS_WString
&pattern
)
684 ACE_TRACE ("ACE_Local_Name_Space::list_name_entries_i");
685 ACE_READ_GUARD_RETURN (ACE_LOCK
, ace_mon
, *this->lock_
, -1);
687 MAP_MANAGER::ITERATOR
map_iterator (*this->name_space_map_
);
688 MAP_MANAGER::ENTRY
*map_entry
;
691 map_iterator
.next (map_entry
) != 0;
692 map_iterator
.advance())
694 if (map_entry
->ext_id_
.strstr (pattern
) != -1)
696 ACE_Name_Binding
entry (map_entry
->ext_id_
,
697 map_entry
->int_id_
.value (),
698 map_entry
->int_id_
.type ());
700 if (set
.insert (entry
) == -1)
708 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
709 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::list_value_entries_i (
710 ACE_BINDING_SET
&set
,
711 const ACE_NS_WString
&pattern
)
713 ACE_TRACE ("ACE_Local_Name_Space::list_value_entries_i");
714 ACE_READ_GUARD_RETURN (ACE_LOCK
, ace_mon
, *this->lock_
, -1);
716 MAP_MANAGER::ITERATOR
map_iterator (*this->name_space_map_
);
717 MAP_MANAGER::ENTRY
*map_entry
;
720 map_iterator
.next (map_entry
) != 0;
721 map_iterator
.advance ())
723 if (map_entry
->int_id_
.value ().strstr (pattern
) != -1)
725 ACE_Name_Binding
entry (map_entry
->ext_id_
,
726 map_entry
->int_id_
.value (),
727 map_entry
->int_id_
.type ());
729 if (set
.insert (entry
) == -1)
736 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
737 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::list_type_entries_i (
738 ACE_BINDING_SET
&set
,
739 const ACE_NS_WString
&pattern
)
741 ACE_TRACE ("ACE_Local_Name_Space::list_type_entries_i");
742 ACE_READ_GUARD_RETURN (ACE_LOCK
, ace_mon
, *this->lock_
, -1);
744 MAP_MANAGER::ITERATOR
map_iterator (*this->name_space_map_
);
745 MAP_MANAGER::ENTRY
*map_entry
;
747 char *compiled_regexp
= 0;
748 // Note that char_rep() allocates memory so we need to delete it
749 char *pattern_rep
= pattern
.char_rep ();
751 // Check for wildcard case first.
752 if (ACE_OS::strcmp ("", pattern_rep
) == 0)
753 compiled_regexp
= ACE_OS::strdup ("");
755 // Compile the regular expression (the 0's cause ACE_OS::compile
756 // to allocate space).
757 #if defined (ACE_HAS_REGEX)
758 compiled_regexp
= ACE_OS::compile (pattern_rep
, 0, 0);
759 #else /* If we don't have regular expressions just the pattern
761 compiled_regexp
= pattern_rep
;
762 #endif /* ACE_HAS_REGEX */
765 map_iterator
.next (map_entry
) != 0;
766 map_iterator
.advance ())
769 const char *type
= map_entry
->int_id_
.type ();
771 if (ACE_OS::strcmp ("", pattern_rep
) == 0 // Everything matches
773 #if defined (ACE_HAS_REGEX)
774 || ACE_OS::step (type
, compiled_regexp
) != 0)
775 #else /* If we don't have regular expressions just use strstr() for
776 substring matching. */
777 || ACE_OS::strstr (type
, compiled_regexp
) != 0)
778 #endif /* ACE_HAS_REGEX */
780 ACE_Name_Binding
entry (map_entry
->ext_id_
,
781 map_entry
->int_id_
.value (),
782 map_entry
->int_id_
.type ());
784 if (set
.insert (entry
) == -1)
788 #if defined (ACE_HAS_REGEX)
790 ACE_OS::free ((void *) compiled_regexp
);
791 #endif /* ACE_HAS_REGEX */
792 delete [] pattern_rep
; // delete pattern_rep;
796 template <ACE_MEM_POOL_1
, class ACE_LOCK
> void
797 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::dump_i (void) const
799 ACE_TRACE ("ACE_Local_Name_Space::dump_i");
801 ACE_DEBUG ((LM_DEBUG
, ACE_BEGIN_DUMP
, this));
803 MAP_MANAGER::ITERATOR
map_iterator (*this->name_space_map_
);
804 MAP_MANAGER::ENTRY
*map_entry
;
807 map_iterator
.next (map_entry
) != 0;
808 map_iterator
.advance())
810 char *key
= map_entry
->ext_id_
.char_rep ();
811 char *value
= map_entry
->int_id_
.value ().char_rep ();
812 #if !defined (ACE_NLOGGING)
813 const char *type
= map_entry
->int_id_
.type ();
814 #endif /* ! ACE_NLOGGING */
816 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("key=%s\nvalue=%s\ntype=%s\n"),
817 ACE_TEXT_CHAR_TO_TCHAR (key
), ACE_TEXT_CHAR_TO_TCHAR (value
), ACE_TEXT_CHAR_TO_TCHAR (type
)));
818 // We need to delete key and value since char_rep allocates
824 ACE_DEBUG ((LM_DEBUG
, ACE_END_DUMP
));
827 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
828 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::list_names (
829 ACE_WSTRING_SET
&set
,
830 const ACE_NS_WString
&pattern
)
832 // Note that we *must* use structured exception handling here
833 // because (1) we may need to commit virtual memory pages and (2)
834 // C++ exception handling doesn't support resumption.
838 result
= this->list_names_i (set
, pattern
);
840 ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
846 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
847 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::list_values (
848 ACE_WSTRING_SET
&set
,
849 const ACE_NS_WString
&pattern
)
851 // Note that we *must* use structured exception handling here
852 // because (1) we may need to commit virtual memory pages and (2)
853 // C++ exception handling doesn't support resumption.
857 result
= this->list_values_i (set
, pattern
);
859 ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
865 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
866 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::list_types (
867 ACE_WSTRING_SET
&set
,
868 const ACE_NS_WString
&pattern
)
870 // Note that we *must* use structured exception handling here
871 // because (1) we may need to commit virtual memory pages and (2)
872 // C++ exception handling doesn't support resumption.
876 result
= this->list_types_i (set
, pattern
);
878 ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
884 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
885 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::list_name_entries (
886 ACE_BINDING_SET
&set
,
887 const ACE_NS_WString
&pattern
)
889 // Note that we *must* use structured exception handling here
890 // because (1) we may need to commit virtual memory pages and (2)
891 // C++ exception handling doesn't support resumption.
895 result
= this->list_name_entries_i (set
, pattern
);
897 ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
903 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
904 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::list_value_entries (
905 ACE_BINDING_SET
&set
,
906 const ACE_NS_WString
&pattern
)
908 // Note that we *must* use structured exception handling here
909 // because (1) we may need to commit virtual memory pages and (2)
910 // C++ exception handling doesn't support resumption.
914 result
= this->list_value_entries_i (set
, pattern
);
916 ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
922 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
923 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::list_type_entries (
924 ACE_BINDING_SET
&set
,
925 const ACE_NS_WString
&pattern
)
927 // Note that we *must* use structured exception handling here
928 // because (1) we may need to commit virtual memory pages and (2)
929 // C++ exception handling doesn't support resumption.
933 result
= this->list_type_entries_i (set
, pattern
);
935 ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
941 template <ACE_MEM_POOL_1
, class ACE_LOCK
> void
942 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::dump (void) const
944 #if defined (ACE_HAS_DUMP)
945 // Note that we *must* use structured exception handling here
946 // because (1) we may need to commit virtual memory pages and (2)
947 // C++ exception handling doesn't support resumption.
949 // This should really be a const cast
950 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
> *fake_this
=
951 (ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
> *) this;
952 ACE_UNUSED_ARG (fake_this
);
958 ACE_SEH_EXCEPT (fake_this
->remap (GetExceptionInformation ()))
961 #endif /* ACE_HAS_DUMP */
964 ACE_END_VERSIONED_NAMESPACE_DECL
966 #endif /* ACE_LOCAL_NAME_SPACE_T_CPP */