tbx
0.7.5
|
Base class for a resource object that can be edited. More...
#include <resobject.h>
Public Member Functions | |
ResObject (const ResObject &other) | |
Copy constructor. | |
virtual | ~ResObject () |
Destructor. | |
ResObject & | operator= (const ResObject &other) |
Assignment. | |
bool | save (std::ostream &file) |
Save a resource object to a stream. More... | |
const ResObjectHeader * | object_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... | |
![]() | |
ResBase (const ResBase &other) | |
Copy constructor. More... | |
virtual | ~ResBase () |
Destructor. | |
ResBase & | operator= (const ResBase &other) |
Assignment. More... | |
Static Public Member Functions | |
static ResObject * | load (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. | |
ResObjectHeader * | object_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... | |
![]() | |
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 | |
![]() | |
ResImpl * | _impl |
Internal Resource implementation. | |
Base class for a resource object that can be edited.
|
inline |
Get ancestor flags.
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
value | true to make this an ancestor object |
void tbx::res::ResObject::check_class_id | ( | int | class_id | ) | const |
Check if this objects class id is as specified.
class_id | the toolbox class id to check against |
ResObjectClassMismatch | if the class id does not match this objects class id |
|
static |
Get pointer to client sprite area.
This is used for new and loaded objects
|
inlineprotected |
Extract a copy of a components data from this object.
new_body | - new component body to copy relocations to |
offset | - offset to start of components in body |
size | - size of component |
|
inline |
Get create on load flag.
void tbx::res::ResObject::create_on_load | ( | bool | value | ) |
Set if the object should be automatically created when the Resource file is loaded.
value | set to true if the object should be created when loaded |
|
protected |
Erase a component of the given size.
offset | location of component |
size | size of component |
|
protected |
Insert a component in an object.
offset | offset to insert the component |
comp_impl | private component implementation handler |
|
static |
Load a resource object from a stream.
file | binary stream to read the object from |
|
protectedvirtual |
Make object writeable, call before any change.
Make this ResObject writeable.
std::invalid_argument | if object is read only without a type relocation table. |
Implements tbx::res::ResBase.
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.
flags | new value for the object flags |
|
protected |
Replace a component.
offset | location to replace |
comp_impl | replacement component |
old_size | size of component replace |
bool tbx::res::ResObject::save | ( | std::ostream & | file | ) |
Save a resource object to a stream.
file | binary stream to save object to |
|
inline |
Get shared flag.
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.
value | true to make this a shared object |
|
inline |
Get show on create flags.
void tbx::res::ResObject::show_on_create | ( | bool | value | ) |
Set if the object to be automatically shown when it is created.
value | true to set object to be shown when created |