#ifndef storage_h #define storage_h 1 #pragma interface #include "Structures.h" #include "Object.h" #define ACTIVE_FLAG 0x01 /** if object has been accessed since last dump **/ #define DIRTY_FLAG 0x02 /** if object has been changed **/ #define LOADED_FLAG 0x04 /** if object has been loaded into memory **/ /****** notice the increasing precedence of the three flags. ******/ const int dbm_block_size = 256; /** server chops up objects into blocks **/ /** of at most this size ... dbm has some **/ /** kind of hard-coded limit. on my **/ /** machine, that was exactly 1013 bytes **/ const int initial_objs=500; /** the number of extra objects to allocate **/ /** after the end of the existing ones. **/ const int grow_by=300; extern int var_found_on; class Object_Store{ friend class Val_List; protected: struct o_record { char flags; Object* optr; }* oarray; int num, allocated; void grow(int by = grow_by); void compile (char* filename, int init = initial_objs); int fill_plist (int obid); Object* get(int); public: Object_Store (char* dbfilename, int init = initial_objs); ~Object_Store(); /** this is the 'shutdown' **/ void update(); int addvar (int obid , String* sym , Value* dat); int rmvar (int obid , String* sym); Value* listvars (int obid); Value* lookup_var (int obid, String* sym); Val_List* collect_var (int obid, String* sym); Value* pass_vlookup(int obid, String* sym); int addcmd (int obid , Val_List* key , String* data); int rmcmd (int obid , String* sym); int purgecmds (int obid); String* match_cmd (int obid , String* input); Value* listmatches (int obid , String* input); Value* listcmds (int obid); int clone_obj (int obid); Value* listparents (int obid); int chparents (int obid, Val_List* newparents); int inparents (int obid, int cparent); int size() {return num;} int obj_exists (int obid); void dump_to_stdout(); // spits out the whole damn DB at once. }; #endif /* storage_h */