Loading...
Searching...
No Matches
IReferenceCounted.h
Go to the documentation of this file.
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_IREFERENCE_COUNTED_H_INCLUDED__
#define __I_IREFERENCE_COUNTED_H_INCLUDED__
#include "irrTypes.h"
namespace irr
{
class IReferenceCounted
{
public:
IReferenceCounted()
: DebugName(0), ReferenceCounter(1)
{
}
virtual ~IReferenceCounted()
{
}
void grab() const { ++ReferenceCounter; }
bool drop() const
{
// someone is doing bad reference counting.
_IRR_DEBUG_BREAK_IF(ReferenceCounter <= 0)
--ReferenceCounter;
if (!ReferenceCounter)
{
delete this;
return true;
}
return false;
}
s32 getReferenceCount() const
{
return ReferenceCounter;
}
const c8* getDebugName() const
{
return DebugName;
}
protected:
void setDebugName(const c8* newName)
{
DebugName = newName;
}
private:
const c8* DebugName;
mutable s32 ReferenceCounter;
};
} // end namespace irr
#endif
irr::IReferenceCounted::getDebugName
const c8 * getDebugName() const
Returns the debug name of the object.
Definition IReferenceCounted.h:142
irr::IReferenceCounted::drop
bool drop() const
Drops the object. Decrements the reference counter by one.
Definition IReferenceCounted.h:116
irr::IReferenceCounted::grab
void grab() const
Grabs the object. Increments the reference counter by one.
Definition IReferenceCounted.h:86
irr::IReferenceCounted::setDebugName
void setDebugName(const c8 *newName)
Sets the debug name of the object.
Definition IReferenceCounted.h:153
irr::IReferenceCounted::~IReferenceCounted
virtual ~IReferenceCounted()
Destructor.
Definition IReferenceCounted.h:52
irr::IReferenceCounted::IReferenceCounted
IReferenceCounted()
Constructor.
Definition IReferenceCounted.h:46
irr::IReferenceCounted::getReferenceCount
s32 getReferenceCount() const
Get the reference count.
Definition IReferenceCounted.h:133
irrTypes.h
_IRR_DEBUG_BREAK_IF
#define _IRR_DEBUG_BREAK_IF(_CONDITION_)
define a break macro for debugging.
Definition irrTypes.h:178
irr
Everything in the Irrlicht Engine can be found in this namespace.
Definition aabbox3d.h:13
irr::c8
char c8
8 bit character variable.
Definition irrTypes.h:31
irr::s32
signed int s32
32 bit signed variable.
Definition irrTypes.h:66
- Irrlicht Engine Documentation © 2003-2012 by Nikolaus Gebhardt. Generated on for Irrlicht 3D Engine by Doxygen 1.15.0