Guiliani  Version 2.4 revision 5970 (build 3)
CGUIFactory Class Reference

Interface for streaming factories. More...

#include <GUIFactory.h>

Inheritance diagram for CGUIFactory:

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)
 
- Public Member Functions inherited from NSmartPtr::RefCounted
 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 Types

typedef std::map< eC_Int, AnimationDescriptorAnimationCallbackMap
 map for animations
 
typedef std::map< eC_Int, BehaviourDescriptorBehaviourCallbackMap
 map for behaviours
 
typedef std::map< eC_Int, CommandDescriptorCommandCallbackMap
 map for commands
 
typedef std::map< eC_Int, ControlDescriptorControlCallbackMap
 map for controls
 
typedef std::map< eC_Int, LayouterDescriptorLayouterCallbackMap
 map for layouters
 
typedef std::map< eC_Int, TextTypeDescriptorTextCallbackMap
 map for text-types
 

Protected Member Functions

virtual ~CGUIFactory ()
 Destructor.
 
virtual CGUIAnimationCreateAnimation (AnimationType_t eAnimation)
 
virtual CGUIBehaviourDecoratorCreateBehaviour (BehaviourClassID_t eBehaviourID)
 
virtual CGUICommandCreateCommand (CommandClassID_t eCommandID)
 
virtual CGUIObjectCreateControl (ControlClassID_t eControlID)
 
virtual CGUILayouterCreateLayouter (LayouterClassID_t eLayouterID)
 
virtual CGUITextCreateText (TextTypeID_t eTextType)
 

Protected Attributes

AnimationCallbackMap m_kAnimationMap
 map for animations
 
BehaviourCallbackMap m_kBehaviourMap
 map for behaviours
 
CommandCallbackMap m_kCommandMap
 map for commands
 
ControlCallbackMap m_kControlMap
 map for controls
 
LayouterCallbackMap m_kLayouterMap
 map for layouters
 
TextCallbackMap m_kTextMap
 map for text-types
 

Friends

class CGUIFactoryManager
 The factory manager needs to call the load methods. More...
 

Detailed Description

Interface for streaming factories.

Factories are used when loading streaming files. Each factory has to be derived from this base class.

Overview

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.

Example usage

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).

class ExampleFactory : public CGUIFactory
{
protected:
};

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.

CGUIObject* ExampleFactory::CreateControl(ControlClassID_t eControlID)
{
switch (eControlID)
{
case CTL_EXAMPLE:
return new ExampleControl();
break;
default:
break;
}
return NULL;
}

The same applies to all other types of objects, such as e.g. commands. As you can see from the following example:

CGUICommand* ExampleFactory::CreateCommand(CommandClassID_t eCommandID)
{
switch (eCommandID)
{
case CMD_EXAMPLE:
return new ExampleCommand();
break;
default:
break;
}
return NULL;
}

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.

GETFACTORY.AddUserFactory(new ExampleFactory());

Member Function Documentation

◆ CreateAnimation()

virtual CGUIAnimation* CGUIFactory::CreateAnimation ( AnimationType_t  eAnimation)
inlineprotectedvirtual

Creates a new animation object.

Parameters
eAnimationThe animation ID.
Returns
The animation that has been created or NULL if the ID was unknown.

Reimplemented in CGUIStandardFactory.

◆ CreateBehaviour()

virtual CGUIBehaviourDecorator* CGUIFactory::CreateBehaviour ( BehaviourClassID_t  eBehaviourID)
inlineprotectedvirtual

Creates a new behaviour decorator.

Parameters
eBehaviourIDID of the behaviour.
Returns
The behaviour that has been created or NULL if the ID was unknown.

Reimplemented in CGUIStandardFactory.

◆ CreateCommand()

virtual CGUICommand* CGUIFactory::CreateCommand ( CommandClassID_t  eCommandID)
inlineprotectedvirtual

Creates a new command.

Parameters
eCommandIDID of the command.
Returns
The command that has been created or NULL if the ID was unknown.

Reimplemented in CGUIStandardFactory.

◆ CreateControl()

virtual CGUIObject* CGUIFactory::CreateControl ( ControlClassID_t  eControlID)
inlineprotectedvirtual

Creates a new GUI object.

Parameters
eControlIDID of the control.
Returns
The object that has been created or NULL if the ID was unknown.

Reimplemented in CGUIStandardFactory.

◆ CreateLayouter()

virtual CGUILayouter* CGUIFactory::CreateLayouter ( LayouterClassID_t  eLayouterID)
inlineprotectedvirtual

Creates a new layouter.

Parameters
eLayouterIDID of the layouter.
Returns
The layouter that has been created or NULL if the ID was unknown.

Reimplemented in CGUIStandardFactory.

◆ CreateText()

virtual CGUIText* CGUIFactory::CreateText ( TextTypeID_t  eTextType)
inlineprotectedvirtual

Creates a new text object.

Parameters
eTextTypeThe text type ID.
Returns
The text that has been created or NULL if the ID was unknown.

Reimplemented in CGUIStandardFactory.

◆ GetAnimations()

void CGUIFactory::GetAnimations ( AnimationVector &  rkAnimations)

Get all registered animations

Parameters
rkAnimationsfill this

◆ GetBehaviours()

void CGUIFactory::GetBehaviours ( BehaviourVector &  rkBehaviours)

Get all registered behaviours

Parameters
rkBehavioursfill this

◆ GetCommands()

void CGUIFactory::GetCommands ( CommandVector &  rkCommands)

Get all registered commands

Parameters
rkCommandsfill this

◆ GetControls()

void CGUIFactory::GetControls ( ControlVector &  rkControls)

Get all registered controls

Parameters
rkControlsfill this

◆ GetLayouters()

void CGUIFactory::GetLayouters ( LayouterVector &  rkLayouters)

Get all registered layouters

Parameters
rkLayoutersfill this

◆ GetTextTypes()

void CGUIFactory::GetTextTypes ( TextTypeVector &  rkTextTypes)

Get all registered text-types

Parameters
rkTextTypesfill this

◆ RegisterAnimation()

eC_Bool CGUIFactory::RegisterAnimation ( AnimationDescriptor  desc)

Register new animation

Parameters
descdescription of the animation
Returns
True if successfully registered

◆ RegisterBehaviour()

eC_Bool CGUIFactory::RegisterBehaviour ( BehaviourDescriptor  desc)

Register new behaviour

Parameters
descdescription of the behaviour
Returns
True if successfully registered

◆ RegisterCommand()

eC_Bool CGUIFactory::RegisterCommand ( CommandDescriptor  desc)

Register new command

Parameters
descdescription of the command
Returns
True if successfully registered

◆ RegisterControl()

eC_Bool CGUIFactory::RegisterControl ( ControlDescriptor  desc)

Register new control

Parameters
descdescription of the control
Returns
True if successfully registered

◆ RegisterLayouter()

eC_Bool CGUIFactory::RegisterLayouter ( LayouterDescriptor  desc)

Register new layouter

Parameters
descdescription of the layouter
Returns
True if successfully registered

◆ RegisterText()

eC_Bool CGUIFactory::RegisterText ( TextTypeDescriptor  desc)

Register new text-type

Parameters
descdescription of the text-type
Returns
True if successfully registered

◆ UnregisterAnimation()

void CGUIFactory::UnregisterAnimation ( const eC_Int &  iID)

Unregister the animation with the given ID

Parameters
iIDID of the animation

◆ UnregisterBehaviour()

void CGUIFactory::UnregisterBehaviour ( const eC_Int &  iID)

Unregister the behaviour with the given ID

Parameters
iIDID of the behaviour

◆ UnregisterCommand()

void CGUIFactory::UnregisterCommand ( const eC_Int &  iID)

Unregister the command with the given ID

Parameters
iIDID of the command

◆ UnregisterControl()

void CGUIFactory::UnregisterControl ( const eC_Int &  iID)

Unregister the control with the given ID

Parameters
iIDID of the control

◆ UnregisterLayouter()

void CGUIFactory::UnregisterLayouter ( const eC_Int &  iID)

Unregister the layouter with the given ID

Parameters
iIDID of the layouter

◆ UnregisterText()

void CGUIFactory::UnregisterText ( const eC_Int &  iID)

Unregister the text-type with the given ID

Parameters
iIDID of the text-type

Friends And Related Function Documentation

◆ CGUIFactoryManager

friend class CGUIFactoryManager
friend

The factory manager needs to call the load methods.


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