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
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Properties | List of all members
Zbl::ZLogReader Class Reference

A QML type that manages reading JSON formatted Zuble log files. QML programs create using Zbl.newLogReader() More...

#include <ZLogReader.h>

Inheritance diagram for Zbl::ZLogReader:
Inheritance graph
[legend]
Collaboration diagram for Zbl::ZLogReader:
Collaboration graph
[legend]

Public Types

typedef QMap< qint64, QStringList > zMarkSet
 

Public Slots

void onBackgroundOpenComplete (bool success, QString errorMsg, QVariantMap contextMap)
 Called by the background thread when file has been opened. More...
 
void openFile (const QString &filePath)
 Opens the log file in a background thread concurrently but does not load it. Sends the openComplete signal when complete. More...
 
QObject * newViewport ()
 Obtains a new empty foreground ZLogViewport object on the log file. More...
 
void close ()
 Close the log file input object and release resources. More...
 
QObject * newBookmark (const QString &name)
 Creates a new ZLogBookmark object and returns it. More...
 
QObject * getBookmark (const QString &name)
 Obtains the bookmark or searchmark with the given name. More...
 
bool setLogmapParameters (const QObject *parameters, const QString &name)
 Updates the specified logmark parameters (note, search type) for the bookmark with the specified name or search phrase. More...
 
bool deleteBookmark (const QString &name)
 Remove the specified bookmark or searchmark by name. More...
 
bool deleteSearch (QObject *search)
 Remove the specified search object from the search map and model. More...
 
QMap< qint64, QStringList > getBookmarkSet (qint64 firstID, qint64 lastID)
 Returns a map containing log mark information for the specified set of log records. More...
 
QStringList getBookmarkNames (qint64 recordID)
 Obtains a list of bookmark names for the specified log record. More...
 
QMap< qint64, QStringList > getSearchmarkSet (qint64 firstID, qint64 lastID)
 Returns a map containing log mark information for the specified set of log records. More...
 

Signals

void openComplete (QString filePath, bool success, QString errorMsg)
 Sent when an openFile() operation has completed;. More...
 
void closeAlert ()
 Sent when the close() function has been called. More...
 
void bookmarksUpdated ()
 Sent when the master log mark database has been updated. More...
 
void searchCreated (QObject *searchObject)
 Sent when a new search object has been created. More...
 
void releaseSearchReferences (QString searchObjectName)
 Sent when a request to delete a ZLogSearch object has been received. More...
 
void notifyFileSize (qint64 fileSize)
 Periodically signals the current log file size. More...
 

Public Member Functions

 ZLogReader (QObject *parent=0)
 Object constructor. More...
 
virtual ~ZLogReader ()
 Virtual object destructor. More...
 
bool getReady ()
 Obtains the state of the ready flag.. More...
 
QString getFilePath ()
 Obtains the path to the log file. More...
 
ZblLogReadergetBackgroundReader ()
 Obtains a pointer to the background reader object that services this log file. More...
 
Q_INVOKABLE QObject * getSearchModel ()
 Obtain a pointer to the data model containing search objects for this log file. More...
 
Q_INVOKABLE bool hasSearch (const QString &searchPhrase, int searchType, QList< int > searchRoles)
 Determine if a specific search object exists. More...
 
Q_INVOKABLE QObject * getSearch (const QString &searchPhrase, int searchType, QList< int > searchRoles)
 Obtains or creates the searchmark with the given search parameters. More...
 
Q_INVOKABLE zblLogSearchPtr getZSearch (const QString &searchPhrase, int searchType, QList< int > searchRoles)
 Obtains or creates a search mark with the given search parameters. More...
 

Static Public Member Functions

static void registerType ()
 Registers ZLogReader as a QML type. More...
 

Protected Member Functions

bool hasBookmark (const QString &name)
 
bool hasSearchMap (const QString &searchName)
 
void appendSearchModel (zblLogSearchPtr search)
 
void removeSearchModel (ZblLogSearch *search)
 
void purgeSearchModel ()
 

Protected Attributes

ZBL_DECLARE_LOGGED_OBJECT ZblLogReaderm_reader
 A log reader worker object to perform log file input and parsing operations in a background thread. More...
 
bool m_ready
 true when when log file is opened and ready to be used, false otherwise. More...
 
QString m_filePath
 Path to log file being read. More...
 
ZLogBookmark::zLogBookmarkList m_bookmarks
 A central repository for log file marks. This is the definitive mark list for the log file, all others are copies. More...
 
QMap< QString, QWeakPointer< ZblLogSearch > > m_searchmarks
 A central repository for log file marks. This is the definitive mark list for the log file, all others are copies. More...
 
ZTableModelm_model
 A data model used to display search objects. More...
 

Properties

bool ready
 true when the log file is opened and ready to be used, false otherwise More...
 
QString filePath
 Path to the log file being read by this object. More...
 

Detailed Description

A QML type that manages reading JSON formatted Zuble log files. QML programs create using Zbl.newLogReader()

Zuble log files are created by the Zuble Log Manager's Qt log message handler. This class allows QML programs to read portions of JSON formatted log files into data models for display.

Each ZLogReader object represents a single open log file. One or more viewport objects (ZLogViewport) can be created as views on the file. Each viewport encapsulates a data model containing a subset of consecutive log records from the file. Viewports can be positioned at specified locations and can be scrolled forward and backward.

One or more search objects (ZLogSearch) can be created to perform background text search operations on some or all log records.

Definition at line 62 of file ZLogReader.h.

Member Typedef Documentation

◆ zMarkSet

typedef QMap<qint64, QStringList> Zbl::ZLogReader::zMarkSet

Definition at line 68 of file ZLogReader.h.

Constructor & Destructor Documentation

◆ ZLogReader()

Zbl::ZLogReader::ZLogReader ( QObject *  parent = 0)
explicit

Object constructor.

Parameters
parentThe parent of the this Object or null for no parent

Definition at line 48 of file ZLogReader.cpp.

◆ ~ZLogReader()

Zbl::ZLogReader::~ZLogReader ( )
virtual

Virtual object destructor.

Definition at line 72 of file ZLogReader.cpp.

Member Function Documentation

◆ appendSearchModel()

void Zbl::ZLogReader::appendSearchModel ( zblLogSearchPtr  search)
protected

Definition at line 439 of file ZLogReader.cpp.

Referenced by getZSearch().

◆ bookmarksUpdated

void Zbl::ZLogReader::bookmarksUpdated ( )
signal

Sent when the master log mark database has been updated.

Referenced by newBookmark(), and Zbl::ZLogViewport::ZLogViewport().

◆ close

void Zbl::ZLogReader::close ( )
slot

Close the log file input object and release resources.

All search objects for this log file reader will become invalidated.

Definition at line 191 of file ZLogReader.cpp.

Referenced by ~ZLogReader().

◆ closeAlert

void Zbl::ZLogReader::closeAlert ( )
signal

Sent when the close() function has been called.

Referenced by close().

◆ deleteBookmark

bool Zbl::ZLogReader::deleteBookmark ( const QString &  name)
slot

Remove the specified bookmark or searchmark by name.

Unnamed searchmarks can be removed by deleteSearchmark(const QString&)

Parameters
nameThe name of the bookmark or searchmark to remove
Returns
true if bookmark or searchmark was removed, false if it didn't exist

Definition at line 585 of file ZLogReader.cpp.

◆ deleteSearch

bool Zbl::ZLogReader::deleteSearch ( QObject *  search)
slot

Remove the specified search object from the search map and model.

WARNING: This will invalidate all existing wrappers to the specified search object.

Parameters
searchA ZLogSearch object representing the search to be deleted
Returns
true if search was removed, false if it didn't exist

Definition at line 593 of file ZLogReader.cpp.

◆ getBackgroundReader()

ZblLogReader * Zbl::ZLogReader::getBackgroundReader ( )

Obtains a pointer to the background reader object that services this log file.

The reader object runs in a background thread to service foreground file i/o requests.

Returns
A pointer to a ZblLogReader object.

Definition at line 226 of file ZLogReader.cpp.

Referenced by Zbl::ZblLogSearch::ZblLogSearch().

◆ getBookmark

QObject * Zbl::ZLogReader::getBookmark ( const QString &  name)
slot

Obtains the bookmark or searchmark with the given name.

Parameters
nameName of the bookmark to return
Returns
A ZLogBookmark or ZLogSearch object

Definition at line 274 of file ZLogReader.cpp.

◆ getBookmarkNames

QStringList Zbl::ZLogReader::getBookmarkNames ( qint64  recordID)
slot

Obtains a list of bookmark names for the specified log record.

Parameters
recordIDLog record ID for which bookmarks will be obtained
Returns
A list of bookmark names

Definition at line 657 of file ZLogReader.cpp.

Referenced by getBookmarkSet(), and Zbl::ZLogViewport::onUpdateBookmarks().

◆ getBookmarkSet

QMap< qint64, QStringList > Zbl::ZLogReader::getBookmarkSet ( qint64  firstID,
qint64  lastID 
)
slot

Returns a map containing log mark information for the specified set of log records.

A list of bookmark names is returned for each log record between the specified first and last log record ID.

Parameters
firstIDLog record ID of the first record in the set.
lastIDLog record ID of the last record in the set.
Returns
A map of log record ID's to string lists of bookmark names

Definition at line 629 of file ZLogReader.cpp.

◆ getFilePath()

QString Zbl::ZLogReader::getFilePath ( )

Obtains the path to the log file.

Returns
A QString containing the file path.

Definition at line 221 of file ZLogReader.cpp.

◆ getReady()

bool Zbl::ZLogReader::getReady ( )

Obtains the state of the ready flag..

Returns
true if file is open and ready to service requests, false if file is not yet opened.

Definition at line 216 of file ZLogReader.cpp.

◆ getSearch()

QObject * Zbl::ZLogReader::getSearch ( const QString &  searchPhrase,
int  searchType,
QList< int >  searchRoles 
)

Obtains or creates the searchmark with the given search parameters.

A new ZLogSearch object will be created to wrap either an existing ZblLogSearch object or a new ZblLogSearch object matching the specified parameters.

Parameters
searchPhraseSearch phrase of the given searchmark to return
searchTypeSearch type of the given serachmark to return
searchRolesA list of log viewport data model roles to search. Only roles in this list will be searched and highlighted. Other roles will be ignored.
Returns
A ZLogSearch object
See also
Zbl::ZLogSearch Zbl::ZblLogSearch

Definition at line 512 of file ZLogReader.cpp.

Referenced by Zbl::ZLogViewport::onSearchDeleteRequested().

◆ getSearchmarkSet

QMap< qint64, QStringList > Zbl::ZLogReader::getSearchmarkSet ( qint64  firstID,
qint64  lastID 
)
slot

Returns a map containing log mark information for the specified set of log records.

A list of searchmark search phrases is returned for each log record between the specified first and last log record ID.

Parameters
firstIDLog record ID of the first record in the set.
lastIDLog record ID of the last record in the set.
Returns
A map of log record ID's to string lists of search phrases

Definition at line 689 of file ZLogReader.cpp.

◆ getSearchModel()

QObject * Zbl::ZLogReader::getSearchModel ( )

Obtain a pointer to the data model containing search objects for this log file.

The model contains a ZLogSearch object wrapper for each extant ZblLogSearch object in the searchmark map. The model can be used to display search objects.

Returns
A ZTableModel object

Definition at line 502 of file ZLogReader.cpp.

◆ getZSearch()

zblLogSearchPtr Zbl::ZLogReader::getZSearch ( const QString &  searchPhrase,
int  searchType,
QList< int >  searchRoles 
)

Obtains or creates a search mark with the given search parameters.

Parameters
searchPhrase
searchType
searchRoles
Returns
A QSharedPointer<ZblLogSearch> smart pointer

Definition at line 358 of file ZLogReader.cpp.

Referenced by getSearch(), and Zbl::ZLogViewport::ZLogViewport().

◆ hasBookmark()

bool Zbl::ZLogReader::hasBookmark ( const QString &  name)
protected

Definition at line 545 of file ZLogReader.cpp.

Referenced by newBookmark().

◆ hasSearch()

bool Zbl::ZLogReader::hasSearch ( const QString &  searchPhrase,
int  searchType,
QList< int >  searchRoles 
)

Determine if a specific search object exists.

Definition at line 507 of file ZLogReader.cpp.

◆ hasSearchMap()

bool Zbl::ZLogReader::hasSearchMap ( const QString &  searchName)
protected

Definition at line 556 of file ZLogReader.cpp.

Referenced by hasSearch().

◆ newBookmark

QObject * Zbl::ZLogReader::newBookmark ( const QString &  name)
slot

Creates a new ZLogBookmark object and returns it.

Parameters
nameName of the bookmark. Bookmark names must be unique within the namespace for each log file.
Returns
A pointer to a ZLogBookmark object or NULL if the named bookmark object already exists.
See also
getBookmark(const QString& name)

Definition at line 232 of file ZLogReader.cpp.

◆ newViewport

QObject * Zbl::ZLogReader::newViewport ( )
slot

Obtains a new empty foreground ZLogViewport object on the log file.

Returns
A ZLogViewport object

Definition at line 207 of file ZLogReader.cpp.

◆ notifyFileSize

void Zbl::ZLogReader::notifyFileSize ( qint64  fileSize)
signal

Periodically signals the current log file size.

Parameters
fileSize

◆ onBackgroundOpenComplete

void Zbl::ZLogReader::onBackgroundOpenComplete ( bool  success,
QString  errorMsg,
QVariantMap  contextMap 
)
slot

Called by the background thread when file has been opened.

Parameters
successtrue if open successful, false if error
errorMsgerror message
contextMapopaque user-defined data

Definition at line 122 of file ZLogReader.cpp.

◆ openComplete

void Zbl::ZLogReader::openComplete ( QString  filePath,
bool  success,
QString  errorMsg 
)
signal

Sent when an openFile() operation has completed;.

Parameters
filePaththe path to the log file
successtrue if open successful, false if failed
errorMsgError message if success == false

Referenced by onBackgroundOpenComplete().

◆ openFile

void Zbl::ZLogReader::openFile ( const QString &  filePath)
slot

Opens the log file in a background thread concurrently but does not load it. Sends the openComplete signal when complete.

Parameters
filePathPath to a Zuble log file

Definition at line 176 of file ZLogReader.cpp.

◆ purgeSearchModel()

void Zbl::ZLogReader::purgeSearchModel ( )
protected

Definition at line 484 of file ZLogReader.cpp.

Referenced by close().

◆ registerType()

void Zbl::ZLogReader::registerType ( )
static

Registers ZLogReader as a QML type.

Definition at line 78 of file ZLogReader.cpp.

Referenced by Zbl::Zblcore::registerTypes().

◆ releaseSearchReferences

void Zbl::ZLogReader::releaseSearchReferences ( QString  searchObjectName)
signal

Sent when a request to delete a ZLogSearch object has been received.

The backing ZblLogSearch object will be released and all ZLogSearch objects that reference it will become invalid after this signal is sent.

Parameters
QStringA pointer to a ZLogSearch object that.

Referenced by deleteSearch().

◆ removeSearchModel()

void Zbl::ZLogReader::removeSearchModel ( ZblLogSearch search)
protected

Definition at line 456 of file ZLogReader.cpp.

Referenced by deleteSearch(), and getSearch().

◆ searchCreated

void Zbl::ZLogReader::searchCreated ( QObject *  searchObject)
signal

Sent when a new search object has been created.

Parameters
searchObjectA pointer to the new ZLogSearch object.

◆ setLogmapParameters

bool Zbl::ZLogReader::setLogmapParameters ( const QObject *  parameters,
const QString &  name 
)
slot

Updates the specified logmark parameters (note, search type) for the bookmark with the specified name or search phrase.

Each parameter in the specified dictionary of name/value pairs will be replaced. Parameters not in the dictionary will retain their original values.

If the specified bookmark or searchmark doesn't currently exist in ZLogReader's repository when this method is called no action is taken and false is returned.

Parameters
parametersa dictionary object containing name/value pairs for each parameter to be updated.
nameName or search phrase of the logmark object to be updated. Specify a name for bookmarks and named searchmarks or a search phrase for unnamed searchmarks.
Returns
true if update was successful, false otherwise

Definition at line 578 of file ZLogReader.cpp.

Member Data Documentation

◆ m_bookmarks

ZLogBookmark::zLogBookmarkList Zbl::ZLogReader::m_bookmarks
protected

A central repository for log file marks. This is the definitive mark list for the log file, all others are copies.

Marks are used to flag log file records for selection, for returning search results and for storing user-defined bookmarks. They're contained in ZLogMap objects, each of which defines a specific group of marks based on their source. All marks satisfying a specific search phrase are returned in a single ZLogMap, for example. All bookmarks with the same name occupy a single ZLogMap object.

Each log viewport contains a ZLogMap for the current selection. Thus each selection is independent and local to each viewport. Search results and bookmarks are shared between viewports. Both can optionally be stored in a notation file.

Mark lookups traverse the list of map objects.

Definition at line 567 of file ZLogReader.h.

Referenced by getBookmark(), getBookmarkNames(), hasBookmark(), and newBookmark().

◆ m_filePath

QString Zbl::ZLogReader::m_filePath
protected

Path to log file being read.

Definition at line 546 of file ZLogReader.h.

Referenced by getFilePath(), onBackgroundOpenComplete(), openFile(), purgeSearchModel(), and registerType().

◆ m_model

ZTableModel* Zbl::ZLogReader::m_model
protected

A data model used to display search objects.

Definition at line 584 of file ZLogReader.h.

Referenced by appendSearchModel(), getSearchModel(), purgeSearchModel(), and removeSearchModel().

◆ m_reader

ZBL_DECLARE_LOGGED_OBJECT ZblLogReader* Zbl::ZLogReader::m_reader
protected

A log reader worker object to perform log file input and parsing operations in a background thread.

Definition at line 533 of file ZLogReader.h.

Referenced by close(), getBackgroundReader(), newViewport(), onBackgroundOpenComplete(), openFile(), and registerType().

◆ m_ready

bool Zbl::ZLogReader::m_ready
protected

true when when log file is opened and ready to be used, false otherwise.

Definition at line 540 of file ZLogReader.h.

Referenced by close(), getReady(), and onBackgroundOpenComplete().

◆ m_searchmarks

QMap<QString, QWeakPointer<ZblLogSearch> > Zbl::ZLogReader::m_searchmarks
protected

A central repository for log file marks. This is the definitive mark list for the log file, all others are copies.

Definition at line 578 of file ZLogReader.h.

Referenced by close(), deleteSearch(), getSearch(), getZSearch(), and hasSearchMap().

Property Documentation

◆ filePath

QString Zbl::ZLogReader::filePath
read

Path to the log file being read by this object.

Definition at line 101 of file ZLogReader.h.

Referenced by openFile(), and registerType().

◆ ready

bool Zbl::ZLogReader::ready
read

true when the log file is opened and ready to be used, false otherwise

Definition at line 95 of file ZLogReader.h.


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