ISIS Core Library 0.7.2 (api 3.0.0)
Data Structures | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions

isis::data::ValueArray< TYPE > Class Template Reference

Generic class for type (and length) - aware pointers. More...

#include <valuearray.hpp>

Inheritance diagram for isis::data::ValueArray< TYPE >:
isis::data::ValueArrayBase isis::util::_internal::GenericValue

Data Structures

struct  BasicDeleter
 Default delete-functor for c-arrays (uses free()). More...
struct  NonDeleter
 delete-functor which does nothing (in case someone else manages the data). More...

Public Types

typedef
_internal::ValueArrayIterator
< const TYPE > 
const_iterator
typedef const_iterator::reference const_reference
typedef
_internal::ValueArrayIterator
< TYPE > 
iterator
typedef iterator::reference reference

Public Member Functions

iterator begin ()
const_iterator begin () const
virtual value_iterator beginGeneric ()
virtual const_value_iterator beginGeneric () const
size_t bytesPerElem () const
iterator end ()
const_iterator end () const
void endianSwap ()
std::pair
< util::ValueReference,
util::ValueReference
getMinMax () const
 Get minimum/maximum of a ValueArray.
boost::shared_ptr< const void > getRawAddress (size_t offset=0) const
 Get the raw address the ValueArray points to.
boost::shared_ptr< void > getRawAddress (size_t offset=0)
scaling_pair getScalingTo (unsigned short typeID, autoscaleOption scaleopt=autoscale) const
 get the scaling (and offset) which would be used in an conversion
unsigned short getTypeID () const
std::string getTypeName () const
bool isFloat () const
bool isInteger () const
 operator boost::shared_ptr< TYPE > & ()
 Implicit conversion to boost::shared_ptr<TYPE> The returned smart pointer will be part of the reference-counting and will correctly delete the data (using the given deleter) if required.
 operator const boost::shared_ptr< TYPE > & () const
TYPE & operator[] (size_t idx)
 Reference element at at given index.
const TYPE & operator[] (size_t idx) const
std::vector< Referencesplice (size_t size) const
 Splice up the ValueArray into equal sized blocks.
virtual std::string toString (bool labeled=false) const
 ValueArray (const boost::shared_ptr< TYPE > &ptr, size_t length)
 Creates ValueArray from a boost::shared_ptr of the same type.
 ValueArray (TYPE *const ptr, size_t length)
 Creates ValueArray from a pointer of type TYPE.
 ValueArray (size_t length)
 Creates a ValueArray pointing to a newly allocated array of elements of the given type.
template<typename D >
 ValueArray (TYPE *const ptr, size_t length, D d)
 Creates ValueArray from a pointer of type TYPE.
virtual ~ValueArray ()

Static Public Member Functions

static std::string staticName ()

Static Public Attributes

static const unsigned short staticID = util::_internal::TypeID<TYPE>::value << 8

Protected Member Functions

ValueArrayBaseclone () const
 Create a ValueArray of the same type pointing at the same address.
 ValueArray ()

Detailed Description

template<typename TYPE>
class isis::data::ValueArray< TYPE >

Generic class for type (and length) - aware pointers.

The class is designed for arrays, but you can also "point" to an single element by just use "1" for the length. The pointers are reference counted and will be deleted automatically by a customizable deleter. The copy is cheap, thus the copy of a ValueArray will reference the same data. The usual pointer dereferencing interface ("*", "->" and "[]") is supported.

Definition at line 171 of file valuearray.hpp.


Member Typedef Documentation

template<typename TYPE>
typedef _internal::ValueArrayIterator<const TYPE> isis::data::ValueArray< TYPE >::const_iterator

Definition at line 187 of file valuearray.hpp.

template<typename TYPE>
typedef const_iterator::reference isis::data::ValueArray< TYPE >::const_reference

Definition at line 189 of file valuearray.hpp.

template<typename TYPE>
typedef _internal::ValueArrayIterator<TYPE> isis::data::ValueArray< TYPE >::iterator

Definition at line 186 of file valuearray.hpp.

template<typename TYPE>
typedef iterator::reference isis::data::ValueArray< TYPE >::reference

Definition at line 188 of file valuearray.hpp.


Constructor & Destructor Documentation

template<typename TYPE>
isis::data::ValueArray< TYPE >::ValueArray ( ) [inline, protected]

Definition at line 181 of file valuearray.hpp.

template<typename TYPE>
isis::data::ValueArray< TYPE >::ValueArray ( size_t  length) [inline]

Creates a ValueArray pointing to a newly allocated array of elements of the given type.

The array is zero-initialized. If the requested length is 0 no memory will be allocated and the pointer be "empty".

Parameters:
lengthamount of elements in the new array

Definition at line 213 of file valuearray.hpp.

template<typename TYPE>
isis::data::ValueArray< TYPE >::ValueArray ( const boost::shared_ptr< TYPE > &  ptr,
size_t  length 
) [inline]

Creates ValueArray from a boost::shared_ptr of the same type.

It will inherit the deleter of the shared_ptr.

Parameters:
ptrthe shared_ptr to share the data with
lengththe length of the used array (ValueArray does NOT check for length, this is just here for child classes which may want to check)

Definition at line 229 of file valuearray.hpp.

template<typename TYPE>
isis::data::ValueArray< TYPE >::ValueArray ( TYPE *const  ptr,
size_t  length 
) [inline]

Creates ValueArray from a pointer of type TYPE.

The pointers are automatically deleted by an instance of BasicDeleter and should not be used outside once used here.

Parameters:
ptrthe pointer to the used array
lengththe length of the used array (ValueArray does NOT check for length, this is just here for child classes which may want to check)

Definition at line 238 of file valuearray.hpp.

template<typename TYPE>
template<typename D >
isis::data::ValueArray< TYPE >::ValueArray ( TYPE *const  ptr,
size_t  length,
d 
) [inline]

Creates ValueArray from a pointer of type TYPE.

The pointers are automatically deleted by an copy of d and should not be used outside once used here (this does not apply, if d does not delete). D must implement operator()(TYPE *p).

Parameters:
ptrthe pointer to the used array
lengththe length of the used array in elements (ValueArray does NOT check for length),
dthe deleter to be used when the data shall be deleted ( d() is called then )

Definition at line 250 of file valuearray.hpp.

template<typename TYPE>
virtual isis::data::ValueArray< TYPE >::~ValueArray ( ) [inline, virtual]

Definition at line 252 of file valuearray.hpp.


Member Function Documentation

template<typename TYPE>
iterator isis::data::ValueArray< TYPE >::begin ( ) [inline]

Definition at line 272 of file valuearray.hpp.

template<typename TYPE>
const_iterator isis::data::ValueArray< TYPE >::begin ( ) const [inline]

Definition at line 274 of file valuearray.hpp.

template<typename TYPE>
virtual const_value_iterator isis::data::ValueArray< TYPE >::beginGeneric ( ) const [inline, virtual]

Implements isis::data::ValueArrayBase.

Definition at line 268 of file valuearray.hpp.

template<typename TYPE>
virtual value_iterator isis::data::ValueArray< TYPE >::beginGeneric ( ) [inline, virtual]

Implements isis::data::ValueArrayBase.

Definition at line 265 of file valuearray.hpp.

template<typename TYPE>
size_t isis::data::ValueArray< TYPE >::bytesPerElem ( ) const [inline, virtual]
Returns:
the byte-size of the type of the data this ValueArray points to.

Implements isis::data::ValueArrayBase.

Definition at line 323 of file valuearray.hpp.

template<typename TYPE>
ValueArrayBase* isis::data::ValueArray< TYPE >::clone ( ) const [inline, protected, virtual]

Create a ValueArray of the same type pointing at the same address.

Implements isis::data::ValueArrayBase.

Definition at line 182 of file valuearray.hpp.

template<typename TYPE>
const_iterator isis::data::ValueArray< TYPE >::end ( ) const [inline]

Definition at line 275 of file valuearray.hpp.

template<typename TYPE>
iterator isis::data::ValueArray< TYPE >::end ( ) [inline]

Definition at line 273 of file valuearray.hpp.

template<typename TYPE>
void isis::data::ValueArray< TYPE >::endianSwap ( ) [inline, virtual]

Implements isis::data::ValueArrayBase.

Definition at line 373 of file valuearray.hpp.

template<typename TYPE>
std::pair<util::ValueReference, util::ValueReference> isis::data::ValueArray< TYPE >::getMinMax ( ) const [inline, virtual]

Get minimum/maximum of a ValueArray.

This computes the minimum and maximum value of the stored data and stores them in ValueReference-Objects. This actually returns the bounding box of the values in the value space of the type. This means:

  • min/max numbers for numbers from a 1-D value space (aka real numbers)
  • complex(lowest real value,lowest imaginary value) / complex(biggest real value,biggest imaginary value) for complex numbers
  • color(lowest red value,lowest green value, lowest blue value)/color(biggest red value,biggest green value, biggest blue value) for color The computed min/max are of the same type as the stored data, but can be compared to other ValueReference without knowing this type via the lt/gt function of ValueBase. The following code checks if the value range of ValueArray-object data1 is a real subset of data2:
     std::pair<util::ValueReference,util::ValueReference> minmax1=data1.getMinMax(), minmax2=data2.getMinMax();
     if(minmax1.first->gt(minmax2.second) && minmax1.second->lt(minmax2.second)
      std::cout << minmax1 << " is a subset of " minmax2 << std::endl;
    
    Returns:
    a pair of ValueReferences referring to the found minimum/maximum of the data

Implements isis::data::ValueArrayBase.

Definition at line 325 of file valuearray.hpp.

template<typename TYPE>
boost::shared_ptr<const void> isis::data::ValueArray< TYPE >::getRawAddress ( size_t  offset = 0) const [inline, virtual]

Get the raw address the ValueArray points to.

An offset can be added to the result. If it is not zero, the resulting shared_ptr will use DelProxy as deleter. Thus, it will increase the reference count of the original pointer by one and decrease it when the deletion of the offset pointer is triggered.

Parameters:
offsetammount of bytes to displace the resulting pointer from the actual pointer
Returns:
a shared_ptr with the memory address of the data handled by this ValueArray.

Implements isis::data::ValueArrayBase.

Definition at line 254 of file valuearray.hpp.

template<typename TYPE>
boost::shared_ptr<void> isis::data::ValueArray< TYPE >::getRawAddress ( size_t  offset = 0) [inline, virtual]

Get the raw address the ValueArray points to.

An offset can be added to the result. If it is not zero, the resulting shared_ptr will use DelProxy as deleter. Thus, it will increase the reference count of the original pointer by one and decrease it when the deletion of the offset pointer is triggered.

Parameters:
offsetammount of bytes to displace the resulting pointer from the actual pointer
Returns:
a shared_ptr with the memory address of the data handled by this ValueArray.

Implements isis::data::ValueArrayBase.

Definition at line 262 of file valuearray.hpp.

template<typename TYPE>
scaling_pair isis::data::ValueArray< TYPE >::getScalingTo ( unsigned short  typeID,
autoscaleOption  scaleopt = autoscale 
) const [inline, virtual]

get the scaling (and offset) which would be used in an conversion

Implements isis::data::ValueArrayBase.

Definition at line 362 of file valuearray.hpp.

template<typename TYPE>
unsigned short isis::data::ValueArray< TYPE >::getTypeID ( ) const [inline, virtual]
Returns:
the ID of its actual type

Implements isis::util::_internal::GenericValue.

Definition at line 294 of file valuearray.hpp.

template<typename TYPE>
std::string isis::data::ValueArray< TYPE >::getTypeName ( ) const [inline, virtual]
Returns:
the name of its actual type

Implements isis::util::_internal::GenericValue.

Definition at line 293 of file valuearray.hpp.

template<typename TYPE>
bool isis::data::ValueArray< TYPE >::isFloat ( ) const [inline, virtual]
Returns:
true if the type is a floating point scalar

Implements isis::util::_internal::GenericValue.

Definition at line 295 of file valuearray.hpp.

template<typename TYPE>
bool isis::data::ValueArray< TYPE >::isInteger ( ) const [inline, virtual]
Returns:
true if the type is a integral scalar

Implements isis::util::_internal::GenericValue.

Definition at line 296 of file valuearray.hpp.

template<typename TYPE>
isis::data::ValueArray< TYPE >::operator boost::shared_ptr< TYPE > & ( ) [inline]

Implicit conversion to boost::shared_ptr<TYPE> The returned smart pointer will be part of the reference-counting and will correctly delete the data (using the given deleter) if required.

Returns:
boost::shared_ptr<TYPE> handling same data as the object.

Definition at line 320 of file valuearray.hpp.

template<typename TYPE>
isis::data::ValueArray< TYPE >::operator const boost::shared_ptr< TYPE > & ( ) const [inline]

Definition at line 321 of file valuearray.hpp.

template<typename TYPE>
const TYPE& isis::data::ValueArray< TYPE >::operator[] ( size_t  idx) const [inline]

Definition at line 311 of file valuearray.hpp.

template<typename TYPE>
TYPE& isis::data::ValueArray< TYPE >::operator[] ( size_t  idx) [inline]

Reference element at at given index.

If index is invalid, behaviour is undefined. Probably it will crash.

Returns:
reference to element at at given index.

Definition at line 308 of file valuearray.hpp.

template<typename TYPE>
std::vector<Reference> isis::data::ValueArray< TYPE >::splice ( size_t  size) const [inline, virtual]

Splice up the ValueArray into equal sized blocks.

This virtually creates new data blocks of the given size by computing new pointers into the block and creating ValueArray objects for them. This ValueArray objects use the reference counting of the original ValueArray via DelProxy, so the original data are only deleted (as a whole) when all spliced and all "normal" ValueArray for this data are deleted.

Parameters:
sizethe maximum size of the spliced parts of the data (the last part can be smaller)
Returns:
a vector of references to ValueArray's which point to the parts of the spliced data

Implements isis::data::ValueArrayBase.

Definition at line 337 of file valuearray.hpp.

template<typename TYPE>
static std::string isis::data::ValueArray< TYPE >::staticName ( ) [inline, static]
Returns:
the name of the type

Definition at line 299 of file valuearray.hpp.

template<typename TYPE>
virtual std::string isis::data::ValueArray< TYPE >::toString ( bool  labeled = false) const [inline, virtual]

Get the string representation of the Value.

This tries to use the isis type conversion to create a string from the Value. If thats no available, it will fall back to boost::lexical_cast. And it will send a warning to CoreDebug. If the lexical cast fails as well, boost::bad_lexical_cast is thrown.

Parameters:
labeledif true the typename will be appended to the resulting string in brackets.

Implements isis::util::_internal::GenericValue.

Definition at line 278 of file valuearray.hpp.


Field Documentation

template<typename TYPE>
const unsigned short isis::data::ValueArray< TYPE >::staticID = util::_internal::TypeID<TYPE>::value << 8 [static]

Definition at line 191 of file valuearray.hpp.


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