Image Component Library (ICL)
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
icl::core::ImgBuffer Class Reference

Singelton class that provides access to reusable temporary images. More...

#include <ImgBuffer.h>

Inheritance diagram for icl::core::ImgBuffer:
icl::utils::Uncopyable

Public Member Functions

 ~ImgBuffer ()
 Destructor. More...
 
template<class T >
ICLCore_API Img< T > * get ()
 returns an independent image if available, otherwise, a new one is added More...
 
template<class T >
ICLCore_API Img< T > * get (const utils::Size &size, int channels)
 returns an independent image with preferably correct parameters or a new one More...
 
template<class T >
ICLCore_API Img< T > * get (const ImgParams &params)
 returns an independent image with preferably correct parameters or a new one More...
 
ImgBaseget (depth d)
 non template version for get(void) More...
 
ImgBaseget (depth d, const utils::Size &size, int channels)
 non template version for get(const Size&,channels) More...
 
ImgBaseget (depth d, const ImgParams &p)
 non template version for get(const ImgParams&) More...
 

Static Public Member Functions

static ImgBufferinstance ()
 Obtain the singelton instance of ImgBuffer. More...
 

Private Member Functions

 ImgBuffer ()
 private contructor -> use static function instance to get the singelton instance More...
 

Private Attributes

Data * data
 internal data storage class More...
 

Additional Inherited Members

- Protected Member Functions inherited from icl::utils::Uncopyable
 Uncopyable ()
 Empty base constructor. More...
 

Detailed Description

Singelton class that provides access to reusable temporary images.

General Information

For global functions as those, provided by the ICLQuick module, it is a common problem that functions that return whole images always have to allocation new memory for those images. To avoid this, a globel function can ask the singelton ImgBuffer instance for a temporary image (using one of the ImgBuffer::get functions). This will return a pointer to an image whose memory is managed by the ImgBuffer class.

How Appropriate Images are Found

ICL Images internally use SmartPtr instances to manage their channel data pointers. ImgBase instances can be asked whether they are independent, i.e. no other image does currently share the image data.

The ImgBuffer does internally manage a list potentially reusable Img-Instances for each possible image depth.

get(void)

If ImgBuffer::get<T>(void) is called, the ImgBuffer searches in the current buffer-list for depth-T for an image that is currently independent, i.e, the ImgBuffer itself holds the only reference to the images memory. If an independent image can be found, it is returned, otherwise a new image is added to the ImgBuffers internal buffer list for depth-T.

get(params)

If ImgBuffer::get<T>(const ImgParams&) or ImgBuffer::get<T>(const Size&,int) is called, the ImgBuffer will first search for an image that is not only independent but that already has the desired parameters. If a compatible image is found, it is returned. Otherwise, an independent image is preferred. If an independent image can be found, it's parameters are adapted to the desired parameters. Otherwise, a new image with the desired parameters is created, stored and returned.

Constructor & Destructor Documentation

◆ ImgBuffer()

icl::core::ImgBuffer::ImgBuffer ( )
private

private contructor -> use static function instance to get the singelton instance

◆ ~ImgBuffer()

icl::core::ImgBuffer::~ImgBuffer ( )

Destructor.

Member Function Documentation

◆ get() [1/6]

template<class T >
ICLCore_API Img<T>* icl::core::ImgBuffer::get ( )

returns an independent image if available, otherwise, a new one is added

◆ get() [2/6]

template<class T >
ICLCore_API Img<T>* icl::core::ImgBuffer::get ( const utils::Size size,
int  channels 
)

returns an independent image with preferably correct parameters or a new one

◆ get() [3/6]

template<class T >
ICLCore_API Img<T>* icl::core::ImgBuffer::get ( const ImgParams params)

returns an independent image with preferably correct parameters or a new one

◆ get() [4/6]

ImgBase* icl::core::ImgBuffer::get ( depth  d)

non template version for get(void)

◆ get() [5/6]

ImgBase* icl::core::ImgBuffer::get ( depth  d,
const utils::Size size,
int  channels 
)

non template version for get(const Size&,channels)

◆ get() [6/6]

ImgBase* icl::core::ImgBuffer::get ( depth  d,
const ImgParams p 
)

non template version for get(const ImgParams&)

◆ instance()

static ImgBuffer* icl::core::ImgBuffer::instance ( )
static

Obtain the singelton instance of ImgBuffer.

Member Data Documentation

◆ data

Data* icl::core::ImgBuffer::data
private

internal data storage class

internal data storage pointer


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