Use =default for skeleton copy constructor
[ACE_TAO.git] / ACE / apps / JAWS2 / JAWS / Cache_Object.h
blobfa6120ee15920ebcc0b985537913b3fde3279ca3
1 // -*- C++ -*-
4 #ifndef JAWS_CACHE_OBJECT_H
5 #define JAWS_CACHE_OBJECT_H
7 #include "ace/Thread_Mutex.h"
8 #include "ace/Synch_Traits.h"
9 #include "ace/Malloc.h"
10 #include "ace/RW_Thread_Mutex.h"
11 #include "ace/Lock_Adapter_T.h"
13 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
14 class ACE_Allocator;
15 ACE_END_VERSIONED_NAMESPACE_DECL
18 // Cache bucket -- use Hash_Bucket to hold cacheable objects.
20 class JAWS_Cache_Object
22 public:
23 JAWS_Cache_Object (const void *, size_t);
24 virtual ~JAWS_Cache_Object ();
26 void *internal () const;
27 void internal (void *);
29 const void *data () const;
30 size_t size () const;
31 unsigned int count () const;
33 int acquire ();
34 int release ();
36 time_t last_access () const;
37 time_t first_access () const;
39 unsigned int priority () const;
41 enum { ACE_CO_REFERENCED, ACE_CO_COUNTED };
43 void *heap_item () const;
44 void heap_item (void *item);
46 virtual ACE_Lock & lock () = 0;
48 protected:
49 virtual unsigned int count_i () const = 0;
50 virtual int acquire_i () = 0;
51 virtual int release_i () = 0;
52 virtual unsigned int priority_i () const = 0;
54 private:
55 void *internal_;
56 const void *data_;
57 size_t size_;
59 time_t last_access_;
60 time_t first_access_;
61 time_t new_last_access_;
63 void *heap_item_;
66 class JAWS_Referenced_Cache_Object : public JAWS_Cache_Object
68 public:
69 JAWS_Referenced_Cache_Object (const void *, size_t);
70 virtual ~JAWS_Referenced_Cache_Object ();
72 virtual ACE_Lock & lock ();
74 protected:
75 virtual unsigned int count_i () const;
76 virtual int acquire_i ();
77 virtual int release_i ();
78 virtual unsigned int priority_i () const;
80 private:
81 mutable ACE_SYNCH_RW_MUTEX count_;
82 mutable ACE_Lock_Adapter<ACE_SYNCH_RW_MUTEX> lock_adapter_;
85 class JAWS_Counted_Cache_Object : public JAWS_Cache_Object
87 public:
88 JAWS_Counted_Cache_Object (const void *, size_t);
89 virtual ~JAWS_Counted_Cache_Object ();
91 virtual ACE_Lock & lock ();
93 protected:
94 virtual unsigned int count_i () const;
95 virtual int acquire_i ();
96 virtual int release_i ();
97 virtual unsigned int priority_i () const;
99 private:
100 unsigned int count_;
101 unsigned int new_count_;
102 mutable ACE_SYNCH_MUTEX lock_;
103 mutable ACE_Lock_Adapter<ACE_SYNCH_MUTEX> lock_adapter_;
106 class JAWS_Cache_Object_Factory
108 public:
109 JAWS_Cache_Object_Factory (ACE_Allocator *alloc = 0);
110 virtual ~JAWS_Cache_Object_Factory ();
112 int open (ACE_Allocator *alloc = 0);
114 virtual JAWS_Cache_Object * create (const void *, size_t) = 0;
115 virtual void destroy (JAWS_Cache_Object *) = 0;
117 protected:
118 ACE_Allocator *allocator_;
121 class JAWS_Referenced_Cache_Object_Factory : public JAWS_Cache_Object_Factory
123 public:
124 JAWS_Referenced_Cache_Object_Factory (ACE_Allocator *alloc = 0);
125 virtual ~JAWS_Referenced_Cache_Object_Factory ();
127 virtual JAWS_Cache_Object * create (const void *, size_t);
128 virtual void destroy (JAWS_Cache_Object *);
131 class JAWS_Counted_Cache_Object_Factory : public JAWS_Cache_Object_Factory
133 public:
134 JAWS_Counted_Cache_Object_Factory (ACE_Allocator *alloc = 0);
135 virtual ~JAWS_Counted_Cache_Object_Factory ();
137 virtual JAWS_Cache_Object * create (const void *, size_t);
138 virtual void destroy (JAWS_Cache_Object *);
141 #endif /* JAWS_CACHE_OBJECT_H */