Main Page   Class Hierarchy   Alphabetical List   Compound List   Compound Members  

util::Blob< T > Class Template Reference

#include <Blob.h>

Inheritance diagram for util::Blob< T >:

util::Object List of all members.

Detailed Description

template<class T>
class util::Blob< T >

Blob (Binary Large OBject) is a class for storing a pointer to data and the size of the data.

As a template, Blob can store pointers to any type of data.


Public Methods

 Blob (T *ptr=NULL, int len=0, bool release=false, bool array=false)
 Create a new Blob.

 Blob (const Blob &other)
 Copy a Blob.

 ~Blob ()
 Destroy a Blob.

Blob & operator= (const Blob &other)
 Copy a blob.

bool operator== (const Blob &other) const
 Returns true if and only if the two blobs point to the same memory location.

const T * getData () const
 Get a pointer to the internal data.

void setData (T *data)
 Set the internal data pointer.

T * getData ()
 Get a pointer to the internal data.

int getLength () const
 Get the size of the data.

T * release ()
 Release the data.

bool isOwner () const
 Check the release flag.

void setOwner (bool release)
 Set the ownership of the internal pointer.

bool isArray () const
 Check whether the internal pointer is an array.

void setArray (bool array)
 Set the type of the internal pointer.


Constructor & Destructor Documentation

template<class T>
util::Blob< T >::Blob T *    ptr = NULL,
int    len = 0,
bool    release = false,
bool    array = false
[inline]
 

Create a new Blob.

Parameters:
ptr  a pointer to data
length  the number of items that can be sequentially accessed at the pointer
release  if true, the memory pointed to by ptr is released upon deletion of the Blob
array  if true, and release is true, then delete[] is used when destroying the internal pointer (instead of delete, which is used by default)

template<class T>
util::Blob< T >::Blob const Blob< T > &    other [inline]
 

Copy a Blob.

The memory pointed by the pointer in other is not copied. Instead, the two Blobs now reference the same memory location.


Member Function Documentation

template<class T>
bool util::Blob< T >::isArray   const [inline]
 

Check whether the internal pointer is an array.

If it is, delete[] is used instead of delete when destroying the pointer.

template<class T>
bool util::Blob< T >::isOwner   const [inline]
 

Check the release flag.

If release is true, this blob is the "owner" of its internal pointer.

template<class T>
Blob& util::Blob< T >::operator= const Blob< T > &    other [inline]
 

Copy a blob.

If the release flag is true, the memory pointer is deleted. Upon copying, the release flag is always set to false to ensure no data is deleted multiple times.

template<class T>
T* util::Blob< T >::release   [inline]
 

Release the data.

The release flag is set to false, and the internal pointer is returned.

template<class T>
void util::Blob< T >::setArray bool    array [inline]
 

Set the type of the internal pointer.

Parameters:
array  if true, delete[] is used instead of delete (the default) when destroying the internal pointer

template<class T>
void util::Blob< T >::setData T *    data [inline]
 

Set the internal data pointer.

If the release flag is true, the old data is deleted.

template<class T>
void util::Blob< T >::setOwner bool    release [inline]
 

Set the ownership of the internal pointer.

Parameters:
release  if true, this blob deletes its internal pointer when destroyed


The documentation for this class was generated from the following file:
Documentation generated on 11.09.2003 with Doxygen.
The documentation is copyrighted material.
Copyright © Topi Mäenpää 2003. All rights reserved.