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 | Signals | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Static Private Attributes | List of all members
Zbl::ZApplication Class Reference

Zuble's Singleton Application Object. More...

#include <ZApplication.h>

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

Public Types

enum  zAppDataTag {
  appDirPath, appFilePath, appName, appPid,
  appVersion, appArguments, appLibraryPath
}
 
typedef enum Zbl::ZApplication::zAppDataTag appDataTag
 

Signals

void settingsBundleAvailable (QString bundleId)
 This signal is sent by the settings bundle manager when an application settings bundle is added to the settings bundle map. More...
 

Public Member Functions

 ZApplication (QObject *parent=nullptr)
 Don't construct this. Use zInit and zInstance instead. More...
 
bool zInit ()
 Initializes the application settings from information in the Zuble application's settings metadata file. More...
 
void addThreadApp (ZblApp *appObject)
 Adds the specified ZblApp object to the list of running thread applications. More...
 
void removeThreadApp (ZblApp *appObject)
 Removes the specified ZblApp object from the list of running thread applications. More...
 
ZTextFeedzStatus ()
 Obtains Zuble's main status text feed. Output text sent to this feed is broadcast to all Zuble status subscribers. Connect to the ZTextFeed::dataReady signal to subscribe to the status stream. More...
 
Q_INVOKABLE QVariant getAppData (int tag)
 Obtains application object data for background threads. More...
 

Static Public Member Functions

static QString resolvePath (const QString &path, bool includeUrlScheme=true)
 Converts relative file paths into canonical file paths. Paths prefixed with prefix are mapped relative to the root path. More...
 
static QString resolvePath (const QString &prefix, const QString &root, const QString &path, bool includeUrlScheme=true)
 Converts relative file paths into canonical file paths. Paths prefixed with prefix are mapped relative to the root path. More...
 
static QString getPathScheme (const QString &path)
 Obtains the scheme part of a URL path. More...
 
static QString removePathScheme (const QString &path)
 Removes the scheme part from a URL path. More...
 
static bool hasPathScheme (const QString &path)
 Determines if a URL contains a scheme. More...
 
static QString getRootPath ()
 Obtains the canonical path to the Zuble application's root directory. More...
 
static QString getMainQmlPath ()
 Obtains the canonical path to the Zuble application's main QML file. More...
 
static QString getDataPath ()
 Obtains the canonical path to the Zuble application's data directory. More...
 
static QString getAppName ()
 Obtains the name of the Zuble application. More...
 
static QString getOrganization ()
 Obtains the organization of the Zuble application. More...
 
static QString getCurrentThreadAddress ()
 Returns the human-readable memory address of the current thread. More...
 
static QString getObjectThreadAddress (QObject *object)
 Returns the human-readable memory address of the specified object's thread. More...
 
static void debugObjectThreadAddress (const char *label, QObject *obj)
 Sends object's thread address to qDebug. More...
 
static void debugCompareThreadAddress (const char *label, QObject *obj)
 Sends both current thread address and object's thread address to qDebug. More...
 
static void debugCurrentThreadAddress (const char *label)
 Sends current thread address to qDebug. More...
 
static void debugGuiThreadAddress (const char *label)
 Sends QApplication's thread address to qDebug. More...
 

Static Public Attributes

static const QString m_appPathPrefix = "zbl://"
 URL scheme used to specify Zuble app directory location: "zbl://". More...
 
static const QString m_homePathPrefix = "home://"
 URL scheme used to specify user's home directory location: "home://". More...
 
static const QString m_dataPathPrefix = "data://"
 URL scheme used to specify user's Zuble data directory location: "data://". More...
 
static const QString m_fileUrlPrefix = "file://"
 URL scheme used to specify local file location: "file://". More...
 
static const QString m_resourcePathPrefix = "qrc://"
 URL scheme used to specify Qt binary resource location: "qrc://". More...
 

Protected Member Functions

bool initDefaultApplicationSettings ()
 Checks the Zuble application directory for a settings metafile and uses it if found. Otherwise checks for a default settings metafile, creates a default metafile if that doesn't exist, and uses the default metafile instead. More...
 

Static Private Attributes

static QList< ZblApp * > m_zappObjects
 
static ZTextFeed m_status
 The main application status text feed. More...
 
static const QString m_defaultOrganization = "zubleapp"
 The Zuble application default organization name, "zuble". More...
 
static const QString m_defaultApplication = ZApplication::getAppName()
 The Zuble application default application name. More...
 
static const QString m_defaultSettingsID = "default"
 The Zuble application settings application name. More...
 
static const QString m_defaultZubleAppSettings
 Settings metadata to use when no other settings data can be found. More...
 
static const QString m_settingMetadataFileName = "zblsettings.xml"
 Name of default settings metadata file in Zuble application directory. More...
 
static const QString m_settingMetadataInitName = "zblinitset.xml"
 Name of default settings metadata file in user's home directory, created if no metadata file found in application directory. More...
 

Detailed Description

Zuble's Singleton Application Object.

This is an application process-wide singleton object that runs in the foreground Qt thread. It acts as an interface to the QApplication object for Zuble applications and provides cross-thread services.

TBD: add setDefaultLocale method to call QLocale::setDefault()

Definition at line 54 of file ZApplication.h.

Member Typedef Documentation

◆ appDataTag

These integer keys are used by Zuble background threads to request information from the Zuble applicaiton object running in the main thread.

see the getAppData method for more informaiton

Member Enumeration Documentation

◆ zAppDataTag

These integer keys are used by Zuble background threads to request information from the Zuble applicaiton object running in the main thread.

see the getAppData method for more informaiton

Enumerator
appDirPath 
appFilePath 
appName 
appPid 
appVersion 
appArguments 
appLibraryPath 

Definition at line 68 of file ZApplication.h.

Constructor & Destructor Documentation

◆ ZApplication()

Zbl::ZApplication::ZApplication ( QObject *  parent = nullptr)

Don't construct this. Use zInit and zInstance instead.

Definition at line 124 of file ZApplication.cpp.

Member Function Documentation

◆ addThreadApp()

void Zbl::ZApplication::addThreadApp ( ZblApp appObject)

Adds the specified ZblApp object to the list of running thread applications.

Parameters
appObjectThe ZblApp object to add

Definition at line 538 of file ZApplication.cpp.

◆ debugCompareThreadAddress()

void Zbl::ZApplication::debugCompareThreadAddress ( const char *  label,
QObject *  obj 
)
static

Sends both current thread address and object's thread address to qDebug.

Definition at line 529 of file ZApplication.cpp.

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

◆ debugCurrentThreadAddress()

void Zbl::ZApplication::debugCurrentThreadAddress ( const char *  label)
static

Sends current thread address to qDebug.

Definition at line 519 of file ZApplication.cpp.

Referenced by debugCompareThreadAddress().

◆ debugGuiThreadAddress()

void Zbl::ZApplication::debugGuiThreadAddress ( const char *  label)
static

Sends QApplication's thread address to qDebug.

Definition at line 524 of file ZApplication.cpp.

Referenced by debugCompareThreadAddress().

◆ debugObjectThreadAddress()

void Zbl::ZApplication::debugObjectThreadAddress ( const char *  label,
QObject *  obj 
)
static

Sends object's thread address to qDebug.

Definition at line 514 of file ZApplication.cpp.

Referenced by debugCompareThreadAddress().

◆ getAppData()

QVariant Zbl::ZApplication::getAppData ( int  tag)

Obtains application object data for background threads.

Objects running in the main thread should call QApplication methods directly instead of calling this method.

Use QMetaObject::invokeMethod with a connection type of Qt::BlockingQueuedConnection to call this method from a background thread. The background thread will block until foreground thread obtains the requested data. (WARNING: don't use Qt::BlockingQueuedConnection for code running in the main thread!)

Parameters
tagA value that determines what kind of data is returned from the data request. It must be one of the appDataTag enumeration values.
Returns
A variant object containing the requested data, or an invalid variant object if the tag was not a valid appDataTag value.

Definition at line 450 of file ZApplication.cpp.

◆ getAppName()

QString Zbl::ZApplication::getAppName ( )
static

Obtains the name of the Zuble application.

Returns

Definition at line 430 of file ZApplication.cpp.

Referenced by Zbl::ZSettings::getBundleSettings(), getDataPath(), and Zbl::ZSettings::insertBundle().

◆ getCurrentThreadAddress()

QString Zbl::ZApplication::getCurrentThreadAddress ( )
static

Returns the human-readable memory address of the current thread.

Definition at line 504 of file ZApplication.cpp.

Referenced by debugCurrentThreadAddress(), Zbl::ZblApp::getCurrentThreadAddress(), and Zbl::ZblLogManager::zInit().

◆ getDataPath()

QString Zbl::ZApplication::getDataPath ( )
static

Obtains the canonical path to the Zuble application's data directory.

Returns

Definition at line 384 of file ZApplication.cpp.

Referenced by Zbl::ZSettings::getBundleSettings(), initDefaultApplicationSettings(), and resolvePath().

◆ getMainQmlPath()

QString Zbl::ZApplication::getMainQmlPath ( )
static

Obtains the canonical path to the Zuble application's main QML file.

Returns

Definition at line 419 of file ZApplication.cpp.

Referenced by Zbl::ZblApp::getMainQmlPath().

◆ getObjectThreadAddress()

QString Zbl::ZApplication::getObjectThreadAddress ( QObject *  object)
static

Returns the human-readable memory address of the specified object's thread.

Definition at line 487 of file ZApplication.cpp.

Referenced by debugGuiThreadAddress(), debugObjectThreadAddress(), getCurrentThreadAddress(), Zbl::ZblApp::getObjectThreadAddress(), Zbl::Zblcore::registerTypes(), and Zbl::ZblLogManager::zInit().

◆ getOrganization()

QString Zbl::ZApplication::getOrganization ( )
static

Obtains the organization of the Zuble application.

Returns

Definition at line 440 of file ZApplication.cpp.

Referenced by getDataPath(), and Zbl::ZSettings::insertBundle().

◆ getPathScheme()

QString Zbl::ZApplication::getPathScheme ( const QString &  path)
static

Obtains the scheme part of a URL path.

Parameters
pathThe URL from which to extract the scheme.
Returns
The URL scheme, or an empty string if the URL has no scheme.

Definition at line 327 of file ZApplication.cpp.

Referenced by Zbl::ZblApp::isResourcePath(), Zbl::ZxQuery::setFocusUrl(), and Zbl::ZxQuery::setQueryUrl().

◆ getRootPath()

QString Zbl::ZApplication::getRootPath ( )
static

Obtains the canonical path to the Zuble application's root directory.

Returns

Definition at line 409 of file ZApplication.cpp.

Referenced by getMainQmlPath(), Zbl::ZblApp::getRootPath(), initDefaultApplicationSettings(), Zbl::ZblApp::resolveAppPath(), and resolvePath().

◆ hasPathScheme()

bool Zbl::ZApplication::hasPathScheme ( const QString &  path)
static

Determines if a URL contains a scheme.

A URL is determined to contain a scheme if the first forward slash character is immediately followed by a colon, ie: ":/"

Examples:

"file://home/bob/hello" hasPathScheme() == true

"/home/bob/hello" hasPathScheme() == false

"/file:home/bob/hello" hasPathScheme() == false

Parameters
pathThe URL to test for a scheme
Returns
true if the URL has a scheme, false otherwise.

Definition at line 368 of file ZApplication.cpp.

Referenced by resolvePath().

◆ initDefaultApplicationSettings()

bool Zbl::ZApplication::initDefaultApplicationSettings ( )
protected

Checks the Zuble application directory for a settings metafile and uses it if found. Otherwise checks for a default settings metafile, creates a default metafile if that doesn't exist, and uses the default metafile instead.

Returns
true if app settings bundle loaded sucessfully

Definition at line 148 of file ZApplication.cpp.

Referenced by zInit().

◆ removePathScheme()

QString Zbl::ZApplication::removePathScheme ( const QString &  path)
static

Removes the scheme part from a URL path.

Parameters
pathThe URL from which to remove the scheme.
Returns
The URL path minus the scheme.

Definition at line 346 of file ZApplication.cpp.

◆ removeThreadApp()

void Zbl::ZApplication::removeThreadApp ( ZblApp appObject)

Removes the specified ZblApp object from the list of running thread applications.

Parameters
appObjectThe ZblApp object to add

Definition at line 560 of file ZApplication.cpp.

◆ resolvePath() [1/2]

QString Zbl::ZApplication::resolvePath ( const QString &  path,
bool  includeUrlScheme = true 
)
static

Converts relative file paths into canonical file paths. Paths prefixed with prefix are mapped relative to the root path.

example: zbl://myfile.js for prefix "zbl" and root path /zuble/apps and app "myapp" is converted to "file:///zuble/apps/myapp/myfile.js"

Parameters
pathFile path to be converted
includeUrlSchemereturned path will be prefixed with "file://" if true (default), set false to remove "file://" prefix from returned path

Definition at line 280 of file ZApplication.cpp.

Referenced by Zbl::ZblLogAgent::createLogFile(), Zbl::ZblLogWorker::createLogFile(), Zbl::ZblLogManager::createTemporaryLogProfile(), initDefaultApplicationSettings(), Zbl::ZSettings::insertBundle(), Zbl::ZblLogManager::loadCurrentLogProfile(), Zbl::ZSettings::open(), Zbl::ZxQuery::ResourceUrlFile::open(), Zbl::ZblLogReader::openFile(), Zbl::ZSettings::rectifySettingsDataPath(), Zbl::ZblApp::resolveAppPath(), Zbl::ZblApp::resolveHomePath(), Zbl::ZblApp::resolvePath(), and Zbl::ZFile::setFileName().

◆ resolvePath() [2/2]

QString Zbl::ZApplication::resolvePath ( const QString &  prefix,
const QString &  root,
const QString &  path,
bool  includeUrlScheme = true 
)
static

Converts relative file paths into canonical file paths. Paths prefixed with prefix are mapped relative to the root path.

example: zbl://myfile.js for prefix "zbl" and root path /zuble/apps and app "myapp" is converted to "file:///zuble/apps/myapp/myfile.js"

Parameters
prefix
rootRoot path to be prepended in place of "zbl://" prefix
pathFile path to be converted
includeUrlSchemereturned path will be prefixed with "file://" if true (default), set false to remove "file://" prefix from returned path

Definition at line 250 of file ZApplication.cpp.

◆ settingsBundleAvailable

void Zbl::ZApplication::settingsBundleAvailable ( QString  bundleId)
signal

This signal is sent by the settings bundle manager when an application settings bundle is added to the settings bundle map.

Parameters
bundleId

Referenced by Zbl::ZblLogManager::setApplicationObject().

◆ zInit()

bool Zbl::ZApplication::zInit ( )

Initializes the application settings from information in the Zuble application's settings metadata file.

If a metadata file is not found default settings from the zuble core plugin resource file are used.

Returns
true if app settings initialized successfully

Definition at line 134 of file ZApplication.cpp.

◆ zStatus()

ZTextFeed & Zbl::ZApplication::zStatus ( )

Obtains Zuble's main status text feed. Output text sent to this feed is broadcast to all Zuble status subscribers. Connect to the ZTextFeed::dataReady signal to subscribe to the status stream.

Returns
A reference to the ZTextFeed object that represents Zuble's main status text stream

Definition at line 244 of file ZApplication.cpp.

Member Data Documentation

◆ m_appPathPrefix

const QString Zbl::ZApplication::m_appPathPrefix = "zbl://"
static

URL scheme used to specify Zuble app directory location: "zbl://".

Definition at line 340 of file ZApplication.h.

Referenced by Zbl::ZblApp::resolveAppPath(), and resolvePath().

◆ m_dataPathPrefix

const QString Zbl::ZApplication::m_dataPathPrefix = "data://"
static

URL scheme used to specify user's Zuble data directory location: "data://".

Definition at line 352 of file ZApplication.h.

Referenced by initDefaultApplicationSettings(), and resolvePath().

◆ m_defaultApplication

const QString Zbl::ZApplication::m_defaultApplication = ZApplication::getAppName()
staticprivate

The Zuble application default application name.

Definition at line 397 of file ZApplication.h.

◆ m_defaultOrganization

const QString Zbl::ZApplication::m_defaultOrganization = "zubleapp"
staticprivate

The Zuble application default organization name, "zuble".

Definition at line 391 of file ZApplication.h.

Referenced by getDataPath(), and getOrganization().

◆ m_defaultSettingsID

const QString Zbl::ZApplication::m_defaultSettingsID = "default"
staticprivate

The Zuble application settings application name.

Definition at line 403 of file ZApplication.h.

Referenced by initDefaultApplicationSettings().

◆ m_defaultZubleAppSettings

const QString Zbl::ZApplication::m_defaultZubleAppSettings
staticprivate

Settings metadata to use when no other settings data can be found.

Definition at line 409 of file ZApplication.h.

Referenced by initDefaultApplicationSettings().

◆ m_fileUrlPrefix

const QString Zbl::ZApplication::m_fileUrlPrefix = "file://"
static

URL scheme used to specify local file location: "file://".

Definition at line 358 of file ZApplication.h.

Referenced by resolvePath().

◆ m_homePathPrefix

const QString Zbl::ZApplication::m_homePathPrefix = "home://"
static

URL scheme used to specify user's home directory location: "home://".

Definition at line 346 of file ZApplication.h.

Referenced by Zbl::ZblApp::resolveHomePath(), and resolvePath().

◆ m_resourcePathPrefix

const QString Zbl::ZApplication::m_resourcePathPrefix = "qrc://"
static

URL scheme used to specify Qt binary resource location: "qrc://".

Definition at line 364 of file ZApplication.h.

Referenced by resolvePath().

◆ m_settingMetadataFileName

const QString Zbl::ZApplication::m_settingMetadataFileName = "zblsettings.xml"
staticprivate

Name of default settings metadata file in Zuble application directory.

Definition at line 416 of file ZApplication.h.

Referenced by initDefaultApplicationSettings().

◆ m_settingMetadataInitName

const QString Zbl::ZApplication::m_settingMetadataInitName = "zblinitset.xml"
staticprivate

Name of default settings metadata file in user's home directory, created if no metadata file found in application directory.

Definition at line 423 of file ZApplication.h.

Referenced by initDefaultApplicationSettings().

◆ m_status

ZTextFeed Zbl::ZApplication::m_status
staticprivate

The main application status text feed.

This feed accumulates status text messages from all parts of Zuble and broadcasts them to subscribers.

A Qt message handler may be set to redirect Qt messages to this text feed. TBD: is this true?

See also
captureQtMessages

Definition at line 383 of file ZApplication.h.

Referenced by zStatus().

◆ m_zappObjects

QList< ZblApp * > Zbl::ZApplication::m_zappObjects
staticprivate

Definition at line 369 of file ZApplication.h.

Referenced by addThreadApp(), and removeThreadApp().


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