diff options
Diffstat (limited to 'Database/internals/database-references.h')
-rw-r--r-- | Database/internals/database-references.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/Database/internals/database-references.h b/Database/internals/database-references.h new file mode 100644 index 0000000..65e4cdf --- /dev/null +++ b/Database/internals/database-references.h @@ -0,0 +1,58 @@ +#ifndef __DATABASE_REFERENCES_H__
+#define __DATABASE_REFERENCES_H__
+
+class SegmentData;
+class RefFrom;
+class RefTo;
+
+/** The reference system, where the database will be able to hold references from and to memory pointers.
+ */
+
+class RefFrom : public Base {
+ public:
+ RefFrom(RefTo * refTo, SegmentRefData * data);
+ ~RefFrom()
+ SegmentRefData * getRefSegData() { return refTo->getSegRefData(); }
+ SegmentRefData * getSegRefData() { return data; }
+ RefFrom * getNext() { return next; }
+ private:
+ RefTo * refTo;
+ RefFrom * next, * prev;
+ SegmentRefData * data;
+};
+
+class RefTo : public Base {
+ public:
+ RefTo(Uint32 ptr, SegmentRefData * data);
+ ~RefTo();
+ SegmentRefData * getRefSegData() { return refFrom->getSegRefData(); }
+ SegmentRefData * getSegRefData() { return data; }
+ private:
+ RefFrom * refFrom;
+ SegmentRefData * data;
+};
+
+class SegmentRefData : public Base {
+ public:
+ SegmentRefData(Uint32 ptr, Segment * seg);
+ ~SegmentRefData()
+ Uint32 getPtr() { return ptr; }
+ Segment * getSegment() { return seg; }
+ SegmentRefData * getSegmentRefData(Uint32 ptr) { return seg->getSegmentRefData(ptr); }
+
+ RefTo * getRefTo() { return refTo; }
+ RefFrom * getRefFrom() { return firstRefFrom; }
+
+ void setRefTo(RefTo * newRefTo) { refTo = newRefTo; checkDestroy(); }
+ void setFirstRefFrom(RefFrom * newFirstRefFrom) { firstRefFrom = newFirstRefFrom; checkDestroy(); }
+
+ private:
+ RefTo * refTo;
+ RefFrom * firstRefFrom;
+
+ Uint32 ptr;
+ Segment * seg;
+ void checkDestroy() { if (!refTo && !firstRefFrom) delete this; }
+};
+
+#endif
|