Inheritance diagram for mortic::IObject:
Public Member Functions | |
IObject () | |
Constructor. | |
IObject (IRoot *root, std::string name) | |
Standard Constructor. | |
virtual | ~IObject () |
Destructor. | |
std::string | getName () |
Gets the name of the object. | |
unsigned int | getID () |
Gets the ID of the object. | |
void | setName (std::string name) |
Sets the name of the object. | |
void | grab () |
Reserves the object for use. | |
void | drop () |
Release an object. | |
unsigned int | getInstances () |
Get the number of places this object is being used. |
An object in mortic is just any class instance in mortic. Almost every class is derived from IObject. It provides simple reference counting as well as a simple way to get an object through the root.
Definition at line 33 of file IObject.h.
|
Constructor. This is the default constructor. Do not use this! It doesn't do anything, and half of the time it causes a segfault. It's only here to keep the compilers happy. |
|
Standard Constructor. This is the constructor you want to use. This constructor automatically registers the new object with the root, and sets up the reference counting correctly.
|
|
Destructor.
|
|
Release an object. The purpose of grab() and drop() are explained in grab().
|
|
Gets the ID of the object. Every object gets a unique ID. No other object will ever have the same ID until this object dies. This lets you pass a simple integer to a script, and then turn it into an object.
|
|
Get the number of places this object is being used. This is the function that gets the internal counter mentioned in grab(). When this hits 0, the object is destroyed.
|
|
Gets the name of the object. Name is a bit of a misnomer in this case. (har har) Think of it more as a name for the group of objects. For example, the name of ISceneManager is SceneManager. IFile's name is File. This lets you reference these objects as a group through the root.
|
|
Reserves the object for use. The memory management of mortic is very simple. Every object maintains a count, which is increased by grab() and decreased by drop(). What this means is, you can ensure that an object will not be destroyed by calling grab(). Then, you can say that you're fine with it being destroyed by calling drop(). As a simple rule, always grab an object during the time when you are using it. However, be sure to drop() it!
|
|
Sets the name of the object. Although it is bad practice, you can change the name of an object at runtime. Why? Who knows. But, the option is there.
|