2 #ifndef JAWS_CACHE_HEAP_T_H
3 #define JAWS_CACHE_HEAP_T_H
5 #include "ace/Malloc.h"
6 #include "JAWS/Cache_Object.h"
8 // Forward declarations
9 template <class EXT_ID
, class FACTORY
, class HASH_FUNC
, class EQ_FUNC
>
10 class JAWS_Cache_Manager
;
12 template <class EXT_ID
, class FACTORY
, class HASH_FUNC
, class EQ_FUNC
>
13 class JAWS_Cache_Heap_Item
;
16 template <class EXT_ID
, class FACT
, class H_FN
, class E_FN
>
18 // Roll my own heap here. Eventually, a heap should be its own
19 // standalone data structure.
22 typedef JAWS_Cache_Manager
<EXT_ID
, FACT
, H_FN
, E_FN
> Cache_Manager
;
23 typedef JAWS_Cache_Heap_Item
<EXT_ID
, FACT
, H_FN
, E_FN
> Cache_Heap_Item
;
25 JAWS_Cache_Heap (ACE_Allocator
*alloc
= 0, size_t maxsize
= 8192);
26 // maxsize is the total number of objects the in memory cache is
31 int is_empty () const;
35 size_t maxsize () const;
37 int maxsize (Cache_Manager
*cm
, size_t new_maxsize
);
38 // attempt to grow (or shrink) the heap. Return 0 on success, -1 on
41 int insert (const EXT_ID
&ext_id
, JAWS_Cache_Object
*const &int_id
);
42 // attempt to insert int_id into heap.
44 int remove (EXT_ID
&ext_id
, JAWS_Cache_Object
*&int_id
);
45 // attempt to remove the top element of heap.
47 int remove (void *item
);
48 // treat item as a Cache_Heap_Item, and remove it from the heap
50 int adjust (void *item
);
51 // treat item as a Cache_Heap_Item, and alter its heap position
54 void insert_i (Cache_Heap_Item
*item
);
55 // insert item into heap.
57 void remove_i (size_t pos
);
58 // remove the element residing at pos, but do not delete it.
61 // remove the element residing at the top of heap, but do not delete it.
64 ACE_Allocator
*allocator_
;
69 Cache_Heap_Item
**heap_
;
73 template <class EXT_ID
, class FACT
, class H_FN
, class E_FN
>
74 class JAWS_Cache_Heap_Item
76 friend class JAWS_Cache_Heap
<EXT_ID
, FACT
, H_FN
, E_FN
>;
79 JAWS_Cache_Heap_Item (const EXT_ID
&ext_id
, JAWS_Cache_Object
*const &int_id
);
80 unsigned int priority ();
84 JAWS_Cache_Object
*int_id_
;
89 #include "JAWS/Cache_Heap_T.cpp"
91 #endif /* JAWS_CACHE_HEAP_T_H */