00001
00002
00003 #ifndef ACE_HASH_CACHE_MAP_MANAGER_T_CPP
00004 #define ACE_HASH_CACHE_MAP_MANAGER_T_CPP
00005
00006 #include "ace/Hash_Cache_Map_Manager_T.h"
00007
00008 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00009 #pragma once
00010 #endif
00011
00012 #if !defined (__ACE_INLINE__)
00013 #include "ace/Hash_Cache_Map_Manager_T.inl"
00014 #endif
00015
00016 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00017
00018 ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Cache_Map_Manager)
00019
00020 #define ACE_T1 class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY, class ATTRIBUTES
00021 #define ACE_T2 KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES
00022
00023 template <ACE_T1>
00024 ACE_Hash_Cache_Map_Manager<ACE_T2>::ACE_Hash_Cache_Map_Manager (CACHING_STRATEGY &caching_s,
00025 size_t size,
00026 ACE_Allocator *alloc)
00027 : ACE_HCMM_BASE (caching_s,
00028 size,
00029 alloc)
00030 {
00031 }
00032
00033 template <ACE_T1>
00034 ACE_Hash_Cache_Map_Manager<ACE_T2>::~ACE_Hash_Cache_Map_Manager (void)
00035 {
00036 }
00037
00038 template <ACE_T1> int
00039 ACE_Hash_Cache_Map_Manager<ACE_T2>::bind (const KEY &key,
00040 const VALUE &value,
00041 CACHE_ENTRY *&entry)
00042 {
00043
00044
00045
00046 CACHE_VALUE cache_value (value,
00047 this->caching_strategy_.attributes ());
00048
00049 int bind_result = this->map_.bind (key,
00050 cache_value,
00051 entry);
00052
00053 if (bind_result != -1)
00054 {
00055
00056 int result = this->caching_strategy_.notify_bind (bind_result,
00057 cache_value.second ());
00058
00059 if (result == -1)
00060 {
00061
00062 this->map_.unbind (key);
00063
00064
00065
00066 bind_result = -1;
00067
00068 }
00069 }
00070
00071 return bind_result;
00072 }
00073
00074 template <ACE_T1> int
00075 ACE_Hash_Cache_Map_Manager<ACE_T2>::rebind (const KEY &key,
00076 const VALUE &value,
00077 CACHE_ENTRY *&entry)
00078 {
00079 CACHE_VALUE cache_value (value,
00080 this->caching_strategy_.attributes ());
00081
00082 int rebind_result = this->map_.rebind (key,
00083 cache_value,
00084 entry);
00085
00086 if (rebind_result != -1)
00087 {
00088
00089 int result = this->caching_strategy_.notify_rebind (rebind_result,
00090 cache_value.second ());
00091
00092 if (result == -1)
00093 {
00094
00095
00096
00097
00098 if (rebind_result == 0)
00099 this->map_.unbind (key);
00100
00101
00102
00103 rebind_result = -1;
00104
00105 }
00106
00107 }
00108
00109 return rebind_result;
00110 }
00111
00112 template <ACE_T1> int
00113 ACE_Hash_Cache_Map_Manager<ACE_T2>::trybind (const KEY &key,
00114 VALUE &value,
00115 CACHE_ENTRY *&entry)
00116 {
00117 CACHE_VALUE cache_value (value,
00118 this->caching_strategy_.attributes ());
00119
00120 int trybind_result = this->map_.trybind (key,
00121 cache_value,
00122 entry);
00123
00124 if (trybind_result != -1)
00125 {
00126 int result = this->caching_strategy_.notify_trybind (trybind_result,
00127 cache_value.second ());
00128
00129 if (result == -1)
00130 {
00131
00132
00133
00134 if (trybind_result == 0)
00135 this->map_.unbind (key);
00136
00137 trybind_result = -1;
00138
00139 }
00140 else
00141 {
00142
00143
00144
00145 if (trybind_result == 1)
00146 value = cache_value.first ();
00147
00148 }
00149
00150 }
00151
00152 return trybind_result;
00153 }
00154
00155 template <ACE_T1> int
00156 ACE_Hash_Cache_Map_Manager<ACE_T2>::find (const KEY &key,
00157 CACHE_ENTRY *&entry)
00158 {
00159
00160 int find_result = this->map_.find (key,
00161 entry);
00162
00163 if (find_result != -1)
00164 {
00165
00166 int result = this->caching_strategy_.notify_find (find_result,
00167 entry->int_id_.second ());
00168
00169
00170
00171 if (result == -1)
00172 find_result = -1;
00173 else
00174 find_result = 0;
00175
00176 }
00177
00178 return find_result;
00179 }
00180
00181 template <ACE_T1> int
00182 ACE_Hash_Cache_Map_Manager<ACE_T2>::find (const KEY &key,
00183 VALUE &value)
00184 {
00185 CACHE_ENTRY *entry = 0;
00186
00187 int result = this->find (key,
00188 entry);
00189
00190 if (result != -1)
00191 {
00192 value = entry->int_id_.first ();
00193 }
00194
00195 return result;
00196 }
00197
00198 template <ACE_T1> int
00199 ACE_Hash_Cache_Map_Manager<ACE_T2>::find (const KEY &key)
00200 {
00201 CACHE_ENTRY *entry = 0;
00202
00203 return this->find (key,
00204 entry);
00205 }
00206
00207 template <ACE_T1> int
00208 ACE_Hash_Cache_Map_Manager<ACE_T2>::unbind (CACHE_ENTRY *entry)
00209 {
00210
00211 int unbind_result = this->map_.unbind (entry);
00212
00213 if (unbind_result != -1)
00214 {
00215
00216 int result = this->caching_strategy_.notify_unbind (unbind_result,
00217 entry->int_id_.second ());
00218
00219 if (result == -1)
00220 unbind_result = -1;
00221
00222 }
00223
00224 return unbind_result;
00225 }
00226
00227 ACE_END_VERSIONED_NAMESPACE_DECL
00228
00229 #undef ACE_T1
00230 #undef ACE_T2
00231
00232 #endif