stromx  0.8.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
stromx::runtime::MatrixWrapper Class Referenceabstract

Concrete matrix without memory management. More...

#include <MatrixWrapper.h>

Inheritance diagram for stromx::runtime::MatrixWrapper:
stromx::runtime::Matrix stromx::runtime::Data stromx::runtime::DataInterface stromx::cvsupport::Matrix

Public Member Functions

 MatrixWrapper (const unsigned int bufferSize, uint8_t *const buffer)
 
 MatrixWrapper ()
 
virtual const VariantHandlevariant () const
 
virtual uint8_t * buffer ()
 
virtual unsigned int bufferSize () const
 
virtual unsigned int rows () const
 
virtual unsigned int cols () const
 
virtual unsigned int stride () const
 
virtual ValueType valueType () const
 
virtual uint8_t * data ()
 
virtual const uint8_t * data () const
 
virtual void initializeMatrix (const unsigned int rows, const unsigned int cols, const unsigned int stride, uint8_t *data, const ValueType valueType)
 
virtual void serialize (OutputProvider &output) const
 
virtual void deserialize (InputProvider &input, const Version &version)
 
void resize (const unsigned int rows, const unsigned int cols, const ValueType valueType)
 
void resize (const unsigned int size)
 
void open (const std::string &filename)
 
void save (const std::string &filename) const
 
- Public Member Functions inherited from stromx::runtime::Matrix
virtual unsigned int valueSize () const
 
template<class T >
T & at (const unsigned row, const unsigned col)
 
template<class T >
const T & at (const unsigned int row, const unsigned col) const
 
template<class T >
const T value (const unsigned int row, const unsigned int col) const
 
- Public Member Functions inherited from stromx::runtime::DataInterface
virtual const Versionversion () const =0
 
virtual const std::string & type () const =0
 
virtual const std::string & package () const =0
 
virtual Dataclone () const =0
 
bool isVariant (const VariantInterface &v) const
 

Static Public Member Functions

static void save (const std::string &filename, const runtime::Matrix &matrix)
 
- Static Public Member Functions inherited from stromx::runtime::Matrix
static unsigned int valueSize (const ValueType valueType)
 

Protected Member Functions

void setBuffer (uint8_t *const buffer, const unsigned int bufferSize)
 
virtual void allocate (const unsigned int rows, const unsigned int cols, const runtime::Matrix::ValueType valueType)=0
 

Additional Inherited Members

- Public Types inherited from stromx::runtime::Matrix
enum  ValueType {
  NONE, INT_8, UINT_8, INT_16,
  UINT_16, INT_32, UINT_32, FLOAT_32,
  FLOAT_64
}
 
- Static Protected Member Functions inherited from stromx::runtime::Matrix
static const runtime::VariantHandle dataVariantFromValueType (const ValueType valueType)
 

Detailed Description

Concrete matrix without memory management.

Constructor & Destructor Documentation

§ MatrixWrapper() [1/2]

stromx::runtime::MatrixWrapper::MatrixWrapper ( const unsigned int  bufferSize,
uint8_t *const  buffer 
)

Constructs an matrix wrapper from a given memory buffer. The buffer is not owned by the matrix and is thus not freed upon destruction of the matrix wrapper.

§ MatrixWrapper() [2/2]

stromx::runtime::MatrixWrapper::MatrixWrapper ( )

Constructs an empty matrix wrapper, i.e. is an matrix wrapper without associated memory buffer.

Member Function Documentation

§ allocate()

virtual void stromx::runtime::MatrixWrapper::allocate ( const unsigned int  rows,
const unsigned int  cols,
const runtime::Matrix::ValueType  valueType 
)
protectedpure virtual

Allocates or resizes the matrix to the given dimension. Must be defined in derived class which implement the memory management. Implementations of this function should call setBuffer() and initializeMatrix().

Since
0.2

§ buffer()

virtual uint8_t* stromx::runtime::MatrixWrapper::buffer ( )
inlinevirtual

Returns the address of the buffer of the matrix. This is not necessarily a pointer to the matrix data which can be located at a different position in the buffer.

Implements stromx::runtime::Matrix.

§ bufferSize()

virtual unsigned int stromx::runtime::MatrixWrapper::bufferSize ( ) const
inlinevirtual

Returns the size of the buffer.

Implements stromx::runtime::Matrix.

§ cols()

virtual unsigned int stromx::runtime::MatrixWrapper::cols ( ) const
inlinevirtual

Returns the number columns of the matrix.

Implements stromx::runtime::Matrix.

§ data() [1/2]

virtual uint8_t* stromx::runtime::MatrixWrapper::data ( )
inlinevirtual

Returns the address of the matrix data.

Implements stromx::runtime::Matrix.

§ data() [2/2]

virtual const uint8_t* stromx::runtime::MatrixWrapper::data ( ) const
inlinevirtual

Returns the address of the matrix data as a constant pointer.

Implements stromx::runtime::Matrix.

§ deserialize()

void stromx::runtime::MatrixWrapper::deserialize ( InputProvider in,
const Version version 
)
virtual

Deserializes a data object.

Parameters
outThe input which the data obtained from.
versionThe version of the data class which serialized the input.

Reimplemented from stromx::runtime::Data.

§ initializeMatrix()

void stromx::runtime::MatrixWrapper::initializeMatrix ( const unsigned int  rows,
const unsigned int  cols,
const unsigned int  stride,
uint8_t *  data,
const ValueType  valueType 
)
virtual

Initializes the matrix to the given data. Note that this function does not change the matrix buffer but merely changes the description of the data contained in the matrix buffer.

Implements stromx::runtime::Matrix.

§ open()

void stromx::runtime::MatrixWrapper::open ( const std::string &  filename)

Reads the file filename. The data of the current matrix is replaced by the data of the new image.

§ resize() [1/2]

void stromx::runtime::MatrixWrapper::resize ( const unsigned int  rows,
const unsigned int  cols,
const ValueType  valueType 
)

Resizes the matrix and changes the value type of the matrix.

§ resize() [2/2]

void stromx::runtime::MatrixWrapper::resize ( const unsigned int  size)

Resizes the buffer of the matrix to the given size in bytes. The resized matrix has 1 row and size columns. Its value type is Matrix::NONE. The buffer size of the matrix is guaranteed to be at least size.

§ rows()

virtual unsigned int stromx::runtime::MatrixWrapper::rows ( ) const
inlinevirtual

Returns the number of rows of the matrix.

Implements stromx::runtime::Matrix.

§ save() [1/2]

void stromx::runtime::MatrixWrapper::save ( const std::string &  filename,
const runtime::Matrix matrix 
)
static

Saves the input matrix to filename. The matrix is stored in the NPY format.

§ save() [2/2]

void stromx::runtime::MatrixWrapper::save ( const std::string &  filename) const

Saves the matrix to the file filename. The matrix is stored in the NPY format.

§ serialize()

void stromx::runtime::MatrixWrapper::serialize ( OutputProvider out) const
virtual

Serializes this data object.

Parameters
outThe output which the data is sent to.

Reimplemented from stromx::runtime::Data.

§ setBuffer()

void stromx::runtime::MatrixWrapper::setBuffer ( uint8_t *const  buffer,
const unsigned int  bufferSize 
)
protected

Sets a new matrix buffer. Note that the matrix data defined by dimensions of the matrix value type and data must always be contained in the matrix buffer.

Parameters
bufferThe new buffer. Note that this memory is not released by the MatrixWrapper.
bufferSizeThe size of buffer in bytes.

§ stride()

virtual unsigned int stromx::runtime::MatrixWrapper::stride ( ) const
inlinevirtual

Returns the size of a row in the matrix in bytes.

Implements stromx::runtime::Matrix.

§ valueType()

virtual ValueType stromx::runtime::MatrixWrapper::valueType ( ) const
inlinevirtual

Returns the value type of the data of the matrix.

Implements stromx::runtime::Matrix.

§ variant()

virtual const VariantHandle& stromx::runtime::MatrixWrapper::variant ( ) const
inlinevirtual

Returns the data variant of this data object.

Implements stromx::runtime::DataInterface.


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