libimgdoc2
Loading...
Searching...
No Matches
Public Member Functions | List of all members
imgdoc2::BlobOutputOnHeap Class Reference

implementation of the IBlobOutput interface More...

#include <BlobOutputImplementations.h>

Inheritance diagram for imgdoc2::BlobOutputOnHeap:
imgdoc2::IBlobOutput

Public Member Functions

 ~BlobOutputOnHeap () override
 Destructor which releases the allocated memory.
 
bool Reserve (size_t s) override
 
bool SetData (size_t offset, size_t size, const void *data) override
 
bool GetHasData () const
 
const std::uint8_t * GetDataC () const
 
std::uint8_t * GetData ()
 
size_t GetSizeOfData () const
 
 BlobOutputOnHeap (const BlobOutputOnHeap &)=delete
 
BlobOutputOnHeapoperator= (const BlobOutputOnHeap &)=delete
 
 BlobOutputOnHeap (BlobOutputOnHeap &&)=delete
 
BlobOutputOnHeapoperator= (BlobOutputOnHeap &&)=delete
 
- Public Member Functions inherited from imgdoc2::IBlobOutput
virtual bool Reserve (size_t s)=0
 
virtual bool SetData (size_t offset, size_t size, const void *data)=0
 
 IBlobOutput (const IBlobOutput &)=delete
 
IBlobOutputoperator= (const IBlobOutput &)=delete
 
 IBlobOutput (IBlobOutput &&)=delete
 
IBlobOutputoperator= (IBlobOutput &&)=delete
 

Detailed Description

implementation of the IBlobOutput interface

An implementation of the IBlobOutput interface which allocates the data being delivered on the heap. The memory allocated is owned by the instance.

Member Function Documentation

◆ GetData()

std::uint8_t * imgdoc2::BlobOutputOnHeap::GetData ( )
inline

Gets a pointer to the data. The size of this buffer is given by "GetSizeOfData". If this instance has not been initialized, nullptr is returned.

Returns
If the instance is initialized, then a pointer to the buffer is returned; nullptr otherwise.

◆ GetDataC()

const std::uint8_t * imgdoc2::BlobOutputOnHeap::GetDataC ( ) const
inline

Gets a const pointer to the data. The size of this buffer is given by "GetSizeOfData". If this instance has not been initialized, nullptr is returned.

Returns
If the instance is initialized, then a pointer to the buffer is returned; nullptr otherwise.

◆ GetHasData()

bool imgdoc2::BlobOutputOnHeap::GetHasData ( ) const
inline

Gets a boolean indicating whether output data has been reserved, in other words - whether "Reserve" was called.

Returns
True if output memory was reserved; false otherwise.

◆ GetSizeOfData()

size_t imgdoc2::BlobOutputOnHeap::GetSizeOfData ( ) const
inline

Gets size of data in bytes. It is usually advised to check "GetHasData()" before.

Returns
The size of the data in bytes.

◆ Reserve()

bool imgdoc2::BlobOutputOnHeap::Reserve ( size_t  s)
inlineoverridevirtual

Notifies about the size of data to be returned. This method must only be called once, additional calls should result in an exception. If this method returns false, it is interpreted as "the client is not interested in the data" and there will not be subsequent calls to "SetData".

Parameters
sThe size of the data being returned.
Returns
True if it succeeds (and the object is ready to handle "SetData" calls), false if it fails.

Implements imgdoc2::IBlobOutput.

◆ SetData()

bool imgdoc2::BlobOutputOnHeap::SetData ( size_t  offset,
size_t  size,
const void *  data 
)
inlineoverridevirtual

Data is passed to the "blob-output"-object with this call. The pointer "data" is only assumed to be valid for the duration of this call - in other words, the object needs to access the memory only within the call (and e.g. make a copy of the data). The address (indicated by offset and size) must be completely within the size as advertised with the "Reserve"-call. The method should validate this condition and throw an exception in case of a violation. If the method returns "false", it is interpreted "the object is not interested in any additional data", and subsequent calls may be suppressed.

Parameters
offsetThe offset.
sizeThe size.
dataThe data.
Returns
True if it succeeds, false if it fails.

Implements imgdoc2::IBlobOutput.


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