The Nebula Device 3: Core::RefCounted Class Reference

The Nebula Device 3

Core::RefCounted Class Reference

#include <refcounted.h>

Inheritance diagram for Core::RefCounted:

Animation::AnimJob Base::DisplayDeviceBase Base::GameContentServerBase Base::InputServerBase Base::JobBase Base::JobPortBase Base::MouseRenderDeviceBase Base::MultipleRenderTargetBase Base::ParticleRendererBase Base::RenderDeviceBase Base::RenderTargetBase Base::ShaderInstanceBase Base::ShaderServerBase Base::ShaderVariableBase Base::ShaderVariableInstanceBase Base::ShaderVariationBase Base::ShapeRendererBase Base::SkinnedMeshRendererBase Base::TextRendererBase Base::TransformDeviceBase Base::VertexLayoutBase Base::VertexLayoutServerBase BaseGameFeature::EntityLoaderBase BaseGameFeature::LoaderServer BaseGameFeature::TimeSource BaseGameFeature::UserProfile Characters::Character Characters::CharacterInstance Characters::CharacterServer Core::CoreServer CoreAnimation::AnimKeyBuffer CoreAnimation::AnimSampleBuffer CoreGraphics::DisplayEventHandler CoreGraphics::RenderEventHandler Debug::DebugCounter Debug::DebugServer Debug::DebugShapeRenderer Debug::DebugTextRenderer Debug::DebugTimer Frame::FrameBatch Frame::FramePassBase Frame::FrameServer Frame::FrameShader FrameSync::FrameSyncSharedData FrameSync::FrameSyncTimer FSM::State FSM::StateMachine FSM::Transition Game::Entity Game::FeatureUnit Game::GameServer Graphics::Display Graphics::GraphicsEntity Graphics::GraphicsServer Graphics::MouseRenderer Graphics::View Http::HttpRequestHandler Http::HttpServer Http::HttpServerProxy Input::InputHandler InternalGraphics::AttachmentServer InternalGraphics::InternalGraphicsEntity InternalGraphics::InternalGraphicsServer InternalGraphics::InternalStage InternalGraphics::InternalView IO::ArchiveBase IO::AssignRegistry IO::Console IO::ConsoleHandler IO::IoServer IO::SchemeRegistry IO::Stream IO::StreamReader IO::StreamWriter Lighting::LightServerBase Messaging::AsyncPort Messaging::Handler Messaging::Message Messaging::Port Models::ModelInstance Models::ModelNode Models::ModelNodeInstance Models::ModelServer Models::VisResolver Net::StdTcpClient Net::StdTcpClientConnection Net::StdTcpServer OSX::OSXThread Particles::ParticleServer Particles::ParticleSystem RenderModules::RenderModule RenderModules::RTPlugin RenderModules::RTPluginRegistry Resources::LoadingResource Resources::ManagedResource Resources::Resource Resources::ResourceDictionary Resources::ResourceLoader Resources::ResourceManager Resources::ResourceMapper Resources::ResourceSaver Resources::ResourceScheduler Script::ActionReader Script::Dialog Script::DialogDesc Script::DialogTake Script::InfoLog Script::InfoLogFilter Script::Task Threading::ObjectRef Visibility::ObserverContext Visibility::VisibilityContainer Visibility::VisibilityContext Visibility::VisibilityQuery Visibility::VisibilitySystemBase Win360::Win360Socket Win360::Win360Thread

Detailed Description

The common base class of Nebula3. Implement a strong refcounted mechanism and runtime type information. Nebula3 checks at application shutdown for propert cleanup of all RefCounted objects. Refcounting leaks will generate a log on the debug output.

FIXME: The RefCounted class uses Interlocked functions and a CriticalSection to guarantee thread-safe refcounting and destruction, but only some classes need this (mostly messages which are passed between threads). If it is guaranteed that an object is only manipulated from the same thread then this thread-synchronization adds unnecessary overhead.

(C) 2006 RadonLabs GmbH

Public Member Functions

 RefCounted ()
 constructor
int GetRefCount () const
 get the current refcount
void AddRef ()
 increment refcount by one
void Release ()
 decrement refcount and destroy object if refcount is zero
bool IsInstanceOf (const Rtti &rtti) const
 return true if this object is instance of given class
bool IsInstanceOf (const Util::String &className) const
 return true if this object is instance of given class by string
bool IsInstanceOf (const Util::FourCC &classFourCC) const
 return true if this object is instance of given class by fourcc
bool IsA (const Rtti &rtti) const
 return true if this object is instance of given class, or a derived class
bool IsA (const Util::String &rttiName) const
 return true if this object is instance of given class, or a derived class, by string
bool IsA (const Util::FourCC &rttiFourCC) const
 return true if this object is instance of given class, or a derived class, by fourcc
const Util::StringGetClassName () const
 get the class name
Util::FourCC GetClassFourCC () const
 get the class FourCC code

Static Public Member Functions

static void DumpRefCountingLeaks ()
 dump refcounting leaks, call at end of application (NEBULA3_DEBUG builds only!)

Protected Member Functions

virtual ~RefCounted ()
 destructor (called when refcount reaches zero)

Member Function Documentation

int Core::RefCounted::GetRefCount (  )  const [inline]

get the current refcount

Return the current refcount of the object.

void Core::RefCounted::AddRef (  )  [inline]

increment refcount by one

Increment the refcount of the object.

void Core::RefCounted::Release (  )  [inline]

decrement refcount and destroy object if refcount is zero

Decrement the refcount and destroy object if refcount is zero.

const Util::String & Core::RefCounted::GetClassName (  )  const [inline]

get the class name

Get the class name of the object.

Util::FourCC Core::RefCounted::GetClassFourCC (  )  const [inline]

get the class FourCC code

Get the class FourCC of the object.

void Core::RefCounted::DumpRefCountingLeaks (  )  [static]

dump refcounting leaks, call at end of application (NEBULA3_DEBUG builds only!)

This method should be called as the very last before an application exits.