[6916] Fixed typos in spell checking code.
[getmangos.git] / dep / ACE_wrappers / ace / Hash_Cache_Map_Manager_T.cpp
blob2d9f163c5d3a3813285d1ccdbcd88b0a242005a4
1 // $Id: Hash_Cache_Map_Manager_T.cpp 80826 2008-03-04 14:51:23Z wotte $
3 #ifndef ACE_HASH_CACHE_MAP_MANAGER_T_CPP
4 #define ACE_HASH_CACHE_MAP_MANAGER_T_CPP
6 #include "ace/Hash_Cache_Map_Manager_T.h"
8 #if !defined (ACE_LACKS_PRAGMA_ONCE)
9 #pragma once
10 #endif /* ACE_LACKS_PRAGMA_ONCE */
12 #if !defined (__ACE_INLINE__)
13 #include "ace/Hash_Cache_Map_Manager_T.inl"
14 #endif /* __ACE_INLINE__ */
16 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
18 ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Cache_Map_Manager)
20 #define ACE_T1 class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY, class ATTRIBUTES
21 #define ACE_T2 KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES
23 template <ACE_T1>
24 ACE_Hash_Cache_Map_Manager<ACE_T2>::ACE_Hash_Cache_Map_Manager (CACHING_STRATEGY &caching_s,
25 size_t size,
26 ACE_Allocator *alloc)
27 : ACE_HCMM_BASE (caching_s,
28 size,
29 alloc)
33 template <ACE_T1>
34 ACE_Hash_Cache_Map_Manager<ACE_T2>::~ACE_Hash_Cache_Map_Manager (void)
38 template <ACE_T1> int
39 ACE_Hash_Cache_Map_Manager<ACE_T2>::bind (const KEY &key,
40 const VALUE &value,
41 CACHE_ENTRY *&entry)
43 // Insert a entry which has the <key> and the <cache_value> which is
44 // the combination of the <value> and the attributes of the caching
45 // strategy.
46 CACHE_VALUE cache_value (value,
47 this->caching_strategy_.attributes ());
49 int bind_result = this->map_.bind (key,
50 cache_value,
51 entry);
53 if (bind_result != -1)
56 int result = this->caching_strategy_.notify_bind (bind_result,
57 cache_value.second ());
59 if (result == -1)
62 this->map_.unbind (key);
64 // Unless the notification goes thru the bind operation is
65 // not complete.
66 bind_result = -1;
71 return bind_result;
74 template <ACE_T1> int
75 ACE_Hash_Cache_Map_Manager<ACE_T2>::rebind (const KEY &key,
76 const VALUE &value,
77 CACHE_ENTRY *&entry)
79 CACHE_VALUE cache_value (value,
80 this->caching_strategy_.attributes ());
82 int rebind_result = this->map_.rebind (key,
83 cache_value,
84 entry);
86 if (rebind_result != -1)
89 int result = this->caching_strategy_.notify_rebind (rebind_result,
90 cache_value.second ());
92 if (result == -1)
95 // Make sure the unbind operation is done only when the
96 // notification fails after a bind which is denoted by
97 // rebind_result = 0
98 if (rebind_result == 0)
99 this->map_.unbind (key);
101 // Unless the notification goes thru the rebind operation is
102 // not complete.
103 rebind_result = -1;
109 return rebind_result;
112 template <ACE_T1> int
113 ACE_Hash_Cache_Map_Manager<ACE_T2>::trybind (const KEY &key,
114 VALUE &value,
115 CACHE_ENTRY *&entry)
117 CACHE_VALUE cache_value (value,
118 this->caching_strategy_.attributes ());
120 int trybind_result = this->map_.trybind (key,
121 cache_value,
122 entry);
124 if (trybind_result != -1)
126 int result = this->caching_strategy_.notify_trybind (trybind_result,
127 cache_value.second ());
129 if (result == -1)
132 // If the entry has got inserted into the map, it is removed
133 // due to failure.
134 if (trybind_result == 0)
135 this->map_.unbind (key);
137 trybind_result = -1;
140 else
143 // If an attempt is made to bind an existing entry the value
144 // is overwritten with the value from the map.
145 if (trybind_result == 1)
146 value = cache_value.first ();
152 return trybind_result;
155 template <ACE_T1> int
156 ACE_Hash_Cache_Map_Manager<ACE_T2>::find (const KEY &key,
157 CACHE_ENTRY *&entry)
159 // Lookup the key and populate the <value>.
160 int find_result = this->map_.find (key,
161 entry);
163 if (find_result != -1)
166 int result = this->caching_strategy_.notify_find (find_result,
167 entry->int_id_.second ());
169 // Unless the find and notification operations go thru, this
170 // method is not successful.
171 if (result == -1)
172 find_result = -1;
173 else
174 find_result = 0;
178 return find_result;
181 template <ACE_T1> int
182 ACE_Hash_Cache_Map_Manager<ACE_T2>::find (const KEY &key,
183 VALUE &value)
185 CACHE_ENTRY *entry = 0;
187 int result = this->find (key,
188 entry);
190 if (result != -1)
192 value = entry->int_id_.first ();
195 return result;
198 template <ACE_T1> int
199 ACE_Hash_Cache_Map_Manager<ACE_T2>::find (const KEY &key)
201 CACHE_ENTRY *entry = 0;
203 return this->find (key,
204 entry);
207 template <ACE_T1> int
208 ACE_Hash_Cache_Map_Manager<ACE_T2>::unbind (CACHE_ENTRY *entry)
210 // Remove the entry from the cache.
211 int unbind_result = this->map_.unbind (entry);
213 if (unbind_result != -1)
216 int result = this->caching_strategy_.notify_unbind (unbind_result,
217 entry->int_id_.second ());
219 if (result == -1)
220 unbind_result = -1;
224 return unbind_result;
227 ACE_END_VERSIONED_NAMESPACE_DECL
229 #undef ACE_T1
230 #undef ACE_T2
232 #endif /* ACE_HASH_CACHE_MAP_MANAGER_T_CPP */