casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
casa::AttributeValuePoi< T > Class Template Reference

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

#include <AttValPoi.h>

Inheritance diagram for casa::AttributeValuePoi< T >:
casa::AttributeValue< T > casa::AttributeValueBase

Public Member Functions

 AttributeValuePoi (T *value, const casacore::Bool strict)
 Constructor for a pointer to a scalar. More...
 
 AttributeValuePoi (casacore::Vector< T > *value, const casacore::Bool strict)
 Constructor for a pointer to a casacore::Vector. More...
 
 AttributeValuePoi (const AttributeValuePoi< T > &other)
 Copy constructor. More...
 
virtual ~AttributeValuePoi ()
 Destructor. More...
 
const AttributeValuePoi< T > & operator= (const AttributeValuePoi< T > &other)
 Assignment operator. More...
 
virtual AttributeValueBaseclone () const
 Return a new copy of the AttributeValuePoi (virtual constructor). More...
 
virtual void operator+= (const AttributeValueBase &other)
 Add other to *this. More...
 
virtual void setValue (const T &value)
 Change the value of the AttributeValue. More...
 
virtual void setValue (const casacore::Vector< T > &value)
 
virtual casacore::DataType getPointerType () const
 Get the DataType of aliased variable. More...
 
virtual casacore::String className () const
 Return class name. More...
 
- Public Member Functions inherited from casa::AttributeValue< T >
 AttributeValue (const T &value, const casacore::Bool strict)
 Construct from a scalar value. More...
 
 AttributeValue (const casacore::Vector< T > &value, const casacore::Bool strict)
 Construct from a casacore::Vector. More...
 
virtual ~AttributeValue ()
 Destructor. More...
 
 AttributeValue (const AttributeValue< T > &other)
 Copy constructor. More...
 
const AttributeValue< T > & operator= (const AttributeValue< T > &other)
 Assignment (copy semantics) More...
 
virtual casacore::Vector< T > getValue () const
 
virtual void print (std::ostream &os)
 
- Public Member Functions inherited from casa::AttributeValueBase
 AttributeValueBase (AttValue::ValueType type, casacore::Bool strict)
 Constructor. More...
 
 AttributeValueBase (const AttributeValueBase &other)
 Copy constructor. More...
 
virtual ~AttributeValueBase ()
 Destructor. More...
 
const AttributeValueBaseoperator= (const AttributeValueBase &other)
 Copy assignment. More...
 
AttValue::ValueType getType () const
 Get the type of the value stored. More...
 
casacore::Bool operator== (const AttributeValueBase &other) const
 Check for equality (and inequality) of two objects derived from AttributeValueBase. More...
 
casacore::Bool operator!= (const AttributeValueBase &other) const
 
virtual void setStrictness (const casacore::Bool &newStrict)
 Set/get the strictness state of this AttributeValue. More...
 
virtual casacore::Bool getStrictness () const
 

Private Member Functions

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

Private Attributes

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

Additional Inherited Members

- Protected Member Functions inherited from casa::AttributeValue< T >
virtual casacore::Bool matches (const AttributeValueBase &other) const
 Implements when the values of two Attributes match or not. More...
 
const AttributeValue< T > & myCast (const AttributeValueBase &other) const
 Cast from Base class. More...
 
- Protected Member Functions inherited from casa::AttributeValueBase
virtual void setType (const AttValue::ValueType &newType)
 Set the type of the value stored. More...
 
casacore::Bool myMatch (const AttributeValueBase &other) const
 Check that private data match. More...
 
- Protected Attributes inherited from casa::AttributeValueBase
AttValue::ValueType itsValueType
 The type of what is stored. More...
 
casacore::Bool itsStrictness
 Whether the match is strict or not. More...
 

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:

casacore::Int varInt = 1;
AttributeValuePoi<casacore::Int> intAtt(&varInt, false);
casacore::Vector<casacore::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.

Definition at line 100 of file AttValPoi.h.

Constructor & Destructor Documentation

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

Constructor for a pointer to a scalar.

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

Constructor for a pointer to a casacore::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>
virtual casacore::String casa::AttributeValuePoi< T >::className ( ) const
inlinevirtual

Return class name.

Reimplemented from casa::AttributeValue< T >.

Definition at line 137 of file AttValPoi.h.

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 casacore::DataType casa::AttributeValuePoi< T >::getPointerType ( ) const
virtual

Get the DataType of aliased variable.

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

Cast from base class.

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>
const AttributeValuePoi<T>& casa::AttributeValuePoi< T >::operator= ( const AttributeValuePoi< T > &  other)

Assignment operator.

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 casacore::Vector< T > &  value)
virtual

Reimplemented from casa::AttributeValue< T >.

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

Update the variable that is aliased to the AttributeValuePoi.

Member Data Documentation

template<class T>
casacore::DataType casa::AttributeValuePoi< T >::itsPointerType
private

The pointer DataType.

Definition at line 156 of file AttValPoi.h.

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

Definition at line 152 of file AttValPoi.h.

template<class T>
casacore::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 151 of file AttValPoi.h.


The documentation for this class was generated from the following file: