Jimcpp 2.1.0
Jimcpp is a high-performance c++ graphics engine.
|
Base class of most objects of the Jimcpp Engine. More...
#include <jimcpp/core/engine/IReferenceCounted.hpp>
Inherited by jpp::ILogger [virtual]
, jpp::IOSOperator [virtual]
, jpp::IRandomizer [virtual]
, jpp::ITimer [virtual]
, jpp::JimcppDevice [virtual]
, jpp::gui::ICursorControl [virtual]
, jpp::gui::IGUIElementFactory [virtual]
, jpp::gui::IGUIEnvironment [virtual]
, jpp::gui::IGUIFont [virtual]
, jpp::gui::IGUIImageList [virtual]
, jpp::gui::IGUISpriteBank [virtual]
, jpp::gui::IGUITreeViewNode, jpp::io::IArchiveLoader [virtual]
, jpp::io::IAttributeExchangingObject [virtual]
, jpp::io::IAttributes [virtual]
, jpp::io::IFileArchive [virtual]
, jpp::io::IFileList [virtual]
, jpp::io::IFileSystem [virtual]
, jpp::io::IReadFile [virtual]
, jpp::io::IWriteFile [virtual]
, jpp::scene::IAnimationEndCallBack [virtual]
, jpp::scene::IColladaMeshWriterNames [virtual]
, jpp::scene::IColladaMeshWriterProperties [virtual]
, jpp::scene::ICollisionCallback [virtual]
, jpp::scene::IGeometryCreator, jpp::scene::IIndexBuffer [virtual]
, jpp::scene::ILightManager, jpp::scene::IMesh [virtual]
, jpp::scene::IMeshBuffer [virtual]
, jpp::scene::IMeshCache [virtual]
, jpp::scene::IMeshLoader [virtual]
, jpp::scene::IMeshManipulator [virtual]
, jpp::scene::IMeshTextureLoader [virtual]
, jpp::scene::IMeshWriter [virtual]
, jpp::scene::ISceneCollisionManager [virtual]
, jpp::scene::ISceneLoader [virtual]
, jpp::scene::ISceneManager [virtual]
, jpp::scene::ISceneNodeAnimatorFactory [virtual]
, jpp::scene::ISceneNodeFactory [virtual]
, jpp::scene::ITriangleSelector [virtual]
, jpp::scene::IVertexBuffer [virtual]
, jpp::scene::SMD3Mesh, jpp::scene::SMD3MeshBuffer, jpp::scene::quake3::IShaderManager, jpp::scene::quake3::SVarGroupList, jpp::video::IContextManager [virtual]
, jpp::video::IImage [virtual]
, jpp::video::IImageLoader [virtual]
, jpp::video::IImageWriter, jpp::video::IMaterialRenderer [virtual]
, jpp::video::IRenderTarget [virtual]
, jpp::video::IShaderConstantSetCallBack [virtual]
, jpp::video::ITexture [virtual]
, jpp::video::IVideoDriver [virtual]
, and jpp::video::IVideoModeList [virtual]
.
Public Member Functions | |
IReferenceCounted () | |
Constructor. | |
virtual | ~IReferenceCounted () |
Destructor. | |
void | grab () const |
Grabs the object. Increments the reference counter by one. | |
bool | drop () const |
Drops the object. Decrements the reference counter by one. | |
s32 | getReferenceCount () const |
Get the reference count. | |
const c8 * | getDebugName () const |
Returns the debug name of the object. | |
Protected Member Functions | |
void | setDebugName (const c8 *newName) |
Sets the debug name of the object. | |
Base class of most objects of the Jimcpp 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 Jimcpp Engine are derived from IReferenceCounted, and so they are reference counted.
When you create an object in the Jimcpp 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<u32>(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.
|
inline |
Drops the object. Decrements the reference counter by one.
The IReferenceCounted class provides a basic reference counting mechanism with its methods grab() and drop(). Most objects of the Jimcpp Engine are derived from IReferenceCounted, and so they are reference counted.
When you create an object in the Jimcpp 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<u32>(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.
|
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.
|
inline |
Get the reference count.
|
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 IReferenceCounted class provides a basic reference counting mechanism with its methods grab() and drop(). Most objects of the Jimcpp Engine are derived from IReferenceCounted, and so they are reference counted.
When you create an object in the Jimcpp 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<u32>(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.
|
inlineprotected |
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.
newName | New debug name to set. |