AppEasy Core SDK  1.5.0
Cross platform mobile and desktop app and game development SDK - The easy way to make apps
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines
IzXomlResource Class Reference

Base class that is used by all classes that can be instantiated from XOML markup. More...

#include <CzXomlResource.h>

Inheritance diagram for IzXomlResource:
CzActions CzActor CzAnim CzAnimTimeline CzApp CzBox2dFixtures CzBox2dJoints CzBox2dMaterial CzCamera CzDataFile CzFacebook CzFont CzGeometry CzImage CzMarket CzModifierManager CzProgram CzRemoteReq CzScene CzScript CzShape CzSound CzStyle CzTemplate CzTemplateFrom CzUserPropertyList CzVideo CzVideoCam CzXomlAddVariable CzXomlBindings CzXomlLoad CzXomlTimer IzBrush

List of all members.

Public Types

enum  eSetPropertyError {
  NotFound = 0, Success = 1, SearchForResource = 2, IncompatibleTypes = -1,
  NoAccess = -2
}
 Values that represent a SetProperty error. More...

Public Member Functions

void setParent (CzXomlResourceManager *parent)
CzXomlResourceManagergetParent ()
void setName (const char *name)
 Sets the name of the resource. Note that resource names should be unique across the same resource type. For example, two images should not share the same name.
CzStringgetName ()
void setDebugInfo (const char *info)
CzStringgetDebugInfo ()
unsigned int getNameHash ()
void setClassType (const char *type_name)
 Sets the class type.
unsigned int getClassTypeHash ()
void setActualClassType (const char *type_name)
 Sets the actual class type.
unsigned int getActualClassTypeHash ()
void setTag (const char *Tag)
 Sets the resource group tag.
unsigned int getTagHash ()
void setManaged (bool managed)
bool isManaged () const
void setContainer (IzXomlResource *container)
IzXomlResourcegetContainer ()
 IzXomlResource ()
virtual ~IzXomlResource ()
virtual int LoadFromXoml (IzXomlResource *parent, bool load_children, CzXmlNode *node)=0
virtual bool PostLoadFromXoml (IzXomlResource *parent, CzXmlNode *node)
virtual void Remove ()
 Removes and destroys this resource.

Static Public Member Functions

static int setProperty (CzXomlClassDef *class_def, IzXomlResource *target, unsigned int property_name, const CzString &data, bool delta)
 Sets the named property of the specified target resource.
static int setProperty (CzXomlClassDef *class_def, IzXomlResource *target, unsigned int property_name, const CzXomlProperty &prop, bool delta)
 Sets the named property of the specified target resource.
static int setProperty (CzXomlClassDef *class_def, IzAnimTarget *target, CzAnimInstance *animation)
 Updates property from supplied animation.
static int setProperty (CzXomlClassDef *class_def, IzXomlResource *target, unsigned int property_name, CzXomlVariable *variable)
 Sets the named property of the specified target resource from a variable.
static int getProperty (CzXomlClassDef *class_def, IzXomlResource *target, unsigned int property_name, CzXomlProperty &prop)
 Gets the named property of the resource.

Protected Attributes

CzString Name
 Resource name (unique per resource type)
CzString DebugInfo
 Filename and line number for debug info.
CzXomlResourceManagerParent
 Parent manager.
bool Managed
 True if managed by the resource system. Managed resources are auto cleaned up by the resource system.
unsigned int NameHash
 Resource name hash.
unsigned int ClassTypeHash
 Base type of XOML class (e.g. Scene, Actor, Animation, Game etc..)
unsigned int ActualClassTypeHash
 Actual type of XOML class.
unsigned int TagHash
 Tag name as a string hash, used to put resources into loading groups.
IzXomlResourceContainer
 The resource that acts as the container for this resource.

Detailed Description

Base class that is used by all classes that can be instantiated from XOML markup.

All classes that can be created from XOML are derived from IzXomlResource. IzXomlResource provides the base details of the XOML resource including:

  • Name of resource
  • Generic type of class
  • Actual type of class
  • Pure virtual LoadFromXoml method that should be implemented by derived classes. The XOML system will call this method to initialise the class from its XML attriibutes and inner tags

Each class that is derived from IzXomlResource must have a creator which is a class derived from IzXomlClassCreator which creates an instance of our XOML class. The creator class is a very simple class as is shown by the scene creator class example below:

class CzSceneCreator : public IzXomlClassCreator
{
public:
    CzSceneCreator()
    {
        setClassName("scene");
    }
    IzXomlResource* CreateInstance(IzXomlResource* parent) { return new CzScene(); }
};

To create a class that can be instantiated from XOML you should:

  • Derive the class from IzXomlResource
  • Set its XOML base type (game, actor, scene, animation etc..)
  • Implement a class derived from IzXomlClassCreator that implements CreateInstance() which creates an instance of the class
  • Add the class type to the list of class creators in CZ_XOML using addClass()

Member Enumeration Documentation

Values that represent a SetProperty error.

NotFound - The requested property was not found Success - Property was set successfully IncompatibleTypes - The supplied data is not compatible with the target property type ReadOnly - The property is read only SearchForResource - The property that was supplied is of type string but the target property is a resuorce. If this occurs then usually the caller will search for the resuorce

Enumerator:
NotFound 
Success 
SearchForResource 
IncompatibleTypes 
NoAccess 

Constructor & Destructor Documentation

virtual IzXomlResource::~IzXomlResource ( ) [inline, virtual]

Member Function Documentation

unsigned int IzXomlResource::getActualClassTypeHash ( ) [inline]
unsigned int IzXomlResource::getClassTypeHash ( ) [inline]
unsigned int IzXomlResource::getNameHash ( ) [inline]
int IzXomlResource::getProperty ( CzXomlClassDef class_def,
IzXomlResource target,
unsigned int  property_name,
CzXomlProperty prop 
) [static]

Gets the named property of the resource.

Returns the named property of the scene. The properties value is returned in a CzXomlProperty which is a structure that contains a union of all possible property types.

Parameters:
[in]class_defIf non-null, class definition used to determine properties.
[in]targetIf non-null, target resource that contains the property.
property_nameName of the target element as a string hash (faster searching).
[out]propThe output property.
Returns:
See eSetPropertyError for list of possible return values
unsigned int IzXomlResource::getTagHash ( ) [inline]
bool IzXomlResource::isManaged ( ) const [inline]
virtual bool IzXomlResource::PostLoadFromXoml ( IzXomlResource parent,
CzXmlNode node 
) [inline, virtual]

Reimplemented in CzActor, and CzScene.

void IzXomlResource::Remove ( ) [virtual]

Removes and destroys this resource.

Reimplemented in CzAnimTimeline.

void IzXomlResource::setActualClassType ( const char *  type_name)

Sets the actual class type.

The actual class type is the actual name of the class without the Cz. For example CzAxtorImage would be actually called ActorImage and this is how it would be referred to in XOML.

Parameters:
type_nameName of the type.
void IzXomlResource::setClassType ( const char *  type_name)

Sets the class type.

The class type is used to dtermine what type of category the class belongs to (e.g. Scene, Actor, Animation, Game etc..)

Parameters:
type_nameClass tyoe name.
void IzXomlResource::setContainer ( IzXomlResource container) [inline]
void IzXomlResource::setDebugInfo ( const char *  info) [inline]
void IzXomlResource::setManaged ( bool  managed) [inline]
void IzXomlResource::setName ( const char *  name)

Sets the name of the resource. Note that resource names should be unique across the same resource type. For example, two images should not share the same name.

Parameters:
nameResource name.
void IzXomlResource::setParent ( CzXomlResourceManager parent) [inline]
int IzXomlResource::setProperty ( CzXomlClassDef class_def,
IzXomlResource target,
unsigned int  property_name,
const CzString data,
bool  delta 
) [static]

Sets the named property of the specified target resource.

Sets the named property of this object. The properties value (data) is supplied as a string and will be converted. If delta is set to true then the existing value of the property will be added to instead of replaced.

Parameters:
[in]class_defIf non-null, class definition used to determine properties
[in,out]targetIf non-null, target resource that contains the property.
property_nameName of the target element as a string hash (faster searching).
[in]dataThe data to set to the property.
deltatrue if property should be added to instead of replaced.
Returns:
See eSetPropertyError for list of possible return values
int IzXomlResource::setProperty ( CzXomlClassDef class_def,
IzXomlResource target,
unsigned int  property_name,
const CzXomlProperty prop,
bool  delta 
) [static]

Sets the named property of the specified target resource.

Sets the named property of this object. The properties value (data) is supplied as a property and will be converted. If delta is set to true then the existing value of the property will be added to instead of replaced. if the class property is of type PT_Resource and the supplied property value is of type string then the this method will return SearchForResource which informs the caller to take the supplied property value as a string that contains the named string and shoudl search for it

Note that only the following automatic type conversions are supported:

  • string - any type can be converted to string
  • bool - string, int and float
  • int - string, bool and float
  • float - string, bool and int
  • vec2 - string, vec3 and vec4
  • vec3 - string, vec4
  • vec4 - string
Parameters:
[in]class_defIf non-null, class definition used to determine properties.
[in,out]targetIf non-null, target resource that contains the property.
property_nameName of the target element as a string hash (faster searching).
[in]propThe data to set to the property.
deltatrue if property should be added to instead of replaced.
Returns:
See eSetPropertyError for list of possible return values
int IzXomlResource::setProperty ( CzXomlClassDef class_def,
IzAnimTarget target,
CzAnimInstance animation 
) [static]

Updates property from supplied animation.

Sets the property that is specified by the supplied animation. When a timeline animation targets the property of the object this method will be called by the animation to move the animations frame data into its target property.

Note that only the following automatic type conversions are supported:

  • string - any type can be converted to string
  • bool - int and float
  • int - bool and float
  • float - bool and int
  • vec2 - vec3 and vec4
  • vec3 - vec4
  • vec4 - none
Parameters:
[in,out]class_defIf non-null, class definition used to determine properties.
[in,out]targetIf non-null, target resource that contains the property.
[in]animationIf non-null, the animation.
Returns:
See eSetPropertyError for list of possible return values
int IzXomlResource::setProperty ( CzXomlClassDef class_def,
IzXomlResource target,
unsigned int  property_name,
CzXomlVariable variable 
) [static]

Sets the named property of the specified target resource from a variable.

Sets the named property of this object. The properties value (data) is supplied as a variable and will be converted. If delta is set to true then the existing value of the property will be added to instead of replaced.

Note that only the following automatic type conversions are supported:

  • string - any type can be converted to string
  • bool - string, int and float
  • int - string, bool and float
  • float - string, bool and int
  • vec2 - string, vec3 and vec4
  • vec3 - string and vec4
  • vec4 - string
Parameters:
[in]class_defIf non-null, class definition used to determine properties.
[in,out]targetIf non-null, target resource that contains the property.
property_nameName of the target element as a string hash (faster searching).
[in,out]variableIf non-null, the suorce variable.
Returns:
See eSetPropertyError for list of possible return values
void IzXomlResource::setTag ( const char *  Tag)

Sets the resource group tag.

Its often useful to be able to determine which group certain resources belong to. For example, you may load a group of resources into the global resource manager but later want to remove them. To save having to individually remove each resource you could remove all of those that fit into a specific group.

Parameters:
TagThe tag.

Member Data Documentation

unsigned int IzXomlResource::ActualClassTypeHash [protected]

Actual type of XOML class.

unsigned int IzXomlResource::ClassTypeHash [protected]

Base type of XOML class (e.g. Scene, Actor, Animation, Game etc..)

The resource that acts as the container for this resource.

Filename and line number for debug info.

bool IzXomlResource::Managed [protected]

True if managed by the resource system. Managed resources are auto cleaned up by the resource system.

Resource name (unique per resource type)

unsigned int IzXomlResource::NameHash [protected]

Resource name hash.

Parent manager.

Reimplemented in CzAnimTimeline, and CzScene.

unsigned int IzXomlResource::TagHash [protected]

Tag name as a string hash, used to put resources into loading groups.


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