Contents User Forum Source Index APIs by Task APIs by Level Data


G3D::Pointer< ValueType > Class Template Reference

Acts like a pointer to a value of type ValueType (i.e., ValueType*), but can operate through accessor methods as well as on a value in memory. More...

#include <Pointer.h>

List of all members.

Public Member Functions

const ValueType getValue () const
const ValueType operator * () const
IndirectValue operator * ()
Pointeroperator= (const Pointer &r)
template<class Class>
 Pointer (Class *object, ValueType(Class::*getMethod)() const, void(Class::*setMethod)(ValueType))
template<class Class>
 Pointer (Class *object, const ValueType &(Class::*getMethod)() const, void(Class::*setMethod)(ValueType))
template<class Class>
 Pointer (Class *object, ValueType(Class::*getMethod)() const, void(Class::*setMethod)(const ValueType &))
template<class Class>
 Pointer (Class *object, const ValueType &(Class::*getMethod)() const, void(Class::*setMethod)(const ValueType &))
template<class Class>
 Pointer (const ReferenceCountedPointer< Class > &object, const ValueType &(Class::*getMethod)() const, void(Class::*setMethod)(const ValueType &))
template<class Class>
 Pointer (const ReferenceCountedPointer< Class > &object, ValueType(Class::*getMethod)() const, void(Class::*setMethod)(const ValueType &))
template<class Class>
 Pointer (const ReferenceCountedPointer< Class > &object, const ValueType &(Class::*getMethod)() const, void(Class::*setMethod)(ValueType))
template<class Class>
 Pointer (const ReferenceCountedPointer< Class > &object, ValueType(Class::*getMethod)() const, void(Class::*setMethod)(ValueType))
 Pointer (const Pointer &p)
 Pointer (ValueType *v)
 Pointer ()
void setValue (const ValueType &v)
 ~Pointer ()

Classes

class  Accessor
class  IndirectValue
class  Interface
class  Memory
class  RefAccessor


Detailed Description

template<class ValueType>
class G3D::Pointer< ValueType >

Acts like a pointer to a value of type ValueType (i.e., ValueType*), but can operate through accessor methods as well as on a value in memory.

This is useful for implementing scripting languages and other applications that need to connect existing APIs by reference.

Because the accessors require values to be passed by value (instead of by reference) this is primarily useful for objects whose memory size is small.

   class Foo {
   public:
      void setEnabled(bool b);
      bool getEnabled() const;
   };

   Foo  f;
   bool b;

   Pointer<bool> p1(&b);
   Pointer<bool> p2(&f, &Foo::getEnabled, &Foo::setEnabled);

p1 = true;
p2 = false;
p2 = *p1; \/\/ Value assignment
   p2 = p1; \/\/ Pointer aliasing

   \/\/ Or, equivalently:
   p1.setValue(true);
   p2.setValue(false);

   p2.setValue(p1.getValue());
   p2 = p1;
   

Note: Because of the way that dereference is implemented, you cannot pass *p through a function that takes varargs (...), e.g., printf("%d", *p) will produce a compile-time error. Instead use printf("%d",(bool)*p) or printf("%d", p.getValue()).


Constructor & Destructor Documentation

template<class ValueType>
G3D::Pointer< ValueType >::Pointer (  )  [inline]

template<class ValueType>
G3D::Pointer< ValueType >::Pointer ( ValueType *  v  )  [inline]

Allows implicit cast from real pointer.

template<class ValueType>
G3D::Pointer< ValueType >::Pointer ( const Pointer< ValueType > &  p  )  [inline]

template<class ValueType>
template<class Class>
G3D::Pointer< ValueType >::Pointer ( const ReferenceCountedPointer< Class > &  object,
ValueType(Class::*)() const   getMethod,
void(Class::*)(ValueType)  setMethod 
) [inline]

template<class ValueType>
template<class Class>
G3D::Pointer< ValueType >::Pointer ( const ReferenceCountedPointer< Class > &  object,
const ValueType &(Class::*)() const   getMethod,
void(Class::*)(ValueType)  setMethod 
) [inline]

template<class ValueType>
template<class Class>
G3D::Pointer< ValueType >::Pointer ( const ReferenceCountedPointer< Class > &  object,
ValueType(Class::*)() const   getMethod,
void(Class::*)(const ValueType &)  setMethod 
) [inline]

template<class ValueType>
template<class Class>
G3D::Pointer< ValueType >::Pointer ( const ReferenceCountedPointer< Class > &  object,
const ValueType &(Class::*)() const   getMethod,
void(Class::*)(const ValueType &)  setMethod 
) [inline]

template<class ValueType>
template<class Class>
G3D::Pointer< ValueType >::Pointer ( Class *  object,
const ValueType &(Class::*)() const   getMethod,
void(Class::*)(const ValueType &)  setMethod 
) [inline]

template<class ValueType>
template<class Class>
G3D::Pointer< ValueType >::Pointer ( Class *  object,
ValueType(Class::*)() const   getMethod,
void(Class::*)(const ValueType &)  setMethod 
) [inline]

template<class ValueType>
template<class Class>
G3D::Pointer< ValueType >::Pointer ( Class *  object,
const ValueType &(Class::*)() const   getMethod,
void(Class::*)(ValueType)  setMethod 
) [inline]

template<class ValueType>
template<class Class>
G3D::Pointer< ValueType >::Pointer ( Class *  object,
ValueType(Class::*)() const   getMethod,
void(Class::*)(ValueType)  setMethod 
) [inline]

template<class ValueType>
G3D::Pointer< ValueType >::~Pointer (  )  [inline]


Member Function Documentation

template<class ValueType>
const ValueType G3D::Pointer< ValueType >::getValue (  )  const [inline]

template<class ValueType>
const ValueType G3D::Pointer< ValueType >::operator * (  )  const [inline]

template<class ValueType>
IndirectValue G3D::Pointer< ValueType >::operator * (  )  [inline]

template<class ValueType>
Pointer& G3D::Pointer< ValueType >::operator= ( const Pointer< ValueType > &  r  )  [inline]

template<class ValueType>
void G3D::Pointer< ValueType >::setValue ( const ValueType &  v  )  [inline]


The documentation for this class was generated from the following file:
Generated on Thu Aug 2 11:40:47 2007 for G3D by doxygen 1.5.2
Hosted by SourceForge.net Logo