#include "Handle.hh" template Handle::Handle (const Handle &to) { attach (to); } template Handle::Handle (T *to) : rep (0) { *this = to; // invoke op = } template Handle::Handle () { rep = create_representation (); } template Handle::~Handle () { detach (); } template Handle & Handle::operator = (const Handle &to) { detach (); attach (to); return *this; } template Handle & Handle::operator = (T *to) { detach (); rep = create_representation (to); return *this; } template T * Handle::data () const { assert (rep != 0); return rep->data(); } template T * Handle::operator -> () { assert (rep != 0); return rep->data(); } template const T * Handle::operator -> () const { assert (rep != 0); return rep->data(); } template T & Handle::operator * () { assert (rep != 0); return *rep->data(); } template const T & Handle::operator * () const { assert (rep != 0); return *rep->data(); } template void Handle::attach (const Handle &to) { rep = to.rep; rep->increment_references (); } template void Handle::detach () { if (rep) { rep->decrement_references (); if (rep->references() == 0) delete rep; } } template int Handle::operator == (const Handle &that) const { assert (this->rep != 0); assert (that.rep != 0); return this->rep->data() == that.rep->data(); } template int Handle::operator != (const Handle &that) const { assert (this->rep != 0); assert (that.rep != 0); return this->rep->data() != that.rep->data(); } template int Handle::operator == (const T *that_ptr) const { assert (this->rep != 0); return this->rep->data() == that_ptr; } template int Handle::operator != (const T *that_ptr) const { assert (this->rep != 0); return this->rep->data() != that_ptr; } template int Handle::operator == (int that) const { assert (this->rep != 0); return this->rep->data() == (void *) that; } template int Handle::operator != (int that) const { assert (this->rep != 0); return this->rep->data() != (void *) that; }