mirror of
https://github.com/mangosfour/server.git
synced 2025-12-21 19:37:02 +00:00
[9775] Cleanups in framework library.
* Removed last bits of threading in grid code. * Removed some weird and unneeded declarations. * General code style fixes. * (Perhaps some things I forgot.) Thanks to Lynx3d for the usual GCC-stabbing...
This commit is contained in:
parent
4d89b41f60
commit
7532061a79
25 changed files with 774 additions and 398 deletions
|
|
@ -23,12 +23,16 @@
|
|||
|
||||
//=====================================================
|
||||
|
||||
template <class TO, class FROM> class Reference : public LinkedListElement
|
||||
template<class TO, class FROM>
|
||||
class Reference : public LinkedListElement
|
||||
{
|
||||
private:
|
||||
|
||||
TO* iRefTo;
|
||||
FROM* iRefFrom;
|
||||
|
||||
protected:
|
||||
|
||||
// Tell our refTo (target) object that we have a link
|
||||
virtual void targetObjectBuildLink() = 0;
|
||||
|
||||
|
|
@ -37,17 +41,24 @@ template <class TO, class FROM> class Reference : public LinkedListElement
|
|||
|
||||
// Tell our refFrom (source) object, that the link is cut (Target destroyed)
|
||||
virtual void sourceObjectDestroyLink() = 0;
|
||||
|
||||
public:
|
||||
Reference() { iRefTo = NULL; iRefFrom = NULL; }
|
||||
|
||||
Reference()
|
||||
: iRefTo(NULL), iRefFrom(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~Reference() {}
|
||||
|
||||
// Create new link
|
||||
void link(TO* toObj, FROM* fromObj)
|
||||
{
|
||||
assert(fromObj); // fromObj MUST not be NULL
|
||||
if(isValid())
|
||||
ASSERT(fromObj); // fromObj MUST not be NULL
|
||||
if (isValid())
|
||||
unlink();
|
||||
if(toObj != NULL)
|
||||
|
||||
if (toObj != NULL)
|
||||
{
|
||||
iRefTo = toObj;
|
||||
iRefFrom = fromObj;
|
||||
|
|
@ -57,13 +68,21 @@ template <class TO, class FROM> class Reference : public LinkedListElement
|
|||
|
||||
// We don't need the reference anymore. Call comes from the refFrom object
|
||||
// Tell our refTo object, that the link is cut
|
||||
void unlink() { targetObjectDestroyLink(); delink(); iRefTo = NULL; iRefFrom = NULL; }
|
||||
void unlink()
|
||||
{
|
||||
targetObjectDestroyLink();
|
||||
delink();
|
||||
iRefTo = NULL;
|
||||
iRefFrom = NULL;
|
||||
}
|
||||
|
||||
// Link is invalid due to destruction of referenced target object. Call comes from the refTo object
|
||||
// Tell our refFrom object, that the link is cut
|
||||
void invalidate() // the iRefFrom MUST remain!!
|
||||
{
|
||||
sourceObjectDestroyLink(); delink(); iRefTo = NULL;
|
||||
sourceObjectDestroyLink();
|
||||
delink();
|
||||
iRefTo = NULL;
|
||||
}
|
||||
|
||||
bool isValid() const // Only check the iRefTo
|
||||
|
|
@ -71,21 +90,22 @@ template <class TO, class FROM> class Reference : public LinkedListElement
|
|||
return iRefTo != NULL;
|
||||
}
|
||||
|
||||
Reference<TO,FROM> * next() { return((Reference<TO,FROM> *) LinkedListElement::next()); }
|
||||
Reference<TO,FROM> const * next() const { return((Reference<TO,FROM> const *) LinkedListElement::next()); }
|
||||
Reference<TO,FROM> * prev() { return((Reference<TO,FROM> *) LinkedListElement::prev()); }
|
||||
Reference<TO,FROM> const * prev() const { return((Reference<TO,FROM> const *) LinkedListElement::prev()); }
|
||||
Reference<TO,FROM> * next() { return((Reference<TO, FROM> *) LinkedListElement::next()); }
|
||||
Reference<TO,FROM> const* next() const { return((Reference<TO, FROM> const*) LinkedListElement::next()); }
|
||||
Reference<TO,FROM> * prev() { return((Reference<TO, FROM> *) LinkedListElement::prev()); }
|
||||
Reference<TO,FROM> const* prev() const { return((Reference<TO, FROM> const*) LinkedListElement::prev()); }
|
||||
|
||||
Reference<TO,FROM> * nocheck_next() { return((Reference<TO,FROM> *) LinkedListElement::nocheck_next()); }
|
||||
Reference<TO,FROM> const * nocheck_next() const { return((Reference<TO,FROM> const *) LinkedListElement::nocheck_next()); }
|
||||
Reference<TO,FROM> * nocheck_prev() { return((Reference<TO,FROM> *) LinkedListElement::nocheck_prev()); }
|
||||
Reference<TO,FROM> const * nocheck_prev() const { return((Reference<TO,FROM> const *) LinkedListElement::nocheck_prev()); }
|
||||
Reference<TO,FROM> * nocheck_next() { return((Reference<TO, FROM> *) LinkedListElement::nocheck_next()); }
|
||||
Reference<TO,FROM> const* nocheck_next() const { return((Reference<TO, FROM> const*) LinkedListElement::nocheck_next()); }
|
||||
Reference<TO,FROM> * nocheck_prev() { return((Reference<TO, FROM> *) LinkedListElement::nocheck_prev()); }
|
||||
Reference<TO,FROM> const* nocheck_prev() const { return((Reference<TO, FROM> const*) LinkedListElement::nocheck_prev()); }
|
||||
|
||||
TO* operator ->() const { return iRefTo; }
|
||||
TO* operator->() const { return iRefTo; }
|
||||
TO* getTarget() const { return iRefTo; }
|
||||
|
||||
FROM* getSource() const { return iRefFrom; }
|
||||
};
|
||||
|
||||
//=====================================================
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue