Home | Namespaces | Hierarchy | Alphabetical List | Class list | Files | Namespace Members | Class members | File members

irr::IUnknown Class Reference

Base class of most objects of the Irrlicht Engine. More...

#include <IUnknown.h>

Inheritance diagram for irr::IUnknown:

irr::gui::ICursorControl irr::gui::IGUIElementFactory irr::gui::IGUIEnvironment irr::gui::IGUIFont irr::gui::IGUISpriteBank irr::ILogger irr::io::IAttributeExchangingObject irr::io::IAttributes irr::io::IFileList irr::io::IFileSystem irr::io::IReadFile irr::io::IWriteFile irr::io::IXMLWriter irr::IOSOperator irr::IrrlichtDevice irr::ITimer irr::scene::IAnimatedMesh irr::scene::IAnimationEndCallBack irr::scene::IMesh irr::scene::IMeshBuffer irr::scene::IMeshCache irr::scene::IMeshLoader irr::scene::IMeshManipulator irr::scene::ISceneCollisionManager irr::scene::ISceneManager irr::scene::ISceneNodeAnimatorFactory irr::scene::ISceneNodeFactory irr::scene::ITriangleSelector irr::scene::quake3::IShaderManager irr::scene::quake3::SVarGroupList irr::scene::SMD3Mesh irr::scene::SMD3MeshBuffer irr::scene::SMD3QuaterionTagList irr::video::IImage irr::video::IImageLoader irr::video::IImageWriter irr::video::IMaterialRenderer irr::video::IShaderConstantSetCallBack irr::video::ITexture irr::video::IVideoDriver irr::video::IVideoModeList List of all members.

Public Member Functions

bool drop ()
const c8getDebugName () const
void grab ()
 IUnknown ()
 Constructor.
virtual ~IUnknown ()
 Destructor.

Protected Member Functions

void setDebugName (const c8 *newName)

Detailed Description

Base class of most objects of the Irrlicht Engine.

This class provides reference counting through the methods grab() and drop(). It also is able to store a debug string for every instance of an object. Most objects of the Irrlicht Engine are derived from IUnknown, and so they are reference counted.

When you create an object in the Irrlicht engine, calling a method which starts with 'create', an object is created, and you get a pointer to the new object. If you no longer need the object, you have to call drop(). This will destroy the object, if grab() was not called in another part of you program, because this part still needs the object. Note, that you only need to call drop() to the object, if you created it, and the method had a 'create' in it.

A simple example:

If you want to create a texture, you may want to call an imaginable method IDriver::createTexture. You call ITexture* texture = driver->createTexture(dimension2d<s32>(128, 128)); If you no longer need the texture, call texture->drop().

If you want to load a texture, you may want to call imaginable method IDriver::loadTexture. You do this like ITexture* texture = driver->loadTexture("example.jpg"); You will not have to drop the pointer to the loaded texture, because the name of the method does not start with 'create'. The texture is stored somewhere by the driver.

Definition at line 41 of file IUnknown.h.


Constructor & Destructor Documentation

irr::IUnknown::IUnknown  )  [inline]
 

Constructor.

Definition at line 46 of file IUnknown.h.

virtual irr::IUnknown::~IUnknown  )  [inline, virtual]
 

Destructor.

Definition at line 52 of file IUnknown.h.


Member Function Documentation

bool irr::IUnknown::drop  )  [inline]
 

Drops the object. Decrements the reference counter by one. Returns true, if the object was deleted. The IUnknown class provides a basic reference counting mechanism with its methods grab() and drop(). Most objects of the Irrlicht Engine are derived from IUnknown, and so they are reference counted.

When you create an object in the Irrlicht engine, calling a method which starts with 'create', an object is created, and you get a pointer to the new object. If you no longer need the object, you have to call drop(). This will destroy the object, if grab() was not called in another part of you program, because this part still needs the object. Note, that you only need to call drop() to the object, if you created it, and the method had a 'create' in it.

A simple example:

If you want to create a texture, you may want to call an imaginable method IDriver::createTexture. You call ITexture* texture = driver->createTexture(dimension2d<s32>(128, 128)); If you no longer need the texture, call texture->drop(). If you want to load a texture, you may want to call imaginable method IDriver::loadTexture. You do this like ITexture* texture = driver->loadTexture("example.jpg"); You will not have to drop the pointer to the loaded texture, because the name of the method does not start with 'create'. The texture is stored somewhere by the driver.

Definition at line 112 of file IUnknown.h.

References _IRR_DEBUG_BREAK_IF.

Referenced by irr::scene::ISceneNode::setParent(), irr::scene::ISceneNode::setTriangleSelector(), and irr::scene::ISceneNode::~ISceneNode().

const c8* irr::IUnknown::getDebugName  )  const [inline]
 

Returns the debug name of the object. The Debugname may only be set and changed by the object itself. This method should only be used in Debug mode.

Returns:
Returns a string, previously set by setDebugName();

Definition at line 129 of file IUnknown.h.

void irr::IUnknown::grab  )  [inline]
 

Grabs the object. Increments the reference counter by one. Someone who calls grab() to an object, should later also call drop() to it. If an object never gets as much drop() as grab() calls, it will never be destroyed. The IUnknown class provides a basic reference counting mechanism with its methods grab() and drop(). Most objects of the Irrlicht Engine are derived from IUnknown, and so they are reference counted.

When you create an object in the Irrlicht engine, calling a method which starts with 'create', an object is created, and you get a pointer to the new object. If you no longer need the object, you have to call drop(). This will destroy the object, if grab() was not called in another part of you program, because this part still needs the object. Note, that you only need to call drop() to the object, if you created it, and the method had a 'create' in it.

A simple example:

If you want to create a texture, you may want to call an imaginable method IDriver::createTexture. You call ITexture* texture = driver->createTexture(dimension2d<s32>(128, 128)); If you no longer need the texture, call texture->drop(). If you want to load a texture, you may want to call imaginable method IDriver::loadTexture. You do this like ITexture* texture = driver->loadTexture("example.jpg"); You will not have to drop the pointer to the loaded texture, because the name of the method does not start with 'create'. The texture is stored somewhere by the driver.

Definition at line 84 of file IUnknown.h.

Referenced by irr::scene::ISceneNode::addChild(), irr::scene::SAnimatedMesh::addMesh(), and irr::scene::ISceneNode::setParent().

void irr::IUnknown::setDebugName const c8 newName  )  [inline, protected]
 

Sets the debug name of the object. The Debugname may only be set and changed by the object itself. This method should only be used in Debug mode.

Parameters:
newName,: New debug name to set.

Definition at line 139 of file IUnknown.h.

Referenced by irr::scene::CMeshBuffer< T >::CMeshBuffer(), irr::scene::SAnimatedMesh::SAnimatedMesh(), and irr::scene::SMesh::SMesh().


The documentation for this class was generated from the following file:
The Irrlicht Engine
The Irrlicht Engine Documentation © 2003-2007 by Nikolaus Gebhardt. Generated on Sun Jun 17 09:38:39 2007 by Doxygen (1.4.2)