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
ZLogReader.h
Go to the documentation of this file.
1 /*
2  * Zuble - A run-time system for QML/Javascript applications
3  * Copyright (C) 2015 Bob Dinitto
4  *
5  * Filename: ZLogReader.h
6  * Created on: 11/16/2015
7  * Author: Bob Dinitto
8  *
9  * Zuble is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  *
23  */
24 
25 #ifndef ZLOGREADER_H
26 #define ZLOGREADER_H
27 
28 #include <QObject>
29 #include <QFile>
30 #include <QObjectCleanupHandler>
31 #include "ZLogMap.h"
32 #include "ZLogSearch.h"
33 #include "ZblLogSearch.h"
34 #include "zglobal.h"
35 
36 namespace Zbl
37 {
38 
39 class ZTableModel;
40 class ZblLogReader;
41 class ZblLogBkSearch;
42 class ZLogViewport;
43 
62 class ZLogReader : public QObject
63 {
64  Q_OBJECT
65 
66 public:
67 
68  typedef QMap<qint64, QStringList> zMarkSet;
69 
76  explicit ZLogReader(QObject *parent = 0);
77 
82  virtual ~ZLogReader();
83 
87  static void registerType();
88 
89 
95  Q_PROPERTY(bool ready READ getReady)
96 
97 
101  Q_PROPERTY(QString filePath READ getFilePath)
102 
110  bool getReady();
111 
117  QString getFilePath();
118 
130 
143  Q_INVOKABLE QObject* getSearchModel();
144 
150  Q_INVOKABLE bool hasSearch(const QString& searchPhrase, int searchType, QList<int> searchRoles);
151 
152 
174  Q_INVOKABLE QObject* getSearch(const QString& searchPhrase, int searchType, QList<int> searchRoles);
175 
176 
185  Q_INVOKABLE zblLogSearchPtr getZSearch(const QString& searchPhrase, int searchType, QList<int> searchRoles);
186 
187 
188 
189 
190 
191 
192 signals:
193 
201  void openComplete(QString filePath, bool success, QString errorMsg);
202 
207  void closeAlert();
208 
209 
210 #if 0
211 
221  void loadComplete(QObject* viewport, QString errorMsg);
222 
223 #endif
224 
230  void bookmarksUpdated();
231 
237  void searchCreated(QObject* searchObject);
238 
249  void releaseSearchReferences(QString searchObjectName);
250 
251 
256  void notifyFileSize(qint64 fileSize);
257 
258 
259 public slots:
260 
261 #if 0
262 
270  void openLogFile(const QString& filePath);
271 
272 #endif
273 
282  void onBackgroundOpenComplete(bool success, QString errorMsg, QVariantMap contextMap);
283 
284 #if 0
285 
291  void onBackgroundLoadIndexComplete(
292  QObject* viewport,
293  QString errorMsg,
294  QVariantMap contextMap);
295 #endif
296 
302  void openFile(const QString& filePath);
303 
311  QObject* newViewport();
312 
319  void close();
320 
333  QObject* newBookmark(const QString& name);
334 
343  QObject* getBookmark(const QString& name);
344 
345 
346 
347 #if 0
348 
373  bool updateLogmark(const QObject* logMark, const QString& name = QString());
374 
375 #endif
376 
400  bool setLogmapParameters(const QObject* parameters, const QString& name);
401 
414  bool deleteBookmark(const QString& name);
415 
427  bool deleteSearch(QObject* search);
428 
429 
430 
443  QMap<qint64, QStringList> getBookmarkSet(qint64 firstID, qint64 lastID);
444 
451  QStringList getBookmarkNames(qint64 recordID);
452 
453 
466  QMap<qint64, QStringList> getSearchmarkSet(qint64 firstID, qint64 lastID);
467 
468 
469 #if 0
470 
481  void purgeSearch();
482 #endif
483 
484 #if 0
485 
493  int getMarkTypes(qint64 recordID);
494 
495 
503  QList<QObject*> getMarks(qint64 recordID, int markTypes);
504 #endif
505 
506 protected:
507 
508  bool hasBookmark(const QString& name);
509 
510  bool hasSearchMap(const QString& searchName);
511 
512  void appendSearchModel(zblLogSearchPtr search);
513 
514  //void populateSearchModel(QSharedPointer<ZTableModel> model);
515 
516  void removeSearchModel(ZblLogSearch* search);
517 
518  void purgeSearchModel();
519 
520 
521 
522  //zblLogSearchPtr getZSearch(const QString& searchPhrase, int searchType, QList<int> searchRoles);
523 
524 
525 
527 
534 
540  bool m_ready;
541 
546  QString m_filePath;
547 
568 
569 
570 
571 
578  QMap<QString, QWeakPointer<ZblLogSearch> > m_searchmarks;
579 
585 
586 };
587 
588 } // Zbl
589 
590 #endif // ZLOGREADER_H
Q_INVOKABLE QObject * getSearchModel()
Obtain a pointer to the data model containing search objects for this log file.
Definition: ZLogReader.cpp:502
QMap< qint64, QStringList > zMarkSet
Definition: ZLogReader.h:68
virtual ~ZLogReader()
Virtual object destructor.
Definition: ZLogReader.cpp:72
QObject * getBookmark(const QString &name)
Obtains the bookmark or searchmark with the given name.
Definition: ZLogReader.cpp:274
static void registerType()
Registers ZLogReader as a QML type.
Definition: ZLogReader.cpp:78
bool deleteBookmark(const QString &name)
Remove the specified bookmark or searchmark by name.
Definition: ZLogReader.cpp:585
#define ZBL_DECLARE_LOGGED_OBJECT
Definition: zglobal.h:94
void openFile(const QString &filePath)
Opens the log file in a background thread concurrently but does not load it. Sends the openComplete s...
Definition: ZLogReader.cpp:176
This class performs log file I/O operations and JSON parsing in a background thread on behalf of a ZL...
Definition: ZblLogReader.h:91
ZLogBookmark::zLogBookmarkList m_bookmarks
A central repository for log file marks. This is the definitive mark list for the log file...
Definition: ZLogReader.h:567
bool setLogmapParameters(const QObject *parameters, const QString &name)
Updates the specified logmark parameters (note, search type) for the bookmark with the specified name...
Definition: ZLogReader.cpp:578
A QML type that manages reading JSON formatted Zuble log files. QML programs create using Zbl...
Definition: ZLogReader.h:62
ZblLogReader * getBackgroundReader()
Obtains a pointer to the background reader object that services this log file.
Definition: ZLogReader.cpp:226
ZLogReader(QObject *parent=0)
Object constructor.
Definition: ZLogReader.cpp:48
QMap< qint64, QStringList > getBookmarkSet(qint64 firstID, qint64 lastID)
Returns a map containing log mark information for the specified set of log records.
Definition: ZLogReader.cpp:629
ZBL_DECLARE_LOGGED_OBJECT ZblLogReader * m_reader
A log reader worker object to perform log file input and parsing operations in a background thread...
Definition: ZLogReader.h:533
void onBackgroundOpenComplete(bool success, QString errorMsg, QVariantMap contextMap)
Called by the background thread when file has been opened.
Definition: ZLogReader.cpp:122
void closeAlert()
Sent when the close() function has been called.
void bookmarksUpdated()
Sent when the master log mark database has been updated.
bool m_ready
true when when log file is opened and ready to be used, false otherwise.
Definition: ZLogReader.h:540
Q_INVOKABLE zblLogSearchPtr getZSearch(const QString &searchPhrase, int searchType, QList< int > searchRoles)
Obtains or creates a search mark with the given search parameters.
Definition: ZLogReader.cpp:358
bool getReady()
Obtains the state of the ready flag..
Definition: ZLogReader.cpp:216
void notifyFileSize(qint64 fileSize)
Periodically signals the current log file size.
Definition: ZAndGate.cpp:6
QObject * newBookmark(const QString &name)
Creates a new ZLogBookmark object and returns it.
Definition: ZLogReader.cpp:232
QObject * newViewport()
Obtains a new empty foreground ZLogViewport object on the log file.
Definition: ZLogReader.cpp:207
void appendSearchModel(zblLogSearchPtr search)
Definition: ZLogReader.cpp:439
bool hasSearchMap(const QString &searchName)
Definition: ZLogReader.cpp:556
QStringList getBookmarkNames(qint64 recordID)
Obtains a list of bookmark names for the specified log record.
Definition: ZLogReader.cpp:657
void releaseSearchReferences(QString searchObjectName)
Sent when a request to delete a ZLogSearch object has been received.
bool ready
true when the log file is opened and ready to be used, false otherwise
Definition: ZLogReader.h:95
This two dimensional table model is used to store and manipulate data.
Definition: ZTableModel.h:96
QSharedPointer< ZblLogSearch > zblLogSearchPtr
Definition: ZblLogSearch.h:681
Q_INVOKABLE QObject * getSearch(const QString &searchPhrase, int searchType, QList< int > searchRoles)
Obtains or creates the searchmark with the given search parameters.
Definition: ZLogReader.cpp:512
void purgeSearchModel()
Definition: ZLogReader.cpp:484
void removeSearchModel(ZblLogSearch *search)
Definition: ZLogReader.cpp:456
void close()
Close the log file input object and release resources.
Definition: ZLogReader.cpp:191
Q_INVOKABLE bool hasSearch(const QString &searchPhrase, int searchType, QList< int > searchRoles)
Determine if a specific search object exists.
Definition: ZLogReader.cpp:507
QString filePath
Path to the log file being read by this object.
Definition: ZLogReader.h:101
void searchCreated(QObject *searchObject)
Sent when a new search object has been created.
bool hasBookmark(const QString &name)
Definition: ZLogReader.cpp:545
QString m_filePath
Path to log file being read.
Definition: ZLogReader.h:546
QString getFilePath()
Obtains the path to the log file.
Definition: ZLogReader.cpp:221
ZTableModel * m_model
A data model used to display search objects.
Definition: ZLogReader.h:584
QMap< QString, QWeakPointer< ZblLogSearch > > m_searchmarks
A central repository for log file marks. This is the definitive mark list for the log file...
Definition: ZLogReader.h:578
This object encapsulates search operation parameters, results, and steady state.
Definition: ZblLogSearch.h:35
QMap< qint64, QStringList > getSearchmarkSet(qint64 firstID, qint64 lastID)
Returns a map containing log mark information for the specified set of log records.
Definition: ZLogReader.cpp:689
bool deleteSearch(QObject *search)
Remove the specified search object from the search map and model.
Definition: ZLogReader.cpp:593
void openComplete(QString filePath, bool success, QString errorMsg)
Sent when an openFile() operation has completed;.
QList< ZLogBookmark * > zLogBookmarkList
Definition: ZLogBookmark.h:57