#include <OTC/collctn/linkable.hh> class OTC_Linkable : public OTC_MPObject {
public:
void unlink();
void kill();
inline OTC_Boolean isLink() const;
inline OTC_Boolean isDead() const;
inline OTC_Linkable* prev() const;
inline OTC_Linkable* next() const;
void addBefore(OTC_Linkable* theObject);
void addAfter(OTC_Linkable* theObject);
void reference();
void unReference();
protected:
OTC_Linkable(OTC_Boolean theIsLink=OTCLIB_FALSE);
virtual ~OTC_Linkable();
};
OTC_Linkable
class, is the basic building block for creating
a doubly linked list of objects. Derived from OTC_Linkable
are
two classes which can be used when constructing a linked list.
These two classes are OTC_Link
and OTC_Anchor
. The first
of these is the base class for any user objects being placed
into a linked list. The second class is used as an anchor point,
from which to hang a linked list of objects. The OTC_Anchor
class is also used in pairs to mark the boundaries for the
traversal of an iterator.
void unlink();
void kill();
inline OTC_Boolean isLink() const;
OTCLIB_TRUE
if this object is
not an anchor point but a link.
inline OTC_Boolean isDead() const;
OTCLIB_TRUE
if the object has
been killed but references still exist.
If there are no references, you shouldn't
be calling this function as no references
implies this objects has been deleted.
inline OTC_Linkable* prev() const;
inline OTC_Linkable* next() const;
void addBefore(OTC_Linkable* theObject);
theObject
before this object in
the list. If theObject
is already
contained within a list, it will first be
unlinked from that list.
void addAfter(OTC_Linkable* theObject);
theObject
after this object in
the list. If theObject
is already
contained within a list, it will first be
unlinked from that list.
void reference();
void unReference();
0
, the object
deletes itself.
OTC_Linkable(OTC_Boolean theIsLink=OTCLIB_FALSE);
theIsLink
should be set to
OTCLIB_TRUE
if the derived class is not
an anchor point, but a link.
virtual ~OTC_Linkable();
unlink()
to detach this object
from the list in which it is contained.
OTC_Linkable
must
be created on the free store, using new
.
OTC_Link
, OTC_Anchor
, OTC_LinkIterator