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
> int
29 ACE_Hash_Cache_Map_Manager
<KEY
, VALUE
, HASH_KEY
, COMPARE_KEYS
, CACHING_STRATEGY
, ATTRIBUTES
>::bind (const KEY
&key
,
33 // Insert a entry which has the <key> and the <cache_value> which is
34 // the combination of the <value> and the attributes of the caching
36 CACHE_VALUE
cache_value (value
,
37 this->caching_strategy_
.attributes ());
39 int bind_result
= this->map_
.bind (key
,
43 if (bind_result
!= -1)
45 int result
= this->caching_strategy_
.notify_bind (bind_result
,
50 this->map_
.unbind (key
);
52 // Unless the notification goes thru the bind operation is
61 template <class KEY
, class VALUE
, class HASH_KEY
, class COMPARE_KEYS
, class CACHING_STRATEGY
, class ATTRIBUTES
> int
62 ACE_Hash_Cache_Map_Manager
<KEY
, VALUE
, HASH_KEY
, COMPARE_KEYS
, CACHING_STRATEGY
, ATTRIBUTES
>::rebind (const KEY
&key
,
66 CACHE_VALUE
cache_value (value
,
67 this->caching_strategy_
.attributes ());
69 int rebind_result
= this->map_
.rebind (key
,
73 if (rebind_result
!= -1)
75 int result
= this->caching_strategy_
.notify_rebind (rebind_result
,
76 cache_value
.second ());
80 // Make sure the unbind operation is done only when the
81 // notification fails after a bind which is denoted by
83 if (rebind_result
== 0)
84 this->map_
.unbind (key
);
86 // Unless the notification goes thru the rebind operation is
96 template <class KEY
, class VALUE
, class HASH_KEY
, class COMPARE_KEYS
, class CACHING_STRATEGY
, class ATTRIBUTES
> int
97 ACE_Hash_Cache_Map_Manager
<KEY
, VALUE
, HASH_KEY
, COMPARE_KEYS
, CACHING_STRATEGY
, ATTRIBUTES
>::trybind (const KEY
&key
,
101 CACHE_VALUE
cache_value (value
,
102 this->caching_strategy_
.attributes ());
104 int trybind_result
= this->map_
.trybind (key
,
108 if (trybind_result
!= -1)
110 int result
= this->caching_strategy_
.notify_trybind (trybind_result
,
111 cache_value
.second ());
115 // If the entry has got inserted into the map, it is removed
117 if (trybind_result
== 0)
118 this->map_
.unbind (key
);
124 // If an attempt is made to bind an existing entry the value
125 // is overwritten with the value from the map.
126 if (trybind_result
== 1)
127 value
= cache_value
.first ();
132 return trybind_result
;
135 template <class KEY
, class VALUE
, class HASH_KEY
, class COMPARE_KEYS
, class CACHING_STRATEGY
, class ATTRIBUTES
> int
136 ACE_Hash_Cache_Map_Manager
<KEY
, VALUE
, HASH_KEY
, COMPARE_KEYS
, CACHING_STRATEGY
, ATTRIBUTES
>::find (const KEY
&key
,
139 // Lookup the key and populate the <value>.
140 int find_result
= this->map_
.find (key
,
143 if (find_result
!= -1)
145 int result
= this->caching_strategy_
.notify_find (find_result
,
146 entry
->int_id_
.second
);
148 // Unless the find and notification operations go thru, this
149 // method is not successful.
159 template <class KEY
, class VALUE
, class HASH_KEY
, class COMPARE_KEYS
, class CACHING_STRATEGY
, class ATTRIBUTES
> int
160 ACE_Hash_Cache_Map_Manager
<KEY
, VALUE
, HASH_KEY
, COMPARE_KEYS
, CACHING_STRATEGY
, ATTRIBUTES
>::find (const KEY
&key
,
163 CACHE_ENTRY
*entry
= 0;
165 int result
= this->find (key
,
170 value
= entry
->int_id_
.first
;
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
)
179 CACHE_ENTRY
*entry
= 0;
181 return this->find (key
,
185 template <class KEY
, class VALUE
, class HASH_KEY
, class COMPARE_KEYS
, class CACHING_STRATEGY
, class ATTRIBUTES
> int
186 ACE_Hash_Cache_Map_Manager
<KEY
, VALUE
, HASH_KEY
, COMPARE_KEYS
, CACHING_STRATEGY
, ATTRIBUTES
>::unbind (CACHE_ENTRY
*entry
)
188 // Remove the entry from the cache.
189 int unbind_result
= this->map_
.unbind (entry
);
191 if (unbind_result
!= -1)
193 int result
= this->caching_strategy_
.notify_unbind (unbind_result
,
194 entry
->int_id_
.second
);
200 return unbind_result
;
203 ACE_END_VERSIONED_NAMESPACE_DECL
205 #endif /* ACE_HASH_CACHE_MAP_MANAGER_T_CPP */