Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

mortic::IObject Class Reference

A generic object class in mortic. More...

Inheritance diagram for mortic::IObject:

mortic::IConfigManager mortic::IEvent mortic::IEventManager mortic::IFile mortic::IFileManager mortic::ILogManager mortic::IScene mortic::ISceneManager mortic::IScript mortic::IScriptManager mortic::IVideoManager List of all members.

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.

Detailed Description

A generic object class in mortic.

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.

See also:
IRoot

Definition at line 33 of file IObject.h.


Constructor & Destructor Documentation

mortic::IObject::IObject  ) 
 

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.

mortic::IObject::IObject IRoot root,
std::string  name
 

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.

  • root - the IRoot to register with
  • name - a name to give the object

virtual mortic::IObject::~IObject  )  [virtual]
 

Destructor.


Member Function Documentation

void mortic::IObject::drop  ) 
 

Release an object.

The purpose of grab() and drop() are explained in grab().

See also:
grab() getInstances()

unsigned int mortic::IObject::getID  ) 
 

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.

Returns:
the ID of the object

unsigned int mortic::IObject::getInstances  ) 
 

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.

Returns:
the number of references to this object
See also:
grab() drop()

std::string mortic::IObject::getName  ) 
 

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.

Returns:
the name of the object
See also:
setName()

void mortic::IObject::grab  ) 
 

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!

See also:
drop() getInstances()

void mortic::IObject::setName std::string  name  ) 
 

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.

  • name - the new name of the object
    See also:
    getName()


Generated on Sat Dec 30 21:21:59 2006 for mortic by  doxygen 1.4.4