tbx  0.7.6
Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
tbx::res::ResObject Class Reference

Base class for a resource object that can be edited. More...

#include <resobject.h>

Inheritance diagram for tbx::res::ResObject:
tbx::res::ResBase tbx::res::ResColourDbox tbx::res::ResColourMenu tbx::res::ResDCS tbx::res::ResFileInfo tbx::res::ResFontDbox tbx::res::ResFontMenu tbx::res::ResIconbar tbx::res::ResMenu tbx::res::ResPrintDbox tbx::res::ResProgInfo tbx::res::ResQuit tbx::res::ResSaveAs tbx::res::ResScale tbx::res::ResWindow

Public Member Functions

 ResObject (const ResObject &other)
 Copy constructor.
 
virtual ~ResObject ()
 Destructor.
 
ResObjectoperator= (const ResObject &other)
 Assignment.
 
bool save (std::ostream &file)
 Save a resource object to a stream. More...
 
const ResObjectHeaderobject_header () const
 Return a pointer to the header information for this object.
 
const char * name () const
 Return pointer to name of object.
 
void name (std::string name)
 Set the name of the object.
 
int class_id () const
 Return class id of object.
 
int object_version () const
 Return version number * 100.
 
void object_version (int new_version)
 Set version for object.
 
unsigned int object_flags () const
 object flags - use methods below for named access to the bits of the flags
 
void object_flags (unsigned int flags)
 Set the object flags for this object. More...
 
bool create_on_load () const
 Get create on load flag. More...
 
void create_on_load (bool value)
 Set if the object should be automatically created when the Resource file is loaded. More...
 
bool show_on_create () const
 Get show on create flags. More...
 
void show_on_create (bool value)
 Set if the object to be automatically shown when it is created. More...
 
bool shared () const
 Get shared flag. More...
 
void shared (bool value)
 Set if the object is to be a shared object. More...
 
bool ancestor () const
 Get ancestor flags. More...
 
void ancestor (bool value)
 Set if the object should be an ancestor object. More...
 
void check_class_id (int class_id) const
 Check if this objects class id is as specified. More...
 
- Public Member Functions inherited from tbx::res::ResBase
 ResBase (const ResBase &other)
 Copy constructor. More...
 
virtual ~ResBase ()
 Destructor.
 
ResBaseoperator= (const ResBase &other)
 Assignment. More...
 

Static Public Member Functions

static ResObjectload (std::istream &file)
 Load a resource object from a stream. More...
 
static OsSpriteAreaPtr client_sprite_pointer ()
 Get pointer to client sprite area. More...
 
static void client_sprite_pointer (OsSpriteAreaPtr ptr)
 Set Sprite area to use for new and loaded objects.
 

Protected Member Functions

 ResObject (std::string name, int class_id, int version, int object_size)
 Protected constructor for creating a subclass.
 
ResObjectHeaderobject_header ()
 Return a pointer to the header information for this object.
 
void make_writeable ()
 Make object writeable, call before any change. More...
 
ResData * component_data (char *new_body, int offset, int size) const
 Extract a copy of a components data from this object. More...
 
void insert_component (int offset, const ResImpl *comp_impl)
 Insert a component in an object. More...
 
void replace_component (int offset, int old_size, const ResImpl *comp_impl)
 Replace a component. More...
 
void erase_component (int offset, int size)
 Erase a component of the given size. More...
 
- Protected Member Functions inherited from tbx::res::ResBase
 ResBase (ResImpl *impl)
 Create from internal resource implementation. More...
 
const char * string (int offset) const
 Return a string at the given offset. More...
 
void string (int offset, const char *value)
 Set a string at the given offset. More...
 
void string (int offset, std::string value)
 Set a string at the given offset. More...
 
void string_with_length (int offset, const char *value, int length=-1)
 Assign a string where the length is at offset+4. More...
 
void string_with_length (int offset, const std::string &value, int length=-1)
 Assign a string where the length is at offset+4. More...
 
const char * message (int offset) const
 Get the message string at the given offset. More...
 
void message (int offset, const char *value)
 Set a message at the given offset. More...
 
void message (int offset, std::string value)
 Set a message at the given offset. More...
 
void message_with_length (int offset, const char *value, int length=-1)
 Assign a message where the length is at offset+4. More...
 
void message_with_length (int offset, const std::string &value, int length=-1)
 Assign a message where the length is at offset+4. More...
 
int int_value (int offset) const
 Get an integer value. More...
 
void int_value (int offset, int value)
 Set a number at the specified offset. More...
 
unsigned int uint_value (int offset) const
 Get an unsigned integer value. More...
 
void uint_value (int offset, unsigned int value)
 Set an unsigned number at the specified offset. More...
 
unsigned char byte_value (int offset) const
 Get a byte value. More...
 
void byte_value (int offset, unsigned char value)
 Set an unsigned byte (8 bit value) at the specified offset. More...
 
unsigned short ushort_value (int offset) const
 Get a unsigned short value. More...
 
void ushort_value (int offset, unsigned short value)
 Set an unsigned short (16 bit value) at the specified offset. More...
 
bool flag (int offset, int mask) const
 Check if any of the bits in a mask are set. More...
 
void flag (int offset, int mask, bool on)
 Set/clear the bits in mask. More...
 
int flag_value (int offset, int mask) const
 Get the bits for the given mask. More...
 
void flag_value (int offset, int mask, int value)
 Set bits in given mask clearing others. More...
 
void init_string (int offset, const char *value)
 Initialise a string in a constructor helper. More...
 
void init_message (int offset, const char *value)
 Initialise a message in a constructor helper. More...
 
void init_sprite_area_ref (int offset)
 Initialise a sprite area reference. More...
 
void init_object_ref (int offset)
 Initialise an object reference. More...
 

Friends

class tbx::Application
 
class ResFile
 

Additional Inherited Members

- Protected Attributes inherited from tbx::res::ResBase
ResImpl * _impl
 Internal Resource implementation.
 

Detailed Description

Base class for a resource object that can be edited.

Member Function Documentation

◆ ancestor() [1/2]

bool tbx::res::ResObject::ancestor ( ) const
inline

Get ancestor flags.

Returns
true if this object will be created as an ancestor

◆ ancestor() [2/2]

void tbx::res::ResObject::ancestor ( bool  value)

Set if the object should be an ancestor object.

An ancestor object will have its object/component placed in the event ID block of any event raised on any of its descendents

Parameters
valuetrue to make this an ancestor object

◆ check_class_id()

void tbx::res::ResObject::check_class_id ( int  class_id) const

Check if this objects class id is as specified.

Parameters
class_idthe toolbox class id to check against
Exceptions
ResObjectClassMismatchif the class id does not match this objects class id

◆ client_sprite_pointer()

OsSpriteAreaPtr tbx::res::ResObject::client_sprite_pointer ( )
static

Get pointer to client sprite area.

This is used for new and loaded objects

◆ component_data()

ResData* tbx::res::ResObject::component_data ( char *  new_body,
int  offset,
int  size 
) const
inlineprotected

Extract a copy of a components data from this object.

Parameters
new_body- new component body to copy relocations to
offset- offset to start of components in body
size- size of component

◆ create_on_load() [1/2]

bool tbx::res::ResObject::create_on_load ( ) const
inline

Get create on load flag.

Returns
true if this object will be created when it is loaded

◆ create_on_load() [2/2]

void tbx::res::ResObject::create_on_load ( bool  value)

Set if the object should be automatically created when the Resource file is loaded.

Parameters
valueset to true if the object should be created when loaded

◆ erase_component()

void tbx::res::ResObject::erase_component ( int  offset,
int  size 
)
protected

Erase a component of the given size.

Parameters
offsetlocation of component
sizesize of component

◆ insert_component()

void tbx::res::ResObject::insert_component ( int  offset,
const ResImpl *  comp_impl 
)
protected

Insert a component in an object.

Parameters
offsetoffset to insert the component
comp_implprivate component implementation handler

◆ load()

ResObject * tbx::res::ResObject::load ( std::istream &  file)
static

Load a resource object from a stream.

Parameters
filebinary stream to read the object from
Returns
pointer to loaded object or 0 if load failed

◆ make_writeable()

void tbx::res::ResObject::make_writeable ( )
protectedvirtual

Make object writeable, call before any change.

Make this ResObject writeable.

Exceptions
std::invalid_argumentif object is read only without a type relocation table.

Implements tbx::res::ResBase.

◆ object_flags()

void tbx::res::ResObject::object_flags ( unsigned int  flags)

Set the object flags for this object.

You can use the create_on_load etc methods to change/interrogate these flags in a clearer way.

Parameters
flagsnew value for the object flags

◆ replace_component()

void tbx::res::ResObject::replace_component ( int  offset,
int  old_size,
const ResImpl *  comp_impl 
)
protected

Replace a component.

Parameters
offsetlocation to replace
comp_implreplacement component
old_sizesize of component replace

◆ save()

bool tbx::res::ResObject::save ( std::ostream &  file)

Save a resource object to a stream.

Parameters
filebinary stream to save object to
Returns
true if save successful

◆ shared() [1/2]

bool tbx::res::ResObject::shared ( ) const
inline

Get shared flag.

Returns
true if this creates shared objects

◆ shared() [2/2]

void tbx::res::ResObject::shared ( bool  value)

Set if the object is to be a shared object.

An object that is shared will only create one Toolbox object that will be reference counted whenever it is created rather than a new object every time it is created.

The Toolbox object will not be deleted until every call to create it has been match by a call to destroy it.

Parameters
valuetrue to make this a shared object

◆ show_on_create() [1/2]

bool tbx::res::ResObject::show_on_create ( ) const
inline

Get show on create flags.

Returns
true if this object will be shown when it is created

◆ show_on_create() [2/2]

void tbx::res::ResObject::show_on_create ( bool  value)

Set if the object to be automatically shown when it is created.

Parameters
valuetrue to set object to be shown when created

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