ContRap-Libraries
Public Member Functions | Protected Attributes

crp::Array< T > Class Template Reference

Class Array defines basis functions for two dimensional arrays. More...

#include <array.h>

Inheritance diagram for crp::Array< T >:
Object crp::Image< T >

Public Member Functions

 Array (int width=0, int height=0)
 Constructs a new array.
 Array (const Array< T > &array)
 Copy constructor.
virtual ~Array ()
 Destructor clears memory.
virtual void destroy ()
 Destroys the current instance.
virtual Objectclone ()
 Returns a pointer to a semantical copy of the current object.
virtual const std::string get_type_name ()
 Returns the type of the object.
virtual std::string to_string () const
 Converts the object to a non-formatted string.
bool has_equal_size_as (const Array< T > &array)
 Returns true if the reference array has the same width and height.
bool is_inside (int x, int y) const
 Checks if a coordinate is inside the current array.
void resize (int width, int height)
 Resizes the array.
void clear (const T &value)
 Sets all contents with a value.
void sub_array (int from_x, int from_y, Array< T > &array)
 Computes a sub array with respect to a rectangular area.
void set_data (T *data, int width, int height)
 Sets foreign data.
int get_width () const
 Returns the width of the array.
int get_height () const
 Returns the height of the array.
int get_size () const
 Returns the size of the array data field.
T & operator() (int x, int y)
 Accesses an element of the array.
const T & operator() (int x, int y) const
 Accesses an element of the array.
Array< T > & operator= (const Array< T > &array)
 Assignment operator.
T * get_data ()
 Returns the raw data pointer.
const T * get_data () const
 Returns a const pointer to the array data.
std::string to_string ()
 Converts the array to string.

Protected Attributes

int width
 Width of the array.
int height
 Height of the array.
T * data
 Data of the array.
bool own_data
 Ownership state of the arrays data.
int size
 Size of the data.

Detailed Description

template<class T>
class crp::Array< T >

Class Array defines basis functions for two dimensional arrays.

The central feature of the Array class is the efficient resizing policy. Arrays build the base for image processing classes, like Image.


Constructor & Destructor Documentation

template<class T>
crp::Array< T >::Array ( int  width = 0,
int  height = 0 
) [inline]

Constructs a new array.

Parameters:
widthWidth of the array
heightHeight of the array
template<class T>
crp::Array< T >::Array ( const Array< T > &  array) [inline]

Copy constructor.

Parameters:
arrayArray to copy
template<class T>
virtual crp::Array< T >::~Array ( ) [inline, virtual]

Destructor clears memory.


Member Function Documentation

template<class T>
void crp::Array< T >::clear ( const T &  value) [inline]

Sets all contents with a value.

Parameters:
valueValue to set
template<class T>
virtual Object* crp::Array< T >::clone ( ) [inline, virtual]

Returns a pointer to a semantical copy of the current object.

Returns:
Copy of the current object

Reimplemented in crp::Image< T >, and crp::RawImage.

template<class T>
virtual void crp::Array< T >::destroy ( ) [inline, virtual]

Destroys the current instance.

Reimplemented in crp::Image< T >.

template<class T>
T* crp::Array< T >::get_data ( ) [inline]

Returns the raw data pointer.

Returns:
Data pointer to the raw data
template<class T>
const T* crp::Array< T >::get_data ( ) const [inline]

Returns a const pointer to the array data.

Returns:
Data pointer to the raw data
template<class T>
int crp::Array< T >::get_height ( ) const [inline]

Returns the height of the array.

Returns:
Height of the array
template<class T>
int crp::Array< T >::get_size ( ) const [inline]

Returns the size of the array data field.

Returns:
Size of the data field
template<class T>
virtual const std::string crp::Array< T >::get_type_name ( ) [inline, virtual]

Returns the type of the object.

Returns:
Type of the object
template<class T>
int crp::Array< T >::get_width ( ) const [inline]

Returns the width of the array.

Returns:
Width of the array
template<class T>
bool crp::Array< T >::has_equal_size_as ( const Array< T > &  array) [inline]

Returns true if the reference array has the same width and height.

Parameters:
referenceReference array
Returns:
True if and only if the arrays have the same dimensions
template<class T>
bool crp::Array< T >::is_inside ( int  x,
int  y 
) const [inline]

Checks if a coordinate is inside the current array.

Parameters:
xX-Coordinate
yY-Coordinate
Returns:
True if (x,y) is inside the current array
template<class T>
const T& crp::Array< T >::operator() ( int  x,
int  y 
) const [inline]

Accesses an element of the array.

Parameters:
xX-Coordinate of the element
yY-Coordinate of the element
Returns:
Array value
template<class T>
T& crp::Array< T >::operator() ( int  x,
int  y 
) [inline]

Accesses an element of the array.

Parameters:
xX-Coordinate of the element
yY-Coordinate of the element
Returns:
Array cell values

Reimplemented in crp::RawImage.

template<class T>
Array<T>& crp::Array< T >::operator= ( const Array< T > &  array) [inline]

Assignment operator.

Parameters:
template<class T>
void crp::Array< T >::resize ( int  width,
int  height 
) [inline]

Resizes the array.

Parameters:
widthNew array width
heightNew array height
template<class T>
void crp::Array< T >::set_data ( T *  data,
int  width,
int  height 
) [inline]

Sets foreign data.

Parameters:
datanew data
widthnew width (should match data)
heightnew height (should match data)
template<class T>
void crp::Array< T >::sub_array ( int  from_x,
int  from_y,
Array< T > &  array 
) [inline]

Computes a sub array with respect to a rectangular area.

Parameters:
from_xStart point X-Coordinate
from_yStart point Y-Coordinate
template<class T>
virtual std::string crp::Array< T >::to_string ( ) const [inline, virtual]

Converts the object to a non-formatted string.

This method is thought to be used for debugging purposes only.

Returns:
String representation of the object

Reimplemented in crp::RawImage.

template<class T>
std::string crp::Array< T >::to_string ( ) [inline]

Converts the array to string.

Returns:
Formatted string with the contents of the array

Field Documentation

template<class T>
T* crp::Array< T >::data [protected]

Data of the array.

Reimplemented in crp::Image< T >.

template<class T>
int crp::Array< T >::height [protected]

Height of the array.

Reimplemented in crp::Image< T >.

template<class T>
bool crp::Array< T >::own_data [protected]

Ownership state of the arrays data.

Reimplemented in crp::Image< T >.

template<class T>
int crp::Array< T >::size [protected]

Size of the data.

Reimplemented in crp::Image< T >.

template<class T>
int crp::Array< T >::width [protected]

Width of the array.

Reimplemented in crp::Image< T >.


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