1 #ifndef ACE_HASH_CACHE_MAP_MANAGER_T_CPP
2 #define ACE_HASH_CACHE_MAP_MANAGER_T_CPP
4 #include "ace/Hash_Cache_Map_Manager_T.h"
6 #if !defined (ACE_LACKS_PRAGMA_ONCE)
8 #endif /* ACE_LACKS_PRAGMA_ONCE */
10 #if !defined (__ACE_INLINE__)
11 #include "ace/Hash_Cache_Map_Manager_T.inl"
12 #endif /* __ACE_INLINE__ */
14 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
16 ACE_ALLOC_HOOK_DEFINE_Tc6(ACE_Hash_Cache_Map_Manager
)
18 template <class KEY
, class VALUE
, class HASH_KEY
, class COMPARE_KEYS
, class CACHING_STRATEGY
, class ATTRIBUTES
>
19 ACE_Hash_Cache_Map_Manager
<KEY
, VALUE
, HASH_KEY
, COMPARE_KEYS
, CACHING_STRATEGY
, ATTRIBUTES
>::ACE_Hash_Cache_Map_Manager (CACHING_STRATEGY
&caching_s
,
22 : ACE_HCMM_BASE (caching_s
,
28 template <class KEY
, class VALUE
, class HASH_KEY
, class COMPARE_KEYS
, class CACHING_STRATEGY
, class ATTRIBUTES
>
29 ACE_Hash_Cache_Map_Manager
<KEY
, VALUE
, HASH_KEY
, COMPARE_KEYS
, CACHING_STRATEGY
, ATTRIBUTES
>::~ACE_Hash_Cache_Map_Manager (void)
33 template <class KEY
, class VALUE
, class HASH_KEY
, class COMPARE_KEYS
, class CACHING_STRATEGY
, class ATTRIBUTES
> int
34 ACE_Hash_Cache_Map_Manager
<KEY
, VALUE
, HASH_KEY
, COMPARE_KEYS
, CACHING_STRATEGY
, ATTRIBUTES
>::bind (const KEY
&key
,
38 // Insert a entry which has the <key> and the <cache_value> which is
39 // the combination of the <value> and the attributes of the caching
41 CACHE_VALUE
cache_value (value
,
42 this->caching_strategy_
.attributes ());
44 int bind_result
= this->map_
.bind (key
,
48 if (bind_result
!= -1)
51 int result
= this->caching_strategy_
.notify_bind (bind_result
,
57 this->map_
.unbind (key
);
59 // Unless the notification goes thru the bind operation is
69 template <class KEY
, class VALUE
, class HASH_KEY
, class COMPARE_KEYS
, class CACHING_STRATEGY
, class ATTRIBUTES
> int
70 ACE_Hash_Cache_Map_Manager
<KEY
, VALUE
, HASH_KEY
, COMPARE_KEYS
, CACHING_STRATEGY
, ATTRIBUTES
>::rebind (const KEY
&key
,
74 CACHE_VALUE
cache_value (value
,
75 this->caching_strategy_
.attributes ());
77 int rebind_result
= this->map_
.rebind (key
,
81 if (rebind_result
!= -1)
84 int result
= this->caching_strategy_
.notify_rebind (rebind_result
,
85 cache_value
.second ());
90 // Make sure the unbind operation is done only when the
91 // notification fails after a bind which is denoted by
93 if (rebind_result
== 0)
94 this->map_
.unbind (key
);
96 // Unless the notification goes thru the rebind operation is
104 return rebind_result
;
107 template <class KEY
, class VALUE
, class HASH_KEY
, class COMPARE_KEYS
, class CACHING_STRATEGY
, class ATTRIBUTES
> int
108 ACE_Hash_Cache_Map_Manager
<KEY
, VALUE
, HASH_KEY
, COMPARE_KEYS
, CACHING_STRATEGY
, ATTRIBUTES
>::trybind (const KEY
&key
,
112 CACHE_VALUE
cache_value (value
,
113 this->caching_strategy_
.attributes ());
115 int trybind_result
= this->map_
.trybind (key
,
119 if (trybind_result
!= -1)
121 int result
= this->caching_strategy_
.notify_trybind (trybind_result
,
122 cache_value
.second ());
127 // If the entry has got inserted into the map, it is removed
129 if (trybind_result
== 0)
130 this->map_
.unbind (key
);
138 // If an attempt is made to bind an existing entry the value
139 // is overwritten with the value from the map.
140 if (trybind_result
== 1)
141 value
= cache_value
.first ();
147 return trybind_result
;
150 template <class KEY
, class VALUE
, class HASH_KEY
, class COMPARE_KEYS
, class CACHING_STRATEGY
, class ATTRIBUTES
> int
151 ACE_Hash_Cache_Map_Manager
<KEY
, VALUE
, HASH_KEY
, COMPARE_KEYS
, CACHING_STRATEGY
, ATTRIBUTES
>::find (const KEY
&key
,
154 // Lookup the key and populate the <value>.
155 int find_result
= this->map_
.find (key
,
158 if (find_result
!= -1)
161 int result
= this->caching_strategy_
.notify_find (find_result
,
162 entry
->int_id_
.second
);
164 // Unless the find and notification operations go thru, this
165 // method is not successful.
176 template <class KEY
, class VALUE
, class HASH_KEY
, class COMPARE_KEYS
, class CACHING_STRATEGY
, class ATTRIBUTES
> int
177 ACE_Hash_Cache_Map_Manager
<KEY
, VALUE
, HASH_KEY
, COMPARE_KEYS
, CACHING_STRATEGY
, ATTRIBUTES
>::find (const KEY
&key
,
180 CACHE_ENTRY
*entry
= 0;
182 int result
= this->find (key
,
187 value
= entry
->int_id_
.first
;
193 template <class KEY
, class VALUE
, class HASH_KEY
, class COMPARE_KEYS
, class CACHING_STRATEGY
, class ATTRIBUTES
> int
194 ACE_Hash_Cache_Map_Manager
<KEY
, VALUE
, HASH_KEY
, COMPARE_KEYS
, CACHING_STRATEGY
, ATTRIBUTES
>::find (const KEY
&key
)
196 CACHE_ENTRY
*entry
= 0;
198 return this->find (key
,
202 template <class KEY
, class VALUE
, class HASH_KEY
, class COMPARE_KEYS
, class CACHING_STRATEGY
, class ATTRIBUTES
> int
203 ACE_Hash_Cache_Map_Manager
<KEY
, VALUE
, HASH_KEY
, COMPARE_KEYS
, CACHING_STRATEGY
, ATTRIBUTES
>::unbind (CACHE_ENTRY
*entry
)
205 // Remove the entry from the cache.
206 int unbind_result
= this->map_
.unbind (entry
);
208 if (unbind_result
!= -1)
211 int result
= this->caching_strategy_
.notify_unbind (unbind_result
,
212 entry
->int_id_
.second
);
219 return unbind_result
;
222 ACE_END_VERSIONED_NAMESPACE_DECL
224 #endif /* ACE_HASH_CACHE_MAP_MANAGER_T_CPP */