#ifndef __libeast_heap_h__ #define __libeast_heap_h__ #include #include "object.h" // Heap // This is a handy container of objects. It is separate from Environment // because an object should be able to move from Environment to Environment // without ever being destroyed. This container automatically frees memory. class Object; class Heap { public: ~Heap(); // List modifiers void add(Object* obj, string name); void forget(const string& name); void forget(Object* name); void del(const string& name); void del(Object* obj); // Accessor by name Object* operator[] (const string& k) {return my_objects[k];} // Map a pointer to a name const string& name(const Object* obj); protected: map my_objects; unsigned int my_temp_counter; }; // The global heap extern Heap heap; #endif