initial
[prop.git] / include / AD / gc / userheap.h
blob8a90bc0d344e586345b1f068e70352b8a1cdff09
1 //////////////////////////////////////////////////////////////////////////////
2 // NOTICE:
3 //
4 // ADLib, Prop and their related set of tools and documentation are in the
5 // public domain. The author(s) of this software reserve no copyrights on
6 // the source code and any code generated using the tools. You are encouraged
7 // to use ADLib and Prop to develop software, in both academic and commercial
8 // settings, and are welcomed to incorporate any part of ADLib and Prop into
9 // your programs.
11 // Although you are under no obligation to do so, we strongly recommend that
12 // you give away all software developed using our tools.
14 // We also ask that credit be given to us when ADLib and/or Prop are used in
15 // your programs, and that this notice be preserved intact in all the source
16 // code.
18 // This software is still under development and we welcome(read crave for)
19 // any suggestions and help from the users.
21 // Allen Leung (leunga@cs.nyu.edu)
22 // 1994-1995
23 //////////////////////////////////////////////////////////////////////////////
25 #ifndef user_collected_heap_h
26 #define user_collected_heap_h
28 #include <AD/gc/gc.h>
29 #include <AD/memory/mem.h>
31 //////////////////////////////////////////////////////////////////////////////
32 // Opaque objects (i.e. objects without any pointers)
33 // can be allocated from the class UserHeap using the methods
34 // m_alloc, c_alloc and free.
36 // Class UserHeap gets its memory from the underlying collector, which
37 // is specified during initialization.
38 //////////////////////////////////////////////////////////////////////////////
39 class UserHeap : public GC {
41 UserHeap(const UserHeap&); // no copy constructor
42 void operator = (const UserHeap&); // no assignment
44 public:
45 ///////////////////////////////////////////////////////////////////////////
46 // Type definitions
47 ///////////////////////////////////////////////////////////////////////////
48 typedef GC::Statistics Statistics;
49 typedef GC::GCNotify GCNofity;
51 protected:
52 ///////////////////////////////////////////////////////////////////////////
53 // The underlying garbage collector.
54 ///////////////////////////////////////////////////////////////////////////
55 GC& underlying_gc;
57 public:
58 ///////////////////////////////////////////////////////////////////////////
59 // Constructor and destructor
60 ///////////////////////////////////////////////////////////////////////////
61 UserHeap(); // use GC::default_gc as default
62 UserHeap(GC&); // use given gc
63 virtual ~UserHeap();
65 ///////////////////////////////////////////////////////////////////////////
66 // Methods for memory allocation and deallocation.
67 // These should only be used for objects without pointers to
68 // GCObject's !!!
69 ///////////////////////////////////////////////////////////////////////////
70 virtual void * m_alloc (size_t);
71 virtual void * c_alloc (size_t);
72 virtual void free (void *);
75 #endif