AttValPoi.h
Classes
- AttributeValuePoi -- Templated class for storing a pointer to the value of an Attribute. (full description)
Interface
- Public Members
- AttributeValuePoi(T* value, const Bool strict)
- AttributeValuePoi(Vector<T> *value, const Bool strict)
- AttributeValuePoi(const AttributeValuePoi<T> &other)
- virtual ~AttributeValuePoi()
- const AttributeValuePoi<T>& operator=(const AttributeValuePoi<T> &other)
- virtual AttributeValueBase *clone() const
- virtual void operator+=(const AttributeValueBase& other)
- virtual void setValue(const T &value)
- virtual void setValue(const Vector<T> &value)
- virtual DataType getPointerType() const
- virtual String className() const
- Private Members
- void updatePointerValue() const
- const AttributeValuePoi<T>& myCast (const AttributeValueBase& other) const
- AttributeValuePoi()
Review Status
- Date Reviewed:
- yyyy/mm/dd
- Programs:
- Tests:
Prerequisite
Etymology
"AttributeValuePoi" is a contraction of "Attribute Value" and
"Pointer", and stores a pointer to the value of an Attribute.
Synopsis
An AttributeValuePoi differs from a
AttributeValue in that instead of using its own variable
to store the actual value like AttributeValue does, it stores a
pointer to the variable used in the constructor. This means that
the AttributeValuePoi is just an alias to this variable, and then
the user can modify the value of an AttributeValuePoi without using
its interface. Alternatively, and perhaps more importantly, the
Attribute interface can be used to modify members of a class.
Example
A simple example will help illustrate the utility of the AttributeValuePoi
class:
Int varInt = 1;
AttributeValuePoi<Int> intAtt(&varInt, False);
Vector<Int> bla = intAtt.getValue();
// bla(0) is 1;
// This wil change also the AttributeValue:
varInt = 2;
bla = intAtt.getValue();
// bla(0) is now 2
intAtt.setValue(5);
// now also varInt == 5
Motivation
The motivation for this class is to be able to provide an Attribute
interface for modifying private members of some classes. For
example, this interface is used to control the linear coordinate
system of the WorldCanvas.
To Do
Member Description
Constructor for a pointer to a scalar.
Constructor for a pointer to a Vector.
AttributeValuePoi(const AttributeValuePoi<T> &other)
Copy constructor.
Destructor.
const AttributeValuePoi<T>& operator=(const AttributeValuePoi<T> &other)
Assignment operator.
Return a new copy of the AttributeValuePoi (virtual constructor).
Add other to *this. Needs to over-ride
base class definition because the pointers need to be
dereferenced prior to addition.
virtual void setValue(const T &value)
virtual void setValue(const Vector<T> &value)
Change the value of the AttributeValue.
Get the DataType of aliased variable.
Return class name
Update the variable that is aliased to the AttributeValuePoi.
const AttributeValuePoi<T>& myCast (const AttributeValueBase& other) const
Cast from base class
Default constructor