casa::AttributeValuePoi< T > Class Template Reference
[Display_internal_classes]

#include <AttValPoi.h>

Inheritance diagram for casa::AttributeValuePoi< T >:

Inheritance graph
[legend]
Collaboration diagram for casa::AttributeValuePoi< T >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<class T>
class casa::AttributeValuePoi< T >

Templated class for storing a pointer to the value of an Attribute.

Intended use:

Internal

Review Status

Date Reviewed:
yyyy/mm/dd
Test programs:
tAttribute

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

known.

Definition at line 100 of file AttValPoi.h.

Public Member Functions

 AttributeValuePoi (T *value, const Bool strict)
 Constructor for a pointer to a scalar.
 AttributeValuePoi (Vector< T > *value, const Bool strict)
 Constructor for a pointer to a Vector.
 AttributeValuePoi (const AttributeValuePoi< T > &other)
 Copy constructor.
virtual ~AttributeValuePoi ()
 Destructor.
const AttributeValuePoi< T > & operator= (const AttributeValuePoi< T > &other)
 Assignment operator.
virtual AttributeValueBaseclone () const
 Return a new copy of the AttributeValuePoi (virtual constructor).
virtual void operator+= (const AttributeValueBase &other)
 Add other to *this.
virtual DataType getPointerType () const
 Get the DataType of aliased variable.
virtual String className () const
 Return class name.
virtual void setValue (const T &value)
 Change the value of the AttributeValue.
virtual void setValue (const Vector< T > &value)

Private Member Functions

void updatePointerValue () const
 Update the variable that is aliased to the AttributeValuePoi.
const AttributeValuePoi< T > & myCast (const AttributeValueBase &other) const
 Cast from base class.
 AttributeValuePoi ()
 Default constructor.

Private Attributes

DataType itsPointerType
 The pointer DataType.
Vector< T > * itsVectorPointerPtr
 Pointer to the aliased variable.
T * itsScalarPointerPtr


Constructor & Destructor Documentation

template<class T>
casa::AttributeValuePoi< T >::AttributeValuePoi ( T *  value,
const Bool  strict 
)

Constructor for a pointer to a scalar.

template<class T>
casa::AttributeValuePoi< T >::AttributeValuePoi ( Vector< T > *  value,
const Bool  strict 
)

Constructor for a pointer to a Vector.

template<class T>
casa::AttributeValuePoi< T >::AttributeValuePoi ( const AttributeValuePoi< T > &  other  ) 

Copy constructor.

template<class T>
virtual casa::AttributeValuePoi< T >::~AttributeValuePoi (  )  [virtual]

Destructor.

template<class T>
casa::AttributeValuePoi< T >::AttributeValuePoi (  )  [private]

Default constructor.


Member Function Documentation

template<class T>
const AttributeValuePoi<T>& casa::AttributeValuePoi< T >::operator= ( const AttributeValuePoi< T > &  other  ) 

Assignment operator.

template<class T>
virtual AttributeValueBase* casa::AttributeValuePoi< T >::clone (  )  const [virtual]

Return a new copy of the AttributeValuePoi (virtual constructor).

Reimplemented from casa::AttributeValue< T >.

template<class T>
virtual void casa::AttributeValuePoi< T >::operator+= ( const AttributeValueBase other  )  [virtual]

Add other to *this.

Needs to over-ride base class definition because the pointers need to be dereferenced prior to addition.

Reimplemented from casa::AttributeValue< T >.

template<class T>
virtual void casa::AttributeValuePoi< T >::setValue ( const T &  value  )  [virtual]

Change the value of the AttributeValue.

Reimplemented from casa::AttributeValue< T >.

template<class T>
virtual void casa::AttributeValuePoi< T >::setValue ( const Vector< T > &  value  )  [virtual]

Reimplemented from casa::AttributeValue< T >.

template<class T>
virtual DataType casa::AttributeValuePoi< T >::getPointerType (  )  const [virtual]

Get the DataType of aliased variable.

template<class T>
virtual String casa::AttributeValuePoi< T >::className (  )  const [inline, virtual]

Return class name.

Reimplemented from casa::AttributeValue< T >.

Definition at line 137 of file AttValPoi.h.

References String.

template<class T>
void casa::AttributeValuePoi< T >::updatePointerValue (  )  const [private]

Update the variable that is aliased to the AttributeValuePoi.

template<class T>
const AttributeValuePoi<T>& casa::AttributeValuePoi< T >::myCast ( const AttributeValueBase other  )  const [private]

Cast from base class.

Reimplemented from casa::AttributeValue< T >.


Member Data Documentation

template<class T>
Vector<T>* casa::AttributeValuePoi< T >::itsVectorPointerPtr [private]

Pointer to the aliased variable.

Only one is ever active depending upon how the object was constructed. The memory allocated to these pointers does not belong to this object.

Definition at line 149 of file AttValPoi.h.

template<class T>
T* casa::AttributeValuePoi< T >::itsScalarPointerPtr [private]

Definition at line 150 of file AttValPoi.h.

template<class T>
DataType casa::AttributeValuePoi< T >::itsPointerType [private]

The pointer DataType.

Definition at line 154 of file AttValPoi.h.


The documentation for this class was generated from the following file:
Generated on Thu Aug 27 21:35:18 2009 for NRAOCASA by  doxygen 1.5.1