1 #ifndef ACE_LOCAL_NAME_SPACE_T_CPP
2 #define ACE_LOCAL_NAME_SPACE_T_CPP
6 #if !defined (ACE_LACKS_PRAGMA_ONCE)
8 #endif /* ACE_LACKS_PRAGMA_ONCE */
10 #include "ace/Local_Name_Space.h"
11 #include "ace/Guard_T.h"
12 #include "ace/OS_NS_regex.h"
13 #include "ace/OS_NS_string.h"
14 #include "ace/OS_NS_unistd.h"
17 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
19 template <class ALLOCATOR
>
20 ACE_Name_Space_Map
<ALLOCATOR
>::ACE_Name_Space_Map (ALLOCATOR
*alloc
)
23 ACE_TRACE ("ACE_Name_Space_Map::ACE_Name_Space_Map");
26 template <class ALLOCATOR
> int
27 ACE_Name_Space_Map
<ALLOCATOR
>::close (ALLOCATOR
*alloc
)
29 ACE_TRACE ("ACE_Name_Space_Map::close");
31 this->table_allocator_
= alloc
;
32 this->entry_allocator_
= alloc
;
33 return this->close_i ();
36 template <class ALLOCATOR
> int
37 ACE_Name_Space_Map
<ALLOCATOR
>::bind (const ACE_NS_String
&ext_id
,
38 const ACE_NS_Internal
&int_id
,
41 ACE_TRACE ("ACE_Name_Space_Map::bind");
43 this->table_allocator_
= alloc
;
44 this->entry_allocator_
= alloc
;
45 return this->bind_i (ext_id
, int_id
);
48 template <class ALLOCATOR
> int
49 ACE_Name_Space_Map
<ALLOCATOR
>::unbind (const ACE_NS_String
&ext_id
,
50 ACE_NS_Internal
&int_id
,
53 ACE_TRACE ("ACE_Name_Space_Map::unbind");
55 this->table_allocator_
= alloc
;
56 this->entry_allocator_
= alloc
;
57 return this->unbind_i (ext_id
, int_id
);
60 template <class ALLOCATOR
> int
61 ACE_Name_Space_Map
<ALLOCATOR
>::rebind (const ACE_NS_String
&ext_id
,
62 const ACE_NS_Internal
&int_id
,
63 ACE_NS_String
&old_ext_id
,
64 ACE_NS_Internal
&old_int_id
,
67 ACE_TRACE ("ACE_Name_Space_Map::rebind");
69 this->table_allocator_
= alloc
;
70 this->entry_allocator_
= alloc
;
71 return this->rebind_i (ext_id
, int_id
, old_ext_id
, old_int_id
);
74 template <class ALLOCATOR
> int
75 ACE_Name_Space_Map
<ALLOCATOR
>::find (const ACE_NS_String
&ext_id
,
76 ACE_NS_Internal
&int_id
,
79 ACE_TRACE ("ACE_Name_Space_Map::find");
81 this->table_allocator_
= alloc
;
82 this->entry_allocator_
= alloc
;
83 return this->find_i (ext_id
, int_id
);
86 #if defined (ACE_WIN32)
87 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
88 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::remap (EXCEPTION_POINTERS
*ep
)
90 ACE_TRACE ("ACE_Local_Name_Space::remap");
92 void *addr
= (void *) ep
->ExceptionRecord
->ExceptionInformation
[1];
94 // The following requires Memory Pool to have ::remap()
95 // defined. Thus currently this will only work for
96 // ACE_MMap_Memory_Pool.
97 if (this->allocator_
->alloc ().memory_pool ().remap (addr
) == -1)
98 // Kick it upstairs...
99 return EXCEPTION_CONTINUE_SEARCH
;
102 // This is 80x86-specific.
103 ep
->ContextRecord
->Edi
= (DWORD
) addr
;
105 ep
->ContextRecord
->IntA0
=
106 ep
->ContextRecord
->IntV0
= (DWORD
) addr
;
107 ep
->ContextRecord
->IntT5
= ep
->ContextRecord
->IntA0
+ 3;
109 // Resume execution at the original point of "failure."
110 return EXCEPTION_CONTINUE_EXECUTION
;
112 #endif /* ACE_WIN32 */
114 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
115 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::shared_bind (
116 const ACE_NS_WString
&name
,
117 const ACE_NS_WString
&value
,
121 // Note that we *must* use structured exception handling here
122 // because (1) we may need to commit virtual memory pages and (2)
123 // C++ exception handling doesn't support resumption.
127 result
= this->shared_bind_i (name
, value
, type
, rebind
);
129 ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
135 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
136 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::shared_bind_i (
137 const ACE_NS_WString
&name
,
138 const ACE_NS_WString
&value
,
142 ACE_TRACE ("ACE_Local_Name_Space::shared_bind_i");
143 const size_t name_len
= (name
.length () + 1) * sizeof (ACE_WCHAR_T
);
144 const size_t value_len
= (value
.length () + 1) * sizeof (ACE_WCHAR_T
);
145 const size_t type_len
= ACE_OS::strlen (type
) + 1;
146 const size_t total_len
= name_len
+ value_len
+ type_len
;
147 char *ptr
= (char *) this->allocator_
->malloc (total_len
);
153 // Note that the value_rep *must* come first to make sure we can
154 // retrieve this pointer later on in unbind().
155 ACE_WCHAR_T
*value_rep
= (ACE_WCHAR_T
*) (ptr
);
156 ACE_WCHAR_T
*name_rep
= (ACE_WCHAR_T
*) (ptr
+ value_len
);
157 char *new_type
= (char *) (ptr
+ value_len
+ name_len
);
159 std::unique_ptr
<ACE_WCHAR_T
[]> name_urep (name
.rep ());
160 std::unique_ptr
<ACE_WCHAR_T
[]> value_urep (value
.rep ());
161 ACE_NS_String
new_name (name_rep
, name_urep
.get (), name_len
);
162 ACE_NS_String
new_value (value_rep
, value_urep
.get (), value_len
);
164 ACE_OS::strcpy (new_type
, type
);
165 ACE_NS_Internal
new_internal (new_value
, new_type
);
170 // Do a normal bind. This will fail if there's already an
171 // <new_internal> with the same name.
172 result
= this->name_space_map_
->bind (new_name
,
178 // Entry already existed so bind failed. Free our
179 // dynamically allocated memory.
180 this->allocator_
->free ((void *) ptr
);
186 // Do a rebind. If there's already any entry, this will
187 // return the existing <new_name> and <new_internal> and
188 // overwrite the existing name binding.
189 ACE_NS_String old_name
;
190 ACE_NS_Internal old_internal
;
192 result
= this->name_space_map_
->rebind (new_name
, new_internal
,
193 old_name
, old_internal
,
197 // Free up the memory we allocated in shared_bind().
198 // Note that this assumes that the "value" pointer comes
199 // first and that the value, name, and type are
200 // contiguously allocated (see above for details)
201 this->allocator_
->free ((void *) (old_internal
.value ()).fast_rep ());
206 // Free our dynamically allocated memory.
207 this->allocator_
->free ((void *) ptr
);
209 // If bind() or rebind() succeed, they will automatically sync
210 // up the map manager entry. However, we must sync up our
211 // name/value memory.
212 this->allocator_
->sync (ptr
, total_len
);
218 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
219 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::unbind (
220 const ACE_NS_WString
&name
)
222 // Note that we *must* use structured exception handling here
223 // because (1) we may need to commit virtual memory pages and (2)
224 // C++ exception handling doesn't support resumption.
228 result
= this->unbind_i (name
);
230 ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
236 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
237 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::unbind_i (
238 const ACE_NS_WString
&name
)
240 ACE_TRACE ("ACE_Local_Name_Space::unbind_i");
242 ACE_WRITE_GUARD_RETURN (ACE_LOCK
, ace_mon
, *this->lock_
, -1);
243 ACE_NS_String
ns_name (name
);
244 ACE_NS_Internal ns_internal
;
245 if (this->name_space_map_
->unbind (ns_name
,
247 this->allocator_
) != 0)
250 // Free up the memory we allocated in shared_bind(). Note that this
251 // assumes that the "value" pointer comes first and that the value,
252 // name and type are contiguously allocated (see shared_bind() for
254 this->allocator_
->free ((void *) (ns_internal
.value ()).fast_rep ());
258 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
259 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::bind (
260 const ACE_NS_WString
&name
,
261 const ACE_NS_WString
&value
,
264 ACE_TRACE ("ACE_Local_Name_Space::bind");
265 ACE_WRITE_GUARD_RETURN (ACE_LOCK
, ace_mon
, *this->lock_
, -1);
267 return this->shared_bind (name
, value
, type
, 0);
270 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
271 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::rebind (
272 const ACE_NS_WString
&name
,
273 const ACE_NS_WString
&value
,
276 ACE_TRACE ("ACE_Local_Name_Space::rebind");
277 ACE_WRITE_GUARD_RETURN (ACE_LOCK
, ace_mon
, *this->lock_
, -1);
279 return this->shared_bind (name
, value
, type
, 1);
282 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
283 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::resolve (
284 const ACE_NS_WString
&name
,
285 ACE_NS_WString
&value
,
288 // Note that we *must* use structured exception handling here
289 // because (1) we may need to commit virtual memory pages and (2)
290 // C++ exception handling doesn't support resumption.
294 result
= this->resolve_i (name
, value
, type
);
296 ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
303 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
304 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::resolve_i (
305 const ACE_NS_WString
&name
,
306 ACE_NS_WString
&value
,
309 ACE_TRACE ("ACE_Local_Name_Space::resolve_i");
310 ACE_READ_GUARD_RETURN (ACE_LOCK
, ace_mon
, *this->lock_
, -1);
312 ACE_NS_String
ns_name (name
);
313 ACE_NS_Internal ns_internal
;
314 ACE_NS_String nbc_string
; // Note the classy variable name! :)
316 if (this->name_space_map_
->find (ns_name
,
318 this->allocator_
) != 0)
321 // Calls conversion operator and then calls the ACE_NS_WString
322 // assignment operator to get a fresh copy. (*#*(@#&!*@!!*@&( HP
323 // compiler causes us to add an extra copy explicitly !! :)
324 nbc_string
= ns_internal
.value ();
327 // Gets type and then the actual reprsentation which is a
329 const char *temp
= ns_internal
.type ();
331 size_t len
= ACE_OS::strlen (ns_internal
.type ());
332 // Makes a copy here. Caller needs to call delete to free up
335 #if defined (ACE_HAS_ALLOC_HOOKS)
336 ACE_ALLOCATOR_RETURN (new_type
,
337 static_cast<char*>(ACE_Allocator::instance()->malloc(sizeof(char) * (len
+ 1))),
340 ACE_NEW_RETURN (new_type
,
343 #endif /* ACE_HAS_ALLOC_HOOKS */
345 ACE_OS::strsncpy (new_type
, temp
, len
+ 1);
350 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
351 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::open (
352 ACE_Naming_Context::Context_Scope_Type scope_in
)
354 ACE_TRACE ("ACE_Local_Name_Space::open");
355 this->ns_scope_
= scope_in
;
357 return this->create_manager ();
360 template <ACE_MEM_POOL_1
, class ACE_LOCK
>
361 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::ACE_Local_Name_Space ()
366 ACE_TRACE ("ACE_Local_Name_Space::ACE_Local_Name_Space");
369 template <ACE_MEM_POOL_1
, class ACE_LOCK
>
370 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::ACE_Local_Name_Space (
371 ACE_Naming_Context::Context_Scope_Type scope_in
,
372 ACE_Name_Options
*name_options
)
375 name_options_ (name_options
),
378 ACE_TRACE ("ACE_Local_Name_Space::ACE_Local_Name_Space");
379 if (this->open (scope_in
) == -1)
380 ACELIB_ERROR ((LM_ERROR
, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_Local_Name_Space::ACE_Local_Name_Space")));
383 template <ACE_MEM_POOL_1
, class ACE_LOCK
>
384 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::~ACE_Local_Name_Space ()
386 ACE_TRACE ("ACE_Local_Name_Space::~ACE_Local_Name_Space");
389 delete this->allocator_
;
393 ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_Local_Name_Space
)
395 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
396 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::create_manager ()
398 // Note that we *must* use structured exception handling here
399 // because (1) we may need to commit virtual memory pages and (2)
400 // C++ exception handling doesn't support resumption.
404 result
= this->create_manager_i ();
406 ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
413 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
414 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::create_manager_i ()
416 ACE_TRACE ("ACE_Local_Name_Space::create_manager_i");
417 // Get directory name
418 const ACE_TCHAR
*dir
= this->name_options_
->namespace_dir ();
419 const ACE_TCHAR
*database
= this->name_options_
->database ();
421 // Use process name as the file name.
422 size_t len
= ACE_OS::strlen (dir
);
423 len
+= ACE_OS::strlen (ACE_DIRECTORY_SEPARATOR_STR
);
424 len
+= ACE_OS::strlen (database
) + 1;
426 if (len
>= MAXNAMELEN
+ MAXPATHLEN
)
428 errno
= ENAMETOOLONG
;
432 ACE_OS::strcpy (this->context_file_
, dir
);
433 ACE_OS::strcat (this->context_file_
, ACE_DIRECTORY_SEPARATOR_STR
);
434 ACE_OS::strcat (this->context_file_
, database
);
436 ACE_MEM_POOL_OPTIONS
options (this->name_options_
->base_address ());
438 ACE_TCHAR lock_name_for_local_name_space
[MAXNAMELEN
+ MAXPATHLEN
];
439 ACE_TCHAR lock_name_for_backing_store
[MAXPATHLEN
+ MAXNAMELEN
];
440 const ACE_TCHAR
*postfix
= database
;
442 size_t length
= sizeof lock_name_for_local_name_space
/ sizeof (ACE_TCHAR
);
443 ACE_OS::strsncpy (lock_name_for_local_name_space
,
447 ACE_OS::strncat (lock_name_for_local_name_space
,
448 ACE_DIRECTORY_SEPARATOR_STR
,
449 length
- ACE_OS::strlen (lock_name_for_local_name_space
));
450 ACE_OS::strncat (lock_name_for_local_name_space
,
451 ACE_TEXT ("name_space_"),
452 length
- ACE_OS::strlen (lock_name_for_local_name_space
));
453 ACE_OS::strncat (lock_name_for_local_name_space
,
455 length
- ACE_OS::strlen (lock_name_for_local_name_space
));
457 length
= sizeof lock_name_for_backing_store
/ sizeof (ACE_TCHAR
);
458 ACE_OS::strsncpy (lock_name_for_backing_store
,
461 ACE_OS::strncat (lock_name_for_backing_store
,
462 ACE_DIRECTORY_SEPARATOR_STR
,
463 length
- ACE_OS::strlen (lock_name_for_backing_store
));
464 ACE_OS::strncat (lock_name_for_backing_store
,
465 ACE_TEXT ("backing_store_"),
466 length
- ACE_OS::strlen (lock_name_for_backing_store
));
467 ACE_OS::strncat (lock_name_for_backing_store
,
469 length
- ACE_OS::strlen (ACE_TEXT ("backing_store_")));
471 // Create the allocator with the appropriate options.
472 ACE_NEW_RETURN (this->allocator_
,
473 ALLOCATOR (this->context_file_
,
474 lock_name_for_backing_store
,
477 if (ACE_LOG_MSG
->op_status ())
478 ACELIB_ERROR_RETURN ((LM_ERROR
,
479 ACE_TEXT ("Allocator::Allocator\n")),
482 ACE_NEW_RETURN (this->lock_
,
483 ACE_LOCK (lock_name_for_local_name_space
),
486 #if !defined (ACE_LACKS_ACCESS)
487 // Now check if the backing store has been created successfully
488 if (ACE_OS::access (this->context_file_
, F_OK
) != 0)
489 ACELIB_ERROR_RETURN ((LM_ERROR
,
490 ACE_TEXT ("create_manager\n")),
492 #endif /* ACE_LACKS_ACCESS */
496 // This is the easy case since if we find the Name Server Map
497 // Manager we know it's already initialized.
498 if (this->allocator_
->find (ACE_NAME_SERVER_MAP
, ns_map
) == 0)
500 this->name_space_map_
= (ACE_Name_Space_Map
<ALLOCATOR
> *) ns_map
;
502 ACELIB_DEBUG ((LM_DEBUG
,
503 ACE_TEXT ("name_space_map_ = %@, ns_map = %@\n"),
504 this->name_space_map_
, ns_map
));
507 // This is the hard part since we have to avoid potential race
508 // conditions... We will use the double check here
511 ACE_GUARD_RETURN (ACE_LOCK
, ace_mon
, *this->lock_
, -1);
513 // This is the easy case since if we find the Name Server Map
514 // Manager we know it's already initialized.
515 if (this->allocator_
->find (ACE_NAME_SERVER_MAP
, ns_map
) == 0)
517 this->name_space_map_
= (ACE_Name_Space_Map
<ALLOCATOR
> *) ns_map
;
519 ACELIB_DEBUG ((LM_DEBUG
,
520 ACE_TEXT ("name_space_map_ = %@, ns_map = %@\n"),
521 this->name_space_map_
, ns_map
));
525 size_t map_size
= sizeof *this->name_space_map_
;
526 ns_map
= this->allocator_
->malloc (map_size
);
528 // Initialize the map into its memory location (e.g., shared memory).
529 this->name_space_map_
=
530 new (ns_map
) ACE_Name_Space_Map
<ALLOCATOR
> (this->allocator_
);
532 if (this->allocator_
->bind (ACE_NAME_SERVER_MAP
, ns_map
) == -1)
533 ACELIB_ERROR_RETURN ((LM_ERROR
,
534 ACE_TEXT ("create_manager\n")), -1);
538 ACELIB_DEBUG ((LM_DEBUG
,
539 ACE_TEXT ("name_space_map_ = %@, ns_map = %@\n"),
540 this->name_space_map_
, ns_map
));
546 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
547 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::list_names_i (
548 ACE_WSTRING_SET
&set
,
549 const ACE_NS_WString
&pattern
)
551 ACE_TRACE ("ACE_Local_Name_Space::list_names_i");
552 ACE_READ_GUARD_RETURN (ACE_LOCK
, ace_mon
, *this->lock_
, -1);
554 MAP_MANAGER::ITERATOR
map_iterator (*this->name_space_map_
);
555 MAP_MANAGER::ENTRY
*map_entry
;
560 map_iterator
.next (map_entry
) != 0;
561 map_iterator
.advance())
563 if (map_entry
->ext_id_
.strstr (pattern
) != -1)
565 ACE_NS_WString
entry (map_entry
->ext_id_
);
567 if (set
.insert (entry
) == -1)
580 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
581 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::list_values_i (
582 ACE_WSTRING_SET
&set
,
583 const ACE_NS_WString
&pattern
)
585 ACE_TRACE ("ACE_Local_Name_Space::list_values_i");
586 ACE_READ_GUARD_RETURN (ACE_LOCK
, ace_mon
, *this->lock_
, -1);
588 MAP_MANAGER::ITERATOR
map_iterator (*this->name_space_map_
);
589 MAP_MANAGER::ENTRY
*map_entry
;
594 map_iterator
.next (map_entry
) != 0;
595 map_iterator
.advance ())
597 if (map_entry
->int_id_
.value ().strstr (pattern
) != -1)
599 ACE_NS_WString
entry (map_entry
->int_id_
.value ());
601 if (set
.insert (entry
) == -1)
614 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
615 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::list_types_i (
616 ACE_WSTRING_SET
&set
,
617 const ACE_NS_WString
&pattern
)
619 ACE_TRACE ("ACE_Local_Name_Space::list_types_i");
620 ACE_READ_GUARD_RETURN (ACE_LOCK
, ace_mon
, *this->lock_
, -1);
622 MAP_MANAGER::ITERATOR
map_iterator (*this->name_space_map_
);
623 MAP_MANAGER::ENTRY
*map_entry
;
625 char *compiled_regexp
= 0;
627 // Note that char_rep() allocates memory so we need to delete it
628 char *pattern_rep
= pattern
.char_rep ();
630 // Check for wildcard case first.
631 if (ACE_OS::strcmp ("", pattern_rep
) == 0)
632 ACE_ALLOCATOR_RETURN (compiled_regexp
,
636 // Compile the regular expression (the 0's cause ACE_OS::compile
637 // to allocate space).
638 #if defined (ACE_HAS_REGEX)
639 compiled_regexp
= ACE_OS::compile (pattern_rep
, 0, 0);
641 // If we don't have regular expressions just use the pattern
643 compiled_regexp
= pattern_rep
;
644 #endif /* ACE_HAS_REGEX */
649 map_iterator
.next (map_entry
) != 0;
650 map_iterator
.advance ())
653 const char *type
= map_entry
->int_id_
.type ();
655 // Everything matches the wildcard.
656 if (ACE_OS::strcmp ("", pattern_rep
) == 0
657 #if defined (ACE_HAS_REGEX)
658 || ACE_OS::step (type
, compiled_regexp
) != 0)
660 // If we don't have regular expressions just use strstr() for
661 // substring matching.
662 || ACE_OS::strstr (type
, compiled_regexp
) != 0)
663 #endif /* ACE_HAS_REGEX */
666 ACE_NS_WString
entry (type
);
668 if (set
.insert (entry
) == -1)
677 #if defined (ACE_HAS_REGEX)
679 ACE_OS::free ((void *) compiled_regexp
);
680 #endif /* ACE_HAS_REGEX */
681 #if defined (ACE_HAS_ALLOC_HOOKS)
682 ACE_Allocator::instance()->free(pattern_rep
);
684 delete [] pattern_rep
; // delete pattern_rep;
685 #endif /* ACE_HAS_ALLOC_HOOKS */
689 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
690 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::list_name_entries_i (
691 ACE_BINDING_SET
&set
,
692 const ACE_NS_WString
&pattern
)
694 ACE_TRACE ("ACE_Local_Name_Space::list_name_entries_i");
695 ACE_READ_GUARD_RETURN (ACE_LOCK
, ace_mon
, *this->lock_
, -1);
697 MAP_MANAGER::ITERATOR
map_iterator (*this->name_space_map_
);
698 MAP_MANAGER::ENTRY
*map_entry
;
701 map_iterator
.next (map_entry
) != 0;
702 map_iterator
.advance())
704 if (map_entry
->ext_id_
.strstr (pattern
) != -1)
706 ACE_Name_Binding
entry (map_entry
->ext_id_
,
707 map_entry
->int_id_
.value (),
708 map_entry
->int_id_
.type ());
710 if (set
.insert (entry
) == -1)
718 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
719 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::list_value_entries_i (
720 ACE_BINDING_SET
&set
,
721 const ACE_NS_WString
&pattern
)
723 ACE_TRACE ("ACE_Local_Name_Space::list_value_entries_i");
724 ACE_READ_GUARD_RETURN (ACE_LOCK
, ace_mon
, *this->lock_
, -1);
726 MAP_MANAGER::ITERATOR
map_iterator (*this->name_space_map_
);
727 MAP_MANAGER::ENTRY
*map_entry
;
730 map_iterator
.next (map_entry
) != 0;
731 map_iterator
.advance ())
733 if (map_entry
->int_id_
.value ().strstr (pattern
) != -1)
735 ACE_Name_Binding
entry (map_entry
->ext_id_
,
736 map_entry
->int_id_
.value (),
737 map_entry
->int_id_
.type ());
739 if (set
.insert (entry
) == -1)
746 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
747 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::list_type_entries_i (
748 ACE_BINDING_SET
&set
,
749 const ACE_NS_WString
&pattern
)
751 ACE_TRACE ("ACE_Local_Name_Space::list_type_entries_i");
752 ACE_READ_GUARD_RETURN (ACE_LOCK
, ace_mon
, *this->lock_
, -1);
754 MAP_MANAGER::ITERATOR
map_iterator (*this->name_space_map_
);
755 MAP_MANAGER::ENTRY
*map_entry
;
757 char *compiled_regexp
= 0;
758 // Note that char_rep() allocates memory so we need to delete it
759 char *pattern_rep
= pattern
.char_rep ();
761 // Check for wildcard case first.
762 if (ACE_OS::strcmp ("", pattern_rep
) == 0)
763 compiled_regexp
= ACE_OS::strdup ("");
765 // Compile the regular expression (the 0's cause ACE_OS::compile
766 // to allocate space).
767 #if defined (ACE_HAS_REGEX)
768 compiled_regexp
= ACE_OS::compile (pattern_rep
, 0, 0);
769 #else /* If we don't have regular expressions just the pattern
771 compiled_regexp
= pattern_rep
;
772 #endif /* ACE_HAS_REGEX */
775 map_iterator
.next (map_entry
) != 0;
776 map_iterator
.advance ())
779 const char *type
= map_entry
->int_id_
.type ();
781 if (ACE_OS::strcmp ("", pattern_rep
) == 0 // Everything matches
783 #if defined (ACE_HAS_REGEX)
784 || ACE_OS::step (type
, compiled_regexp
) != 0)
785 #else /* If we don't have regular expressions just use strstr() for
786 substring matching. */
787 || ACE_OS::strstr (type
, compiled_regexp
) != 0)
788 #endif /* ACE_HAS_REGEX */
790 ACE_Name_Binding
entry (map_entry
->ext_id_
,
791 map_entry
->int_id_
.value (),
792 map_entry
->int_id_
.type ());
794 if (set
.insert (entry
) == -1)
798 #if defined (ACE_HAS_REGEX)
800 ACE_OS::free ((void *) compiled_regexp
);
801 #endif /* ACE_HAS_REGEX */
802 #if defined (ACE_HAS_ALLOC_HOOKS)
803 ACE_Allocator::instance()->free(pattern_rep
);
805 delete [] pattern_rep
; // delete pattern_rep;
806 #endif /* ACE_HAS_ALLOC_HOOKS */
810 template <ACE_MEM_POOL_1
, class ACE_LOCK
> void
811 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::dump_i () const
813 ACE_TRACE ("ACE_Local_Name_Space::dump_i");
815 ACELIB_DEBUG ((LM_DEBUG
, ACE_BEGIN_DUMP
, this));
817 MAP_MANAGER::ITERATOR
map_iterator (*this->name_space_map_
);
818 MAP_MANAGER::ENTRY
*map_entry
;
821 map_iterator
.next (map_entry
) != 0;
822 map_iterator
.advance())
824 char *key
= map_entry
->ext_id_
.char_rep ();
825 char *value
= map_entry
->int_id_
.value ().char_rep ();
826 #if !defined (ACE_NLOGGING)
827 const char *type
= map_entry
->int_id_
.type ();
828 #endif /* ! ACE_NLOGGING */
830 ACELIB_DEBUG ((LM_DEBUG
, ACE_TEXT ("key=%C\nvalue=%C\ntype=%C\n"),
832 // We need to delete key and value since char_rep allocates
834 #if defined (ACE_HAS_ALLOC_HOOKS)
835 ACE_Allocator::instance()->free(key
);
836 ACE_Allocator::instance()->free(value
);
840 #endif /* ACE_HAS_ALLOC_HOOKS */
843 ACELIB_DEBUG ((LM_DEBUG
, ACE_END_DUMP
));
846 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
847 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::list_names (
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_names_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_values (
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_values_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_types (
886 ACE_WSTRING_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_types_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_name_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_name_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_value_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_value_entries_i (set
, pattern
);
935 ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
941 template <ACE_MEM_POOL_1
, class ACE_LOCK
> int
942 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::list_type_entries (
943 ACE_BINDING_SET
&set
,
944 const ACE_NS_WString
&pattern
)
946 // Note that we *must* use structured exception handling here
947 // because (1) we may need to commit virtual memory pages and (2)
948 // C++ exception handling doesn't support resumption.
952 result
= this->list_type_entries_i (set
, pattern
);
954 ACE_SEH_EXCEPT (this->remap (GetExceptionInformation ()))
960 template <ACE_MEM_POOL_1
, class ACE_LOCK
> void
961 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
>::dump () const
963 #if defined (ACE_HAS_DUMP)
964 // Note that we *must* use structured exception handling here
965 // because (1) we may need to commit virtual memory pages and (2)
966 // C++ exception handling doesn't support resumption.
968 // This should really be a const cast
969 ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
> *fake_this
=
970 (ACE_Local_Name_Space
<ACE_MEM_POOL_2
, ACE_LOCK
> *) this;
971 ACE_UNUSED_ARG (fake_this
);
977 ACE_SEH_EXCEPT (fake_this
->remap (GetExceptionInformation ()))
980 #endif /* ACE_HAS_DUMP */
983 ACE_END_VERSIONED_NAMESPACE_DECL
985 #endif /* ACE_LOCAL_NAME_SPACE_T_CPP */