arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
NBufferFile< File, T > Class Template Reference

A File backed buffer which uses the provided files for buffering with the indicated max size. A file is made available for reading as soon as it reached the size limit. You must provide the files opened in "Write" mode with the addFile() method! More...

#include <Buffers.h>

Inheritance diagram for NBufferFile< File, T >:
BaseBuffer< T >

Public Member Functions

 NBufferFile (int fileSize)
 Provide the file size in objects!
 
 ~NBufferFile ()
 RAII close the files.
 
bool addFile (File &file)
 
Taddress ()
 not supported
 
int available () override
 provides the number of entries that are available to read
 
int availableForWrite () override
 provides the number of entries that are available to write
 
void clear ()
 same as reset
 
virtual int clearArray (int len)
 Removes the next len entries.
 
void end ()
 clean up files
 
bool isEmpty ()
 
virtual bool isFull ()
 checks if the buffer is full
 
virtual float levelPercent ()
 Returns the level of the buffer in %.
 
const charnextFileName ()
 Determines the next unique file name (after calling addFile)
 
bool peek (T &data) override
 peeks the actual entry from the buffer
 
bool read (T &result) override
 reads a single value
 
int readArray (T data[], int len) override
 reads multiple values
 
void reset ()
 clears the buffer
 
virtual bool resize (int bytes)
 Resizes the buffer if supported: returns false if not supported.
 
void setFileDeleteCallback (void(*cb)(const char *filename))
 Define the file delete operation.
 
size_t size () override
 
bool write (T sample) override
 write add an entry to the buffer
 
int writeArray (const T data[], int len) override
 Fills the buffer data.
 
virtual int writeArrayOverwrite (const T data[], int len)
 Fills the buffer data and overwrites the oldest data if the buffer is full.
 

Protected Member Functions

void cleanupFile (File &file)
 

Protected Attributes

File empty
 
Queue< Fileempty_files
 
int file_count = 0
 
void(* file_delete_callback )(const char *filename)
 
Queue< Filefilled_files
 
const uint16_t max_file_name = 256
 
Str next_file_name
 
int number_of_objects_per_file = 0
 
File read_file
 
File write_file
 

Detailed Description

template<class File, typename T>
class audio_tools::NBufferFile< File, T >

A File backed buffer which uses the provided files for buffering with the indicated max size. A file is made available for reading as soon as it reached the size limit. You must provide the files opened in "Write" mode with the addFile() method!

Template Parameters
Filefile class
Tbuffered data type

Constructor & Destructor Documentation

◆ NBufferFile()

template<class File , typename T >
NBufferFile ( int  fileSize)
inline

Provide the file size in objects!

◆ ~NBufferFile()

template<class File , typename T >
~NBufferFile ( )
inline

RAII close the files.

Member Function Documentation

◆ addFile()

template<class File , typename T >
bool addFile ( File file)
inline

add a buffer file, opened in Write mode. If it already contains any content it will be overwritten

◆ address()

template<class File , typename T >
T * address ( )
inlinevirtual

not supported

Implements BaseBuffer< T >.

◆ available()

template<class File , typename T >
int available ( )
inlineoverridevirtual

provides the number of entries that are available to read

Implements BaseBuffer< T >.

◆ availableForWrite()

template<class File , typename T >
int availableForWrite ( )
inlineoverridevirtual

provides the number of entries that are available to write

Implements BaseBuffer< T >.

◆ cleanupFile()

template<class File , typename T >
void cleanupFile ( File file)
inlineprotected

◆ clear()

void clear ( )
inlineinherited

same as reset

◆ clearArray()

virtual int clearArray ( int  len)
inlinevirtualinherited

Removes the next len entries.

Reimplemented in SingleBuffer< T >.

◆ end()

template<class File , typename T >
void end ( )
inline

clean up files

◆ isEmpty()

bool isEmpty ( )
inlineinherited

◆ isFull()

virtual bool isFull ( )
inlinevirtualinherited

◆ levelPercent()

virtual float levelPercent ( )
inlinevirtualinherited

Returns the level of the buffer in %.

◆ nextFileName()

template<class File , typename T >
const char * nextFileName ( )
inline

Determines the next unique file name (after calling addFile)

◆ peek()

template<class File , typename T >
bool peek ( T result)
inlineoverridevirtual

peeks the actual entry from the buffer

Implements BaseBuffer< T >.

◆ read()

template<class File , typename T >
bool read ( T result)
inlineoverridevirtual

reads a single value

Implements BaseBuffer< T >.

◆ readArray()

template<class File , typename T >
int readArray ( T  data[],
int  len 
)
inlineoverridevirtual

reads multiple values

Reimplemented from BaseBuffer< T >.

◆ reset()

template<class File , typename T >
void reset ( )
inlinevirtual

clears the buffer

Implements BaseBuffer< T >.

◆ resize()

virtual bool resize ( int  bytes)
inlinevirtualinherited

Resizes the buffer if supported: returns false if not supported.

Reimplemented in NBuffer< T >, RingBuffer< T >, DynamicMultiBuffer< T, BufferType >, SingleBuffer< T >, RingBufferFile< File, T >, and RedisBuffer< T >.

◆ setFileDeleteCallback()

template<class File , typename T >
void setFileDeleteCallback ( void(*)(const char *filename cb)
inline

Define the file delete operation.

◆ size()

template<class File , typename T >
size_t size ( )
inlineoverridevirtual

Implements BaseBuffer< T >.

◆ write()

template<class File , typename T >
bool write ( T  data)
inlineoverridevirtual

write add an entry to the buffer

Implements BaseBuffer< T >.

◆ writeArray()

template<class File , typename T >
int writeArray ( const T  data[],
int  len 
)
inlineoverridevirtual

Fills the buffer data.

Reimplemented from BaseBuffer< T >.

◆ writeArrayOverwrite()

virtual int writeArrayOverwrite ( const T  data[],
int  len 
)
inlinevirtualinherited

Fills the buffer data and overwrites the oldest data if the buffer is full.

Member Data Documentation

◆ empty

template<class File , typename T >
File empty
protected

◆ empty_files

template<class File , typename T >
Queue<File> empty_files
protected

◆ file_count

template<class File , typename T >
int file_count = 0
protected

◆ file_delete_callback

template<class File , typename T >
void(* file_delete_callback) (const char *filename)
protected

◆ filled_files

template<class File , typename T >
Queue<File> filled_files
protected

◆ max_file_name

template<class File , typename T >
const uint16_t max_file_name = 256
protected

◆ next_file_name

template<class File , typename T >
Str next_file_name
protected

◆ number_of_objects_per_file

template<class File , typename T >
int number_of_objects_per_file = 0
protected

◆ read_file

template<class File , typename T >
File read_file
protected

◆ write_file

template<class File , typename T >
File write_file
protected

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