G3D::Pointer< ValueType > Class Template ReferenceActs 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 * () |
| Pointer & | operator= (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>
template<class ValueType>
Allows implicit cast from real pointer.
template<class ValueType>
template<class ValueType>
template<class Class>
template<class ValueType>
template<class Class>
template<class ValueType>
template<class Class>
template<class ValueType>
template<class Class>
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>
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>
template<class ValueType>
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
1.5.2
Hosted by
|