#include #include "database-references.h" #include "database.h" RefFrom::RefFrom(RefTo * refTo, SegmentRefData * data) : refTo(refTo), data(data) { assert(refTo); assert(data); next = data->getRefFrom(); prev = 0; data->setFirstRefFrom(this); if (next) next->prev = this; } RefFrom::~RefFrom() { if (next) next->prev = prev; if (prev) prev->next = next; else data->setFirstRefFrom(next); } RefTo::RefTo(absolute_ptr ptr, SegmentRefData * data, Database * database) : data(data) { assert(database); Segment * destSeg = database->getSegment(ptr.segment_id); assert(destSeg); refFrom = new RefFrom(this, destSeg->getSegmentRefData(ptr.ptr)); RefTo * t = data->getRefTo(); if (t) { delete t; data->setRefTo(this); } } RefTo::~RefTo() { data->setRefTo(0); delete refFrom; } SegmentRefData::SegmentRefData(Uint32 ptr, Segment * seg) : ptr(ptr), seg(seg) { seg->setSegmentRefData(ptr, this); } SegmentRefData::~SegmentRefData() { seg->setSegmentRefData(ptr, 0); }