Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / Map_T.h
blob3e6d29fa14587d2a45889b18ee842573be934c9c
1 /* -*- C++ -*- */
3 //=============================================================================
4 /**
5 * @file Map_T.h
7 * @author Irfan Pyarali <irfan@cs.wustl.edu>
8 */
9 //=============================================================================
11 #ifndef ACE_MAP_T_H
12 #define ACE_MAP_T_H
13 #include /**/ "ace/pre.h"
15 #include "ace/Map_Manager.h"
16 #include "ace/Hash_Map_Manager_T.h"
17 #include "ace/Active_Map_Manager.h"
18 #include "ace/Pair_T.h"
20 #if !defined (ACE_LACKS_PRAGMA_ONCE)
21 # pragma once
22 #endif /* ACE_LACKS_PRAGMA_ONCE */
24 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
26 /**
27 * @class ACE_Noop_Key_Generator
29 * @brief Defines a noop key generator.
31 template <class T>
32 class ACE_Noop_Key_Generator
34 public:
35 /// Functor method: generates a new key.
36 int operator () (T &);
39 /**
40 * @class ACE_Incremental_Key_Generator
42 * @brief Defines a simple incremental key generator.
44 * Generates a new key of type T by incrementing current
45 * value. Requirements on T are:
46 * - Constructor that accepts 0 in the constructor.
47 * - Prefix increment.
48 * - Assignment.
49 * Note that a primitive types such as u_long, int, etc., are
50 * suitable for this class.
52 template <class T>
53 class ACE_Incremental_Key_Generator
55 public:
56 /// Constructor.
57 ACE_Incremental_Key_Generator () = default;
59 /// Functor method: generates a new key.
60 int operator () (T &t);
62 /// Returns the current value.
63 const T& current_value () const;
65 protected:
66 /// Current value.
67 T t_ {};
70 /**
71 * @class ACE_Iterator_Impl
73 * @brief Defines a abstract iterator.
75 * Implementation to be provided by subclasses.
77 template <class T>
78 class ACE_Iterator_Impl
80 public:
81 /// Destructor.
82 virtual ~ACE_Iterator_Impl () = default;
84 /// Clone.
85 virtual ACE_Iterator_Impl<T> *clone () const = 0;
87 /// Comparison.
88 virtual int compare (const ACE_Iterator_Impl<T> &rhs) const = 0;
90 /// Dereference.
91 virtual T dereference () const = 0;
93 /// Advance.
94 virtual void plus_plus () = 0;
96 /// Reverse.
97 virtual void minus_minus () = 0;
101 * @class ACE_Reverse_Iterator_Impl
103 * @brief Defines a abstract reverse iterator.
105 * Implementation to be provided by subclasses.
107 template <class T>
108 class ACE_Reverse_Iterator_Impl
110 public:
111 /// Destructor.
112 virtual ~ACE_Reverse_Iterator_Impl () = default;
114 /// Clone.
115 virtual ACE_Reverse_Iterator_Impl<T> *clone () const = 0;
117 /// Comparison.
118 virtual int compare (const ACE_Reverse_Iterator_Impl<T> &rhs) const = 0;
120 /// Dereference.
121 virtual T dereference () const = 0;
123 /// Advance.
124 virtual void plus_plus () = 0;
126 /// Reverse.
127 virtual void minus_minus () = 0;
131 * @class ACE_Iterator
133 * @brief Defines the iterator interface.
135 * Implementation to be provided by forwarding.
137 template <class T>
138 class ACE_Iterator
140 public:
141 // = Traits.
142 typedef T value_type;
143 typedef ACE_Iterator_Impl<T> implementation;
145 /// Constructor.
146 ACE_Iterator (ACE_Iterator_Impl<T> *impl);
148 /// Copy constructor.
149 ACE_Iterator (const ACE_Iterator<T> &rhs);
151 /// Destructor.
152 ~ACE_Iterator ();
154 /// Assignment operator.
155 ACE_Iterator<T> &operator= (const ACE_Iterator<T> &rhs);
157 /// Comparison operators.
158 bool operator== (const ACE_Iterator<T> &rhs) const;
159 bool operator!= (const ACE_Iterator<T> &rhs) const;
161 /// Dereference operator.
162 T operator *() const;
164 /// Prefix advance.
165 ACE_Iterator<T> &operator++ ();
167 /// Postfix advance.
168 ACE_Iterator<T> operator++ (int);
170 /// Prefix reverse.
171 ACE_Iterator<T> &operator-- ();
173 /// Postfix reverse.
174 ACE_Iterator<T> operator-- (int);
176 /// Accessor to implementation object.
177 ACE_Iterator_Impl<T> &impl ();
179 protected:
180 /// Implementation pointer.
181 ACE_Iterator_Impl<T> *implementation_;
185 * @class ACE_Reverse_Iterator
187 * @brief Defines the reverse iterator interface.
189 * Implementation to be provided by forwarding.
191 template <class T>
192 class ACE_Reverse_Iterator
194 public:
195 // = Traits.
196 typedef T value_type;
197 typedef ACE_Reverse_Iterator_Impl<T> implementation;
199 /// Constructor.
200 ACE_Reverse_Iterator (ACE_Reverse_Iterator_Impl<T> *impl);
202 /// Copy constructor.
203 ACE_Reverse_Iterator (const ACE_Reverse_Iterator<T> &rhs);
205 /// Destructor.
206 ~ACE_Reverse_Iterator ();
208 /// Assignment operator.
209 ACE_Reverse_Iterator<T> &operator= (const ACE_Reverse_Iterator<T> &rhs);
212 * @name Comparison Operators
214 * The usual equality operators.
216 //@{
217 bool operator== (const ACE_Reverse_Iterator<T> &rhs) const;
218 bool operator!= (const ACE_Reverse_Iterator<T> &rhs) const;
219 //@}
221 /// Dereference operator.
222 T operator *() const;
224 /// Prefix advance.
225 ACE_Reverse_Iterator<T> &operator++ ();
227 /// Postfix advance.
228 ACE_Reverse_Iterator<T> operator++ (int);
230 /// Prefix reverse.
231 ACE_Reverse_Iterator<T> &operator-- ();
233 /// Postfix reverse.
234 ACE_Reverse_Iterator<T> operator-- (int);
236 /// Accessor to implementation object.
237 ACE_Reverse_Iterator_Impl<T> &impl ();
239 protected:
240 /// Implementation pointer.
241 ACE_Reverse_Iterator_Impl<T> *implementation_;
245 * @class ACE_Map
247 * @brief Defines a map interface.
249 * Implementation to be provided by subclasses.
251 template <class KEY, class VALUE>
252 class ACE_Map
254 public:
255 // = Traits.
256 typedef KEY
257 key_type;
258 typedef VALUE
259 mapped_type;
260 typedef ACE_Reference_Pair<const KEY, VALUE>
261 value_type;
262 typedef ACE_Iterator<value_type>
263 iterator;
264 typedef ACE_Reverse_Iterator<value_type>
265 reverse_iterator;
266 typedef ACE_Iterator_Impl<value_type>
267 iterator_implementation;
268 typedef ACE_Reverse_Iterator_Impl<value_type>
269 reverse_iterator_implementation;
271 /// Close down and release dynamically allocated resources.
272 virtual ~ACE_Map () = default;
274 /// Initialize a map with size @a length.
275 virtual int open (size_t length = ACE_DEFAULT_MAP_SIZE,
276 ACE_Allocator *alloc = nullptr) = 0;
278 /// Close down a <Map> and release dynamically allocated resources.
279 virtual int close () = 0;
282 * Add @a key / @a value pair to the map. If @a key is already in the
283 * map then no changes are made and 1 is returned. Returns 0 on a
284 * successful addition. This function fails for maps that do not
285 * allow user specified keys. @a key is an "in" parameter.
287 virtual int bind (const KEY &key,
288 const VALUE &value) = 0;
291 * Add @a key / @a value pair to the map. @a key is an "inout" parameter
292 * and maybe modified/extended by the map to add additional
293 * information. To recover original key, call the <recover_key>
294 * method.
296 virtual int bind_modify_key (const VALUE &value,
297 KEY &key) = 0;
300 * Produce a key and return it through @a key which is an "out"
301 * parameter. For maps that do not naturally produce keys, the map
302 * adapters will use the @c KEY_GENERATOR class to produce a key.
303 * However, the users are responsible for not jeopardizing this key
304 * production scheme by using user specified keys with keys produced
305 * by the key generator.
307 virtual int create_key (KEY &key) = 0;
310 * Add @a value to the map, and the corresponding key produced by the
311 * Map is returned through @a key which is an "out" parameter. For
312 * maps that do not naturally produce keys, the map adapters will
313 * use the @c KEY_GENERATOR class to produce a key. However, the
314 * users are responsible for not jeopardizing this key production
315 * scheme by using user specified keys with keys produced by the key
316 * generator.
318 virtual int bind_create_key (const VALUE &value,
319 KEY &key) = 0;
322 * Add @a value to the map. The user does not care about the
323 * corresponding key produced by the Map. For maps that do not
324 * naturally produce keys, the map adapters will use the
325 * @c KEY_GENERATOR class to produce a key. However, the users are
326 * responsible for not jeopardizing this key production scheme by
327 * using user specified keys with keys produced by the key
328 * generator.
330 virtual int bind_create_key (const VALUE &value) = 0;
332 /// Recovers the original key potentially modified by the map during
333 /// <bind_modify_key>.
334 virtual int recover_key (const KEY &modified_key,
335 KEY &original_key) = 0;
338 * Reassociate @a key with @a value. The function fails if @a key is
339 * not in the map for maps that do not allow user specified keys.
340 * However, for maps that allow user specified keys, if the key is
341 * not in the map, a new @a key / @a value association is created.
343 virtual int rebind (const KEY &key,
344 const VALUE &value) = 0;
347 * Reassociate @a key with @a value, storing the old value into the
348 * "out" parameter @a old_value. The function fails if @a key is not
349 * in the map for maps that do not allow user specified keys.
350 * However, for maps that allow user specified keys, if the key is
351 * not in the map, a new @a key / @a value association is created.
353 virtual int rebind (const KEY &key,
354 const VALUE &value,
355 VALUE &old_value) = 0;
358 * Reassociate @a key with @a value, storing the old key and value
359 * into the "out" parameters @a old_key and @a old_value. The
360 * function fails if @a key is not in the map for maps that do not
361 * allow user specified keys. However, for maps that allow user
362 * specified keys, if the key is not in the map, a new @a key / @a value
363 * association is created.
365 virtual int rebind (const KEY &key,
366 const VALUE &value,
367 KEY &old_key,
368 VALUE &old_value) = 0;
371 * Associate @a key with @a value if and only if @a key is not in the
372 * map. If @a key is already in the map, then the @a value parameter
373 * is overwritten with the existing value in the map. Returns 0 if a
374 * new @a key / @a value association is created. Returns 1 if an
375 * attempt is made to bind an existing entry. This function fails
376 * for maps that do not allow user specified keys.
378 virtual int trybind (const KEY &key,
379 VALUE &value) = 0;
381 /// Locate @a value associated with @a key.
382 virtual int find (const KEY &key,
383 VALUE &value) = 0;
385 /// Is @a key in the map?
386 virtual int find (const KEY &key) = 0;
388 /// Remove @a key from the map.
389 virtual int unbind (const KEY &key) = 0;
391 /// Remove @a key from the map, and return the @a value associated with
392 /// @a key.
393 virtual int unbind (const KEY &key,
394 VALUE &value) = 0;
396 /// Return the current size of the map.
397 virtual size_t current_size () const = 0;
399 /// Return the total size of the map.
400 virtual size_t total_size () const = 0;
402 /// Dump the state of an object.
403 virtual void dump () const = 0;
405 // = STL styled iterator factory functions.
407 /// Return forward iterator.
408 iterator begin ();
409 iterator end ();
411 /// Return reverse iterator.
412 reverse_iterator rbegin ();
413 reverse_iterator rend ();
415 protected:
416 // = Protected no-op constructor.
417 ACE_Map () = default;
419 /// Return forward iterator.
420 virtual ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *begin_impl () = 0;
421 virtual ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *end_impl () = 0;
423 /// Return reverse iterator.
424 virtual ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *rbegin_impl () = 0;
425 virtual ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *rend_impl () = 0;
427 private:
428 // = Disallow these operations.
429 void operator= (const ACE_Map<KEY, VALUE> &) = delete;
430 ACE_Map (const ACE_Map<KEY, VALUE> &) = delete;
434 * @class ACE_Map_Impl_Iterator_Adapter
436 * @brief Defines a iterator implementation for the Map_Impl class.
438 * Implementation to be provided by <IMPLEMENTATION>.
440 template <class T, class IMPLEMENTATION, class ENTRY>
441 class ACE_Map_Impl_Iterator_Adapter : public ACE_Iterator_Impl<T>
443 public:
444 // = Traits.
445 typedef IMPLEMENTATION
446 implementation;
448 /// Constructor.
449 ACE_Map_Impl_Iterator_Adapter (const IMPLEMENTATION &impl);
451 /// Destructor.
452 virtual ~ACE_Map_Impl_Iterator_Adapter () = default;
454 /// Clone.
455 virtual ACE_Iterator_Impl<T> *clone () const;
457 /// Comparison.
458 virtual int compare (const ACE_Iterator_Impl<T> &rhs) const;
460 /// Dereference.
461 virtual T dereference () const;
463 /// Advance.
464 virtual void plus_plus ();
466 /// Reverse.
467 virtual void minus_minus ();
469 /// Accessor to implementation object.
470 IMPLEMENTATION &impl ();
472 protected:
473 /// All implementation details are forwarded to this class.
474 IMPLEMENTATION implementation_;
478 * @class ACE_Map_Impl_Reverse_Iterator_Adapter
480 * @brief Defines a reverse iterator implementation for the Map_Impl class.
482 * Implementation to be provided by IMPLEMENTATION.
484 template <class T, class IMPLEMENTATION, class ENTRY>
485 class ACE_Map_Impl_Reverse_Iterator_Adapter : public ACE_Reverse_Iterator_Impl<T>
487 public:
488 // = Traits.
489 typedef IMPLEMENTATION
490 implementation;
492 /// Constructor.
493 ACE_Map_Impl_Reverse_Iterator_Adapter (const IMPLEMENTATION &impl);
495 /// Destructor.
496 virtual ~ACE_Map_Impl_Reverse_Iterator_Adapter ();
498 /// Clone.
499 virtual ACE_Reverse_Iterator_Impl<T> *clone () const;
501 /// Comparison.
502 virtual int compare (const ACE_Reverse_Iterator_Impl<T> &rhs) const;
504 /// Dereference.
505 virtual T dereference () const;
507 /// Advance.
508 virtual void plus_plus ();
510 /// Reverse.
511 virtual void minus_minus ();
513 /// Accessor to implementation object.
514 IMPLEMENTATION &impl ();
516 protected:
517 /// All implementation details are forwarded to this class.
518 IMPLEMENTATION implementation_;
522 * @class ACE_Map_Impl
524 * @brief Defines a map implementation.
526 * Implementation to be provided by <IMPLEMENTATION>.
528 template <class KEY, class VALUE, class IMPLEMENTATION, class ITERATOR, class REVERSE_ITERATOR, class ENTRY>
529 class ACE_Map_Impl : public ACE_Map<KEY, VALUE>
531 public:
532 // = Traits.
533 typedef ACE_Map_Impl_Iterator_Adapter<typename ACE_Map<KEY, VALUE>::value_type, ITERATOR, ENTRY>
534 iterator_impl;
535 typedef ACE_Map_Impl_Reverse_Iterator_Adapter<typename ACE_Map<KEY, VALUE>::value_type, REVERSE_ITERATOR, ENTRY>
536 reverse_iterator_impl;
538 typedef IMPLEMENTATION
539 implementation;
541 /// Initialize with the ACE_DEFAULT_MAP_SIZE.
542 ACE_Map_Impl (ACE_Allocator *alloc = nullptr);
544 /// Initialize with @a size entries. The @a size parameter is ignored
545 /// by maps for which an initialize size does not make sense.
546 ACE_Map_Impl (size_t size,
547 ACE_Allocator *alloc = nullptr);
549 /// Close down and release dynamically allocated resources.
550 virtual ~ACE_Map_Impl ();
552 /// Initialize a <Map> with size @a length.
553 virtual int open (size_t length = ACE_DEFAULT_MAP_SIZE,
554 ACE_Allocator *alloc = nullptr);
556 /// Close down a <Map> and release dynamically allocated resources.
557 virtual int close ();
560 * Add @a key / @a value pair to the map. If @a key is already in the
561 * map then no changes are made and 1 is returned. Returns 0 on a
562 * successful addition. This function fails for maps that do not
563 * allow user specified keys. @a key is an "in" parameter.
565 virtual int bind (const KEY &key,
566 const VALUE &value);
569 * Add @a key / @a value pair to the map. @a key is an "inout" parameter
570 * and maybe modified/extended by the map to add additional
571 * information. To recover original key, call the <recover_key>
572 * method.
574 virtual int bind_modify_key (const VALUE &value,
575 KEY &key);
578 * Produce a key and return it through @a key which is an "out"
579 * parameter. For maps that do not naturally produce keys, the map
580 * adapters will use the @c KEY_GENERATOR class to produce a key.
581 * However, the users are responsible for not jeopardizing this key
582 * production scheme by using user specified keys with keys produced
583 * by the key generator.
585 virtual int create_key (KEY &key);
588 * Add @a value to the map, and the corresponding key produced by the
589 * Map is returned through @a key which is an "out" parameter. For
590 * maps that do not naturally produce keys, the map adapters will
591 * use the @c KEY_GENERATOR class to produce a key. However, the
592 * users are responsible for not jeopardizing this key production
593 * scheme by using user specified keys with keys produced by the key
594 * generator.
596 virtual int bind_create_key (const VALUE &value,
597 KEY &key);
600 * Add @a value to the map. The user does not care about the
601 * corresponding key produced by the Map. For maps that do not
602 * naturally produce keys, the map adapters will use the
603 * @c KEY_GENERATOR class to produce a key. However, the users are
604 * responsible for not jeopardizing this key production scheme by
605 * using user specified keys with keys produced by the key
606 * generator.
608 virtual int bind_create_key (const VALUE &value);
610 /// Recovers the original key potentially modified by the map during
611 /// <bind_modify_key>.
612 virtual int recover_key (const KEY &modified_key,
613 KEY &original_key);
616 * Reassociate @a key with @a value. The function fails if @a key is
617 * not in the map for maps that do not allow user specified keys.
618 * However, for maps that allow user specified keys, if the key is
619 * not in the map, a new @a key / @a value association is created.
621 virtual int rebind (const KEY &key,
622 const VALUE &value);
625 * Reassociate @a key with @a value, storing the old value into the
626 * "out" parameter @a old_value. The function fails if @a key is not
627 * in the map for maps that do not allow user specified keys.
628 * However, for maps that allow user specified keys, if the key is
629 * not in the map, a new @a key / @a value association is created.
631 virtual int rebind (const KEY &key,
632 const VALUE &value,
633 VALUE &old_value);
636 * Reassociate @a key with @a value, storing the old key and value
637 * into the "out" parameters @a old_key and @a old_value. The
638 * function fails if @a key is not in the map for maps that do not
639 * allow user specified keys. However, for maps that allow user
640 * specified keys, if the key is not in the map, a new @a key / @a value
641 * association is created.
643 virtual int rebind (const KEY &key,
644 const VALUE &value,
645 KEY &old_key,
646 VALUE &old_value);
649 * Associate @a key with @a value if and only if @a key is not in the
650 * map. If @a key is already in the map, then the @a value parameter
651 * is overwritten with the existing value in the map. Returns 0 if a
652 * new @a key / @a value association is created. Returns 1 if an
653 * attempt is made to bind an existing entry. This function fails
654 * for maps that do not allow user specified keys.
656 virtual int trybind (const KEY &key,
657 VALUE &value);
659 /// Locate @a value associated with @a key.
660 virtual int find (const KEY &key,
661 VALUE &value);
663 /// Is @a key in the map?
664 virtual int find (const KEY &key);
666 /// Remove @a key from the map.
667 virtual int unbind (const KEY &key);
669 /// Remove @a key from the map, and return the @a value associated with
670 /// @a key.
671 virtual int unbind (const KEY &key,
672 VALUE &value);
674 /// Return the current size of the map.
675 virtual size_t current_size () const;
677 /// Return the total size of the map.
678 virtual size_t total_size () const;
680 /// Dump the state of an object.
681 virtual void dump () const;
683 /// Accessor to implementation object.
684 IMPLEMENTATION &impl ();
686 protected:
687 /// All implementation details are forwarded to this class.
688 IMPLEMENTATION implementation_;
690 // = STL styled iterator factory functions.
692 /// Return forward iterator.
693 virtual ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *begin_impl ();
694 virtual ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *end_impl ();
696 /// Return reverse iterator.
697 virtual ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *rbegin_impl ();
698 virtual ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *rend_impl ();
700 private:
701 // = Disallow these operations.
702 void operator= (const ACE_Map_Impl<KEY, VALUE, IMPLEMENTATION, ITERATOR, REVERSE_ITERATOR, ENTRY> &) = delete;
703 ACE_Map_Impl (const ACE_Map_Impl<KEY, VALUE, IMPLEMENTATION, ITERATOR, REVERSE_ITERATOR, ENTRY> &) = delete;
707 * @class ACE_Active_Map_Manager_Iterator_Adapter
709 * @brief Defines a iterator implementation for the Active_Map_Manager_Adapter.
711 * Implementation to be provided by ACE_Active_Map_Manager::iterator.
713 template <class T, class VALUE>
714 class ACE_Active_Map_Manager_Iterator_Adapter : public ACE_Iterator_Impl<T>
716 public:
717 // = Traits.
718 typedef typename ACE_Active_Map_Manager<VALUE>::iterator
719 implementation;
721 /// Constructor.
722 ACE_Active_Map_Manager_Iterator_Adapter (const ACE_Map_Iterator<ACE_Active_Map_Manager_Key, VALUE, ACE_Null_Mutex> &impl);
724 /// Destructor.
725 virtual ~ACE_Active_Map_Manager_Iterator_Adapter ();
727 /// Clone.
728 virtual ACE_Iterator_Impl<T> *clone () const;
730 /// Comparison.
731 virtual int compare (const ACE_Iterator_Impl<T> &rhs) const;
733 /// Dereference.
734 virtual T dereference () const;
736 /// Advance.
737 virtual void plus_plus ();
739 /// Reverse.
740 virtual void minus_minus ();
742 /// Accessor to implementation object.
743 ACE_Map_Iterator<ACE_Active_Map_Manager_Key, VALUE, ACE_Null_Mutex> &impl ();
745 protected:
746 /// All implementation details are forwarded to this class.
747 ACE_Map_Iterator<ACE_Active_Map_Manager_Key, VALUE, ACE_Null_Mutex> implementation_;
751 * @class ACE_Active_Map_Manager_Reverse_Iterator_Adapter
753 * @brief Defines a reverse iterator implementation for the Active_Map_Manager_Adapter.
755 * Implementation to be provided by ACE_Active_Map_Manager::reverse_iterator.
757 template <class T, class VALUE>
758 class ACE_Active_Map_Manager_Reverse_Iterator_Adapter : public ACE_Reverse_Iterator_Impl<T>
760 public:
761 // = Traits.
762 typedef typename ACE_Active_Map_Manager<VALUE>::reverse_iterator
763 implementation;
765 /// Constructor.
766 ACE_Active_Map_Manager_Reverse_Iterator_Adapter (const ACE_Map_Reverse_Iterator<ACE_Active_Map_Manager_Key, VALUE, ACE_Null_Mutex> &impl);
768 /// Destructor.
769 virtual ~ACE_Active_Map_Manager_Reverse_Iterator_Adapter ();
771 /// Clone.
772 virtual ACE_Reverse_Iterator_Impl<T> *clone () const;
774 /// Comparison.
775 virtual int compare (const ACE_Reverse_Iterator_Impl<T> &rhs) const;
777 /// Dereference.
778 virtual T dereference () const;
780 /// Advance.
781 virtual void plus_plus ();
783 /// Reverse.
784 virtual void minus_minus ();
786 /// Accessor to implementation object.
787 ACE_Map_Reverse_Iterator<ACE_Active_Map_Manager_Key, VALUE, ACE_Null_Mutex> &impl ();
789 protected:
790 /// All implementation details are forwarded to this class.
791 ACE_Map_Reverse_Iterator<ACE_Active_Map_Manager_Key, VALUE, ACE_Null_Mutex> implementation_;
795 * @class ACE_Active_Map_Manager_Adapter
797 * @brief Defines a map implementation.
799 * Implementation to be provided by <ACE_Active_Map_Manager>.
801 template <class KEY, class VALUE, class KEY_ADAPTER>
802 class ACE_Active_Map_Manager_Adapter : public ACE_Map<KEY, VALUE>
804 public:
805 // = Traits.
806 typedef std::pair<KEY, VALUE>
807 expanded_value;
808 typedef ACE_Active_Map_Manager_Iterator_Adapter<ACE_Reference_Pair<const KEY, VALUE>, expanded_value>
809 iterator_impl;
810 typedef ACE_Active_Map_Manager_Reverse_Iterator_Adapter<ACE_Reference_Pair<const KEY, VALUE>, expanded_value>
811 reverse_iterator_impl;
812 typedef ACE_Active_Map_Manager<expanded_value>
813 implementation;
815 /// Initialize with the ACE_DEFAULT_MAP_SIZE.
816 ACE_Active_Map_Manager_Adapter (ACE_Allocator *alloc = nullptr);
818 /// Initialize with @a size entries. The @a size parameter is ignored
819 /// by maps for which an initialize size does not make sense.
820 ACE_Active_Map_Manager_Adapter (size_t size,
821 ACE_Allocator *alloc = nullptr);
823 /// Close down and release dynamically allocated resources.
824 virtual ~ACE_Active_Map_Manager_Adapter ();
826 /// Initialize a Map with size @a length.
827 virtual int open (size_t length = ACE_DEFAULT_MAP_SIZE,
828 ACE_Allocator *alloc = nullptr);
830 /// Close down a Map and release dynamically allocated resources.
831 virtual int close ();
834 * Add @a key / @a value pair to the map. If @a key is already in the
835 * map then no changes are made and 1 is returned. Returns 0 on a
836 * successful addition. This function fails for maps that do not
837 * allow user specified keys. @a key is an "in" parameter.
839 virtual int bind (const KEY &key,
840 const VALUE &value);
843 * Add @a key / @a value pair to the map. @a key is an "inout" parameter
844 * and maybe modified/extended by the map to add additional
845 * information. To recover original key, call the recover_key()
846 * method.
848 virtual int bind_modify_key (const VALUE &value, KEY &key);
851 * Produce a key and return it through @a key which is an "out"
852 * parameter. For maps that do not naturally produce keys, the map
853 * adapters will use the @c KEY_GENERATOR class to produce a key.
854 * However, the users are responsible for not jeopardizing this key
855 * production scheme by using user specified keys with keys produced
856 * by the key generator.
858 virtual int create_key (KEY &key);
861 * Add @a value to the map, and the corresponding key produced by the
862 * Map is returned through @a key which is an "out" parameter. For
863 * maps that do not naturally produce keys, the map adapters will
864 * use the @c KEY_GENERATOR class to produce a key. However, the
865 * users are responsible for not jeopardizing this key production
866 * scheme by using user specified keys with keys produced by the key
867 * generator.
869 virtual int bind_create_key (const VALUE &value,
870 KEY &key);
873 * Add @a value to the map. The user does not care about the
874 * corresponding key produced by the Map. For maps that do not
875 * naturally produce keys, the map adapters will use the
876 * @c KEY_GENERATOR class to produce a key. However, the users are
877 * responsible for not jeopardizing this key production scheme by
878 * using user specified keys with keys produced by the key
879 * generator.
881 virtual int bind_create_key (const VALUE &value);
883 /// Recovers the original key potentially modified by the map during
884 /// bind_modify_key().
885 virtual int recover_key (const KEY &modified_key,
886 KEY &original_key);
889 * Reassociate @a key with @a value. The function fails if @a key is
890 * not in the map for maps that do not allow user specified keys.
891 * However, for maps that allow user specified keys, if the key is
892 * not in the map, a new @a key / @a value association is created.
894 virtual int rebind (const KEY &key,
895 const VALUE &value);
898 * Reassociate @a key with @a value, storing the old value into the
899 * "out" parameter @a old_value. The function fails if @a key is not
900 * in the map for maps that do not allow user specified keys.
901 * However, for maps that allow user specified keys, if the key is
902 * not in the map, a new @a key / @a value association is created.
904 virtual int rebind (const KEY &key,
905 const VALUE &value,
906 VALUE &old_value);
909 * Reassociate @a key with @a value, storing the old key and value
910 * into the "out" parameters @a old_key and @a old_value. The
911 * function fails if @a key is not in the map for maps that do not
912 * allow user specified keys. However, for maps that allow user
913 * specified keys, if the key is not in the map, a new @a key / @a value
914 * association is created.
916 virtual int rebind (const KEY &key,
917 const VALUE &value,
918 KEY &old_key,
919 VALUE &old_value);
922 * Associate @a key with @a value if and only if @a key is not in the
923 * map. If @a key is already in the map, then the @a value parameter
924 * is overwritten with the existing value in the map. Returns 0 if a
925 * new @a key / @a value association is created. Returns 1 if an
926 * attempt is made to bind an existing entry. This function fails
927 * for maps that do not allow user specified keys.
929 virtual int trybind (const KEY &key,
930 VALUE &value);
932 /// Locate @a value associated with @a key.
933 virtual int find (const KEY &key,
934 VALUE &value);
936 /// Is @a key in the map?
937 virtual int find (const KEY &key);
939 /// Remove @a key from the map.
940 virtual int unbind (const KEY &key);
942 /// Remove @a key from the map, and return the @a value associated with
943 /// @a key.
944 virtual int unbind (const KEY &key,
945 VALUE &value);
947 /// Return the current size of the map.
948 virtual size_t current_size () const;
950 /// Return the total size of the map.
951 virtual size_t total_size () const;
953 /// Dump the state of an object.
954 virtual void dump () const;
956 /// Accessor to implementation object.
957 ACE_Active_Map_Manager<std::pair<KEY, VALUE> > &impl ();
959 /// Accessor to key adapter.
960 KEY_ADAPTER &key_adapter ();
962 protected:
963 /// Find helper.
964 virtual int find (const KEY &key,
965 expanded_value *&internal_value);
967 /// Unbind helper.
968 virtual int unbind (const KEY &key,
969 expanded_value *&internal_value);
971 /// All implementation details are forwarded to this class.
972 ACE_Active_Map_Manager<std::pair<KEY, VALUE> > implementation_;
974 /// Adapts between the user key and the Active_Map_Manager_Key.
975 KEY_ADAPTER key_adapter_;
977 // = STL styled iterator factory functions.
979 /// Return forward iterator.
980 virtual ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *begin_impl ();
981 virtual ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *end_impl ();
983 /// Return reverse iterator.
984 virtual ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *rbegin_impl ();
985 virtual ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *rend_impl ();
987 private:
988 // = Disallow these operations.
989 void operator= (const ACE_Active_Map_Manager_Adapter<KEY, VALUE, KEY_ADAPTER> &) = delete;
990 ACE_Active_Map_Manager_Adapter (const ACE_Active_Map_Manager_Adapter<KEY, VALUE, KEY_ADAPTER> &) = delete;
994 * @class ACE_Hash_Map_Manager_Ex_Iterator_Adapter
996 * @brief Defines a iterator implementation for the Hash_Map_Manager_Adapter.
998 * Implementation to be provided by ACE_Hash_Map_Manager_Ex::iterator.
1000 template <class T, class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS>
1001 class ACE_Hash_Map_Manager_Ex_Iterator_Adapter : public ACE_Iterator_Impl<T>
1003 public:
1004 // = Traits.
1005 typedef typename ACE_Hash_Map_Manager_Ex<KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex>::iterator
1006 implementation;
1008 /// Constructor.
1009 ACE_Hash_Map_Manager_Ex_Iterator_Adapter (const ACE_Hash_Map_Iterator_Ex<KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> &impl);
1011 /// Destructor.
1012 virtual ~ACE_Hash_Map_Manager_Ex_Iterator_Adapter ();
1014 /// Clone.
1015 virtual ACE_Iterator_Impl<T> *clone () const;
1017 /// Comparison.
1018 virtual int compare (const ACE_Iterator_Impl<T> &rhs) const;
1020 /// Dereference.
1021 virtual T dereference () const;
1023 /// Advance.
1024 virtual void plus_plus ();
1026 /// Reverse.
1027 virtual void minus_minus ();
1029 /// Accessor to implementation object.
1030 ACE_Hash_Map_Iterator_Ex<KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> &impl ();
1032 protected:
1033 /// All implementation details are forwarded to this class.
1034 ACE_Hash_Map_Iterator_Ex<KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> implementation_;
1038 * @class ACE_Hash_Map_Manager_Ex_Reverse_Iterator_Adapter
1040 * @brief Defines a reverse iterator implementation for the Hash_Map_Manager_Adapter.
1042 * Implementation to be provided by ACE_Hash_Map_Manager_Ex::reverse_iterator.
1044 template <class T, class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS>
1045 class ACE_Hash_Map_Manager_Ex_Reverse_Iterator_Adapter : public ACE_Reverse_Iterator_Impl<T>
1047 public:
1048 // = Traits.
1049 typedef typename ACE_Hash_Map_Manager_Ex<KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex>::reverse_iterator
1050 implementation;
1052 /// Constructor.
1053 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);
1055 /// Destructor.
1056 virtual ~ACE_Hash_Map_Manager_Ex_Reverse_Iterator_Adapter ();
1058 /// Clone.
1059 virtual ACE_Reverse_Iterator_Impl<T> *clone () const;
1061 /// Comparison.
1062 virtual int compare (const ACE_Reverse_Iterator_Impl<T> &rhs) const;
1064 /// Dereference.
1065 virtual T dereference () const;
1067 /// Advance.
1068 virtual void plus_plus ();
1070 /// Reverse.
1071 virtual void minus_minus ();
1073 /// Accessor to implementation object.
1074 ACE_Hash_Map_Reverse_Iterator_Ex<KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> &impl ();
1076 protected:
1077 /// All implementation details are forwarded to this class.
1078 ACE_Hash_Map_Reverse_Iterator_Ex<KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> implementation_;
1082 * @class ACE_Hash_Map_Manager_Ex_Adapter
1084 * @brief Defines a map implementation.
1086 * Implementation to be provided by ACE_Hash_Map_Manager_Ex.
1088 template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class KEY_GENERATOR>
1089 class ACE_Hash_Map_Manager_Ex_Adapter : public ACE_Map<KEY, VALUE>
1091 public:
1092 // = Traits.
1093 typedef ACE_Hash_Map_Manager_Ex_Iterator_Adapter<ACE_Reference_Pair<const KEY, VALUE>, KEY, VALUE, HASH_KEY, COMPARE_KEYS>
1094 iterator_impl;
1095 typedef ACE_Hash_Map_Manager_Ex_Reverse_Iterator_Adapter<ACE_Reference_Pair<const KEY, VALUE>, KEY, VALUE, HASH_KEY, COMPARE_KEYS>
1096 reverse_iterator_impl;
1097 typedef ACE_Hash_Map_Manager_Ex<KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex>
1098 implementation;
1100 /// Initialize with the ACE_DEFAULT_MAP_SIZE.
1101 ACE_Hash_Map_Manager_Ex_Adapter (ACE_Allocator *alloc = nullptr);
1103 /// Initialize with @a size entries. The @a size parameter is ignored
1104 /// by maps for which an initialize size does not make sense.
1105 ACE_Hash_Map_Manager_Ex_Adapter (size_t size,
1106 ACE_Allocator *alloc = nullptr);
1108 /// Close down and release dynamically allocated resources.
1109 virtual ~ACE_Hash_Map_Manager_Ex_Adapter ();
1111 /// Initialize a Map with size @a length.
1112 virtual int open (size_t length = ACE_DEFAULT_MAP_SIZE,
1113 ACE_Allocator *alloc = nullptr);
1115 /// Close down a Map and release dynamically allocated resources.
1116 virtual int close ();
1119 * Add @a key / @a value pair to the map. If @a key is already in the
1120 * map then no changes are made and 1 is returned. Returns 0 on a
1121 * successful addition. This function fails for maps that do not
1122 * allow user specified keys. @a key is an "in" parameter.
1124 virtual int bind (const KEY &key,
1125 const VALUE &value);
1128 * Add @a key / @a value pair to the map. @a key is an "inout" parameter
1129 * and maybe modified/extended by the map to add additional
1130 * information. To recover original key, call the <recover_key>
1131 * method.
1133 virtual int bind_modify_key (const VALUE &value,
1134 KEY &key);
1137 * Produce a key and return it through @a key which is an "out"
1138 * parameter. For maps that do not naturally produce keys, the map
1139 * adapters will use the @c KEY_GENERATOR class to produce a key.
1140 * However, the users are responsible for not jeopardizing this key
1141 * production scheme by using user specified keys with keys produced
1142 * by the key generator.
1144 virtual int create_key (KEY &key);
1147 * Add @a value to the map, and the corresponding key produced by the
1148 * Map is returned through @a key which is an "out" parameter. For
1149 * maps that do not naturally produce keys, the map adapters will
1150 * use the @c KEY_GENERATOR class to produce a key. However, the
1151 * users are responsible for not jeopardizing this key production
1152 * scheme by using user specified keys with keys produced by the key
1153 * generator.
1155 virtual int bind_create_key (const VALUE &value,
1156 KEY &key);
1159 * Add @a value to the map. The user does not care about the
1160 * corresponding key produced by the Map. For maps that do not
1161 * naturally produce keys, the map adapters will use the
1162 * @c KEY_GENERATOR class to produce a key. However, the users are
1163 * responsible for not jeopardizing this key production scheme by
1164 * using user specified keys with keys produced by the key
1165 * generator.
1167 virtual int bind_create_key (const VALUE &value);
1169 /// Recovers the original key potentially modified by the map during
1170 /// bind_modify_key().
1171 virtual int recover_key (const KEY &modified_key,
1172 KEY &original_key);
1175 * Reassociate @a key with @a value. The function fails if @a key is
1176 * not in the map for maps that do not allow user specified keys.
1177 * However, for maps that allow user specified keys, if the key is
1178 * not in the map, a new @a key / @a value association is created.
1180 virtual int rebind (const KEY &key,
1181 const VALUE &value);
1184 * Reassociate @a key with @a value, storing the old value into the
1185 * "out" parameter @a old_value. The function fails if @a key is not
1186 * in the map for maps that do not allow user specified keys.
1187 * However, for maps that allow user specified keys, if the key is
1188 * not in the map, a new @a key / @a value association is created.
1190 virtual int rebind (const KEY &key,
1191 const VALUE &value,
1192 VALUE &old_value);
1195 * Reassociate @a key with @a value, storing the old key and value
1196 * into the "out" parameters @a old_key and @a old_value. The
1197 * function fails if @a key is not in the map for maps that do not
1198 * allow user specified keys. However, for maps that allow user
1199 * specified keys, if the key is not in the map, a new @a key / @a value
1200 * association is created.
1202 virtual int rebind (const KEY &key,
1203 const VALUE &value,
1204 KEY &old_key,
1205 VALUE &old_value);
1208 * Associate @a key with @a value if and only if @a key is not in the
1209 * map. If @a key is already in the map, then the @a value parameter
1210 * is overwritten with the existing value in the map. Returns 0 if a
1211 * new @a key / @a value association is created. Returns 1 if an
1212 * attempt is made to bind an existing entry. This function fails
1213 * for maps that do not allow user specified keys.
1215 virtual int trybind (const KEY &key,
1216 VALUE &value);
1218 /// Locate @a value associated with @a key.
1219 virtual int find (const KEY &key,
1220 VALUE &value);
1222 /// Is @a key in the map?
1223 virtual int find (const KEY &key);
1225 /// Remove @a key from the map.
1226 virtual int unbind (const KEY &key);
1228 /// Remove @a key from the map, and return the @a value associated with
1229 /// @a key.
1230 virtual int unbind (const KEY &key,
1231 VALUE &value);
1233 /// Return the current size of the map.
1234 virtual size_t current_size () const;
1236 /// Return the total size of the map.
1237 virtual size_t total_size () const;
1239 /// Dump the state of an object.
1240 virtual void dump () const;
1242 /// Accessor to implementation object.
1243 ACE_Hash_Map_Manager_Ex<KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> &impl ();
1245 /// Accessor to key generator.
1246 KEY_GENERATOR &key_generator ();
1248 protected:
1249 /// All implementation details are forwarded to this class.
1250 ACE_Hash_Map_Manager_Ex<KEY, VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> implementation_;
1252 /// Functor class used for generating key.
1253 KEY_GENERATOR key_generator_;
1255 // = STL styled iterator factory functions.
1257 /// Return forward iterator.
1258 virtual ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *begin_impl ();
1259 virtual ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *end_impl ();
1261 /// Return reverse iterator.
1262 virtual ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *rbegin_impl ();
1263 virtual ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *rend_impl ();
1265 private:
1266 // = Disallow these operations.
1267 void operator= (const ACE_Hash_Map_Manager_Ex_Adapter<KEY, VALUE, HASH_KEY, COMPARE_KEYS, KEY_GENERATOR> &) = delete;
1268 ACE_Hash_Map_Manager_Ex_Adapter (const ACE_Hash_Map_Manager_Ex_Adapter<KEY, VALUE, HASH_KEY, COMPARE_KEYS, KEY_GENERATOR> &) = delete;
1272 * @class ACE_Map_Manager_Iterator_Adapter
1274 * @brief Defines a iterator implementation for the Map_Manager_Adapter.
1276 * Implementation to be provided by ACE_Map_Manager::iterator.
1278 template <class T, class KEY, class VALUE>
1279 class ACE_Map_Manager_Iterator_Adapter : public ACE_Iterator_Impl<T>
1281 public:
1282 // = Traits.
1283 typedef typename ACE_Map_Manager<KEY, VALUE, ACE_Null_Mutex>::iterator
1284 implementation;
1286 /// Constructor.
1287 ACE_Map_Manager_Iterator_Adapter (const ACE_Map_Iterator<KEY, VALUE, ACE_Null_Mutex> &impl);
1289 /// Destructor.
1290 virtual ~ACE_Map_Manager_Iterator_Adapter ();
1292 /// Clone.
1293 virtual ACE_Iterator_Impl<T> *clone () const;
1295 /// Comparison.
1296 virtual int compare (const ACE_Iterator_Impl<T> &rhs) const;
1298 /// Dereference.
1299 virtual T dereference () const;
1301 /// Advance.
1302 virtual void plus_plus ();
1304 /// Reverse.
1305 virtual void minus_minus ();
1307 /// Accessor to implementation object.
1308 ACE_Map_Iterator<KEY, VALUE, ACE_Null_Mutex> &impl ();
1310 protected:
1311 /// All implementation details are forwarded to this class.
1312 ACE_Map_Iterator<KEY, VALUE, ACE_Null_Mutex> implementation_;
1316 * @class ACE_Map_Manager_Reverse_Iterator_Adapter
1318 * @brief Defines a reverse iterator implementation for the Map Manager.
1320 * Implementation to be provided by ACE_Map_Manager::reverse_iterator.
1322 template <class T, class KEY, class VALUE>
1323 class ACE_Map_Manager_Reverse_Iterator_Adapter : public ACE_Reverse_Iterator_Impl<T>
1325 public:
1326 // = Traits.
1327 typedef typename ACE_Map_Manager<KEY, VALUE, ACE_Null_Mutex>::reverse_iterator
1328 implementation;
1330 /// Constructor.
1331 ACE_Map_Manager_Reverse_Iterator_Adapter (const ACE_Map_Reverse_Iterator<KEY, VALUE, ACE_Null_Mutex> &impl);
1333 /// Destructor.
1334 virtual ~ACE_Map_Manager_Reverse_Iterator_Adapter ();
1336 /// Clone.
1337 virtual ACE_Reverse_Iterator_Impl<T> *clone () const;
1339 /// Comparison.
1340 virtual int compare (const ACE_Reverse_Iterator_Impl<T> &rhs) const;
1342 /// Dereference.
1343 virtual T dereference () const;
1345 /// Advance.
1346 virtual void plus_plus ();
1348 /// Reverse.
1349 virtual void minus_minus ();
1351 /// Accessor to implementation object.
1352 ACE_Map_Reverse_Iterator<KEY, VALUE, ACE_Null_Mutex> &impl ();
1354 protected:
1355 /// All implementation details are forwarded to this class.
1356 ACE_Map_Reverse_Iterator<KEY, VALUE, ACE_Null_Mutex> implementation_;
1360 * @class ACE_Map_Manager_Adapter
1362 * @brief Defines a map implementation.
1364 * Implementation to be provided by ACE_Map_Manager.
1366 template <class KEY, class VALUE, class KEY_GENERATOR>
1367 class ACE_Map_Manager_Adapter : public ACE_Map<KEY, VALUE>
1369 public:
1370 // = Traits.
1371 typedef ACE_Map_Manager_Iterator_Adapter<ACE_Reference_Pair<const KEY, VALUE>, KEY, VALUE>
1372 iterator_impl;
1373 typedef ACE_Map_Manager_Reverse_Iterator_Adapter<ACE_Reference_Pair<const KEY, VALUE>, KEY, VALUE>
1374 reverse_iterator_impl;
1375 typedef ACE_Map_Manager<KEY, VALUE, ACE_Null_Mutex>
1376 implementation;
1378 /// Initialize with the ACE_DEFAULT_MAP_SIZE.
1379 ACE_Map_Manager_Adapter (ACE_Allocator *alloc = nullptr);
1381 /// Initialize with @a size entries. The @a size parameter is ignored
1382 /// by maps for which an initialize size does not make sense.
1383 ACE_Map_Manager_Adapter (size_t size,
1384 ACE_Allocator *alloc = nullptr);
1386 /// Close down and release dynamically allocated resources.
1387 virtual ~ACE_Map_Manager_Adapter ();
1389 /// Initialize a <Map> with size @a length.
1390 virtual int open (size_t length = ACE_DEFAULT_MAP_SIZE,
1391 ACE_Allocator *alloc = nullptr);
1393 /// Close down a <Map> and release dynamically allocated resources.
1394 virtual int close ();
1397 * Add @a key / @a value pair to the map. If @a key is already in the
1398 * map then no changes are made and 1 is returned. Returns 0 on a
1399 * successful addition. This function fails for maps that do not
1400 * allow user specified keys. @a key is an "in" parameter.
1402 virtual int bind (const KEY &key,
1403 const VALUE &value);
1406 * Add @a key / @a value pair to the map. @a key is an "inout" parameter
1407 * and maybe modified/extended by the map to add additional
1408 * information. To recover original key, call the <recover_key>
1409 * method.
1411 virtual int bind_modify_key (const VALUE &value,
1412 KEY &key);
1415 * Produce a key and return it through @a key which is an "out"
1416 * parameter. For maps that do not naturally produce keys, the map
1417 * adapters will use the @c KEY_GENERATOR class to produce a key.
1418 * However, the users are responsible for not jeopardizing this key
1419 * production scheme by using user specified keys with keys produced
1420 * by the key generator.
1422 virtual int create_key (KEY &key);
1425 * Add @a value to the map, and the corresponding key produced by the
1426 * Map is returned through @a key which is an "out" parameter. For
1427 * maps that do not naturally produce keys, the map adapters will
1428 * use the @c KEY_GENERATOR class to produce a key. However, the
1429 * users are responsible for not jeopardizing this key production
1430 * scheme by using user specified keys with keys produced by the key
1431 * generator.
1433 virtual int bind_create_key (const VALUE &value,
1434 KEY &key);
1437 * Add @a value to the map. The user does not care about the
1438 * corresponding key produced by the Map. For maps that do not
1439 * naturally produce keys, the map adapters will use the
1440 * @c KEY_GENERATOR class to produce a key. However, the users are
1441 * responsible for not jeopardizing this key production scheme by
1442 * using user specified keys with keys produced by the key
1443 * generator.
1445 virtual int bind_create_key (const VALUE &value);
1447 /// Recovers the original key potentially modified by the map during
1448 /// <bind_modify_key>.
1449 virtual int recover_key (const KEY &modified_key,
1450 KEY &original_key);
1453 * Reassociate @a key with @a value. The function fails if @a key is
1454 * not in the map for maps that do not allow user specified keys.
1455 * However, for maps that allow user specified keys, if the key is
1456 * not in the map, a new @a key / @a value association is created.
1458 virtual int rebind (const KEY &key,
1459 const VALUE &value);
1462 * Reassociate @a key with @a value, storing the old value into the
1463 * "out" parameter @a old_value. The function fails if @a key is not
1464 * in the map for maps that do not allow user specified keys.
1465 * However, for maps that allow user specified keys, if the key is
1466 * not in the map, a new @a key / @a value association is created.
1468 virtual int rebind (const KEY &key,
1469 const VALUE &value,
1470 VALUE &old_value);
1473 * Reassociate @a key with @a value, storing the old key and value
1474 * into the "out" parameters @a old_key and @a old_value. The
1475 * function fails if @a key is not in the map for maps that do not
1476 * allow user specified keys. However, for maps that allow user
1477 * specified keys, if the key is not in the map, a new @a key / @a value
1478 * association is created.
1480 virtual int rebind (const KEY &key,
1481 const VALUE &value,
1482 KEY &old_key,
1483 VALUE &old_value);
1486 * Associate @a key with @a value if and only if @a key is not in the
1487 * map. If @a key is already in the map, then the @a value parameter
1488 * is overwritten with the existing value in the map. Returns 0 if a
1489 * new @a key / @a value association is created. Returns 1 if an
1490 * attempt is made to bind an existing entry. This function fails
1491 * for maps that do not allow user specified keys.
1493 virtual int trybind (const KEY &key,
1494 VALUE &value);
1496 /// Locate @a value associated with @a key.
1497 virtual int find (const KEY &key,
1498 VALUE &value);
1500 /// Is @a key in the map?
1501 virtual int find (const KEY &key);
1503 /// Remove @a key from the map.
1504 virtual int unbind (const KEY &key);
1506 /// Remove @a key from the map, and return the @a value associated with
1507 /// @a key.
1508 virtual int unbind (const KEY &key,
1509 VALUE &value);
1511 /// Return the current size of the map.
1512 virtual size_t current_size () const;
1514 /// Return the total size of the map.
1515 virtual size_t total_size () const;
1517 /// Dump the state of an object.
1518 virtual void dump () const;
1520 /// Accessor to implementation object.
1521 ACE_Map_Manager<KEY, VALUE, ACE_Null_Mutex> &impl ();
1523 /// Accessor to key generator.
1524 KEY_GENERATOR &key_generator ();
1526 protected:
1527 /// All implementation details are forwarded to this class.
1528 ACE_Map_Manager<KEY, VALUE, ACE_Null_Mutex> implementation_;
1530 /// Functor class used for generating key.
1531 KEY_GENERATOR key_generator_;
1533 // = STL styled iterator factory functions.
1535 /// Return forward iterator.
1536 virtual ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *begin_impl ();
1537 virtual ACE_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *end_impl ();
1539 /// Return reverse iterator.
1540 virtual ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *rbegin_impl ();
1541 virtual ACE_Reverse_Iterator_Impl<ACE_Reference_Pair<const KEY, VALUE> > *rend_impl ();
1543 private:
1544 // = Disallow these operations.
1545 void operator= (const ACE_Map_Manager_Adapter<KEY, VALUE, KEY_GENERATOR> &) = delete;
1546 ACE_Map_Manager_Adapter (const ACE_Map_Manager_Adapter<KEY, VALUE, KEY_GENERATOR> &) = delete;
1549 ACE_END_VERSIONED_NAMESPACE_DECL
1551 #if defined (__ACE_INLINE__)
1552 #include "ace/Map_T.inl"
1553 #endif /* __ACE_INLINE__ */
1555 #include "ace/Map_T.cpp"
1557 #include /**/ "ace/post.h"
1558 #endif /* ACE_MAP_T_H */