ldas-tools-framecpp  2.7.0
Public Types | Public Member Functions | Static Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Private Types | Private Attributes | List of all members
FrameCPP::Common::DynamicMemoryBufferT< BT > Class Template Referenceabstract

Buffer appropriate for caching frame data. More...

#include <DynamicMemoryBuffer.hh>

Inheritance diagram for FrameCPP::Common::DynamicMemoryBufferT< BT >:
Inheritance graph
[legend]
Collaboration diagram for FrameCPP::Common::DynamicMemoryBufferT< BT >:
Collaboration graph
[legend]

Public Types

typedef BT buffer_type
 
typedef BT buffer_type
 
typedef buffer_type::char_type char_type
 
typedef buffer_type::char_type char_type
 
typedef INT_4U buffer_size_type
 
typedef INT_4U buffer_size_type
 
typedef start_time_normalized_type start_time_type
 
typedef start_time_normalized_type start_time_type
 
typedef delta_t_normalized_type delta_t_type
 
typedef delta_t_normalized_type delta_t_type
 
typedef INT_8U size_type
 type for number of bytes to read and size of buffer More...
 
typedef INT_8U size_type
 type for number of bytes to read and size of buffer More...
 

Public Member Functions

 DynamicMemoryBufferT (bool ParentAutoDelete=true)
 Default constructor. More...
 
virtual ~DynamicMemoryBufferT ()
 Destructor. More...
 
virtual void NextBlock (const char *Buffer, size_type Size)
 Add a buffer to the frame file memory image. More...
 
virtual void Reset ()
 Initialize buffer to accumulate a frame file. More...
 
 DynamicMemoryBufferT (bool ParentAutoDelete=true)
 Default constructor. More...
 
virtual ~DynamicMemoryBufferT ()
 Destructor. More...
 
virtual void NextBlock (const char *Buffer, size_type Size)
 Add a buffer to the frame file memory image. More...
 
virtual void Reset ()
 Initialize buffer to accumulate a frame file. More...
 
bool FilterInternally () const
 Returns true if filtering happens internally; false otherwise. More...
 
bool FilterInternally () const
 Returns true if filtering happens internally; false otherwise. More...
 
std::string str ()
 
void str (const std::string &S)
 
std::string str ()
 
void str (const std::string &S)
 
template<class DT >
void filter (const DT &Data)
 
virtual void filter (const char_type *Start, const char_type *End)=0
 
bool AutoDelete () const
 
void AutoDelete (bool Value)
 
bool AutoDelete () const
 
void AutoDelete (bool Value)
 
virtual void FilterAdd (FrameCPP::Common::StreamFilter *Filter)
 Adds a filter to the stream. More...
 
virtual void FilterAdd (FrameCPP::Common::StreamFilter *Filter)
 Adds a filter to the stream. More...
 
virtual void FilterRemove (FrameCPP::Common::StreamFilter *Filter)
 Removes a filter from the stream. More...
 
virtual void FilterRemove (FrameCPP::Common::StreamFilter *Filter)
 Removes a filter from the stream. More...
 
void FilterBuffer (const char *Begin, const char *End)
 
void FilterBuffer (const char *Begin, const char *End)
 
const std::string & BufferId () const
 Retrieve the string identification of the buffer. More...
 
const std::string & BufferId () const
 Retrieve the string identification of the buffer. More...
 
delta_t_type DeltaT () const
 Retrieve the duration of the stream. More...
 
delta_t_type DeltaT () const
 Retrieve the duration of the stream. More...
 
size_type NextBlockSize () const
 Return the number of bytes to be made available. More...
 
size_type NextBlockSize () const
 Return the number of bytes to be made available. More...
 
size_type Position () const
 Return the current position in the stream being scanned. More...
 
size_type Position () const
 Return the current position in the stream being scanned. More...
 
bool Ready () const
 Check if a complete frame file is ready for processing. More...
 
bool Ready () const
 Check if a complete frame file is ready for processing. More...
 
start_time_type StartTime () const
 Retrieve the start time of the stream. More...
 
start_time_type StartTime () const
 Retrieve the start time of the stream. More...
 

Static Public Attributes

static const buffer_size_type M_BUFFER_SIZE_DEFAULT = 256 * 1024
 The default size for buffered input and output. More...
 
static const buffer_size_type M_BUFFER_SIZE_SYSTEM
 

Protected Types

typedef std::list< FrameCPP::Common::StreamFilter *> filters_type
 Type specifying the container holding the active filters. More...
 
typedef std::list< FrameCPP::Common::StreamFilter *> filters_type
 Type specifying the container holding the active filters. More...
 

Protected Member Functions

virtual MemoryBufferTsetbuf (char_type *S, std::streamsize N)
 Routine to register if the caller has specified a buffer. More...
 
virtual MemoryBufferTsetbuf (char_type *S, std::streamsize N)
 Routine to register if the caller has specified a buffer. More...
 
virtual void buffer ()
 Initialization of the buffer. More...
 
virtual void buffer ()
 Initialization of the buffer. More...
 
void bufferId (const std::string &Id)
 
void bufferId (const std::string &Id)
 

Protected Attributes

filters_type m_filters
 Container holding all active filters. More...
 

Private Types

typedef FrameBufferInterface::Scanner scanner_type
 
typedef FrameBufferInterface::Scanner scanner_type
 

Private Attributes

std::ostringstream accumulated_buffer
 

Detailed Description

template<typename BT = std::stringbuf>
class FrameCPP::Common::DynamicMemoryBufferT< BT >

Buffer appropriate for caching frame data.

If the buffer is for input, then the buffer needs to be initialized with the contents. The initialization needs to be done as via by reading chuncks of data and having the class stitch them together until a complete frame file object is available for processing.

//---------------------------------------------------------------
// The following example uses input from a file to show how
// chuncks of data would be requested and then supplied
// to the class for inclussion in the in memory frame file
// stream.
//===============================================================
// Make sure that everything is reset to the initial conditions
//---------------------------------------------------------------
mb.Reset( );
boost::scoped_array read_buffer;
DynamicMemoryBuffer::size_type read_buffer_size = 0;
std::ifstream s;
s.open( filename.c_str( ) );
//---------------------------------------------------------------
// Keep looping till we are informed that a complete frame file
// image is ready for processing
//---------------------------------------------------------------
while ( ! mb.Ready( ) )
{
//-------------------------------------------------------------
// Request the number of bytes upon which to wait
//-------------------------------------------------------------
read_size = mb.NextBlockSize( );
//-------------------------------------------------------------
// Make sure the buffer which hold the temporary results is
// large enough for the results.
//-------------------------------------------------------------
if ( read_buffer_size < read_size )
{
read_buffer.reset( new char[ read_size ] );
read_buffer_size = read_size;
}
//-------------------------------------------------------------
// Read the requested number of bytes, blocking if need be
//-------------------------------------------------------------
s.read( read_buffer.get( ), read_size );
//-------------------------------------------------------------
// Send them off for processing
//-------------------------------------------------------------
mb.NextBlock( read_buffer.get( ), read_size );
}
s.close( );

Member Typedef Documentation

◆ buffer_size_type [1/2]

◆ buffer_size_type [2/2]

◆ buffer_type [1/2]

template<typename BT = std::stringbuf>
typedef BT FrameCPP::Common::MemoryBufferT< BT >::buffer_type
inherited

◆ buffer_type [2/2]

template<typename BT = std::stringbuf>
typedef BT FrameCPP::Common::MemoryBufferT< BT >::buffer_type
inherited

◆ char_type [1/2]

template<typename BT = std::stringbuf>
typedef buffer_type::char_type FrameCPP::Common::MemoryBufferT< BT >::char_type
inherited

◆ char_type [2/2]

template<typename BT = std::stringbuf>
typedef buffer_type::char_type FrameCPP::Common::MemoryBufferT< BT >::char_type
inherited

◆ delta_t_type [1/2]

◆ delta_t_type [2/2]

◆ filters_type [1/2]

Type specifying the container holding the active filters.

◆ filters_type [2/2]

Type specifying the container holding the active filters.

◆ scanner_type [1/2]

template<typename BT = std::stringbuf>
typedef FrameBufferInterface::Scanner FrameCPP::Common::DynamicMemoryBufferT< BT >::scanner_type
private

◆ scanner_type [2/2]

template<typename BT = std::stringbuf>
typedef FrameBufferInterface::Scanner FrameCPP::Common::DynamicMemoryBufferT< BT >::scanner_type
private

◆ size_type [1/2]

type for number of bytes to read and size of buffer

◆ size_type [2/2]

type for number of bytes to read and size of buffer

◆ start_time_type [1/2]

◆ start_time_type [2/2]

Constructor & Destructor Documentation

◆ DynamicMemoryBufferT() [1/2]

template<typename BT >
FrameCPP::Common::DynamicMemoryBufferT< BT >::DynamicMemoryBufferT ( bool  ParentAutoDelete = true)

Default constructor.

Parameters
[in]ParentAutoDeleteTrue if dynamic memory associated with the temporary buffer should be release once this object goes out of scope.
Returns
A new class instance.

The default constructor will initialize all the parts used in the general case.

◆ ~DynamicMemoryBufferT() [1/2]

template<typename BT >
FrameCPP::Common::DynamicMemoryBufferT< BT >::~DynamicMemoryBufferT ( )
virtual

Destructor.

Be careful to release all the resources that were created for this object.

◆ DynamicMemoryBufferT() [2/2]

template<typename BT = std::stringbuf>
FrameCPP::Common::DynamicMemoryBufferT< BT >::DynamicMemoryBufferT ( bool  ParentAutoDelete = true)

Default constructor.

Parameters
[in]ParentAutoDeleteTrue if dynamic memory associated with the temporary buffer should be release once this object goes out of scope.
Returns
A new class instance.

◆ ~DynamicMemoryBufferT() [2/2]

template<typename BT = std::stringbuf>
virtual FrameCPP::Common::DynamicMemoryBufferT< BT >::~DynamicMemoryBufferT ( )
virtual

Destructor.

Member Function Documentation

◆ AutoDelete() [1/4]

bool FrameCPP::Common::FrameBufferInterface::AutoDelete ( ) const
inlineinherited

◆ AutoDelete() [2/4]

bool FrameCPP::Common::FrameBufferInterface::AutoDelete ( ) const
inherited

◆ AutoDelete() [3/4]

void FrameCPP::Common::FrameBufferInterface::AutoDelete ( bool  Value)
inlineinherited

◆ AutoDelete() [4/4]

void FrameCPP::Common::FrameBufferInterface::AutoDelete ( bool  Value)
inherited

◆ buffer() [1/2]

template<typename BT >
void FrameCPP::Common::MemoryBufferT< BT >::buffer ( )
protectedvirtualinherited

Initialization of the buffer.

Implements FrameCPP::Common::FrameBufferInterface.

◆ buffer() [2/2]

template<typename BT = std::stringbuf>
virtual void FrameCPP::Common::MemoryBufferT< BT >::buffer ( )
protectedvirtualinherited

Initialization of the buffer.

Implements FrameCPP::Common::FrameBufferInterface.

◆ BufferId() [1/2]

const std::string & FrameCPP::Common::FrameBufferInterface::BufferId ( ) const
inlineinherited

Retrieve the string identification of the buffer.

Returns
An identifier associated with the open buffer.

◆ BufferId() [2/2]

const std::string& FrameCPP::Common::FrameBufferInterface::BufferId ( ) const
inherited

Retrieve the string identification of the buffer.

Returns
An identifier associated with the open buffer.

◆ bufferId() [1/2]

void FrameCPP::Common::FrameBufferInterface::bufferId ( const std::string &  Id)
inlineprotectedinherited

◆ bufferId() [2/2]

void FrameCPP::Common::FrameBufferInterface::bufferId ( const std::string &  Id)
protectedinherited

◆ DeltaT() [1/2]

delta_t_type FrameCPP::Common::FrameBufferInterface::Scanner::DeltaT ( ) const
inherited

Retrieve the duration of the stream.

◆ DeltaT() [2/2]

FrameBufferInterface::Scanner::delta_t_type FrameCPP::Common::FrameBufferInterface::Scanner::DeltaT ( ) const
inlineinherited

Retrieve the duration of the stream.

◆ filter() [1/2]

template<class DT >
void FrameCPP::Common::FrameBufferInterface::filter ( const DT Data)
inlineinherited

◆ filter() [2/2]

virtual void FrameCPP::Common::FrameBufferInterface::filter ( const char_type Start,
const char_type End 
)
pure virtualinherited

◆ FilterAdd() [1/2]

void FrameCPP::Common::FrameBufferInterface::FilterAdd ( FrameCPP::Common::StreamFilter Filter)
virtualinherited

Adds a filter to the stream.

Parameters
[in]FilterFilter function to add to the stream

Reimplemented in FrameCPP::Common::FrameBuffer< BT >, and FrameCPP::Common::FrameBuffer< BT >.

◆ FilterAdd() [2/2]

virtual void FrameCPP::Common::FrameBufferInterface::FilterAdd ( FrameCPP::Common::StreamFilter Filter)
virtualinherited

Adds a filter to the stream.

Parameters
[in]FilterFilter function to add to the stream

Reimplemented in FrameCPP::Common::FrameBuffer< BT >, and FrameCPP::Common::FrameBuffer< BT >.

◆ FilterBuffer() [1/2]

void FrameCPP::Common::FrameBufferInterface::FilterBuffer ( const char *  Begin,
const char *  End 
)
inherited

◆ FilterBuffer() [2/2]

void FrameCPP::Common::FrameBufferInterface::FilterBuffer ( const char *  Begin,
const char *  End 
)
inherited

◆ FilterInternally() [1/2]

template<typename BT = std::stringbuf>
bool FrameCPP::Common::MemoryBufferT< BT >::FilterInternally ( ) const
virtualinherited

Returns true if filtering happens internally; false otherwise.

Implements FrameCPP::Common::FrameBufferInterface.

◆ FilterInternally() [2/2]

template<typename BT >
bool FrameCPP::Common::MemoryBufferT< BT >::FilterInternally ( ) const
virtualinherited

Returns true if filtering happens internally; false otherwise.

Filtering currently is not optimized at the this layer so this method will always return false.

Implements FrameCPP::Common::FrameBufferInterface.

◆ FilterRemove() [1/2]

void FrameCPP::Common::FrameBufferInterface::FilterRemove ( FrameCPP::Common::StreamFilter Filter)
virtualinherited

Removes a filter from the stream.

Parameters
[in]FilterFilter function to remove from the stream

Reimplemented in FrameCPP::Common::FrameBuffer< BT >, and FrameCPP::Common::FrameBuffer< BT >.

◆ FilterRemove() [2/2]

virtual void FrameCPP::Common::FrameBufferInterface::FilterRemove ( FrameCPP::Common::StreamFilter Filter)
virtualinherited

Removes a filter from the stream.

Parameters
[in]FilterFilter function to remove from the stream

Reimplemented in FrameCPP::Common::FrameBuffer< BT >, and FrameCPP::Common::FrameBuffer< BT >.

◆ NextBlock() [1/2]

template<typename BT >
void FrameCPP::Common::DynamicMemoryBufferT< BT >::NextBlock ( const char *  Buffer,
size_type  Size 
)
virtual

Add a buffer to the frame file memory image.

Parameters
[in]BufferThe buffer to scan
[in]SizeThe number of bytes in Buffer

Reimplemented from FrameCPP::Common::FrameBufferInterface::Scanner.

◆ NextBlock() [2/2]

template<typename BT = std::stringbuf>
virtual void FrameCPP::Common::DynamicMemoryBufferT< BT >::NextBlock ( const char *  Buffer,
size_type  Size 
)
virtual

Add a buffer to the frame file memory image.

Parameters
[in]BufferThe buffer to scan
[in]SizeThe number of bytes in Buffer

Reimplemented from FrameCPP::Common::FrameBufferInterface::Scanner.

◆ NextBlockSize() [1/2]

FrameBufferInterface::Scanner::size_type FrameCPP::Common::FrameBufferInterface::Scanner::NextBlockSize ( ) const
inlineinherited

Return the number of bytes to be made available.

◆ NextBlockSize() [2/2]

size_type FrameCPP::Common::FrameBufferInterface::Scanner::NextBlockSize ( ) const
inherited

Return the number of bytes to be made available.

◆ Position() [1/2]

size_type FrameCPP::Common::FrameBufferInterface::Scanner::Position ( ) const
inherited

Return the current position in the stream being scanned.

◆ Position() [2/2]

FrameBufferInterface::Scanner::size_type FrameCPP::Common::FrameBufferInterface::Scanner::Position ( ) const
inlineinherited

Return the current position in the stream being scanned.

◆ Ready() [1/2]

bool FrameCPP::Common::FrameBufferInterface::Scanner::Ready ( ) const
inherited

Check if a complete frame file is ready for processing.

◆ Ready() [2/2]

bool FrameCPP::Common::FrameBufferInterface::Scanner::Ready ( ) const
inlineinherited

Check if a complete frame file is ready for processing.

◆ Reset() [1/2]

template<typename BT = std::stringbuf>
virtual void FrameCPP::Common::DynamicMemoryBufferT< BT >::Reset ( )
virtual

Initialize buffer to accumulate a frame file.

Reimplemented from FrameCPP::Common::FrameBufferInterface::Scanner.

◆ Reset() [2/2]

template<typename BT >
void FrameCPP::Common::DynamicMemoryBufferT< BT >::Reset ( )
virtual

Initialize buffer to accumulate a frame file.

Reimplemented from FrameCPP::Common::FrameBufferInterface::Scanner.

◆ setbuf() [1/2]

template<typename BT >
MemoryBufferT< BT > * FrameCPP::Common::MemoryBufferT< BT >::setbuf ( char_type S,
std::streamsize  N 
)
protectedvirtualinherited

Routine to register if the caller has specified a buffer.

◆ setbuf() [2/2]

template<typename BT = std::stringbuf>
virtual MemoryBufferT* FrameCPP::Common::MemoryBufferT< BT >::setbuf ( char_type S,
std::streamsize  N 
)
protectedvirtualinherited

Routine to register if the caller has specified a buffer.

◆ StartTime() [1/2]

FrameBufferInterface::Scanner::start_time_type FrameCPP::Common::FrameBufferInterface::Scanner::StartTime ( ) const
inlineinherited

Retrieve the start time of the stream.

◆ StartTime() [2/2]

start_time_type FrameCPP::Common::FrameBufferInterface::Scanner::StartTime ( ) const
inherited

Retrieve the start time of the stream.

◆ str() [1/4]

template<typename BT = std::stringbuf>
std::string FrameCPP::Common::MemoryBufferT< BT >::str ( )
inherited

◆ str() [2/4]

template<typename BT >
std::string FrameCPP::Common::MemoryBufferT< BT >::str ( )
inherited

◆ str() [3/4]

template<typename BT >
void FrameCPP::Common::MemoryBufferT< BT >::str ( const std::string &  S)
inherited

◆ str() [4/4]

template<typename BT = std::stringbuf>
void FrameCPP::Common::MemoryBufferT< BT >::str ( const std::string &  S)
inherited

Member Data Documentation

◆ accumulated_buffer

template<typename BT = std::stringbuf>
std::ostringstream FrameCPP::Common::DynamicMemoryBufferT< BT >::accumulated_buffer
private

◆ M_BUFFER_SIZE_DEFAULT

static const buffer_size_type FrameCPP::Common::FrameBufferInterface::M_BUFFER_SIZE_DEFAULT = 256 * 1024
staticinherited

The default size for buffered input and output.

◆ M_BUFFER_SIZE_SYSTEM

static const buffer_size_type FrameCPP::Common::FrameBufferInterface::M_BUFFER_SIZE_SYSTEM
staticinherited
Initial value:

◆ m_filters

filters_type FrameCPP::Common::FrameBufferInterface::m_filters
protectedinherited

Container holding all active filters.


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