ContRap-Libraries
|
Class Array defines basis functions for two dimensional arrays. More...
#include <array.h>
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 Object * | clone () |
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. |
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.
crp::Array< T >::Array | ( | int | width = 0 , |
int | height = 0 |
||
) | [inline] |
Constructs a new array.
width | Width of the array |
height | Height of the array |
crp::Array< T >::Array | ( | const Array< T > & | array | ) | [inline] |
Copy constructor.
array | Array to copy |
virtual crp::Array< T >::~Array | ( | ) | [inline, virtual] |
Destructor clears memory.
void crp::Array< T >::clear | ( | const T & | value | ) | [inline] |
Sets all contents with a value.
value | Value to set |
virtual Object* crp::Array< T >::clone | ( | ) | [inline, virtual] |
Returns a pointer to a semantical copy of the current object.
Reimplemented in crp::Image< T >, and crp::RawImage.
virtual void crp::Array< T >::destroy | ( | ) | [inline, virtual] |
Destroys the current instance.
Reimplemented in crp::Image< T >.
T* crp::Array< T >::get_data | ( | ) | [inline] |
Returns the raw data pointer.
const T* crp::Array< T >::get_data | ( | ) | const [inline] |
Returns a const pointer to the array data.
int crp::Array< T >::get_height | ( | ) | const [inline] |
Returns the height of the array.
int crp::Array< T >::get_size | ( | ) | const [inline] |
Returns the size of the array data field.
virtual const std::string crp::Array< T >::get_type_name | ( | ) | [inline, virtual] |
Returns the type of the object.
int crp::Array< T >::get_width | ( | ) | const [inline] |
Returns the width of the array.
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.
reference | Reference array |
bool crp::Array< T >::is_inside | ( | int | x, |
int | y | ||
) | const [inline] |
Checks if a coordinate is inside the current array.
x | X-Coordinate |
y | Y-Coordinate |
const T& crp::Array< T >::operator() | ( | int | x, |
int | y | ||
) | const [inline] |
Accesses an element of the array.
x | X-Coordinate of the element |
y | Y-Coordinate of the element |
T& crp::Array< T >::operator() | ( | int | x, |
int | y | ||
) | [inline] |
Accesses an element of the array.
x | X-Coordinate of the element |
y | Y-Coordinate of the element |
Reimplemented in crp::RawImage.
Array<T>& crp::Array< T >::operator= | ( | const Array< T > & | array | ) | [inline] |
Assignment operator.
void crp::Array< T >::resize | ( | int | width, |
int | height | ||
) | [inline] |
Resizes the array.
width | New array width |
height | New array height |
void crp::Array< T >::set_data | ( | T * | data, |
int | width, | ||
int | height | ||
) | [inline] |
Sets foreign data.
data | new data |
width | new width (should match data) |
height | new height (should match data) |
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.
from_x | Start point X-Coordinate |
from_y | Start point Y-Coordinate |
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.
Reimplemented in crp::RawImage.
std::string crp::Array< T >::to_string | ( | ) | [inline] |
Converts the array to string.
T* crp::Array< T >::data [protected] |
Data of the array.
Reimplemented in crp::Image< T >.
int crp::Array< T >::height [protected] |
Height of the array.
Reimplemented in crp::Image< T >.
bool crp::Array< T >::own_data [protected] |
Ownership state of the arrays data.
Reimplemented in crp::Image< T >.
int crp::Array< T >::size [protected] |
Size of the data.
Reimplemented in crp::Image< T >.
int crp::Array< T >::width [protected] |
Width of the array.
Reimplemented in crp::Image< T >.