diff options
author | unknown <Pixel@.(none)> | 2009-09-16 22:24:08 -0700 |
---|---|---|
committer | unknown <Pixel@.(none)> | 2009-09-16 22:24:08 -0700 |
commit | 6a653b35990e9a642dd4af9b8ee5742d5a84956c (patch) | |
tree | 31dac2b537af43584bbc6237df824cad7dba1a00 /Database/internals/database-references.cpp | |
parent | 2142bda77399a49f0a6684cccb4bb3420c2a10df (diff) |
Adding basic Database structure.
Diffstat (limited to 'Database/internals/database-references.cpp')
-rw-r--r-- | Database/internals/database-references.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/Database/internals/database-references.cpp b/Database/internals/database-references.cpp new file mode 100644 index 0000000..8520f16 --- /dev/null +++ b/Database/internals/database-references.cpp @@ -0,0 +1,47 @@ +#include "database-references.h"
+
+RefFrom::RefFrom(RefTo * refTo, SegmentRefData * data) : refTo(refTo), data(data) {
+ assert(refto);
+ assert(data);
+
+ next = data->getRefFrom();
+ prev = 0;
+ data->firstRefFrom = 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->refTo = 0;
+ delete refFrom;
+}
+
+SegmentRefData::SegmentRefData(Uint32 ptr, Segment * seg) : ptr(ptr), seg(seg) {
+ seg->setSegmentRefData(ptr, this);
+}
+
+SegmentRefData::~SegmentRefData() {
+ seg->setSegmentRefData(ptr, 0);
+}
|