WARNING: USE THIS SOFTWARE AT YOUR OWN RISK! THIS IS EXPERIMENTAL SOFTWARE NOT INTENDED FOR PRODUCTION USE! Zuble is currently an early stage prototype. As such Zuble is minimally tested and inherently unstable. It is provided for experimental, development, and demonstration purposes only. | Zuble QML Types | Zuble C++ Classes | Zuble Overview |
Zuble
0.1
Zuble Framework C++/QML extension API
|
This class performs log file I/O operations and JSON parsing in a background thread on behalf of a ZLogReader object. More...
#include <ZblLogReader.h>
Classes | |
class | ZblLogError |
A class for passing log file input error information. More... | |
Public Slots | |
void | openFile (const QString &filePath, QVariantMap contextMap=QVariantMap()) |
Opens the log file in a concurrent background thread. Sends the openComplete signal when open is complete. More... | |
void | close () |
void | loadViewport (QObject *viewport, qint64 seekPosition, qint64 viewportSize, ZblLogSearchParams searchParams, bool loadMarkupColumn=false, QVariantMap contextMap=QVariantMap()) |
Loads a viewport's log record data model with the a set of records located by a file seek index. More... | |
void | move (QObject *viewport, qint64 recordCount, qint64 seekIndex, bool forward, ZblLogSearchParams searchParams, bool loadMarkupColumn) |
Moves the viewport forward or backward a specific number of records. More... | |
void | loadRecordLinkMessageText (QObject *searchmark, QVariant links) |
Loads the message text from the log file for the specified ZLogSearch object. More... | |
Signals | |
void | openComplete (bool success, QString errorMsg, QVariantMap contextMap) |
Sent when the file open operation started by calling openFile() has completed. More... | |
void | loadRecordsComplete (QObject *viewport, QString errorMsg, QVariantMap contextMap) |
DEPRECATED! Don't use! More... | |
void | loadComplete (QObject *viewport, ZblLogSearchParams searchParams, bool endOfData, QString errorMsg, QVariantMap context) |
Sent when loading log records into a viewport by calling ZblLogReader::loadViewport() has completed. More... | |
void | linkMessageText (QVariant linkList) |
Sent when loadRecordLinkMessageText has completed. More... | |
void | notifyFileSize (qint64 fileSize) |
Periodically signals the current log file size. More... | |
Public Member Functions | |
ZblLogReader (QObject *parent=0) | |
virtual | ~ZblLogReader () |
Static Public Member Functions | |
static void | zInit (int logRecordRoleCount) |
Must be called only once before calling newLogReader();. More... | |
static ZblLogReader * | newLogReader () |
creates a new ZblLogReader object and moves it to the shared background log reader thread. More... | |
Protected Member Functions | |
void | timerEvent (QTimerEvent *event) |
Periodically sends notifyFileSize signal. More... | |
void | parseNextFileRecord (ZLogViewport *viewport, const QByteArray &ba, qint64 seekPos, ZblLogScanner &logScanner, ZDataRow &cellBuffer, ZblLogError &logError) |
Picks the next file record off the input stream buffer, parses it and contatenates results to the data model cell output buffer. More... | |
void | storeViewportData (ZDataRow &cellData, ZLogViewport *viewport, bool truncate=false) |
Appends data to the back of the viewport's data model. More... | |
int | parseAndStoreViewportData (zRowBuffer &logRecords, zSeekBuffer &seekPositions, qint64 rowCount, ZLogViewport *viewport, ZblLogScanner &logScanner) |
Parses rows from a row buffer and prepends them to the front of the viewport's data model. More... | |
QString | loadRowsAhead (ZLogViewport *viewport, qint64 seekPos, qint64 rowCount, bool truncate, const ZblLogSearchParams *searchParams, bool loadMarkupColumn, qint64 &foundCount, qint64 &storedCount, bool &eof) |
Appends log records to the data model scanning foreward in the file from the specified seek position. More... | |
QString | loadRowsBehind (ZLogViewport *viewport, qint64 seekPos, qint64 rowCount, const ZblLogSearchParams *searchParams, bool loadMarkupColumn, qint64 &foundCount, qint64 &storedCount, bool &bof) |
Prepends log data records to the data model scanning backward in the file from the specified seek position. More... | |
void | initializeMetadata () |
Reads the log file metadata contained in the first record of the log file. More... | |
Protected Attributes | |
ZBL_DECLARE_LOGGED_OBJECT QFile | m_inputFile |
Input file object from which log records will be read. More... | |
bool | m_fileActive |
true if input file is open and ready for reading, false otherwise. More... | |
ZSettings * | m_notationFile |
a file for storing metadata (bookmarks, notations, identification) about the log file. More... | |
QVariantMap | m_metadata |
A QVariantMap containing meta information about the log file. More... | |
QUuid | m_uuid |
A UUID that uniquely identifies this log file. More... | |
qint64 | m_firstRecordPos |
File position of the first log record of the search operation. More... | |
int | m_timerID |
Timer ID for file size timer. Zero == timer inactive. More... | |
Static Protected Attributes | |
static QMutex | m_lock |
Histogram buffer caches bytes of file data for subsequent parsing into log records. More... | |
static QThread * | m_readerThread = 0 |
A single background thread services all ZblLogReader objects. More... | |
static int | m_readerCount = 0 |
Counts instances of ZblLogReader objects. More... | |
static qint64 | m_defaultPageSize = 10000 |
number of rows in a default page. More... | |
static int | m_recordRoleCount = -1 |
Number of roles in a log record. More... | |
static const int | m_updateBatchSize = 10 |
The number of rows to accumulate before sending a row update to the data model. Batching rows reduces thread context switching overhead. More... | |
static const qint64 | m_maxLineSize = 20000 |
The maximum number of bytes a log record can contain. More... | |
Private Types | |
typedef QQueue< QByteArray > | zRowBuffer |
typedef QList< qint64 > | zSeekBuffer |
This class performs log file I/O operations and JSON parsing in a background thread on behalf of a ZLogReader object.
A single background thread supports all ZblLogReader objects. Log files are read into ZblTableModel objects that can be displayed by QML container classes. Each model is encapsulated in a ZLogViewport object that contains a subset of the log file's records.
Viewports can be scrolled forward or backward and they can be resized and relocated.
Zuble log files contain a File Identification Record (FIR) as the first record of the log file (seek position zero up to the first line feed) with an identifying UUID and JSON metadata object. The UUID links the log file to it's associated notation file.
A File Identification Record is encoded as follows:
{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}{JSON-OBJECT}
Where {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} represents a UUID that uniquely identifies the log file.
Where {JSON-OBJECT} represents a JSON formatted object containing at least the following keys:
TBD: rename these keys to change dash to underscore
Log file consumers should ignore keys they don't recognize. Log file producers are responsible for ensuring the uniqueness of the encapsulated UUID.
Definition at line 91 of file ZblLogReader.h.
|
private |
Definition at line 95 of file ZblLogReader.h.
|
private |
Definition at line 96 of file ZblLogReader.h.
|
explicit |
Definition at line 58 of file ZblLogReader.cpp.
Referenced by newLogReader().
|
virtual |
Definition at line 69 of file ZblLogReader.cpp.
|
slot |
Definition at line 231 of file ZblLogReader.cpp.
Referenced by openFile().
|
protected |
Reads the log file metadata contained in the first record of the log file.
Metadata is stored in the m_fileMetadata variable. This method sets the m_firstRecordPos variable to the seek position of the first log record.
Definition at line 91 of file ZblLogReader.cpp.
Referenced by openFile().
|
signal |
Sent when loadRecordLinkMessageText has completed.
linkList | An encapsulated ZblLogLinkList object containing message text. |
|
signal |
Sent when loading log records into a viewport by calling ZblLogReader::loadViewport() has completed.
viewport | The ZLogViewport object |
searchParams | search parameters that were passed to loadViewport() method |
endOfData | true if load operation encountered end-of-data, false otherwise |
errorMsg | a message pertaining to an error condition or empty string if no errors |
context | A user-defined QVariantMap that was passed to the ZblLogReader::loadViewport() |
Referenced by loadViewport().
|
slot |
Loads the message text from the log file for the specified ZLogSearch object.
This method should be invoked from the calling thread with a queued connection type so that it operates asynchronously.
The onLinkTextComplete slot of the specified searchmark object is called asynchronously (with a queued connection) when the load operation has completed.
searchmark | A ZblLogSearch object for which link messages will be loaded |
links | An encapsulated ZblLogLinkList object containing the log links to be loaded. For each link the index is the log record's ID and the value is its file seek position. |
Definition at line 816 of file ZblLogReader.cpp.
|
signal |
DEPRECATED! Don't use!
viewport | |
errorMsg | |
contextMap |
|
protected |
Appends log records to the data model scanning foreward in the file from the specified seek position.
viewport | Viewport into which data will be loaded from file |
seekPos | starting file position |
rowCount | number of log records to load |
truncate | true to remove an equal number of rows from the beginning of the data model as were appended to the end |
searchParams | search parameters |
foundCount | number of complete data rows found in file |
storedCount | number of log records parsed and stored in model |
eof | true if beginning of file was encountered during load operation, false if not |
Definition at line 311 of file ZblLogReader.cpp.
Referenced by loadViewport(), and move().
|
protected |
Prepends log data records to the data model scanning backward in the file from the specified seek position.
viewport | Viewport into which data will be loaded from file |
seekPos | starting file position |
rowCount | number of log records to load |
searchParams | search parameters |
foundCount | number of complete data rows found in file |
storedCount | number of log records parsed and stored in model |
bof | true if beginning of file was encountered during load operation, false if not |
Definition at line 623 of file ZblLogReader.cpp.
Referenced by move().
|
slot |
Loads a viewport's log record data model with the a set of records located by a file seek index.
This method should be invoked from the calling thread with a queued connection type so that it operates asynchronously.
This is an asynchronous operation that sends the loadComplete signal when the operation has completed or failed. This signal is sent on both the ZblLogReader and ZLogViewport objects
viewport | The ZLogViewport object to load with log records |
seekPosition | The file seek position to start reading |
viewportSize | The number of log records to load. |
searchParams | A ZblSearchParams object to use for highlighting, or an invalid QVariant for no highlighting |
loadMarkupColumn | true to load data into markup column of log record data model, false to ignore markup column |
contextMap | A user-defined variant map that is passed back with the loadRecordsComplete signal |
Definition at line 246 of file ZblLogReader.cpp.
|
slot |
Moves the viewport forward or backward a specific number of records.
viewport | The viewport to move, must be a ZLogViewport object |
recordCount | the number of records to move |
seekIndex | current file seek position of first record in viewport if forward == false; current file seek position of first record after viewport if forward == true; |
forward | true to move forward, false to move backward |
searchParams | A ZblSearchParams object to use for scanning/highlighting, or an invalid ZblSearchParams object to disable scanning/highlighting |
loadMarkupColumn | true to load data into markup column of viewport's log record data model, false to ignore markup column. If loadMarkupColumn == true and searchParams is valid scanning/highlighting will occur. |
Definition at line 755 of file ZblLogReader.cpp.
|
static |
creates a new ZblLogReader object and moves it to the shared background log reader thread.
Definition at line 180 of file ZblLogReader.cpp.
Referenced by Zbl::ZLogReader::ZLogReader().
|
signal |
|
signal |
Sent when the file open operation started by calling openFile() has completed.
success | true if file opened successully, false if open failed |
errorMsg | An error message if open failed |
contextMap | A user-defined context that was passed to the |
Referenced by openFile().
|
slot |
Opens the log file in a concurrent background thread. Sends the openComplete signal when open is complete.
filePath | Path to a Zuble log file |
Definition at line 201 of file ZblLogReader.cpp.
|
protected |
Parses rows from a row buffer and prepends them to the front of the viewport's data model.
logRecords | a list of byte arrays, one per row |
rowCount | the number of rows to parse & store |
viewport | the viewport in which to store the rows |
Definition at line 534 of file ZblLogReader.cpp.
Referenced by loadRowsBehind().
|
protected |
Picks the next file record off the input stream buffer, parses it and contatenates results to the data model cell output buffer.
viewport | |
ba | |
seekPos | |
logScanner | |
cellBuffer | |
logError |
Definition at line 446 of file ZblLogReader.cpp.
Referenced by loadRowsAhead(), and parseAndStoreViewportData().
|
protected |
Appends data to the back of the viewport's data model.
cellData | data to store |
viewport | viewport in which to store data |
truncate | true to remove an equal amount of rows from the model as those that were stored. |
Definition at line 524 of file ZblLogReader.cpp.
Referenced by loadRowsAhead().
|
protected |
Periodically sends notifyFileSize signal.
event |
Definition at line 168 of file ZblLogReader.cpp.
|
static |
Must be called only once before calling newLogReader();.
logRecordRoleCount | Number of roles in a log record. |
Definition at line 75 of file ZblLogReader.cpp.
Referenced by Zbl::ZLogReader::registerType().
|
staticprotected |
number of rows in a default page.
Definition at line 502 of file ZblLogReader.h.
|
protected |
true if input file is open and ready for reading, false otherwise.
Definition at line 467 of file ZblLogReader.h.
Referenced by close(), openFile(), and timerEvent().
|
protected |
File position of the first log record of the search operation.
Definition at line 553 of file ZblLogReader.h.
Referenced by initializeMetadata().
|
protected |
Input file object from which log records will be read.
Definition at line 461 of file ZblLogReader.h.
Referenced by close(), initializeMetadata(), loadRecordLinkMessageText(), loadRowsAhead(), loadRowsBehind(), loadViewport(), openFile(), and timerEvent().
|
staticprotected |
Histogram buffer caches bytes of file data for subsequent parsing into log records.
The page map caches the seek location of pages already scanned to speed up subsequent viewport operations. locks the thread and instance counter objects.
Definition at line 486 of file ZblLogReader.h.
Referenced by newLogReader().
|
staticprotected |
The maximum number of bytes a log record can contain.
Definition at line 520 of file ZblLogReader.h.
Referenced by initializeMetadata(), loadRecordLinkMessageText(), loadRowsAhead(), and loadRowsBehind().
|
protected |
A QVariantMap containing meta information about the log file.
This object is stored as a JSON object in the log file's first record, after the log file's identifying UUID
Definition at line 536 of file ZblLogReader.h.
Referenced by initializeMetadata().
|
protected |
a file for storing metadata (bookmarks, notations, identification) about the log file.
Definition at line 527 of file ZblLogReader.h.
|
staticprotected |
Counts instances of ZblLogReader objects.
Definition at line 497 of file ZblLogReader.h.
Referenced by newLogReader().
|
staticprotected |
A single background thread services all ZblLogReader objects.
Definition at line 491 of file ZblLogReader.h.
Referenced by newLogReader().
|
staticprotected |
Number of roles in a log record.
Definition at line 508 of file ZblLogReader.h.
Referenced by loadRecordLinkMessageText(), parseNextFileRecord(), and zInit().
|
protected |
Timer ID for file size timer. Zero == timer inactive.
Definition at line 559 of file ZblLogReader.h.
Referenced by close(), and openFile().
|
staticprotected |
The number of rows to accumulate before sending a row update to the data model. Batching rows reduces thread context switching overhead.
Definition at line 514 of file ZblLogReader.h.
Referenced by loadRowsAhead().
|
protected |
A UUID that uniquely identifies this log file.
This ID is used to link Zuble log files to their corresponding log notation files. This value is stored as GUID-formatted hex string at file seek position zero. It is immediately followed in the log file by a JSON object containing the log file's metadata if that information is available.
Definition at line 547 of file ZblLogReader.h.
Referenced by initializeMetadata().
Zuble documentation copyright © 2019 Bob Dinitto. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Zuble is a derivative work of Qt version 5. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.