00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef ACE_CACHE_MAP_MANAGER_T_H
00014 #define ACE_CACHE_MAP_MANAGER_T_H
00015
00016 #include "ace/pre.h"
00017
00018 #include "ace/config-all.h"
00019
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif
00023
00024 #include "ace/Default_Constants.h"
00025 #include "ace/Global_Macros.h"
00026 #include "ace/Pair_T.h"
00027
00028 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00029
00030
00031 class ACE_Allocator;
00032
00033 #define ACE_Cache_Map_Iterator ACMI
00034 #define ACE_Cache_Map_Reverse_Iterator ACMRI
00035
00036 template <class KEY, class VALUE, class IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES>
00037 class ACE_Cache_Map_Iterator;
00038
00039 template <class KEY, class VALUE, class REVERSE_IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES>
00040 class ACE_Cache_Map_Reverse_Iterator;
00041
00042
00043 #define ACE_Cache_Map_Manager ACMM
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 template <class KEY, class VALUE, class CMAP_TYPE, class ITERATOR_IMPL, class REVERSE_ITERATOR_IMPL, class CACHING_STRATEGY, class ATTRIBUTES>
00061 class ACE_Cache_Map_Manager
00062 {
00063 public:
00064
00065
00066 typedef KEY key_type;
00067 typedef VALUE mapped_type;
00068 typedef CMAP_TYPE map_type;
00069 typedef CACHING_STRATEGY caching_strategy_type;
00070
00071 typedef ITERATOR_IMPL ITERATOR_IMPLEMENTATION;
00072 typedef REVERSE_ITERATOR_IMPL REVERSE_ITERATOR_IMPLEMENTATION;
00073
00074 friend class ACE_Cache_Map_Iterator<KEY, VALUE, ITERATOR_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>;
00075 friend class ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, REVERSE_ITERATOR_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>;
00076
00077
00078 typedef ACE_Cache_Map_Iterator<KEY, VALUE, ITERATOR_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>
00079 ITERATOR;
00080 typedef ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, REVERSE_ITERATOR_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES>
00081 REVERSE_ITERATOR;
00082
00083
00084 typedef ITERATOR
00085 iterator;
00086 typedef REVERSE_ITERATOR
00087 reverse_iterator;
00088
00089
00090
00091
00092
00093
00094 typedef ACE_Pair<VALUE, ATTRIBUTES> CACHE_VALUE;
00095
00096
00097
00098
00099
00100 ACE_Cache_Map_Manager (CACHING_STRATEGY &caching_strategy,
00101 size_t size = ACE_DEFAULT_MAP_SIZE,
00102 ACE_Allocator *alloc = 0);
00103
00104
00105
00106 virtual ~ACE_Cache_Map_Manager (void);
00107
00108
00109 int open (size_t length = ACE_DEFAULT_MAP_SIZE,
00110 ACE_Allocator *alloc = 0);
00111
00112
00113 int close (void);
00114
00115
00116
00117
00118
00119
00120
00121 int bind (const KEY &key,
00122 const VALUE &value);
00123
00124
00125
00126
00127
00128
00129
00130
00131 int find (const KEY &key,
00132 VALUE &value);
00133
00134
00135
00136
00137
00138
00139
00140
00141 int find (const KEY &key);
00142
00143
00144
00145
00146
00147
00148 int rebind (const KEY &key,
00149 const VALUE &value);
00150
00151
00152
00153
00154
00155
00156
00157
00158 int rebind (const KEY &key,
00159 const VALUE &value,
00160 VALUE &old_value);
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170 int rebind (const KEY &key,
00171 const VALUE &value,
00172 KEY &old_key,
00173 VALUE &old_value);
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183 int trybind (const KEY &key,
00184 VALUE &value);
00185
00186
00187 int unbind (const KEY &key);
00188
00189
00190
00191 int unbind (const KEY &key,
00192 VALUE &value);
00193
00194
00195 int purge (void);
00196
00197
00198 size_t current_size (void) const;
00199
00200
00201 size_t total_size (void) const;
00202
00203
00204 void dump (void) const;
00205
00206
00207
00208
00209 ITERATOR begin (void);
00210 ITERATOR end (void);
00211
00212
00213 REVERSE_ITERATOR rbegin (void);
00214 REVERSE_ITERATOR rend (void);
00215
00216
00217 CMAP_TYPE &map (void);
00218
00219
00220 CACHING_STRATEGY &caching_strategy (void);
00221
00222 protected:
00223
00224
00225 CMAP_TYPE map_;
00226
00227
00228 CACHING_STRATEGY &caching_strategy_;
00229
00230 private:
00231
00232
00233 ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Cache_Map_Manager<KEY, VALUE, CMAP_TYPE, ITERATOR_IMPL, REVERSE_ITERATOR_IMPL, CACHING_STRATEGY, ATTRIBUTES> &))
00234 ACE_UNIMPLEMENTED_FUNC (ACE_Cache_Map_Manager (const ACE_Cache_Map_Manager<KEY, VALUE, CMAP_TYPE, ITERATOR_IMPL, REVERSE_ITERATOR_IMPL, CACHING_STRATEGY, ATTRIBUTES> &))
00235
00236 };
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246 template <class KEY, class VALUE, class IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES>
00247 class ACE_Cache_Map_Iterator
00248 {
00249
00250 public:
00251
00252
00253
00254
00255 typedef ACE_Reference_Pair<KEY, VALUE>
00256 value_type;
00257 typedef ACE_Pair <VALUE, ATTRIBUTES>
00258 CACHE_VALUE;
00259
00260
00261
00262 ACE_Cache_Map_Iterator (const IMPLEMENTATION &iterator_impl);
00263
00264
00265 ACE_Cache_Map_Iterator (const ACE_Cache_Map_Iterator<KEY, VALUE, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &rhs);
00266
00267 virtual ~ACE_Cache_Map_Iterator (void);
00268
00269
00270
00271
00272 ACE_Cache_Map_Iterator <KEY, VALUE, IMPLEMENTATION,
00273 CACHING_STRATEGY, ATTRIBUTES> &operator=
00274 (const ACE_Cache_Map_Iterator<KEY, VALUE, IMPLEMENTATION,
00275 CACHING_STRATEGY, ATTRIBUTES> &rhs);
00276
00277
00278 bool operator== (const ACE_Cache_Map_Iterator<KEY, VALUE, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &rhs) const;
00279 bool operator!= (const ACE_Cache_Map_Iterator<KEY, VALUE, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &rhs) const;
00280
00281
00282
00283 ACE_Reference_Pair<KEY, VALUE> operator* (void) const;
00284
00285
00286
00287
00288 ACE_Cache_Map_Iterator<KEY, VALUE, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &operator++ (void);
00289
00290
00291 ACE_Cache_Map_Iterator<KEY, VALUE, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> operator++ (int);
00292
00293
00294 ACE_Cache_Map_Iterator<KEY, VALUE, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &operator-- (void);
00295
00296
00297 ACE_Cache_Map_Iterator<KEY, VALUE, IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> operator-- (int);
00298
00299
00300
00301 IMPLEMENTATION &iterator_implementation (void);
00302
00303
00304 void dump (void) const;
00305
00306
00307 ACE_ALLOC_HOOK_DECLARE;
00308
00309 protected:
00310
00311
00312 IMPLEMENTATION iterator_implementation_;
00313 };
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323 template <class KEY, class VALUE, class REVERSE_IMPLEMENTATION, class CACHING_STRATEGY, class ATTRIBUTES>
00324 class ACE_Cache_Map_Reverse_Iterator
00325 {
00326 public:
00327
00328
00329
00330
00331 typedef ACE_Reference_Pair<KEY, VALUE> value_type;
00332 typedef ACE_Pair <VALUE, ATTRIBUTES> CACHE_VALUE;
00333
00334
00335
00336 ACE_Cache_Map_Reverse_Iterator (const REVERSE_IMPLEMENTATION &iterator_impl);
00337
00338
00339 ACE_Cache_Map_Reverse_Iterator (const ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &rhs);
00340
00341 ~ACE_Cache_Map_Reverse_Iterator (void);
00342
00343
00344
00345
00346 ACE_Cache_Map_Reverse_Iterator <KEY, VALUE, REVERSE_IMPLEMENTATION,
00347 CACHING_STRATEGY, ATTRIBUTES> &operator=
00348 (const ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, REVERSE_IMPLEMENTATION,
00349 CACHING_STRATEGY, ATTRIBUTES> &rhs);
00350
00351
00352 bool operator== (const ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &rhs) const;
00353 bool operator!= (const ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &rhs) const;
00354
00355
00356
00357 ACE_Reference_Pair<KEY, VALUE> operator* (void) const;
00358
00359
00360
00361
00362 ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &operator++ (void);
00363
00364
00365 ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> operator++ (int);
00366
00367
00368 ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> &operator-- (void);
00369
00370
00371 ACE_Cache_Map_Reverse_Iterator<KEY, VALUE, REVERSE_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES> operator-- (int);
00372
00373
00374
00375 REVERSE_IMPLEMENTATION &iterator_implementation (void);
00376
00377
00378 void dump (void) const;
00379
00380
00381 ACE_ALLOC_HOOK_DECLARE;
00382
00383 protected:
00384
00385
00386 REVERSE_IMPLEMENTATION reverse_iterator_implementation_;
00387 };
00388
00389 ACE_END_VERSIONED_NAMESPACE_DECL
00390
00391 #if defined (__ACE_INLINE__)
00392 #include "ace/Cache_Map_Manager_T.inl"
00393 #endif
00394
00395 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
00396 #include "ace/Cache_Map_Manager_T.cpp"
00397 #endif
00398
00399 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
00400 #pragma implementation ("Cache_Map_Manager_T.cpp")
00401 #endif
00402
00403 #include "ace/post.h"
00404
00405 #endif