[7297] Fixed profession spells sorting in trainer spell list at client.
[getmangos.git] / dep / ACE_wrappers / ace / Map_T.h
blob08947e0e0a4cdfc1e8976d82c1d5cbae1e8c87a6
1 /* -*- C++ -*- */
3 //=============================================================================
4 /**
5 * @file Map_T.h
7 * $Id: Map_T.h 80826 2008-03-04 14:51:23Z wotte $
9 * @author Irfan Pyarali <irfan@cs.wustl.edu>
11 //=============================================================================
13 #ifndef ACE_MAP_T_H
14 #define ACE_MAP_T_H
15 #include /**/ "ace/pre.h"
17 #include "ace/Pair_T.h"
18 #include "ace/Map_Manager.h"
19 #include "ace/Hash_Map_Manager_T.h"
20 #include "ace/Active_Map_Manager.h"
22 #if !defined (ACE_LACKS_PRAGMA_ONCE)
23 # pragma once
24 #endif /* ACE_LACKS_PRAGMA_ONCE */
26 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
28 /**
29 * @class ACE_Noop_Key_Generator
31 * @brief Defines a noop key generator.
33 template <class T>
34 class ACE_Noop_Key_Generator
36 public:
38 /// Functor method: generates a new key.
39 int operator () (T &);
42 /**
43 * @class ACE_Incremental_Key_Generator
45 * @brief Defines a simple incremental key generator.
47 * Generates a new key of type T by incrementing current
48 * value. Requirements on T are:
49 * - Constructor that accepts 0 in the constructor.
50 * - Prefix increment.
51 * - Assignment.
52 * Note that a primitive types such as u_long, int, etc., are
53 * suitable for this class.
55 template <class T>
56 class ACE_Incremental_Key_Generator
58 public:
60 /// Constructor.
61 ACE_Incremental_Key_Generator (void);
63 /// Functor method: generates a new key.
64 int operator () (T &t);
66 /// Returns the current value.
67 const T& current_value (void) const;
69 protected:
71 /// Current value.
72 T t_;
75 /**
76 * @class ACE_Iterator_Impl
78 * @brief Defines a abstract iterator.
80 * Implementation to be provided by subclasses.
82 template <class T>
83 class ACE_Iterator_Impl
85 public:
87 /// Destructor.
88 virtual ~ACE_Iterator_Impl (void);
90 /// Clone.
91 virtual ACE_Iterator_Impl<T> *clone (void) const = 0;
93 /// Comparison.
94 virtual int compare (const ACE_Iterator_Impl<T> &rhs) const = 0;
96 /// Dereference.
97 virtual T dereference (void) const = 0;
99 /// Advance.
100 virtual void plus_plus (void) = 0;
102 /// Reverse.
103 virtual void minus_minus (void) = 0;
107 * @class ACE_Reverse_Iterator_Impl
109 * @brief Defines a abstract reverse iterator.
111 * Implementation to be provided by subclasses.
113 template <class T>
114 class ACE_Reverse_Iterator_Impl
116 public:
118 /// Destructor.
119 virtual ~ACE_Reverse_Iterator_Impl (void);
121 /// Clone.
122 virtual ACE_Reverse_Iterator_Impl<T> *clone (void) const = 0;
124 /// Comparison.
125 virtual int compare (const ACE_Reverse_Iterator_Impl<T> &rhs) const = 0;
127 /// Dereference.
128 virtual T dereference (void) const = 0;
130 /// Advance.
131 virtual void plus_plus (void) = 0;
133 /// Reverse.
134 virtual void minus_minus (void) = 0;
138 * @class ACE_Iterator
140 * @brief Defines the iterator interface.
142 * Implementation to be provided by forwarding.
144 template <class T>
145 class ACE_Iterator
147 public:
149 // = Traits.
150 typedef T value_type;
151 typedef ACE_Iterator_Impl<T> implementation;
153 /// Constructor.
154 ACE_Iterator (ACE_Iterator_Impl<T> *impl);
156 /// Copy constructor.
157 ACE_Iterator (const ACE_Iterator<T> &rhs);
159 /// Destructor.
160 ~ACE_Iterator (void);
162 /// Assignment operator.
163 ACE_Iterator<T> &operator= (const ACE_Iterator<T> &rhs);
165 /// Comparison operators.
166 bool operator== (const ACE_Iterator<T> &rhs) const;
167 bool operator!= (const ACE_Iterator<T> &rhs) const;
169 /// Dereference operator.
170 T operator *() const;
172 /// Prefix advance.
173 ACE_Iterator<T> &operator++ (void);
175 /// Postfix advance.
176 ACE_Iterator<T> operator++ (int);
178 /// Prefix reverse.
179 ACE_Iterator<T> &operator-- (void);
181 /// Postfix reverse.
182 ACE_Iterator<T> operator-- (int);
184 /// Accessor to implementation object.
185 ACE_Iterator_Impl<T> &impl (void);
187 protected:
189 /// Implementation pointer.
190 ACE_Iterator_Impl<T> *implementation_;
194 * @class ACE_Reverse_Iterator
196 * @brief Defines the reverse iterator interface.
198 * Implementation to be provided by forwarding.
200 template <class T>
201 class ACE_Reverse_Iterator
203 public:
205 // = Traits.
206 typedef T value_type;
207 typedef ACE_Reverse_Iterator_Impl<T> implementation;
209 /// Constructor.
210 ACE_Reverse_Iterator (ACE_Reverse_Iterator_Impl<T> *impl);
212 /// Copy constructor.
213 ACE_Reverse_Iterator (const ACE_Reverse_Iterator<T> &rhs);
215 /// Destructor.
216 ~ACE_Reverse_Iterator (void);
218 /// Assignment operator.
219 ACE_Reverse_Iterator<T> &operator= (const ACE_Reverse_Iterator<T> &rhs);
222 * @name Comparison Operators
224 * The usual equality operators.
226 //@{
227 bool operator== (const ACE_Reverse_Iterator<T> &rhs) const;
228 bool operator!= (const ACE_Reverse_Iterator<T> &rhs) const;
229 //@}
231 /// Dereference operator.
232 T operator *() const;
234 /// Prefix advance.
235 ACE_Reverse_Iterator<T> &operator++ (void);
237 /// Postfix advance.
238 ACE_Reverse_Iterator<T> operator++ (int);
240 /// Prefix reverse.
241 ACE_Reverse_Iterator<T> &operator-- (void);
243 /// Postfix reverse.
244 ACE_Reverse_Iterator<T> operator-- (int);
246 /// Accessor to implementation object.
247 ACE_Reverse_Iterator_Impl<T> &impl (void);
249 protected:
251 /// Implementation pointer.
252 ACE_Reverse_Iterator_Impl<T> *implementation_;
256 * @class ACE_Map
258 * @brief Defines a map interface.
260 * Implementation to be provided by subclasses.
262 template <class KEY, class VALUE>
263 class ACE_Map
265 public:
267 // = Traits.
268 typedef KEY
269 key_type;
270 typedef VALUE
271 mapped_type;
272 typedef ACE_Reference_Pair<const KEY, VALUE>
273 value_type;
274 typedef ACE_Iterator<value_type>
275 iterator;
276 typedef ACE_Reverse_Iterator<value_type>
277 reverse_iterator;
278 typedef ACE_Iterator_Impl<value_type>
279 iterator_implementation;
280 typedef ACE_Reverse_Iterator_Impl<value_type>
281 reverse_iterator_implementation;
283 /// Close down and release dynamically allocated resources.
284 virtual ~ACE_Map (void);
286 /// Initialize a map with size @a length.
287 virtual int open (size_t length = ACE_DEFAULT_MAP_SIZE,
288 ACE_Allocator *alloc = 0) = 0;
290 /// Close down a <Map> and release dynamically allocated resources.
291 virtual int close (void) = 0;
294 * Add @a key / @a value pair to the map. If @a key is already in the
295 * map then no changes are made and 1 is returned. Returns 0 on a
296 * successful addition. This function fails for maps that do not
297 * allow user specified keys. @a key is an "in" parameter.
299 virtual int bind (const KEY &key,
300 const VALUE &value) = 0;
303 * Add @a key / @a value pair to the map. @a key is an "inout" parameter
304 * and maybe modified/extended by the map to add additional
305 * information. To recover original key, call the <recover_key>
306 * method.
308 virtual int bind_modify_key (const VALUE &value,
309 KEY &key) = 0;
312 * Produce a key and return it through @a key which is an "out"
313 * parameter. For maps that do not naturally produce keys, the map
314 * adapters will use the @c KEY_GENERATOR class to produce a key.
315 * However, the users are responsible for not jeopardizing this key
316 * production scheme by using user specified keys with keys produced
317 * by the key generator.
319 virtual int create_key (KEY &key) = 0;
322 * Add @a value to the map, and the corresponding key produced by the
323 * Map is returned through @a key which is an "out" parameter. For
324 * maps that do not naturally produce keys, the map adapters will
325 * use the @c KEY_GENERATOR class to produce a key. However, the
326 * users are responsible for not jeopardizing this key production
327 * scheme by using user specified keys with keys produced by the key
328 * generator.
330 virtual int bind_create_key (const VALUE &value,
331 KEY &key) = 0;
334 * Add @a value to the map. The user does not care about the
335 * corresponding key produced by the Map. For maps that do not
336 * naturally produce keys, the map adapters will use the
337 * @c KEY_GENERATOR class to produce a key. However, the users are
338 * responsible for not jeopardizing this key production scheme by
339 * using user specified keys with keys produced by the key
340 * generator.
342 virtual int bind_create_key (const VALUE &value) = 0;
344 /// Recovers the original key potentially modified by the map during
345 /// <bind_modify_key>.
346 virtual int recover_key (const KEY &modified_key,
347 KEY &original_key) = 0;
350 * Reassociate @a key with @a value. The function fails if @a key is
351 * not in the map for maps that do not allow user specified keys.
352 * However, for maps that allow user specified keys, if the key is
353 * not in the map, a new @a key / @a value association is created.
355 virtual int rebind (const KEY &key,
356 const VALUE &value) = 0;
359 * Reassociate @a key with @a value, storing the old value into the
360 * "out" parameter @a old_value. The function fails if @a key is not
361 * in the map for maps that do not allow user specified keys.
362 * However, for maps that allow user specified keys, if the key is
363 * not in the map, a new @a key / @a value association is created.
365 virtual int rebind (const KEY &key,
366 const VALUE &value,
367 VALUE &old_value) = 0;
370 * Reassociate @a key with @a value, storing the old key and value
371 * into the "out" parameters @a old_key and @a old_value. The
372 * function fails if @a key is not in the map for maps that do not
373 * allow user specified keys. However, for maps that allow user
374 * specified keys, if the key is not in the map, a new @a key / @a value
375 * association is created.
377 virtual int rebind (const KEY &key,
378 const VALUE &value,
379 KEY &old_key,
380 VALUE &old_value) = 0;
383 * Associate @a key with @a value if and only if @a key is not in the
384 * map. If @a key is already in the map, then the @a value parameter
385 * is overwritten with the existing value in the map. Returns 0 if a
386 * new @a key / @a value association is created. Returns 1 if an
387 * attempt is made to bind an existing entry. This function fails
388 * for maps that do not allow user specified keys.
390 virtual int trybind (const KEY &key,
391 VALUE &value) = 0;
393 /// Locate @a value associated with @a key.
394 virtual int find (const KEY &key,
395 VALUE &value) = 0;
397 /// Is @a key in the map?
398 virtual int find (const KEY &key) = 0;
400 /// Remove @a key from the map.
401 virtual int unbind (const KEY &key) = 0;
403 /// Remove @a key from the map, and return the @a value associated with
404 /// @a key.
405 virtual int unbind (const KEY &key,
406 VALUE &value) = 0;
408 /// Return the current size of the map.
409 virtual size_t current_size (void) const = 0;
411 /// Return the total size of the map.
412 virtual size_t total_size (void) const = 0;
414 /// Dump the state of an object.
415 virtual void dump (void) const = 0;
417 // = STL styled iterator factory functions.
419 /// Return forward iterator.
420 iterator begin (void);
421 iterator end (void);
423 /// Return reverse iterator.
424 reverse_iterator rbegin (void);
425 reverse_iterator rend (void);
427 protected:
429 // = Protected no-op constructor.
430 ACE_Map (void);
432 /// Return forward iterator.
433 virtual ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *begin_impl (void) = 0;
434 virtual ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *end_impl (void) = 0;
436 /// Return reverse iterator.
437 virtual ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *rbegin_impl (void) = 0;
438 virtual ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *rend_impl (void) = 0;
440 private:
442 // = Disallow these operations.
443 ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Map<KEY, VALUE> &))
444 ACE_UNIMPLEMENTED_FUNC (ACE_Map (const ACE_Map<KEY, VALUE> &))
448 * @class ACE_Map_Impl_Iterator_Adapter
450 * @brief Defines a iterator implementation for the Map_Impl class.
452 * Implementation to be provided by <IMPLEMENTATION>.
454 template <class T, class IMPLEMENTATION, class ENTRY>
455 class ACE_Map_Impl_Iterator_Adapter : public ACE_Iterator_Impl<T>
457 public:
459 // = Traits.
460 typedef IMPLEMENTATION
461 implementation;
463 /// Constructor.
464 ACE_Map_Impl_Iterator_Adapter (const IMPLEMENTATION &impl);
466 /// Destructor.
467 virtual ~ACE_Map_Impl_Iterator_Adapter (void);
469 /// Clone.
470 virtual ACE_Iterator_Impl<T> *clone (void) const;
472 /// Comparison.
473 virtual int compare (const ACE_Iterator_Impl<T> &rhs) const;
475 /// Dereference.
476 virtual T dereference (void) const;
478 /// Advance.
479 virtual void plus_plus (void);
481 /// Reverse.
482 virtual void minus_minus (void);
484 /// Accessor to implementation object.
485 IMPLEMENTATION &impl (void);
487 protected:
489 /// All implementation details are forwarded to this class.
490 IMPLEMENTATION implementation_;
494 * @class ACE_Map_Impl_Reverse_Iterator_Adapter
496 * @brief Defines a reverse iterator implementation for the Map_Impl class.
498 * Implementation to be provided by IMPLEMENTATION.
500 template <class T, class IMPLEMENTATION, class ENTRY>
501 class ACE_Map_Impl_Reverse_Iterator_Adapter : public ACE_Reverse_Iterator_Impl<T>
503 public:
505 // = Traits.
506 typedef IMPLEMENTATION
507 implementation;
509 /// Constructor.
510 ACE_Map_Impl_Reverse_Iterator_Adapter (const IMPLEMENTATION &impl);
512 /// Destructor.
513 virtual ~ACE_Map_Impl_Reverse_Iterator_Adapter (void);
515 /// Clone.
516 virtual ACE_Reverse_Iterator_Impl<T> *clone (void) const;
518 /// Comparison.
519 virtual int compare (const ACE_Reverse_Iterator_Impl<T> &rhs) const;
521 /// Dereference.
522 virtual T dereference (void) const;
524 /// Advance.
525 virtual void plus_plus (void);
527 /// Reverse.
528 virtual void minus_minus (void);
530 /// Accessor to implementation object.
531 IMPLEMENTATION &impl (void);
533 protected:
535 /// All implementation details are forwarded to this class.
536 IMPLEMENTATION implementation_;
540 * @class ACE_Map_Impl
542 * @brief Defines a map implementation.
544 * Implementation to be provided by <IMPLEMENTATION>.
546 template <class KEY, class VALUE, class IMPLEMENTATION, class ITERATOR, class REVERSE_ITERATOR, class ENTRY>
547 class ACE_Map_Impl : public ACE_Map<KEY, VALUE>
549 public:
551 // = Traits.
552 typedef ACE_Map_Impl_Iterator_Adapter<typename ACE_Map<KEY, VALUE>::value_type, ITERATOR, ENTRY>
553 iterator_impl;
554 typedef ACE_Map_Impl_Reverse_Iterator_Adapter<typename ACE_Map<KEY, VALUE>::value_type, REVERSE_ITERATOR, ENTRY>
555 reverse_iterator_impl;
557 typedef IMPLEMENTATION
558 implementation;
560 // = Initialization and termination methods.
561 /// Initialize with the ACE_DEFAULT_MAP_SIZE.
562 ACE_Map_Impl (ACE_Allocator *alloc = 0);
564 /// Initialize with @a size entries. The @a size parameter is ignored
565 /// by maps for which an initialize size does not make sense.
566 ACE_Map_Impl (size_t size,
567 ACE_Allocator *alloc = 0);
569 /// Close down and release dynamically allocated resources.
570 virtual ~ACE_Map_Impl (void);
572 /// Initialize a <Map> with size @a length.
573 virtual int open (size_t length = ACE_DEFAULT_MAP_SIZE,
574 ACE_Allocator *alloc = 0);
576 /// Close down a <Map> and release dynamically allocated resources.
577 virtual int close (void);
580 * Add @a key / @a value pair to the map. If @a key is already in the
581 * map then no changes are made and 1 is returned. Returns 0 on a
582 * successful addition. This function fails for maps that do not
583 * allow user specified keys. @a key is an "in" parameter.
585 virtual int bind (const KEY &key,
586 const VALUE &value);
589 * Add @a key / @a value pair to the map. @a key is an "inout" parameter
590 * and maybe modified/extended by the map to add additional
591 * information. To recover original key, call the <recover_key>
592 * method.
594 virtual int bind_modify_key (const VALUE &value,
595 KEY &key);
598 * Produce a key and return it through @a key which is an "out"
599 * parameter. For maps that do not naturally produce keys, the map
600 * adapters will use the @c KEY_GENERATOR class to produce a key.
601 * However, the users are responsible for not jeopardizing this key
602 * production scheme by using user specified keys with keys produced
603 * by the key generator.
605 virtual int create_key (KEY &key);
608 * Add @a value to the map, and the corresponding key produced by the
609 * Map is returned through @a key which is an "out" parameter. For
610 * maps that do not naturally produce keys, the map adapters will
611 * use the @c KEY_GENERATOR class to produce a key. However, the
612 * users are responsible for not jeopardizing this key production
613 * scheme by using user specified keys with keys produced by the key
614 * generator.
616 virtual int bind_create_key (const VALUE &value,
617 KEY &key);
620 * Add @a value to the map. The user does not care about the
621 * corresponding key produced by the Map. For maps that do not
622 * naturally produce keys, the map adapters will use the
623 * @c KEY_GENERATOR class to produce a key. However, the users are
624 * responsible for not jeopardizing this key production scheme by
625 * using user specified keys with keys produced by the key
626 * generator.
628 virtual int bind_create_key (const VALUE &value);
630 /// Recovers the original key potentially modified by the map during
631 /// <bind_modify_key>.
632 virtual int recover_key (const KEY &modified_key,
633 KEY &original_key);
636 * Reassociate @a key with @a value. The function fails if @a key is
637 * not in the map for maps that do not allow user specified keys.
638 * However, for maps that allow user specified keys, if the key is
639 * not in the map, a new @a key / @a value association is created.
641 virtual int rebind (const KEY &key,
642 const VALUE &value);
645 * Reassociate @a key with @a value, storing the old value into the
646 * "out" parameter @a old_value. The function fails if @a key is not
647 * in the map for maps that do not allow user specified keys.
648 * However, for maps that allow user specified keys, if the key is
649 * not in the map, a new @a key / @a value association is created.
651 virtual int rebind (const KEY &key,
652 const VALUE &value,
653 VALUE &old_value);
656 * Reassociate @a key with @a value, storing the old key and value
657 * into the "out" parameters @a old_key and @a old_value. The
658 * function fails if @a key is not in the map for maps that do not
659 * allow user specified keys. However, for maps that allow user
660 * specified keys, if the key is not in the map, a new @a key / @a value
661 * association is created.
663 virtual int rebind (const KEY &key,
664 const VALUE &value,
665 KEY &old_key,
666 VALUE &old_value);
669 * Associate @a key with @a value if and only if @a key is not in the
670 * map. If @a key is already in the map, then the @a value parameter
671 * is overwritten with the existing value in the map. Returns 0 if a
672 * new @a key / @a value association is created. Returns 1 if an
673 * attempt is made to bind an existing entry. This function fails
674 * for maps that do not allow user specified keys.
676 virtual int trybind (const KEY &key,
677 VALUE &value);
679 /// Locate @a value associated with @a key.
680 virtual int find (const KEY &key,
681 VALUE &value);
683 /// Is @a key in the map?
684 virtual int find (const KEY &key);
686 /// Remove @a key from the map.
687 virtual int unbind (const KEY &key);
689 /// Remove @a key from the map, and return the @a value associated with
690 /// @a key.
691 virtual int unbind (const KEY &key,
692 VALUE &value);
694 /// Return the current size of the map.
695 virtual size_t current_size (void) const;
697 /// Return the total size of the map.
698 virtual size_t total_size (void) const;
700 /// Dump the state of an object.
701 virtual void dump (void) const;
703 /// Accessor to implementation object.
704 IMPLEMENTATION &impl (void);
706 protected:
708 /// All implementation details are forwarded to this class.
709 IMPLEMENTATION implementation_;
711 // = STL styled iterator factory functions.
713 /// Return forward iterator.
714 virtual ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *begin_impl (void);
715 virtual ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *end_impl (void);
717 /// Return reverse iterator.
718 virtual ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *rbegin_impl (void);
719 virtual ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *rend_impl (void);
721 private:
723 // = Disallow these operations.
724 ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Map_Impl<KEY, VALUE, IMPLEMENTATION, ITERATOR, REVERSE_ITERATOR, ENTRY> &))
725 ACE_UNIMPLEMENTED_FUNC (ACE_Map_Impl (const ACE_Map_Impl<KEY, VALUE, IMPLEMENTATION, ITERATOR, REVERSE_ITERATOR, ENTRY> &))
729 * @class ACE_Active_Map_Manager_Iterator_Adapter
731 * @brief Defines a iterator implementation for the Active_Map_Manager_Adapter.
733 * Implementation to be provided by ACE_Active_Map_Manager::iterator.
735 template <class T, class VALUE>
736 class ACE_Active_Map_Manager_Iterator_Adapter : public ACE_Iterator_Impl<T>
738 public:
740 // = Traits.
741 typedef typename ACE_Active_Map_Manager<VALUE>::iterator
742 implementation;
744 /// Constructor.
745 ACE_Active_Map_Manager_Iterator_Adapter (const ACE_Map_Iterator<ACE_Active_Map_Manager_Key, VALUE, ACE_Null_Mutex> &impl);
747 /// Destructor.
748 virtual ~ACE_Active_Map_Manager_Iterator_Adapter (void);
750 /// Clone.
751 virtual ACE_Iterator_Impl<T> *clone (void) const;
753 /// Comparison.
754 virtual int compare (const ACE_Iterator_Impl<T> &rhs) const;
756 /// Dereference.
757 virtual T dereference (void) const;
759 /// Advance.
760 virtual void plus_plus (void);
762 /// Reverse.
763 virtual void minus_minus (void);
765 /// Accessor to implementation object.
766 ACE_Map_Iterator<ACE_Active_Map_Manager_Key, VALUE, ACE_Null_Mutex> &impl (void);
768 protected:
770 /// All implementation details are forwarded to this class.
771 ACE_Map_Iterator<ACE_Active_Map_Manager_Key, VALUE, ACE_Null_Mutex> implementation_;
775 * @class ACE_Active_Map_Manager_Reverse_Iterator_Adapter
777 * @brief Defines a reverse iterator implementation for the Active_Map_Manager_Adapter.
779 * Implementation to be provided by ACE_Active_Map_Manager::reverse_iterator.
781 template <class T, class VALUE>
782 class ACE_Active_Map_Manager_Reverse_Iterator_Adapter : public ACE_Reverse_Iterator_Impl<T>
784 public:
786 // = Traits.
787 typedef typename ACE_Active_Map_Manager<VALUE>::reverse_iterator
788 implementation;
790 /// Constructor.
791 ACE_Active_Map_Manager_Reverse_Iterator_Adapter (const ACE_Map_Reverse_Iterator<ACE_Active_Map_Manager_Key, VALUE, ACE_Null_Mutex> &impl);
793 /// Destructor.
794 virtual ~ACE_Active_Map_Manager_Reverse_Iterator_Adapter (void);
796 /// Clone.
797 virtual ACE_Reverse_Iterator_Impl<T> *clone (void) const;
799 /// Comparison.
800 virtual int compare (const ACE_Reverse_Iterator_Impl<T> &rhs) const;
802 /// Dereference.
803 virtual T dereference (void) const;
805 /// Advance.
806 virtual void plus_plus (void);
808 /// Reverse.
809 virtual void minus_minus (void);
811 /// Accessor to implementation object.
812 ACE_Map_Reverse_Iterator<ACE_Active_Map_Manager_Key, VALUE, ACE_Null_Mutex> &impl (void);
814 protected:
816 /// All implementation details are forwarded to this class.
817 ACE_Map_Reverse_Iterator<ACE_Active_Map_Manager_Key, VALUE, ACE_Null_Mutex> implementation_;
821 * @class ACE_Active_Map_Manager_Adapter
823 * @brief Defines a map implementation.
825 * Implementation to be provided by <ACE_Active_Map_Manager>.
827 template <class KEY, class VALUE, class KEY_ADAPTER>
828 class ACE_Active_Map_Manager_Adapter : public ACE_Map<KEY, VALUE>
830 public:
832 // = Traits.
833 typedef ACE_Pair<KEY, VALUE>
834 expanded_value;
835 typedef ACE_Active_Map_Manager_Iterator_Adapter<ACE_Reference_Pair<const KEY, VALUE>, expanded_value>
836 iterator_impl;
837 typedef ACE_Active_Map_Manager_Reverse_Iterator_Adapter<ACE_Reference_Pair<const KEY, VALUE>, expanded_value>
838 reverse_iterator_impl;
839 typedef ACE_Active_Map_Manager<expanded_value>
840 implementation;
842 // = Initialization and termination methods.
843 /// Initialize with the ACE_DEFAULT_MAP_SIZE.
844 ACE_Active_Map_Manager_Adapter (ACE_Allocator *alloc = 0);
846 /// Initialize with @a size entries. The @a size parameter is ignored
847 /// by maps for which an initialize size does not make sense.
848 ACE_Active_Map_Manager_Adapter (size_t size,
849 ACE_Allocator *alloc = 0);
851 /// Close down and release dynamically allocated resources.
852 virtual ~ACE_Active_Map_Manager_Adapter (void);
854 /// Initialize a <Map> with size @a length.
855 virtual int open (size_t length = ACE_DEFAULT_MAP_SIZE,
856 ACE_Allocator *alloc = 0);
858 /// Close down a <Map> and release dynamically allocated resources.
859 virtual int close (void);
862 * Add @a key / @a value pair to the map. If @a key is already in the
863 * map then no changes are made and 1 is returned. Returns 0 on a
864 * successful addition. This function fails for maps that do not
865 * allow user specified keys. @a key is an "in" parameter.
867 virtual int bind (const KEY &key,
868 const VALUE &value);
871 * Add @a key / @a value pair to the map. @a key is an "inout" parameter
872 * and maybe modified/extended by the map to add additional
873 * information. To recover original key, call the <recover_key>
874 * method.
876 virtual int bind_modify_key (const VALUE &value,
877 KEY &key);
880 * Produce a key and return it through @a key which is an "out"
881 * parameter. For maps that do not naturally produce keys, the map
882 * adapters will use the @c KEY_GENERATOR class to produce a key.
883 * However, the users are responsible for not jeopardizing this key
884 * production scheme by using user specified keys with keys produced
885 * by the key generator.
887 virtual int create_key (KEY &key);
890 * Add @a value to the map, and the corresponding key produced by the
891 * Map is returned through @a key which is an "out" parameter. For
892 * maps that do not naturally produce keys, the map adapters will
893 * use the @c KEY_GENERATOR class to produce a key. However, the
894 * users are responsible for not jeopardizing this key production
895 * scheme by using user specified keys with keys produced by the key
896 * generator.
898 virtual int bind_create_key (const VALUE &value,
899 KEY &key);
902 * Add @a value to the map. The user does not care about the
903 * corresponding key produced by the Map. For maps that do not
904 * naturally produce keys, the map adapters will use the
905 * @c KEY_GENERATOR class to produce a key. However, the users are
906 * responsible for not jeopardizing this key production scheme by
907 * using user specified keys with keys produced by the key
908 * generator.
910 virtual int bind_create_key (const VALUE &value);
912 /// Recovers the original key potentially modified by the map during
913 /// <bind_modify_key>.
914 virtual int recover_key (const KEY &modified_key,
915 KEY &original_key);
918 * Reassociate @a key with @a value. The function fails if @a key is
919 * not in the map for maps that do not allow user specified keys.
920 * However, for maps that allow user specified keys, if the key is
921 * not in the map, a new @a key / @a value association is created.
923 virtual int rebind (const KEY &key,
924 const VALUE &value);
927 * Reassociate @a key with @a value, storing the old value into the
928 * "out" parameter @a old_value. The function fails if @a key is not
929 * in the map for maps that do not allow user specified keys.
930 * However, for maps that allow user specified keys, if the key is
931 * not in the map, a new @a key / @a value association is created.
933 virtual int rebind (const KEY &key,
934 const VALUE &value,
935 VALUE &old_value);
938 * Reassociate @a key with @a value, storing the old key and value
939 * into the "out" parameters @a old_key and @a old_value. The
940 * function fails if @a key is not in the map for maps that do not
941 * allow user specified keys. However, for maps that allow user
942 * specified keys, if the key is not in the map, a new @a key / @a value
943 * association is created.
945 virtual int rebind (const KEY &key,
946 const VALUE &value,
947 KEY &old_key,
948 VALUE &old_value);
951 * Associate @a key with @a value if and only if @a key is not in the
952 * map. If @a key is already in the map, then the @a value parameter
953 * is overwritten with the existing value in the map. Returns 0 if a
954 * new @a key / @a value association is created. Returns 1 if an
955 * attempt is made to bind an existing entry. This function fails
956 * for maps that do not allow user specified keys.
958 virtual int trybind (const KEY &key,
959 VALUE &value);
961 /// Locate @a value associated with @a key.
962 virtual int find (const KEY &key,
963 VALUE &value);
965 /// Is @a key in the map?
966 virtual int find (const KEY &key);
968 /// Remove @a key from the map.
969 virtual int unbind (const KEY &key);
971 /// Remove @a key from the map, and return the @a value associated with
972 /// @a key.
973 virtual int unbind (const KEY &key,
974 VALUE &value);
976 /// Return the current size of the map.
977 virtual size_t current_size (void) const;
979 /// Return the total size of the map.
980 virtual size_t total_size (void) const;
982 /// Dump the state of an object.
983 virtual void dump (void) const;
985 /// Accessor to implementation object.
986 ACE_Active_Map_Manager<ACE_Pair<KEY, VALUE> > &impl (void);
988 /// Accessor to key adapter.
989 KEY_ADAPTER &key_adapter (void);
991 protected:
993 /// Find helper.
994 virtual int find (const KEY &key,
995 expanded_value *&internal_value);
997 /// Unbind helper.
998 virtual int unbind (const KEY &key,
999 expanded_value *&internal_value);
1001 /// All implementation details are forwarded to this class.
1002 ACE_Active_Map_Manager<ACE_Pair<KEY, VALUE> > implementation_;
1004 /// Adapts between the user key and the Active_Map_Manager_Key.
1005 KEY_ADAPTER key_adapter_;
1007 // = STL styled iterator factory functions.
1009 /// Return forward iterator.
1010 virtual ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *begin_impl (void);
1011 virtual ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *end_impl (void);
1013 /// Return reverse iterator.
1014 virtual ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *rbegin_impl (void);
1015 virtual ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *rend_impl (void);
1017 private:
1019 // = Disallow these operations.
1020 ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Active_Map_Manager_Adapter<KEY, VALUE, KEY_ADAPTER> &))
1021 ACE_UNIMPLEMENTED_FUNC (ACE_Active_Map_Manager_Adapter (const ACE_Active_Map_Manager_Adapter<KEY, VALUE, KEY_ADAPTER> &))
1025 * @class ACE_Hash_Map_Manager_Ex_Iterator_Adapter
1027 * @brief Defines a iterator implementation for the Hash_Map_Manager_Adapter.
1029 * Implementation to be provided by ACE_Hash_Map_Manager_Ex::iterator.
1031 template <class T, class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS>
1032 class ACE_Hash_Map_Manager_Ex_Iterator_Adapter : public ACE_Iterator_Impl<T>
1034 public:
1036 // = Traits.
1037 typedef typename ACE_Hash_Map_Manager_Ex<KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex>::iterator
1038 implementation;
1040 /// Constructor.
1041 ACE_Hash_Map_Manager_Ex_Iterator_Adapter (const ACE_Hash_Map_Iterator_Ex<KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> &impl);
1043 /// Destructor.
1044 virtual ~ACE_Hash_Map_Manager_Ex_Iterator_Adapter (void);
1046 /// Clone.
1047 virtual ACE_Iterator_Impl<T> *clone (void) const;
1049 /// Comparison.
1050 virtual int compare (const ACE_Iterator_Impl<T> &rhs) const;
1052 /// Dereference.
1053 virtual T dereference (void) const;
1055 /// Advance.
1056 virtual void plus_plus (void);
1058 /// Reverse.
1059 virtual void minus_minus (void);
1061 /// Accessor to implementation object.
1062 ACE_Hash_Map_Iterator_Ex<KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> &impl (void);
1064 protected:
1066 /// All implementation details are forwarded to this class.
1067 ACE_Hash_Map_Iterator_Ex<KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> implementation_;
1071 * @class ACE_Hash_Map_Manager_Ex_Reverse_Iterator_Adapter
1073 * @brief Defines a reverse iterator implementation for the Hash_Map_Manager_Adapter.
1075 * Implementation to be provided by ACE_Hash_Map_Manager_Ex::reverse_iterator.
1077 template <class T, class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS>
1078 class ACE_Hash_Map_Manager_Ex_Reverse_Iterator_Adapter : public ACE_Reverse_Iterator_Impl<T>
1080 public:
1082 // = Traits.
1083 typedef typename ACE_Hash_Map_Manager_Ex<KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex>::reverse_iterator
1084 implementation;
1086 /// Constructor.
1087 ACE_Hash_Map_Manager_Ex_Reverse_Iterator_Adapter (const ACE_Hash_Map_Reverse_Iterator_Ex<KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> &impl);
1089 /// Destructor.
1090 virtual ~ACE_Hash_Map_Manager_Ex_Reverse_Iterator_Adapter (void);
1092 /// Clone.
1093 virtual ACE_Reverse_Iterator_Impl<T> *clone (void) const;
1095 /// Comparison.
1096 virtual int compare (const ACE_Reverse_Iterator_Impl<T> &rhs) const;
1098 /// Dereference.
1099 virtual T dereference (void) const;
1101 /// Advance.
1102 virtual void plus_plus (void);
1104 /// Reverse.
1105 virtual void minus_minus (void);
1107 /// Accessor to implementation object.
1108 ACE_Hash_Map_Reverse_Iterator_Ex<KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> &impl (void);
1110 protected:
1112 /// All implementation details are forwarded to this class.
1113 ACE_Hash_Map_Reverse_Iterator_Ex<KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> implementation_;
1117 * @class ACE_Hash_Map_Manager_Ex_Adapter
1119 * @brief Defines a map implementation.
1121 * Implementation to be provided by ACE_Hash_Map_Manager_Ex.
1123 template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class KEY_GENERATOR>
1124 class ACE_Hash_Map_Manager_Ex_Adapter : public ACE_Map<KEY, VALUE>
1126 public:
1128 // = Traits.
1129 typedef ACE_Hash_Map_Manager_Ex_Iterator_Adapter<ACE_Reference_Pair<const KEY, VALUE>, KEY, VALUE, HASH_KEY, COMPARE_KEYS>
1130 iterator_impl;
1131 typedef ACE_Hash_Map_Manager_Ex_Reverse_Iterator_Adapter<ACE_Reference_Pair<const KEY, VALUE>, KEY, VALUE, HASH_KEY, COMPARE_KEYS>
1132 reverse_iterator_impl;
1133 typedef ACE_Hash_Map_Manager_Ex<KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex>
1134 implementation;
1136 // = Initialization and termination methods.
1137 /// Initialize with the ACE_DEFAULT_MAP_SIZE.
1138 ACE_Hash_Map_Manager_Ex_Adapter (ACE_Allocator *alloc = 0);
1140 /// Initialize with @a size entries. The @a size parameter is ignored
1141 /// by maps for which an initialize size does not make sense.
1142 ACE_Hash_Map_Manager_Ex_Adapter (size_t size,
1143 ACE_Allocator *alloc = 0);
1145 /// Close down and release dynamically allocated resources.
1146 virtual ~ACE_Hash_Map_Manager_Ex_Adapter (void);
1148 /// Initialize a <Map> with size @a length.
1149 virtual int open (size_t length = ACE_DEFAULT_MAP_SIZE,
1150 ACE_Allocator *alloc = 0);
1152 /// Close down a <Map> and release dynamically allocated resources.
1153 virtual int close (void);
1156 * Add @a key / @a value pair to the map. If @a key is already in the
1157 * map then no changes are made and 1 is returned. Returns 0 on a
1158 * successful addition. This function fails for maps that do not
1159 * allow user specified keys. @a key is an "in" parameter.
1161 virtual int bind (const KEY &key,
1162 const VALUE &value);
1165 * Add @a key / @a value pair to the map. @a key is an "inout" parameter
1166 * and maybe modified/extended by the map to add additional
1167 * information. To recover original key, call the <recover_key>
1168 * method.
1170 virtual int bind_modify_key (const VALUE &value,
1171 KEY &key);
1174 * Produce a key and return it through @a key which is an "out"
1175 * parameter. For maps that do not naturally produce keys, the map
1176 * adapters will use the @c KEY_GENERATOR class to produce a key.
1177 * However, the users are responsible for not jeopardizing this key
1178 * production scheme by using user specified keys with keys produced
1179 * by the key generator.
1181 virtual int create_key (KEY &key);
1184 * Add @a value to the map, and the corresponding key produced by the
1185 * Map is returned through @a key which is an "out" parameter. For
1186 * maps that do not naturally produce keys, the map adapters will
1187 * use the @c KEY_GENERATOR class to produce a key. However, the
1188 * users are responsible for not jeopardizing this key production
1189 * scheme by using user specified keys with keys produced by the key
1190 * generator.
1192 virtual int bind_create_key (const VALUE &value,
1193 KEY &key);
1196 * Add @a value to the map. The user does not care about the
1197 * corresponding key produced by the Map. For maps that do not
1198 * naturally produce keys, the map adapters will use the
1199 * @c KEY_GENERATOR class to produce a key. However, the users are
1200 * responsible for not jeopardizing this key production scheme by
1201 * using user specified keys with keys produced by the key
1202 * generator.
1204 virtual int bind_create_key (const VALUE &value);
1206 /// Recovers the original key potentially modified by the map during
1207 /// <bind_modify_key>.
1208 virtual int recover_key (const KEY &modified_key,
1209 KEY &original_key);
1212 * Reassociate @a key with @a value. The function fails if @a key is
1213 * not in the map for maps that do not allow user specified keys.
1214 * However, for maps that allow user specified keys, if the key is
1215 * not in the map, a new @a key / @a value association is created.
1217 virtual int rebind (const KEY &key,
1218 const VALUE &value);
1221 * Reassociate @a key with @a value, storing the old value into the
1222 * "out" parameter @a old_value. The function fails if @a key is not
1223 * in the map for maps that do not allow user specified keys.
1224 * However, for maps that allow user specified keys, if the key is
1225 * not in the map, a new @a key / @a value association is created.
1227 virtual int rebind (const KEY &key,
1228 const VALUE &value,
1229 VALUE &old_value);
1232 * Reassociate @a key with @a value, storing the old key and value
1233 * into the "out" parameters @a old_key and @a old_value. The
1234 * function fails if @a key is not in the map for maps that do not
1235 * allow user specified keys. However, for maps that allow user
1236 * specified keys, if the key is not in the map, a new @a key / @a value
1237 * association is created.
1239 virtual int rebind (const KEY &key,
1240 const VALUE &value,
1241 KEY &old_key,
1242 VALUE &old_value);
1245 * Associate @a key with @a value if and only if @a key is not in the
1246 * map. If @a key is already in the map, then the @a value parameter
1247 * is overwritten with the existing value in the map. Returns 0 if a
1248 * new @a key / @a value association is created. Returns 1 if an
1249 * attempt is made to bind an existing entry. This function fails
1250 * for maps that do not allow user specified keys.
1252 virtual int trybind (const KEY &key,
1253 VALUE &value);
1255 /// Locate @a value associated with @a key.
1256 virtual int find (const KEY &key,
1257 VALUE &value);
1259 /// Is @a key in the map?
1260 virtual int find (const KEY &key);
1262 /// Remove @a key from the map.
1263 virtual int unbind (const KEY &key);
1265 /// Remove @a key from the map, and return the @a value associated with
1266 /// @a key.
1267 virtual int unbind (const KEY &key,
1268 VALUE &value);
1270 /// Return the current size of the map.
1271 virtual size_t current_size (void) const;
1273 /// Return the total size of the map.
1274 virtual size_t total_size (void) const;
1276 /// Dump the state of an object.
1277 virtual void dump (void) const;
1279 /// Accessor to implementation object.
1280 ACE_Hash_Map_Manager_Ex<KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> &impl (void);
1282 /// Accessor to key generator.
1283 KEY_GENERATOR &key_generator (void);
1285 protected:
1287 /// All implementation details are forwarded to this class.
1288 ACE_Hash_Map_Manager_Ex<KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> implementation_;
1290 /// Functor class used for generating key.
1291 KEY_GENERATOR key_generator_;
1293 // = STL styled iterator factory functions.
1295 /// Return forward iterator.
1296 virtual ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *begin_impl (void);
1297 virtual ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *end_impl (void);
1299 /// Return reverse iterator.
1300 virtual ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *rbegin_impl (void);
1301 virtual ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *rend_impl (void);
1303 private:
1305 // = Disallow these operations.
1306 ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Hash_Map_Manager_Ex_Adapter<KEY, VALUE, HASH_KEY, COMPARE_KEYS, KEY_GENERATOR> &))
1307 ACE_UNIMPLEMENTED_FUNC (ACE_Hash_Map_Manager_Ex_Adapter (const ACE_Hash_Map_Manager_Ex_Adapter<KEY, VALUE, HASH_KEY, COMPARE_KEYS, KEY_GENERATOR> &))
1311 * @class ACE_Map_Manager_Iterator_Adapter
1313 * @brief Defines a iterator implementation for the Map_Manager_Adapter.
1315 * Implementation to be provided by ACE_Map_Manager::iterator.
1317 template <class T, class KEY, class VALUE>
1318 class ACE_Map_Manager_Iterator_Adapter : public ACE_Iterator_Impl<T>
1320 public:
1322 // = Traits.
1323 typedef typename ACE_Map_Manager<KEY, VALUE, ACE_Null_Mutex>::iterator
1324 implementation;
1326 /// Constructor.
1327 ACE_Map_Manager_Iterator_Adapter (const ACE_Map_Iterator<KEY, VALUE, ACE_Null_Mutex> &impl);
1329 /// Destructor.
1330 virtual ~ACE_Map_Manager_Iterator_Adapter (void);
1332 /// Clone.
1333 virtual ACE_Iterator_Impl<T> *clone (void) const;
1335 /// Comparison.
1336 virtual int compare (const ACE_Iterator_Impl<T> &rhs) const;
1338 /// Dereference.
1339 virtual T dereference (void) const;
1341 /// Advance.
1342 virtual void plus_plus (void);
1344 /// Reverse.
1345 virtual void minus_minus (void);
1347 /// Accessor to implementation object.
1348 ACE_Map_Iterator<KEY, VALUE, ACE_Null_Mutex> &impl (void);
1350 protected:
1352 /// All implementation details are forwarded to this class.
1353 ACE_Map_Iterator<KEY, VALUE, ACE_Null_Mutex> implementation_;
1357 * @class ACE_Map_Manager_Reverse_Iterator_Adapter
1359 * @brief Defines a reverse iterator implementation for the Map Manager.
1361 * Implementation to be provided by ACE_Map_Manager::reverse_iterator.
1363 template <class T, class KEY, class VALUE>
1364 class ACE_Map_Manager_Reverse_Iterator_Adapter : public ACE_Reverse_Iterator_Impl<T>
1366 public:
1368 // = Traits.
1369 typedef typename ACE_Map_Manager<KEY, VALUE, ACE_Null_Mutex>::reverse_iterator
1370 implementation;
1372 /// Constructor.
1373 ACE_Map_Manager_Reverse_Iterator_Adapter (const ACE_Map_Reverse_Iterator<KEY, VALUE, ACE_Null_Mutex> &impl);
1375 /// Destructor.
1376 virtual ~ACE_Map_Manager_Reverse_Iterator_Adapter (void);
1378 /// Clone.
1379 virtual ACE_Reverse_Iterator_Impl<T> *clone (void) const;
1381 /// Comparison.
1382 virtual int compare (const ACE_Reverse_Iterator_Impl<T> &rhs) const;
1384 /// Dereference.
1385 virtual T dereference (void) const;
1387 /// Advance.
1388 virtual void plus_plus (void);
1390 /// Reverse.
1391 virtual void minus_minus (void);
1393 /// Accessor to implementation object.
1394 ACE_Map_Reverse_Iterator<KEY, VALUE, ACE_Null_Mutex> &impl (void);
1396 protected:
1398 /// All implementation details are forwarded to this class.
1399 ACE_Map_Reverse_Iterator<KEY, VALUE, ACE_Null_Mutex> implementation_;
1403 * @class ACE_Map_Manager_Adapter
1405 * @brief Defines a map implementation.
1407 * Implementation to be provided by ACE_Map_Manager.
1409 template <class KEY, class VALUE, class KEY_GENERATOR>
1410 class ACE_Map_Manager_Adapter : public ACE_Map<KEY, VALUE>
1412 public:
1414 // = Traits.
1415 typedef ACE_Map_Manager_Iterator_Adapter<ACE_Reference_Pair<const KEY, VALUE>, KEY, VALUE>
1416 iterator_impl;
1417 typedef ACE_Map_Manager_Reverse_Iterator_Adapter<ACE_Reference_Pair<const KEY, VALUE>, KEY, VALUE>
1418 reverse_iterator_impl;
1419 typedef ACE_Map_Manager<KEY, VALUE, ACE_Null_Mutex>
1420 implementation;
1422 // = Initialization and termination methods.
1423 /// Initialize with the ACE_DEFAULT_MAP_SIZE.
1424 ACE_Map_Manager_Adapter (ACE_Allocator *alloc = 0);
1426 /// Initialize with @a size entries. The @a size parameter is ignored
1427 /// by maps for which an initialize size does not make sense.
1428 ACE_Map_Manager_Adapter (size_t size,
1429 ACE_Allocator *alloc = 0);
1431 /// Close down and release dynamically allocated resources.
1432 virtual ~ACE_Map_Manager_Adapter (void);
1434 /// Initialize a <Map> with size @a length.
1435 virtual int open (size_t length = ACE_DEFAULT_MAP_SIZE,
1436 ACE_Allocator *alloc = 0);
1438 /// Close down a <Map> and release dynamically allocated resources.
1439 virtual int close (void);
1442 * Add @a key / @a value pair to the map. If @a key is already in the
1443 * map then no changes are made and 1 is returned. Returns 0 on a
1444 * successful addition. This function fails for maps that do not
1445 * allow user specified keys. @a key is an "in" parameter.
1447 virtual int bind (const KEY &key,
1448 const VALUE &value);
1451 * Add @a key / @a value pair to the map. @a key is an "inout" parameter
1452 * and maybe modified/extended by the map to add additional
1453 * information. To recover original key, call the <recover_key>
1454 * method.
1456 virtual int bind_modify_key (const VALUE &value,
1457 KEY &key);
1460 * Produce a key and return it through @a key which is an "out"
1461 * parameter. For maps that do not naturally produce keys, the map
1462 * adapters will use the @c KEY_GENERATOR class to produce a key.
1463 * However, the users are responsible for not jeopardizing this key
1464 * production scheme by using user specified keys with keys produced
1465 * by the key generator.
1467 virtual int create_key (KEY &key);
1470 * Add @a value to the map, and the corresponding key produced by the
1471 * Map is returned through @a key which is an "out" parameter. For
1472 * maps that do not naturally produce keys, the map adapters will
1473 * use the @c KEY_GENERATOR class to produce a key. However, the
1474 * users are responsible for not jeopardizing this key production
1475 * scheme by using user specified keys with keys produced by the key
1476 * generator.
1478 virtual int bind_create_key (const VALUE &value,
1479 KEY &key);
1482 * Add @a value to the map. The user does not care about the
1483 * corresponding key produced by the Map. For maps that do not
1484 * naturally produce keys, the map adapters will use the
1485 * @c KEY_GENERATOR class to produce a key. However, the users are
1486 * responsible for not jeopardizing this key production scheme by
1487 * using user specified keys with keys produced by the key
1488 * generator.
1490 virtual int bind_create_key (const VALUE &value);
1492 /// Recovers the original key potentially modified by the map during
1493 /// <bind_modify_key>.
1494 virtual int recover_key (const KEY &modified_key,
1495 KEY &original_key);
1498 * Reassociate @a key with @a value. The function fails if @a key is
1499 * not in the map for maps that do not allow user specified keys.
1500 * However, for maps that allow user specified keys, if the key is
1501 * not in the map, a new @a key / @a value association is created.
1503 virtual int rebind (const KEY &key,
1504 const VALUE &value);
1507 * Reassociate @a key with @a value, storing the old value into the
1508 * "out" parameter @a old_value. The function fails if @a key is not
1509 * in the map for maps that do not allow user specified keys.
1510 * However, for maps that allow user specified keys, if the key is
1511 * not in the map, a new @a key / @a value association is created.
1513 virtual int rebind (const KEY &key,
1514 const VALUE &value,
1515 VALUE &old_value);
1518 * Reassociate @a key with @a value, storing the old key and value
1519 * into the "out" parameters @a old_key and @a old_value. The
1520 * function fails if @a key is not in the map for maps that do not
1521 * allow user specified keys. However, for maps that allow user
1522 * specified keys, if the key is not in the map, a new @a key / @a value
1523 * association is created.
1525 virtual int rebind (const KEY &key,
1526 const VALUE &value,
1527 KEY &old_key,
1528 VALUE &old_value);
1531 * Associate @a key with @a value if and only if @a key is not in the
1532 * map. If @a key is already in the map, then the @a value parameter
1533 * is overwritten with the existing value in the map. Returns 0 if a
1534 * new @a key / @a value association is created. Returns 1 if an
1535 * attempt is made to bind an existing entry. This function fails
1536 * for maps that do not allow user specified keys.
1538 virtual int trybind (const KEY &key,
1539 VALUE &value);
1541 /// Locate @a value associated with @a key.
1542 virtual int find (const KEY &key,
1543 VALUE &value);
1545 /// Is @a key in the map?
1546 virtual int find (const KEY &key);
1548 /// Remove @a key from the map.
1549 virtual int unbind (const KEY &key);
1551 /// Remove @a key from the map, and return the @a value associated with
1552 /// @a key.
1553 virtual int unbind (const KEY &key,
1554 VALUE &value);
1556 /// Return the current size of the map.
1557 virtual size_t current_size (void) const;
1559 /// Return the total size of the map.
1560 virtual size_t total_size (void) const;
1562 /// Dump the state of an object.
1563 virtual void dump (void) const;
1565 /// Accessor to implementation object.
1566 ACE_Map_Manager<KEY, VALUE, ACE_Null_Mutex> &impl (void);
1568 /// Accessor to key generator.
1569 KEY_GENERATOR &key_generator (void);
1571 protected:
1573 /// All implementation details are forwarded to this class.
1574 ACE_Map_Manager<KEY, VALUE, ACE_Null_Mutex> implementation_;
1576 /// Functor class used for generating key.
1577 KEY_GENERATOR key_generator_;
1579 // = STL styled iterator factory functions.
1581 /// Return forward iterator.
1582 virtual ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *begin_impl (void);
1583 virtual ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *end_impl (void);
1585 /// Return reverse iterator.
1586 virtual ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *rbegin_impl (void);
1587 virtual ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *rend_impl (void);
1589 private:
1591 // = Disallow these operations.
1592 ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Map_Manager_Adapter<KEY, VALUE, KEY_GENERATOR> &))
1593 ACE_UNIMPLEMENTED_FUNC (ACE_Map_Manager_Adapter (const ACE_Map_Manager_Adapter<KEY, VALUE, KEY_GENERATOR> &))
1596 ACE_END_VERSIONED_NAMESPACE_DECL
1598 #if defined (__ACE_INLINE__)
1599 #include "ace/Map_T.inl"
1600 #endif /* __ACE_INLINE__ */
1602 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
1603 #include "ace/Map_T.cpp"
1604 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
1606 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
1607 #pragma implementation ("Map_T.cpp")
1608 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
1610 #include /**/ "ace/post.h"
1611 #endif /* ACE_MAP_T_H */