Correct feature names
[ACE_TAO.git] / ACE / ace / Active_Map_Manager_T.h
blob472ea71911b73a3571da038d975eec9dd5397d2a
1 /* -*- C++ -*- */
3 //=============================================================================
4 /**
5 * @file Active_Map_Manager_T.h
7 * @author Irfan Pyarali
8 */
9 //=============================================================================
12 #ifndef ACE_ACTIVE_MAP_MANAGER_T_H
13 #define ACE_ACTIVE_MAP_MANAGER_T_H
14 #include /**/ "ace/pre.h"
16 #include "ace/Map_Manager.h"
17 #include "ace/Active_Map_Manager.h"
19 #if !defined (ACE_LACKS_PRAGMA_ONCE)
20 # pragma once
21 #endif /* ACE_LACKS_PRAGMA_ONCE */
23 #include "ace/Null_Mutex.h"
25 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
27 /**
28 * @class ACE_Active_Map_Manager
30 * @brief Define a map abstraction that associates system generated
31 * keys with user specified values.
33 * Since the key is system generated, searches are very fast and
34 * take a constant amount of time.
36 template <class T>
37 class ACE_Active_Map_Manager : public ACE_Map_Manager<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex>
39 public:
40 // = Traits.
41 typedef ACE_Active_Map_Manager_Key key_type;
42 typedef T mapped_type;
44 typedef ACE_Map_Entry<ACE_Active_Map_Manager_Key, T> ENTRY;
45 typedef ACE_Map_Iterator<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex> ITERATOR;
46 typedef ACE_Map_Reverse_Iterator<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex> REVERSE_ITERATOR;
48 typedef ENTRY entry;
49 typedef ITERATOR iterator;
50 typedef REVERSE_ITERATOR reverse_iterator;
52 /// Initialize a Active_Map_Manager with the ACE_DEFAULT_MAP_SIZE.
53 ACE_Active_Map_Manager (ACE_Allocator *alloc = 0);
55 /// Initialize a Active_Map_Manager with @a size entries.
56 ACE_Active_Map_Manager (size_t size,
57 ACE_Allocator *alloc = 0);
59 /// Close down a Active_Map_Manager and release dynamically
60 /// allocated resources.
61 ~ACE_Active_Map_Manager (void);
63 /// Initialize a Active_Map_Manager with size @a length.
64 int open (size_t length = ACE_DEFAULT_MAP_SIZE,
65 ACE_Allocator *alloc = 0);
67 /// Close down a Active_Map_Manager and release dynamically
68 /// allocated resources.
69 int close (void);
71 /// Add @a value to the map, and the corresponding key produced by the
72 /// Active_Map_Manager is returned through @a key.
73 int bind (const T &value,
74 ACE_Active_Map_Manager_Key &key);
76 /// Add @a value to the map. The user does not care about the
77 /// corresponding key produced by the Active_Map_Manager.
78 int bind (const T &value);
80 /**
81 * Reserves a slot in the internal structure and returns the key and
82 * a pointer to the value. User should place their @a value into
83 * @a internal_value. This method is useful in reducing the number
84 * of copies required in some cases. Note that @a internal_value is
85 * only a temporary pointer and will change when the map resizes.
86 * Therefore, the user should use the pointer immediately and not
87 * hold on to it.
89 int bind (ACE_Active_Map_Manager_Key &key,
90 T *&internal_value);
92 /// Reassociate @a key with @a value. The function fails if @a key is
93 /// not in the map.
94 int rebind (const ACE_Active_Map_Manager_Key &key,
95 const T &value);
97 /**
98 * Reassociate @a key with @a value, storing the old value into the
99 * "out" parameter @a old_value. The function fails if @a key is not
100 * in the map.
102 int rebind (const ACE_Active_Map_Manager_Key &key,
103 const T &value,
104 T &old_value);
107 * Reassociate @a key with @a value, storing the old key and value
108 * into the "out" parameter @a old_key and @a old_value. The function
109 * fails if @a key is not in the map.
111 int rebind (const ACE_Active_Map_Manager_Key &key,
112 const T &value,
113 ACE_Active_Map_Manager_Key &old_key,
114 T &old_value);
116 /// Locate @a value associated with @a key.
117 int find (const ACE_Active_Map_Manager_Key &key,
118 T &value) const;
120 /// Is @a key in the map?
121 int find (const ACE_Active_Map_Manager_Key &key) const;
124 * Locate @a value associated with @a key. The value is returned via
125 * @a internal_value and hence a copy is saved. Note that
126 * @a internal_value is only a temporary pointer and will change when
127 * the map resizes. Therefore, the user should use the pointer
128 * immediately and not hold on to it.
130 int find (const ACE_Active_Map_Manager_Key &key,
131 T *&internal_value) const;
133 // Creates a key. User should place their @a value into
134 // <*internal_value>. This method is useful in reducing the number
135 // of copies required in some cases.
137 /// Remove @a key from the map.
138 int unbind (const ACE_Active_Map_Manager_Key &key);
140 /// Remove @a key from the map, and return the @a value associated with
141 /// @a key.
142 int unbind (const ACE_Active_Map_Manager_Key &key,
143 T &value);
146 * Locate @a value associated with @a key. The value is returned via
147 * @a internal_value and hence a copy is saved. Note that
148 * @a internal_value is only a temporary pointer and will change when
149 * the map resizes or when this slot is reused. Therefore, the user
150 * should use the pointer immediately and not hold on to it.
152 int unbind (const ACE_Active_Map_Manager_Key &key,
153 T *&internal_value);
155 /// Return the current size of the map.
156 size_t current_size (void) const;
158 /// Return the total size of the map.
159 size_t total_size (void) const;
161 /// Returns a key that cannot be found in the map.
162 static const ACE_Active_Map_Manager_Key npos (void);
164 /// Dump the state of an object.
165 void dump (void) const;
167 // = STL styled iterator factory functions.
169 /// Return forward iterator.
170 ACE_Map_Iterator<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex> begin (void);
171 ACE_Map_Iterator<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex> end (void);
173 /// Return reverse iterator.
174 ACE_Map_Reverse_Iterator<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex> rbegin (void);
175 ACE_Map_Reverse_Iterator<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex> rend (void);
177 /// Declare the dynamic allocation hooks.
178 ACE_ALLOC_HOOK_DECLARE;
180 protected:
182 /// Private base class
183 typedef ACE_Map_Manager<ACE_Active_Map_Manager_Key, T, ACE_Null_Mutex> ACE_AMM_BASE;
185 private:
186 // = Disallow these operations.
187 ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Active_Map_Manager<T> &))
188 ACE_UNIMPLEMENTED_FUNC (ACE_Active_Map_Manager (const ACE_Active_Map_Manager<T> &))
191 ACE_END_VERSIONED_NAMESPACE_DECL
193 #if defined (__ACE_INLINE__)
194 #include "ace/Active_Map_Manager_T.inl"
195 #endif /* __ACE_INLINE__ */
197 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
198 #include "ace/Active_Map_Manager_T.cpp"
199 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
201 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
202 #pragma implementation ("Active_Map_Manager_T.cpp")
203 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
205 #include /**/ "ace/post.h"
206 #endif /* ACE_ACTIVE_MAP_MANAGER_T_H */