ldas-tools-framecpp  2.6.2
Public Types | Public Member Functions | Static Public Attributes | Protected Types | Protected Member Functions | Protected 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 >:
FrameCPP::Common::MemoryBufferT< BT > FrameCPP::Common::FrameBufferInterface::Scanner FrameCPP::Common::FrameBufferInterface

Public Types

typedef BT buffer_type
 
typedef buffer_type::char_type char_type
 
typedef INT_4U buffer_size_type
 
typedef start_time_normalized_type start_time_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...
 

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...
 
bool FilterInternally () const
 Returns true if filtering happens internally; false otherwise. More...
 
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)
 
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...
 
void FilterBuffer (const char *Begin, const char *End)
 
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...
 
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...
 
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...
 

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 = ~buffer_size_type( 0 )
 

Protected Types

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 void buffer ()
 Initialization of the buffer. More...
 
void bufferId (const std::string &Id)
 

Protected Attributes

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

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

◆ buffer_type

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

◆ char_type

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

◆ delta_t_type

◆ filters_type

Type specifying the container holding the active filters.

◆ size_type

type for number of bytes to read and size of buffer

◆ start_time_type

Constructor & Destructor Documentation

◆ DynamicMemoryBufferT()

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()

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

Destructor.

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

Member Function Documentation

◆ AutoDelete() [1/2]

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

◆ AutoDelete() [2/2]

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

◆ buffer()

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

Initialization of the buffer.

Implements FrameCPP::Common::FrameBufferInterface.

◆ BufferId()

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()

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

◆ DeltaT()

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()

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 >.

◆ FilterBuffer()

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

◆ FilterInternally()

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()

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 >.

◆ NextBlock()

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.

◆ NextBlockSize()

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

Return the number of bytes to be made available.

◆ Position()

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

Return the current position in the stream being scanned.

◆ Ready()

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

Check if a complete frame file is ready for processing.

◆ Reset()

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

Initialize buffer to accumulate a frame file.

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

◆ setbuf()

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.

◆ StartTime()

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

Retrieve the start time of the stream.

◆ str() [1/2]

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

◆ str() [2/2]

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

Member Data Documentation

◆ M_BUFFER_SIZE_DEFAULT

const FrameBufferInterface::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

const buffer_size_type FrameCPP::Common::FrameBufferInterface::M_BUFFER_SIZE_SYSTEM = ~buffer_size_type( 0 )
staticinherited

◆ 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: