Guiliani  Version 2.5 revision 6773 (build 33)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Commands

Implementation of the Command Design Pattern within Guiliani. More...

Classes

class  CGUICommand
 Command object base class. More...
 
class  CGUICommandHandler
 Manages and executes instances of CGUICommand. More...
 
class  CGUILoadAnimationsCmd
 Loads animations and animation chains from a file and deletes all existing ones. More...
 
class  CGUILoadDialogCmd
 Loads a GUI definition from a file. More...
 
class  CGUIQuitCmd
 Quits the Guiliani application by ending the main loop. More...
 
class  CGUIStartAnimationChainCmd
 
class  CGUIStopAnimationChainCmd
 
class  CGUITransitionCmd
 Transits from a source dialog to a destination dialog. More...
 

Detailed Description

Implementation of the Command Design Pattern within Guiliani.

The Command design pattern allows you to encapsulate actions and associated parameters into small, reusable pieces of source code. In the context of GUI development, commands prove especially useful when implementing the link between GUI representation and underlying application logic.

Guiliani implements this design pattern in various classes:

What is a command technically?

Technically a command is a C++ class derived from Guiliani's CGUICommand base-class. This is necessary so Guiliani can deal with your customized commands through the generalized interface of this base class. This interface is extremely slim and only requires you implement a single method. This method is named Do() and includes the specific application logic that you wish to execute therein.

You may place _any_ code inside of these Do() methods that you wish, and therefore also call any user-defined APIs. Just be aware that you should not do any time-consuming tasks here, as this will block the UI. Your API-calls should therefore either return immediately or you should start a dedicated thread from the Do() method if you know that respective processing might take longer.

How can I execute Commands from within the GUI?

Some controls already have dedicated attributes for adding commands to them. (e.g. CGUIButton). For others, you can use Guiliani's predefined Behaviours to execute commands in reaction to an incoming event (e.g. key-pressed or mouse-clicks).

How can I execute Commands from within my application?

You application code can use Guiliani's CGUICommandHandler to execute commands whenever desired. Simply call GETCMDHDL.Execute(new YourCommandClass()) to do so. This will add your new command to the queue of command-objects and Guiliani will process it as soon as possible. Typically, you may want to do this e.g. in order to update a status-icon within the GUI (e.g. battery-power icon) or e.g., to show a popup-window which shows information to the user.

When will the code within my command's Do() method be executed?

It will be executed at the next possible occasion. The precise time can not be defined since this depends on how much time other tasks within the user-interface consume - such as other commands being processed, or graphical operations while updating the screen.

Why is using commands thread-safe?

Thread-safety is granted by the fact, that all Guiliani APIs which deal with commands (such as the GETCMDHDL.Execute() interface) are by design guaranteed to work thread-safe. And Guiliani's CGUICommandHandler component will execute the code contained in the aforementioned Do() method in the GUI's thread-context. Therefore, you can safely access GUI components within this method!

How can I use commands inside the Guiliani HMI Editor?

The Guiliani Editor (GSE) is designed to be extensible and allows you to add custom objects and commands into it. For a detailed description and examples on how to do this please refer to the respective documentation of GSE. The general procedure is to implement Streaming for your custom command(s) and add them to GSE, so that they become available for use within the attribute view.

Is there a tutorial with example code on how to use commands?

Yes. There is a howto on Application Binding om our website which includes the usage of commands.