GCF LOGO VCL LOGO

This class abstracts the common functionalities provided by the different types of applications in GCF3. More...

#include <GCF3/Application>

Public Member Functions

QDateTime launchTimestamp () const
 
ObjectTreeobjectTree () const
 
QObject * findObject (const QString &path) const
 
void loadComponent (Component *component)
 
void unloadComponent (Component *component)
 
QObjectList components () const
 
void activateComponent (Component *component)
 
void deactivateComponent (Component *component)
 
bool isLoaded (const Component *component) const
 
bool isActive (const Component *component) const
 
void unloadAllComponents ()
 
ComponentinstantiateComponent (const QString &library)
 
ComponentloadComponent (const QString &library)
 
ComponentloadComponent (const QString &library, const QList< QPair< QByteArray, QVariant > > &properties)
 
QList< Component * > loadComponents (const QStringList &libraries)
 
QVariantMap argumentsMap () const
 
void processArguments (const QStringList &additionalArgs=QStringList())
 
GCF::Result invokeMethod (const QString &path, const QString &method, const QVariantList &args, bool secureCall=true) const
 This method can be used to invoke a named method in an object. More...
 
GCF::JobListModeljobs () const
 
QString translate (const QString &string) const
 

Static Public Member Functions

static GCF::Result invokeMethod (QObject *object, const QString &method, const QVariantList &args, bool secureCall=true)
 This method can be used to invoke a named method in an object. More...
 
static GCF::Result invokeMethod (QObject *object, const QMetaMethod &method, const QVariantList &args, bool secureCall=true)
 This method can be used to invoke a named method in an object. More...
 

Protected Member Functions

 ApplicationServices ()
 
virtual ~ApplicationServices ()
 

Detailed Description

All application configurations in GCF inherrit this class so that they can offer the following capabilities


Read about the GCF Component Model to learn how this can be used in the application.


The single global instance of this class in the application can be accessed using the gAppService global pointer.

Constructor & Destructor Documentation

GCF::ApplicationServices::ApplicationServices ( )
protected

Constructor

GCF::ApplicationServices::~ApplicationServices ( )
protectedvirtual

Destructor

Member Function Documentation

QDateTime GCF::ApplicationServices::launchTimestamp ( ) const

Returns the date-time at which application was launched.

GCF::ObjectTree * GCF::ApplicationServices::objectTree ( ) const

Returns the object-tree of the application.

QObject * GCF::ApplicationServices::findObject ( const QString &  path) const

Looks for the exposed object specfied by path in the application's object-tree, and returns it if found. Usage

gFindObject("Application.GCF_Component.ObjectType1");
Parameters
hierarchicalpath to the object inside object tree, separated by '.'
void GCF::ApplicationServices::loadComponent ( GCF::Component component)

Loads the component into the application. This function will add the specified component into the object tree and will initialize it. For more details on initialization refer GCF::Component.

Parameters
componentpointer to the component which needs to be loaded.
void GCF::ApplicationServices::unloadComponent ( GCF::Component component)

Unloads the component from the application. Unloading the component will remove the component node from the applciation's object-tree. For more details on unloading refer GCF::Component.

Parameters
componentpointer to the component which needs to be unloaded.
QObjectList GCF::ApplicationServices::components ( ) const
Returns
list of components loaded by the application.
void GCF::ApplicationServices::activateComponent ( GCF::Component component)

Activates the component specified by component. For more details refer to GCF::Component.

Note
to activate a component it should have been loaded by the application first.
Parameters
componentpointer to the component that needs to be activated.
void GCF::ApplicationServices::deactivateComponent ( GCF::Component component)

Deactivates the component specified by component. For more details refer to GCF::Component.

Note
to deactivate a component it should have been loaded by the application first.
Parameters
componentpointer to the component that needs to be deactivated.
bool GCF::ApplicationServices::isLoaded ( const Component component) const
Returns
true if component is loaded; false otherwise.
bool GCF::ApplicationServices::isActive ( const Component component) const
Returns
true if component is active; false otherwise.
void GCF::ApplicationServices::unloadAllComponents ( )

Unloads all the components loaded by the application. Also removes them from the object tree.

GCF::Component * GCF::ApplicationServices::instantiateComponent ( const QString &  libraryName)

Creates an instance of the component from the specified file. The instantiation will fail if the file does not exist or if version of the component is not same as the application version.

Note
This function does not load the component. For loading the component call GCF::ApplicationServices::loadComponent(Component * component) on the component pointer returned by this function.
Do not specify the file extension while invoking this function

Usage

GCF::Component *component = gApp->instantiateComponent("Components/SimpleComponent");
Parameters
libraryNamefull or relative path to the library file.
GCF::Component * GCF::ApplicationServices::loadComponent ( const QString &  libraryName)

Instantiates the component from the file libraryName and loads it.

Note
Do not specify the file extension while invoking this function

Usage

GCF::Component *component = gApp->loadComponent("Components/SimpleComponent");
Parameters
libraryNamefull or relative path to the library file.
GCF::Component * GCF::ApplicationServices::loadComponent ( const QString &  libraryName,
const QList< QPair< QByteArray, QVariant > > &  properties 
)

Overloads GCF::ApplicationServices::loadComponent(Component *component). Loads the specified component and initializes it with the properties specified in properties.

Usage

QList< QPair<QByteArray,QVariant> > properties;
properties << qMakePair<QByteArray,QVariant>("name", "ChangedSimpleComponent");
properties << qMakePair<QByteArray,QVariant>("parameter1", 20);
properties << qMakePair<QByteArray,QVariant>("property2", 456.123);
properties << qMakePair<QByteArray,QVariant>("date", QDate::currentDate());
GCF::Component *component = gApp->loadComponent("Components/SimpleComponent", properties);
Parameters
libraryNamepath to the library file.
propertiesproperties that needs to be set on component before loading
QList< Component * > GCF::ApplicationServices::loadComponents ( const QStringList &  libraries)

This function loops over each and every library name provided in libraries and invokes the loadComponent() method to load components. It returns a list of components that got loaded.

QVariantMap GCF::ApplicationServices::argumentsMap ( ) const
Returns
QVariantMap which contains all the command line arguments.
void GCF::ApplicationServices::processArguments ( const QStringList &  additionalArgs = QStringList())

Parses the list of arguments supplied to the application. This method expects the strings in the arguments to be in a "-key:value" format. This would then be loaded as <key, value> pair in to an internal map which can then be retrieved using GCF::ApplicationServices::argumentsMap().

By default this method processes –loadComponents argument as a command, and can be used to load a comma separated list of components.

Usage

QStringList args;
args << "--loadComponents:Components/SimpleComponent,Components/GuiComponent";
gApp->processArguments(args);
Parameters
additionalArgscan be used to supply additional arguments, and is optional.
GCF::Result GCF::ApplicationServices::invokeMethod ( const QString &  path,
const QString &  method,
const QVariantList &  args,
bool  secureCall = true 
) const
Parameters
pathcomplete path of the object in the objectTree()
methodname of the method to invoke in the object. (Only the name. Not the complete signature)
argslist of arguments to to pass to the method
secureCallif true, then the function will check for allowmetaaccess attribute. If false, then it will ignore the attribute.
Returns
Upon success this function will return a true. Calling data() on the returned result will provide the value returned by the invoked method.
Note
Only public methods and signals can be invoked by this function.
See Also
allowmetaaccess attribute
GCF::Result GCF::ApplicationServices::invokeMethod ( QObject *  object,
const QString &  method,
const QVariantList &  args,
bool  secureCall = true 
)
static
Parameters
objectpointer to a QObject in which a method needs to be invoked
methodname of the method to invoke in the object. (Only the name. Not the complete signature)
argslist of arguments to to pass to the method
secureCallif true, then the function will check for allowmetaaccess attribute. If false, then it will ignore the attribute.
Returns
Upon success this function will return a true. Calling data() on the returned result will provide the value returned by the invoked method.
Note
Only public methods and signals can be invoked by this function.
See Also
allowmetaaccess attribute
GCF::Result GCF::ApplicationServices::invokeMethod ( QObject *  object,
const QMetaMethod &  method,
const QVariantList &  args,
bool  secureCall = true 
)
static
Parameters
objectpointer to a QObject in which a method needs to be invoked
methodmeta information of the method that needs to be invoked
argslist of arguments to to pass to the method
secureCallif true, then the function will check for allowmetaaccess attribute. If false, then it will ignore the attribute.
Returns
Upon success this function will return a true. Calling data() on the returned result will provide the value returned by the invoked method.
Note
Only public methods and signals can be invoked by this function.
See Also
allowmetaaccess attribute
GCF::JobListModel * GCF::ApplicationServices::jobs ( ) const
Returns
the list of jobs for the application. See GCF::AbstractJob for more information.
GCF::ApplicationServices::translate ( const QString &  string) const

Returns the translation for string in "GCF" context, if it is available.