Interface for streaming factories. More...
#include <GUIFactory.h>
Public Member Functions | |
void | GetAnimations (AnimationVector &rkAnimations) |
void | GetBehaviours (BehaviourVector &rkBehaviours) |
void | GetCommands (CommandVector &rkCommands) |
void | GetControls (ControlVector &rkControls) |
void | GetLayouters (LayouterVector &rkLayouters) |
void | GetTextTypes (TextTypeVector &rkTextTypes) |
eC_Bool | RegisterAnimation (AnimationDescriptor desc) |
eC_Bool | RegisterBehaviour (BehaviourDescriptor desc) |
eC_Bool | RegisterCommand (CommandDescriptor desc) |
eC_Bool | RegisterControl (ControlDescriptor desc) |
eC_Bool | RegisterLayouter (LayouterDescriptor desc) |
eC_Bool | RegisterText (TextTypeDescriptor desc) |
void | UnregisterAnimation (const eC_Int &iID) |
void | UnregisterBehaviour (const eC_Int &iID) |
void | UnregisterCommand (const eC_Int &iID) |
void | UnregisterControl (const eC_Int &iID) |
void | UnregisterLayouter (const eC_Int &iID) |
void | UnregisterText (const eC_Int &iID) |
![]() | |
RefCounted () | |
Create RefCounted object. The reference count is initialized to 0. | |
virtual | ~RefCounted () |
Destroy reference counted object. | |
void | AddRef () |
Increase reference count. | |
eC_Int | RefCount () const |
void | Release () |
bool | Unique () const |
Protected Member Functions | |
virtual | ~CGUIFactory () |
Destructor. | |
virtual CGUIAnimation * | CreateAnimation (const AnimationType_t &eAnimation) |
virtual CGUIBehaviourDecorator * | CreateBehaviour (const BehaviourClassID_t &eBehaviourID) |
virtual CGUICommand * | CreateCommand (const CommandClassID_t &eCommandID) |
virtual CGUIObject * | CreateControl (const ControlClassID_t &eControlID) |
virtual CGUILayouter * | CreateLayouter (const LayouterClassID_t &eLayouterID) |
virtual CGUIText * | CreateText (const TextTypeID_t &eTextType) |
Friends | |
class | CGUIFactoryManager |
The factory manager needs to call the load methods. More... | |
Interface for streaming factories.
Factories are used when loading streaming files. Each factory has to be derived from this base class.
A factory creates GUI objects (controls), commands, layouters, behaviours and texts based on their IDs. The CGUIFactoryManager calls a method of this class, then calls ReadFromStream on the returned object.
For creating your own customized factory, you must derive it from CGUIFactory, implement the corresponding CreateXXX-interfaces and register it with the CGUIFactoryManager.
Guiliani's standard objects are instantiated within the CGUIStandardFactory which comes with the framework. If you wish to add customized objects, so that they can be read from a streaming-file, you must implement a corresponding factory and register it with the framework. The factory's sole purpose is to instantiate your customized objects. This is done by mapping an ID read from a stream onto the matching new CSomeCustomizedClass() call.
The following example code snippets demonstrate how this is done in practice. You must derive your customized factory from the CGUIFactory base class and re-implement those interfaces, for which you have created customized objects (In this example Controls and Commands).
There exist dedicated methods for each of the different object types (controls, commands, layouters, behaviours and texts.) The factory method gets called by the framework and receives an ID, which it then uses internally within a switch/case statement to construct the matching object.
The following example implements the CreateControl interface of a customized factory named ExampleFactory. If Guiliani itself reads an ID from a stream which it did not recognize, it calls the registered UserFactory's methods, thus requesting them to instantiate the object identified by eControlID. These IDs are typically declared as enumerations within the UserControlResource.h / UserCommandResource.h / UserLayouterResource.h / UserBehaviourResource.h and UserTextTypeResource.h headers. All the factory needs to do, is to check for the ID in a switch/case, create the corresponding object if possible, or return NULL otherwise.
The same applies to all other types of objects, such as e.g. commands. As you can see from the following example:
Once you have finished implementing your customized factory, use the CGUIFactoryManagers AddUserFactory interface to make your factory known within the framework, and you are done. The framework will now be able to use your factory to load your custom objects from a stream.
|
inlineprotectedvirtual |
Creates a new animation object.
eAnimation | The animation ID. |
Reimplemented in CGUIStandardFactory.
|
inlineprotectedvirtual |
Creates a new behaviour decorator.
eBehaviourID | ID of the behaviour. |
Reimplemented in CGUIStandardFactory.
|
inlineprotectedvirtual |
Creates a new command.
eCommandID | ID of the command. |
Reimplemented in CGUIStandardFactory.
|
inlineprotectedvirtual |
Creates a new GUI object.
eControlID | ID of the control. |
Reimplemented in CGUIStandardFactory.
|
inlineprotectedvirtual |
Creates a new layouter.
eLayouterID | ID of the layouter. |
Reimplemented in CGUIStandardFactory.
|
inlineprotectedvirtual |
Creates a new text object.
eTextType | The text type ID. |
Reimplemented in CGUIStandardFactory.
void CGUIFactory::GetAnimations | ( | AnimationVector & | rkAnimations | ) |
Get all registered animations
rkAnimations | fill this |
void CGUIFactory::GetBehaviours | ( | BehaviourVector & | rkBehaviours | ) |
Get all registered behaviours
rkBehaviours | fill this |
void CGUIFactory::GetCommands | ( | CommandVector & | rkCommands | ) |
Get all registered commands
rkCommands | fill this |
void CGUIFactory::GetControls | ( | ControlVector & | rkControls | ) |
Get all registered controls
rkControls | fill this |
void CGUIFactory::GetLayouters | ( | LayouterVector & | rkLayouters | ) |
Get all registered layouters
rkLayouters | fill this |
void CGUIFactory::GetTextTypes | ( | TextTypeVector & | rkTextTypes | ) |
Get all registered text-types
rkTextTypes | fill this |
eC_Bool CGUIFactory::RegisterAnimation | ( | AnimationDescriptor | desc | ) |
Register new animation
desc | description of the animation |
eC_Bool CGUIFactory::RegisterBehaviour | ( | BehaviourDescriptor | desc | ) |
Register new behaviour
desc | description of the behaviour |
eC_Bool CGUIFactory::RegisterCommand | ( | CommandDescriptor | desc | ) |
Register new command
desc | description of the command |
eC_Bool CGUIFactory::RegisterControl | ( | ControlDescriptor | desc | ) |
Register new control
desc | description of the control |
eC_Bool CGUIFactory::RegisterLayouter | ( | LayouterDescriptor | desc | ) |
Register new layouter
desc | description of the layouter |
eC_Bool CGUIFactory::RegisterText | ( | TextTypeDescriptor | desc | ) |
Register new text-type
desc | description of the text-type |
void CGUIFactory::UnregisterAnimation | ( | const eC_Int & | iID | ) |
Unregister the animation with the given ID
iID | ID of the animation |
void CGUIFactory::UnregisterBehaviour | ( | const eC_Int & | iID | ) |
Unregister the behaviour with the given ID
iID | ID of the behaviour |
void CGUIFactory::UnregisterCommand | ( | const eC_Int & | iID | ) |
Unregister the command with the given ID
iID | ID of the command |
void CGUIFactory::UnregisterControl | ( | const eC_Int & | iID | ) |
Unregister the control with the given ID
iID | ID of the control |
void CGUIFactory::UnregisterLayouter | ( | const eC_Int & | iID | ) |
Unregister the layouter with the given ID
iID | ID of the layouter |
void CGUIFactory::UnregisterText | ( | const eC_Int & | iID | ) |
Unregister the text-type with the given ID
iID | ID of the text-type |
|
friend |
The factory manager needs to call the load methods.