NAME
OTC_MCObject -
Mixin class for memory cluster objects.
SYNOPSIS
#include <OTC/memory/mcobject.hh>
class OTC_MCObject
{
public:
void* operator new(size_t theSize, OTC_Cluster& theCluster);
protected:
void* operator new(size_t);
OTC_MCObject();
inline void operator delete(void*);
virtual ~OTC_MCObject();
};
CLASS TYPE
Abstract
DESCRIPTION
The OTC_MCObject class is a mixin class which gives to a derived
object the ability to be allocated within a memory cluster.
Allocation within a cluster is achieved through an overloaded
version of operator new() which takes an instance of OTC_Cluster
as argument. Objects do not have to be deleted explicitly, all
objects in the cluster being automatically destroyed when the
cluster is destroyed. Destructors for derived classes will be
called.
EXAMPLE
class Foo : public OTC_MCObject { protected: ~Foo(); };
OTC_Cluster cluster;
Foo* foo = new (cluster) Foo;
ALLOCATION
void* operator new(size_t theSize, OTC_Cluster& theCluster);
Returns memory from theCluster of
theSize.
INITIALISATION
OTC_MCObject();
Adds the object into the cluster which
its memory was allocated from.
DELETION
inline void operator delete(void*);
This doesn't do anything as memory is
released when the arena held by the
OTC_Cluster is deleted. This should only
be called by OTC_Cluster and not by
the user of a derived class.
NOTES
A derived class destructor should have protected access to
prevent creation of the class in any context except that of
a cluster.
SEE ALSO
OTC_Cluster
LIBRARY
OTC
AUTHOR(S)
Graham Dumpleton
COPYRIGHT
Copyright 1994 TELSTRA CORPORATION LIMITED
Copyright 1994 DUMPLETON SOFTWARE CONSULTING PTY LIMITED