|
| Pointer () |
|
| Pointer (ValueType *v) |
|
bool | isNull () const |
|
Pointer & | operator= (const Pointer &r) |
|
| Pointer (const Pointer &p) |
|
template<class Class > |
| Pointer (const shared_ptr< Class > &object, ValueType(Class::*getMethod)() const, void(Class::*setMethod)(ValueType)) |
|
template<class Class > |
| Pointer (const shared_ptr< Class > &object, const ValueType &(Class::*getMethod)() const, void(Class::*setMethod)(ValueType)) |
|
| Pointer (ValueType(*getMethod)(), void(*setMethod)(ValueType)) |
|
| Pointer (const ValueType &(*getMethod)(), void(*setMethod)(ValueType)) |
|
template<class Class > |
| Pointer (const shared_ptr< Class > &object, ValueType(Class::*getMethod)() const, void(Class::*setMethod)(const ValueType &)) |
|
template<class Class > |
| Pointer (const shared_ptr< Class > &object, const 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 (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)(ValueType)) |
|
template<class Class > |
| Pointer (Class *object, ValueType(Class::*getMethod)() const, void(Class::*setMethod)(ValueType)) |
|
| ~Pointer () |
|
const ValueType | getValue () const |
|
void | setValue (const ValueType &v) |
| Assign a value to the referenced element. If this Pointer was initialized with a NULL setMethod, the call is ignored. More...
|
|
IndirectValue | operator* () |
|
const ValueType | operator* () const |
|
template<typename 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
\/\/ 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())
.
[McGuire], GUIs for Real-time Programs, using Universal Pointers, SIGGRAPH 2008 Poster.