NIST Biometric Evaluation Framework
Software components for biometric technology evaluations
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
BiometricEvaluation::IO::FileLogsheet Class Reference

A class to represent a single logging mechanism with a file as the backing store. More...

#include <be_io_filelogsheet.h>

Inherits BiometricEvaluation::IO::Logsheet.

Public Member Functions

 FileLogsheet (const std::string &url, const std::string &description)
 Create a new log sheet. More...
 
 FileLogsheet (const std::string &url)
 Open an existing log sheet for appending. More...
 
 ~FileLogsheet ()
 Destructor. More...
 
std::string sequence (bool allEntries=false, bool trim=true, int32_t cursor=BE_FILELOGSHEET_SEQ_NEXT)
 Sequence through a FileLogsheet, returning one entry per invocation. More...
 
void write (const std::string &entry)
 Write a string as an entry to the backing store. More...
 
void writeComment (const std::string &entry)
 Write a string as a comment to the backing store. More...
 
void writeDebug (const std::string &entry)
 Write a string as a debug entry to the backing store. More...
 
void sync ()
 Synchronize any buffered data to the underlying backing store. More...
 
- Public Member Functions inherited from BiometricEvaluation::IO::Logsheet
 Logsheet ()
 Create a Logsheet that has no backing store. More...
 
virtual ~Logsheet ()
 Destructor. More...
 
void newEntry ()
 Start a new entry, causing the existing entry to be closed and written. More...
 
std::string getCurrentEntry () const
 Obtain the contents of the current entry currently under construction. More...
 
void resetCurrentEntry ()
 Reset the current entry buffer to the beginning. More...
 
uint32_t getCurrentEntryNumber () const
 Obtain the current entry number. More...
 
virtual void write (const std::string &entry)
 Write a string as an entry to the backing store. More...
 
virtual void writeComment (const std::string &entry)
 Write a string as a comment to the backing store. More...
 
virtual void writeDebug (const std::string &entry)
 Write a string as a debug entry to the backing store. More...
 
void setCommit (const bool state)
 Enable or disable the commitment of normal entries to the backing log storage. More...
 
bool getCommit () const
 Get the current entry commit state. More...
 
void setDebugCommit (const bool state)
 Enable or disable the commitment of debug entries to the backing log storage. More...
 
bool getDebugCommit () const
 Get the current debug entry commit state. More...
 
void setCommentCommit (const bool state)
 Enable or disable the commitment of comment entries to the backing log storage. More...
 
bool getCommentCommit () const
 Get the current comment entry commit state. More...
 
virtual void sync ()
 Synchronize any buffered data to the underlying backing store. More...
 
void setAutoSync (bool state)
 Turn on/off auto-sync of the data. More...
 
bool getAutoSync () const
 Return the current auto-sync state. More...
 

Static Public Member Functions

static void mergeLogsheets (std::vector< std::shared_ptr< FileLogsheet > > &logsheets)
 Merge multiple FileLogsheets into a single FileLogsheet. More...
 
static std::string trim (const std::string &entry)
 Trim delimiters from FileLogsheet entries. More...
 
- Static Public Member Functions inherited from BiometricEvaluation::IO::Logsheet
static Logsheet::Kind getTypeFromURL (const std::string &url)
 Map the URL scheme, taken from a string containing the entire URL, into a Logsheet type. More...
 
static bool lineIsEntry (const std::string &line)
 Helper function to determine whether a string is a valid log entry. More...
 
static bool lineIsComment (const std::string &line)
 Helper function to determine whether a string is a valid comment log entry. More...
 
static bool lineIsDebug (const std::string &line)
 Helper function to determine whether a string is a valid debug log entry. More...
 
static std::string trim (const std::string &entry)
 Trim delimiters from Logsheet entries. More...
 

Static Public Attributes

static const int32_t BE_FILELOGSHEET_SEQ_START = 1
 Sequence from beginning. More...
 
static const int32_t BE_FILELOGSHEET_SEQ_NEXT = 2
 Sequence from current position. More...
 
- Static Public Attributes inherited from BiometricEvaluation::IO::Logsheet
static const char CommentDelimiter = '#'
 Delimiter for a comment line in the log sheet. More...
 
static const char EntryDelimiter = 'E'
 Delimiter for an entry line in the log sheet. More...
 
static const char DebugDelimiter = 'D'
 Delimiter for an debug line in the log sheet. More...
 
static const std::string DescriptionTag
 The tag for the description string. More...
 
static const std::string FILEURLSCHEME
 The URL scheme to be used for FileLogsheet URL strings. More...
 
static const std::string SYSLOGURLSCHEME
 The URL scheme to be used for SysLogsheet URL strings. More...
 

Protected Member Functions

 FileLogsheet (const FileLogsheet &)
 Prevent copying of FileLogsheet objects. More...
 
FileLogsheetoperator= (const FileLogsheet &)
 Prevent copying of FileLogsheet objects. More...
 
void updateCursor ()
 Update the cursor position of the sequence file. More...
 
- Protected Member Functions inherited from BiometricEvaluation::IO::Logsheet
void incrementEntryNumber ()
 Increment the current entry number. More...
 
std::string getCurrentEntryNumberAsString () const
 Obtain the current entry 'tag', in 'Edddd' format. More...
 

Protected Attributes

std::unique_ptr< std::fstream > _theLogFile
 Stream used for writing the log file. More...
 
std::shared_ptr< std::fstream > _sequenceFile
 Stream used for sequencing. More...
 
std::streamoff _cursor
 Position of the sequencer, relative to SOF. More...
 

Additional Inherited Members

- Public Types inherited from BiometricEvaluation::IO::Logsheet
enum class  Kind { Null , File , Syslog }
 

Detailed Description

A class to represent a single logging mechanism with a file as the backing store.

A FileLogsheet object can be constructed and passed back to the client by the LogCabinet object. All sheets created in this manner are placed in a common area maintained by the cabinet.

Definition at line 34 of file be_io_filelogsheet.h.

Constructor & Destructor Documentation

◆ FileLogsheet() [1/3]

BiometricEvaluation::IO::FileLogsheet::FileLogsheet ( const std::string &  url,
const std::string &  description 
)

Create a new log sheet.

the log sheet is named by the uniform resource locator, usually starting with 'file://'. However, relative and absolute path names are also accepted for backward compatibility.

Parameters
[in]urlThe Uniform Resource Locator of the FileLogsheet to be created.
[in]descriptionThe text used to describe the sheet. This text is written into the log file prior to any entries.
Exceptions
Error::ParameterErrorThe URL is malformed.
Error::ObjectExistsThe sheet was previously created.
Error::StrategyErrorAn error occurred when using the underlying file system, or name or parentDir is malformed.

◆ FileLogsheet() [2/3]

BiometricEvaluation::IO::FileLogsheet::FileLogsheet ( const std::string &  url)

Open an existing log sheet for appending.

On open, the current entry counter is set to the last entry number plus one.

Note
Opening a large FileLogsheet may be a costly operation.
Parameters
[in]urlThe Uniform Resource Locator of the FileLogsheet to be opened.
Exceptions
Error::ParameterErrorThe URL is malformed.
Error::ObjectDoesNotExistThe sheet does not exist.
Error::StrategyErrorAn error occurred when using the underlying file system, or name or parentDir is malformed.

◆ ~FileLogsheet()

BiometricEvaluation::IO::FileLogsheet::~FileLogsheet ( )

Destructor.

◆ FileLogsheet() [3/3]

BiometricEvaluation::IO::FileLogsheet::FileLogsheet ( const FileLogsheet )
protected

Prevent copying of FileLogsheet objects.

Member Function Documentation

◆ mergeLogsheets()

static void BiometricEvaluation::IO::FileLogsheet::mergeLogsheets ( std::vector< std::shared_ptr< FileLogsheet > > &  logsheets)
static

Merge multiple FileLogsheets into a single FileLogsheet.

Logsheet 2 - n will be appended to Logsheet 1.

Parameters
logSheetsLogsheet to merge.
Exceptions
Error::FileErrorError during log sequence.
Error::StrategyErrorError during log sequence.

◆ sequence()

std::string BiometricEvaluation::IO::FileLogsheet::sequence ( bool  allEntries = false,
bool  trim = true,
int32_t  cursor = BE_FILELOGSHEET_SEQ_NEXT 
)

Sequence through a FileLogsheet, returning one entry per invocation.

Parameters
allEntriesInclude debgug and comment entries when sequencing
trimWhether or not to include entry delimiters.
cursorThe location within the sequence to return.
Returns
The contents of the sequenced entry, as was originally given to write().
Exceptions
Error::FileError,Erroroccured while performing file IO.
Error::ObjectDoesNotExistThe FileLogsheet cannot be found on disk.
Error::StrategyErrorInvalid cursor position or the contents of the FileLogsheet is malformed.

◆ trim()

static std::string BiometricEvaluation::IO::FileLogsheet::trim ( const std::string &  entry)
static

Trim delimiters from FileLogsheet entries.

Works for comments and numbered entries.

Parameters
[in]entryThe entry to trim.
Returns
Delimiter-less entry.

◆ write()

void BiometricEvaluation::IO::FileLogsheet::write ( const std::string &  entry)
virtual

Write a string as an entry to the backing store.

This does not affect the current log entry buffer, but does increment the entry number.

Parameters
[in]entryThe text of the log entry.
Exceptions
Error::StrategyErrorAn error occurred when using the underlying backing store.

Reimplemented from BiometricEvaluation::IO::Logsheet.

◆ writeComment()

void BiometricEvaluation::IO::FileLogsheet::writeComment ( const std::string &  entry)
virtual

Write a string as a comment to the backing store.

This does not affect the current log entry buffer, and does not increment the entry number. A comment line is prefixed with CommentDelimiter followed by a space by this method.

Parameters
[in]entryThe text of the comment.
Exceptions
Error::StrategyErrorAn error occurred when using the underlying backing store.

Reimplemented from BiometricEvaluation::IO::Logsheet.

◆ writeDebug()

void BiometricEvaluation::IO::FileLogsheet::writeDebug ( const std::string &  entry)
virtual

Write a string as a debug entry to the backing store.

This does not affect the current log entry buffer, and does not increment the entry number. A debug line is prefixed with DebugDelimiter followed by a space.

Parameters
[in]entryThe text of the debug message.
Exceptions
Error::StrategyErrorAn error occurred when logging.

Reimplemented from BiometricEvaluation::IO::Logsheet.

◆ sync()

void BiometricEvaluation::IO::FileLogsheet::sync ( )
virtual

Synchronize any buffered data to the underlying backing store.

This syncing is dependent on the behavior of the underlying storage mechanism.

Exceptions
Error::StrategyErrorAn error occurred when using the underlying backing store.

Reimplemented from BiometricEvaluation::IO::Logsheet.

◆ operator=()

FileLogsheet & BiometricEvaluation::IO::FileLogsheet::operator= ( const FileLogsheet )
protected

Prevent copying of FileLogsheet objects.

◆ updateCursor()

void BiometricEvaluation::IO::FileLogsheet::updateCursor ( )
protected

Update the cursor position of the sequence file.

Exceptions
Error::FileErrorError getting file position from sequence file.

Member Data Documentation

◆ BE_FILELOGSHEET_SEQ_START

const int32_t BiometricEvaluation::IO::FileLogsheet::BE_FILELOGSHEET_SEQ_START = 1
static

Sequence from beginning.

Definition at line 113 of file be_io_filelogsheet.h.

◆ BE_FILELOGSHEET_SEQ_NEXT

const int32_t BiometricEvaluation::IO::FileLogsheet::BE_FILELOGSHEET_SEQ_NEXT = 2
static

Sequence from current position.

Definition at line 115 of file be_io_filelogsheet.h.

◆ _theLogFile

std::unique_ptr<std::fstream> BiometricEvaluation::IO::FileLogsheet::_theLogFile
protected

Stream used for writing the log file.

Definition at line 178 of file be_io_filelogsheet.h.

◆ _sequenceFile

std::shared_ptr<std::fstream> BiometricEvaluation::IO::FileLogsheet::_sequenceFile
protected

Stream used for sequencing.

Definition at line 191 of file be_io_filelogsheet.h.

◆ _cursor

std::streamoff BiometricEvaluation::IO::FileLogsheet::_cursor
protected

Position of the sequencer, relative to SOF.

Definition at line 194 of file be_io_filelogsheet.h.


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