Zuble QML Types   |  Zuble C++ Classes   |  Table of Contents

Zuble Core Services - Cog


The Cog is an internal singleton object (ZblCog) that provides binary resource management and sprocket object factory services to Zuble applications. Sprockets are QML extension plugins that extend Zuble's core capabilities or add custom C++ code to Zuble QML applications.

QML code uses the Zbl object to access ZblCog features. C++ code can call ZblCog::zInstance() or use the zCog macro to obtain a reference to the ZblCog object.

Binary Resource Manager

The binary resource manager allows Zuble applications to link a uri to a resource file path such that the resource can be referenced by uri rather than file name in the application code. Resource files can then be mapped to a resource uri and loaded dynamically through either the C++ or Javascript API, or by specifying the resource in the Zuble application configuration file (zblconfig.xml).

This allows Zuble applications to switch binary resources containing images and QML code by simply editing the resource bundle mapping in the zblconfig.xml file. This feature is intended to ease implementation of application localization but could serve other purposes as well.

Additionally QML extension plugins such as sprockets can specify a resource bundle within the plugin's metadata for use by the plugin. The plugin resource bundle can then be loaded automatically by the resource manager either before or after the plugin is loaded. This allows Zuble's QML types, images and other binary data to easily be packaged and deployed with Zuble sprocket plugins in a standardized format.

Sprocket Object Factory

The ZblCog object manages Zuble sprockets by creating object factories for Zuble background script threads so scripts can create Zuble objects using the Zbl API. Sprockets use the ZblCog::registerSprocket() and ZblCog::registerSprocketObject() methods to register sprocket objects to be included in object factories created by ZblCog.