Quad Pang
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions
XRes Class Reference

Use this class to read setting from resource. More...

#include <XRes.h>

List of all members.

Public Member Functions

 XRes (XCongo *xcongo, const char *repName, int resId=XCongo::ID_STATIC)
 Create resoucse from configuation object.
 XRes (XRes *xres, const char *repName, int resId=XCongo::ID_STATIC)
 Create sub-resource from resource object.
 ~XRes ()
 XRes (XCongo *xcongo, const char *repName, int resId=XCongo::ID_STATIC)
 Create resoucse from configuation object.
 XRes (XRes *xres, const char *repName, int resId=XCongo::ID_STATIC)
 Create sub-resource from resource object.
 ~XRes ()

Resource Variable Accessors

All methods in this group has the same first argument and return value

Parameters:
nameFull qualified name of the resource
valValue to be read and returned. StringValue function will allocate buffer with new[]. Call delete[] on this variable when value is longer needed for cleanup.
Returns:
true on success, false on failure
bool IntValue (const char *name, int *val)
 Query Integer value.
bool StringValue (const char *name, char **val)
 Query String value.
bool DoubleValue (const char *name, double *val)
 Query Double value.

Resource Variable Accessors

All methods in this group has the same first argument and return value

Parameters:
nameFull qualified name of the resource
valValue to be read and returned. StringValue function will allocate buffer with new[]. Call delete[] on this variable when value is longer needed for cleanup.
Returns:
true on success, false on failure
bool IntValue (const char *name, int *val)
 Query Integer value.
bool StringValue (const char *name, char **val)
 Query String value.
bool DoubleValue (const char *name, double *val)
 Query Double value.

Private Attributes

Initialization Attributes

Bellow attributes are used for initilization only and hidden afterwards. After creation resource is opaque to it's users.

XCongompXCongo
 Parent of this resource.
int mResId
 Used when Resource is part of array container.
char * mRepName
 Name of resource parent.

Detailed Description

Use this class to read setting from resource.

Resource contains initialisation data for singe object.

NAME is object property to read. Examples:

VALUE can be of type int, double and char*. In the case of char* memory for that value is allocated with new[] and user should take care for cleanup.

RESOURCE ID is integer from 0 to SizeOf(REP_NAME) including ID_STATIC. Resource ID with SizeOf function can be used as method to read array of objects from configuration files. If you want to read red component color of 3th quad you could use:

IntValue("Quads", 3, "mColor.mRed")

It is is equivalent to

IntValue("Quads[3].mColor.mRed")

See also:
XCongo.

Definition at line 33 of file XRes.h.


Constructor & Destructor Documentation

XRes::XRes ( XCongo xcongo,
const char *  repName,
int  resId = XCongo::ID_STATIC 
)

Create resoucse from configuation object.

Parameters:
xcongoConfiguration object.
repNamename of global repository in configuration object.
resIdId (array index) of resource.

XRes(xcongo, "Quads", 3) is equivalent to XRes(xcongo, "Quads[3]").

Definition at line 16 of file XRes.cpp.

References mRepName.

    : mpXCongo(xcongo), mResId(resId)
{
    size_t name_size = strlen(repName) + 1;

    mRepName = new char[name_size];
    memcpy(mRepName, repName, name_size);
}
XRes::XRes ( XRes xres,
const char *  repName,
int  resId = XCongo::ID_STATIC 
)

Create sub-resource from resource object.

Parameters:
xresResource object.
repNamename of subojbect in resource object.
resIdId (array index) of resource.

XRes(xres, "mBullet", 3) is equivalent to XRes(xres, "mBullet[3]").

Definition at line 25 of file XRes.cpp.

References mRepName, and mResId.

: mpXCongo(xres->mpXCongo), mResId(resId)
{
    size_t name_size = strlen(xres->mRepName) + 10 + strlen(repName) + 1;
    mRepName = new char[name_size];
    sprintf(mRepName, "%s[%d].%s", xres->mRepName, xres->mResId, repName);
}

Definition at line 34 of file XRes.cpp.

References mRepName.

{
    delete []mRepName;
}
XRes::XRes ( XCongo xcongo,
const char *  repName,
int  resId = XCongo::ID_STATIC 
)

Create resoucse from configuation object.

Parameters:
xcongoConfiguration object.
repNamename of global repository in configuration object.
resIdId (array index) of resource.

XRes(xcongo, "Quads", 3) is equivalent to XRes(xcongo, "Quads[3]").

XRes::XRes ( XRes xres,
const char *  repName,
int  resId = XCongo::ID_STATIC 
)

Create sub-resource from resource object.

Parameters:
xresResource object.
repNamename of subojbect in resource object.
resIdId (array index) of resource.

XRes(xres, "mBullet", 3) is equivalent to XRes(xres, "mBullet[3]").


Member Function Documentation

bool XRes::DoubleValue ( const char *  name,
double *  val 
)

Query Double value.

Definition at line 49 of file XRes.cpp.

References XCongo::DoubleValue(), mpXCongo, mRepName, and mResId.

Referenced by Bongo::Init(), Ball::Init(), Box::Init(), Arrow::Init(), BongoOrthoMover::Init(), BongoRealMover::Init(), and ViewController::Init().

{
    return mpXCongo->DoubleValue(mRepName, mResId, name, val);
}
bool XRes::DoubleValue ( const char *  name,
double *  val 
)

Query Double value.

bool XRes::IntValue ( const char *  name,
int *  val 
)

Query Integer value.

bool XRes::IntValue ( const char *  name,
int *  val 
)

Query Integer value.

Definition at line 39 of file XRes.cpp.

References XCongo::IntValue(), mpXCongo, mRepName, and mResId.

Referenced by Lifetime::Init(), Bongo::Init(), Ball::Init(), Box::Init(), and Box::LoadTexture().

{
    return mpXCongo->IntValue(mRepName, mResId, name, val);
}
bool XRes::StringValue ( const char *  name,
char **  val 
)

Query String value.

Definition at line 44 of file XRes.cpp.

References mpXCongo, mRepName, mResId, and XCongo::StringValue().

Referenced by Factory::CreateQuad(), Factory::CreateQuadMover(), and Box::LoadTexture().

{
    return mpXCongo->StringValue(mRepName, mResId, name, val);
}
bool XRes::StringValue ( const char *  name,
char **  val 
)

Query String value.


Member Data Documentation

XCongo * XRes::mpXCongo [private]

Parent of this resource.

Definition at line 109 of file XRes.h.

Referenced by DoubleValue(), IntValue(), and StringValue().

char * XRes::mRepName [private]

Name of resource parent.

Definition at line 113 of file XRes.h.

Referenced by DoubleValue(), IntValue(), StringValue(), XRes(), and ~XRes().

int XRes::mResId [private]

Used when Resource is part of array container.

Definition at line 111 of file XRes.h.

Referenced by DoubleValue(), IntValue(), StringValue(), and XRes().


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