#ifndef __DATABASE_H__ #define __DATABASE_H__ #include "database-types.h" #include "database-segment.h" #include "database-internal.h" class Database : public Base { public: Database() : start(0), end(0), currentId(1) { } ~Database() { while(start) delete start; } DatabaseCell * getStart() { return start; } DatabaseCell * getEnd() { return end; } void setStart(DatabaseCell * newStart) { start = newStart; } void setEnd(DatabaseCell * newEnd) { end = newEnd; } Segment * getSegment(Uint32 id) { // TODO: have a hash table. DatabaseCell * cursor; for (cursor = start; start; cursor = cursor->getNext()) if (cursor->getId() == id) return cursor->getSegment(); return 0; } Uint32 GetNextSegId() { return currentId++; } Segment * CreateSegment(Cpu * cpu, Uint64 cpu_base, absolute_ptr origin, Uint32 size, Uint32 extra_size = 0, const Byte * data = 0) { DatabaseCell * r = new DatabaseCell(this, cpu, cpu_base, origin, size, extra_size, data); return r->getSegment(); } void Serialize(Handle * out); void Deserialize(Handle *in); private: DatabaseCell * start, * end; Uint32 currentId; }; #endif