The Nebula Device 3: Util::Proxy< TYPE > Class Template Reference

The Nebula Device 3

Util::Proxy< TYPE > Class Template Reference

#include <proxy.h>


Detailed Description

template<class TYPE>
class Util::Proxy< TYPE >

A Proxy holds an embedded object of any class and offers compare operators which are routed to the target object. Several Proxies may point to the same target object, a refcount is associated with the target object, and it will automatically be destroyed when all Proxies have gone. Proxies are useful in some situations when working with container classes, since they guarantee that the target object doesn't move in memory even when the proxy itself is moved around by the container class.

(C) 2007 Radon Labs GmbH


Public Member Functions

 Proxy ()
 default constructor
 Proxy (const TYPE &rhs)
 construct from type
 Proxy (const Proxy< TYPE > &rhs)
 copy constructor
void operator= (const TYPE &rhs)
 assignment operator from type
void operator= (const Proxy< TYPE > &rhs)
 assignment operator from proxy
bool operator== (const TYPE &rhs) const
 equality operator with type
bool operator!= (const TYPE &rhs) const
 inequality operator with type
bool operator> (const TYPE &rhs) const
 greater-then operator with type
bool operator< (const TYPE &rhs) const
 less-then operator with type
bool operator>= (const TYPE &rhs) const
 greater-or-equal operator with type
bool operator<= (const TYPE &rhs) const
 less-or-equal operator with type
bool operator== (const Proxy< TYPE > &rhs) const
 equality operator with proxy
bool operator!= (const Proxy< TYPE > &rhs) const
 inequality operator with proxy
bool operator> (const Proxy< TYPE > &rhs) const
 greater-then operator with proxy
bool operator< (const Proxy< TYPE > &rhs) const
 less-then operator with proxy
bool operator>= (const Proxy< TYPE > &rhs) const
 greater-or-equal operator with proxy
bool operator<= (const Proxy< TYPE > &rhs) const
 less-or-equal operator with proxy
const TYPE & GetObject () const
 access to contained object
int GetObjectRefCount () const
 get refcount of object
bool IsValid () const
 return true if the proxy contains a valid object
void Clear ()
 clear content

Constructor & Destructor Documentation

template<class TYPE>
Util::Proxy< TYPE >::Proxy ( const TYPE &  rhs  )  [inline, explicit]

construct from type

Constructing a proxy from TYPE always creates a new target object.

template<class TYPE>
Util::Proxy< TYPE >::Proxy ( const Proxy< TYPE > &  rhs  )  [inline, explicit]

copy constructor

Constructing a proxy from another proxy shares the target object of the right-hand-side proxy and increments its refcount.


Member Function Documentation

template<class TYPE>
void Util::Proxy< TYPE >::operator= ( const TYPE &  rhs  )  [inline]

assignment operator from type

Assigning a TYPE to the proxy will throw away the previous target object and create a new one.

template<class TYPE>
void Util::Proxy< TYPE >::operator= ( const Proxy< TYPE > &  rhs  )  [inline]

assignment operator from proxy

Assigning a proxy to this proxy will share the right-hand-side's target object and incremnet its refcount.