dtCore::Base Class Reference

Base class to support naming and message passing. More...

#include <base.h>

Inheritance diagram for dtCore::Base:

dtABC::BaseABC dtABC::State dtABC::StateManager dtABC::Weather dtAudio::AudioManager dtAudio::SoundEffectBinder dtCore::DeltaDrawable dtCore::DeltaWin dtCore::InputDevice dtCore::InputMapper dtCore::MotionModel dtCore::Recorder< RecordableT, FrameDataT > dtCore::Scene dtCore::ShaderManager dtCore::ShaderParameter dtCore::System dtCore::View dtDAL::GameEvent dtGame::DeadReckoningHelper dtGame::GameManager dtGame::GMComponent dtHLAGM::DDMRegionCalculator dtHLAGM::ParameterTranslator dtNet::NetMgr dtNetGM::NetworkBridge dtScript::ScriptManager dtTerrain::TerrainDataReader dtTerrain::TerrainDataRenderer dtTerrain::TerrainDecorationLayer

List of all members.

Public Member Functions

 Base (const std::string &name="base")
 Constructor.
void SetName (const std::string &name)
 Sets the name of this instance.
const std::string & GetName () const
 Returns the name of this instance.
void SetUniqueId (const UniqueId &id)
 This sets the unique ID, for general purposes this should not be used.
const UniqueIdGetUniqueId () const
 This class returns an instance the the UniqueID.
virtual void OnMessage (MessageData *data)
 Override to receive messages.
void AddSender (Base *sender)
 Receive all messages from the supplied sender instance.
void RemoveSender (Base *sender)
 Stop receiving messages from the supplied sender instance.
void SendMessage (const std::string &message="", void *data=0)
 Send a message to any instances that are subscribed to this instance.

Protected Member Functions

virtual ~Base ()
 Destructor.

Classes

struct  MessageData
 Data that gets passed through SendMessage. More...


Detailed Description

Base class to support naming and message passing.

The Base class handles things that are required by most of the dtCore classes such as naming, RTTI, and message passing. To name an instance, call SetName() or pass it to the constructor.

Inter-class message passing is handled by "subscribing" the instance to a sender using AddSender(). Anytime the sender calls SendMessage(), the receiver class' OnMessage() will get triggered. The MessageData that gets passed to OnMessage() contains a pointer to the sender, and optionally, a text message and pointer to user data.

This class is also reference counted using the osg::Referenced class. To safely keep the reference count up-to-date, pointers to Base classes should be stored in a RefPtr template. For example:

 RefPtr<Base> mPointerToMyBase;

Constructor & Destructor Documentation

dtCore::Base::Base ( const std::string &  name = "base"  ) 

Constructor.

Parameters:
name the instance name

dtCore::Base::~Base (  )  [protected, virtual]

Destructor.


Member Function Documentation

void dtCore::Base::SetName ( const std::string &  name  ) 

Sets the name of this instance.

Parameters:
name the new name

const std::string & dtCore::Base::GetName (  )  const

Returns the name of this instance.

Returns:
the current name

Reimplemented in dtCore::ShaderParameter.

void dtCore::Base::SetUniqueId ( const UniqueId id  )  [inline]

This sets the unique ID, for general purposes this should not be used.

const UniqueId& dtCore::Base::GetUniqueId (  )  const [inline]

This class returns an instance the the UniqueID.

virtual void dtCore::Base::OnMessage ( MessageData data  )  [inline, virtual]

Override to receive messages.

Reimplemented in dtABC::Action, dtABC::BaseABC, dtABC::StateManager, dtABC::Trigger, dtABC::Widget, dtAnim::CharDrawable, dtAudio::AudioManager, dtAudio::Sound, dtCore::Camera, dtCore::EffectManager, dtCore::FlyMotionModel, dtCore::FPSMotionModel, dtCore::Recorder< RecordableT, FrameDataT >, dtCore::Scene, dtCore::ShaderManager, dtCore::ShaderParamOscillator, dtCore::Tripod, dtCore::UFOMotionModel, dtCore::WalkMotionModel, dtGame::GameManager, dtGUI::CEUIDrawable, and dtTerrain::Terrain.

void dtCore::Base::AddSender ( Base sender  ) 

Receive all messages from the supplied sender instance.

Subscribe this instance to the supplied sender.

Any message that sender sends, will be received in the OnMessage() method.

Parameters:
sender The sender that this instance should listen to

void dtCore::Base::RemoveSender ( Base sender  ) 

Stop receiving messages from the supplied sender instance.

void dtCore::Base::SendMessage ( const std::string &  message = "",
void *  data = 0 
)

Send a message to any instances that are subscribed to this instance.

Send a message to any instance thats subscribed to us.

Any supplied string or void* data will be passed to the receiver's OnMessage() method.

Parameters:
message Optional string message
data Optional pointer to user data
message Optional text message (def = "")
data Optional void pointer to any user data (def = 0)


http://www.delta3d.org
2.0.0 generated 14 Feb 2008