NIST Biometric Evaluation Framework
Software components for biometric technology evaluations
|
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... | |
![]() | |
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 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 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... | |
FileLogsheet & | operator= (const FileLogsheet &) |
Prevent copying of FileLogsheet objects. More... | |
void | updateCursor () |
Update the cursor position of the sequence file. More... | |
![]() | |
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 | |
![]() | |
enum class | Kind { Null , File , Syslog } |
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.
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.
[in] | url | The Uniform Resource Locator of the FileLogsheet to be created. |
[in] | description | The text used to describe the sheet. This text is written into the log file prior to any entries. |
Error::ParameterError | The URL is malformed. |
Error::ObjectExists | The sheet was previously created. |
Error::StrategyError | An error occurred when using the underlying file system, or name or parentDir is malformed. |
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.
[in] | url | The Uniform Resource Locator of the FileLogsheet to be opened. |
Error::ParameterError | The URL is malformed. |
Error::ObjectDoesNotExist | The sheet does not exist. |
Error::StrategyError | An error occurred when using the underlying file system, or name or parentDir is malformed. |
BiometricEvaluation::IO::FileLogsheet::~FileLogsheet | ( | ) |
Destructor.
|
protected |
Prevent copying of FileLogsheet objects.
|
static |
Merge multiple FileLogsheets into a single FileLogsheet.
Logsheet 2 - n will be appended to Logsheet 1.
logSheets | Logsheet to merge. |
Error::FileError | Error during log sequence. |
Error::StrategyError | Error during log 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.
allEntries | Include debgug and comment entries when sequencing |
trim | Whether or not to include entry delimiters. |
cursor | The location within the sequence to return. |
Error::FileError,Error | occured while performing file IO. |
Error::ObjectDoesNotExist | The FileLogsheet cannot be found on disk. |
Error::StrategyError | Invalid cursor position or the contents of the FileLogsheet is malformed. |
|
static |
Trim delimiters from FileLogsheet entries.
Works for comments and numbered entries.
[in] | entry | The entry to trim. |
|
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.
[in] | entry | The text of the log entry. |
Error::StrategyError | An error occurred when using the underlying backing store. |
Reimplemented from BiometricEvaluation::IO::Logsheet.
|
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.
[in] | entry | The text of the comment. |
Error::StrategyError | An error occurred when using the underlying backing store. |
Reimplemented from BiometricEvaluation::IO::Logsheet.
|
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.
[in] | entry | The text of the debug message. |
Error::StrategyError | An error occurred when logging. |
Reimplemented from BiometricEvaluation::IO::Logsheet.
|
virtual |
Synchronize any buffered data to the underlying backing store.
This syncing is dependent on the behavior of the underlying storage mechanism.
Error::StrategyError | An error occurred when using the underlying backing store. |
Reimplemented from BiometricEvaluation::IO::Logsheet.
|
protected |
Prevent copying of FileLogsheet objects.
|
protected |
Update the cursor position of the sequence file.
Error::FileError | Error getting file position from sequence file. |
|
static |
Sequence from beginning.
Definition at line 113 of file be_io_filelogsheet.h.
|
static |
Sequence from current position.
Definition at line 115 of file be_io_filelogsheet.h.
|
protected |
Stream used for writing the log file.
Definition at line 178 of file be_io_filelogsheet.h.
|
protected |
Stream used for sequencing.
Definition at line 191 of file be_io_filelogsheet.h.
|
protected |
Position of the sequencer, relative to SOF.
Definition at line 194 of file be_io_filelogsheet.h.