#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();
};
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.
class Foo : public OTC_MCObject { protected: ~Foo(); };
OTC_Cluster cluster;
Foo* foo = new (cluster) Foo;
void* operator new(size_t theSize, OTC_Cluster& theCluster);
theCluster
of
theSize
.
OTC_MCObject();
inline void operator delete(void*);
OTC_Cluster
is deleted. This should only
be called by OTC_Cluster
and not by
the user of a derived class.
protected
access to
prevent creation of the class in any context except that of
a cluster.
OTC_Cluster