TrueReality  v0.1.1912
trManager::ActorBase Class Referenceabstract

A base class for all actors in the entity system. More...

#include <ActorBase.h>

Inheritance diagram for trManager::ActorBase:
Collaboration diagram for trManager::ActorBase:

Public Types

using BaseClass = trManager::EntityBase
 
- Public Types inherited from trManager::EntityBase
using BaseClass = trBase::Base
 
- Public Types inherited from trBase::Base
using BaseClass = trBase::SmrtClass
 
- Public Types inherited from trBase::SmrtClass
using BaseClass = osg::Referenced
 

Public Member Functions

 ActorBase (const std::string &name=CLASS_TYPE)
 Holds the class type name for efficient comparisons. More...
 
virtual const std::string & GetType () const override=0
 Returns the class type. More...
 
virtual void RegisterForMessage (const std::string &messageType, const std::string &invokableName)
 Registers an actor for messages. More...
 
virtual void UnRegisterFromMessage (const std::string &messageType)
 Unregister an actor that is listening for a given message. More...
 
virtual void RegisterForMessagesAboutEntity (const trBase::UniqueId &aboutEntityId, const std::string &invokableName)
 Registers for messages about a specific actor. More...
 
virtual void UnregisterFromMessagesAboutEntity (const trBase::UniqueId &aboutEntityId)
 Unregisters from messages about a specific actor. More...
 
virtual void BuildInvokables ()
 Builds the default invokables for this class. More...
 
virtual void OnTick (const trManager::MessageBase &msg)=0
 Convenience function that will receive Tick Messages from the System Manager This does not happen automatically, each class needs to register for the message. More...
 
virtual void OnTickRemote (const trManager::MessageBase &msg)
 Convenience function that will receive a Network Tick Message from the System Manager This does not happen automatically, each class needs to register for the message. More...
 
virtual bool SendMessage (const trManager::MessageBase &message)
 Send a message to an Actor, Actor Module, or a Director. More...
 
virtual bool SendNetworkMessage (const trManager::MessageBase &message)
 Send a Network message to an Actor, Actor Module, or a Director. More...
 
virtual bool AddActorModule (trManager::EntityBase &actorModule)
 Adds an Actor Module to the current Actor. More...
 
virtual bool RemoveActorModule (trManager::EntityBase &actorModule)
 Removes the given Actor Module from the current Actor. More...
 
virtual bool RemoveActorModule (const trBase::UniqueId &id)
 Removes the given Actor Module from the current Actor. More...
 
virtual bool RemoveAllActorModules ()
 
virtual trManager::EntityBaseFindActorModule (const trBase::UniqueId &id)
 Finds and returns the Actor Module cast down to Entity. More...
 
virtual void OnAddedToSysMan () override
 Called by the System Manager when EntityBase Registration is complete. More...
 
virtual void OnRemovedFromSysMan () override
 Called by the System Manager after removing and Unregistering the EntityBase. More...
 
- Public Member Functions inherited from trManager::EntityBase
 EntityBase (const std::string &name=CLASS_TYPE)
 Invokable for Tick Remote messages. More...
 
const EntityTypeGetEntityType ()
 Returns the Entity Type, which is usually a Director, Actor, or an Actor module. More...
 
virtual void SetSystemManager (trManager::SystemManager *sysMan)
 This method is used by the System Manager to pass the Entity an instance if itself when it is registered. More...
 
virtual const bool & IsRegistered ()
 Returns True if the Instance is registered with a System Manager. More...
 
virtual void SetRegistration (bool isRegistered)
 Is set to True by the System Manager when the class instance is registered with it. More...
 
virtual void AddInvokable (trManager::Invokable &newInvokable)
 Adds an invokable that can receive a message. More...
 
virtual void RemoveInvokable (trManager::Invokable *invokable)
 Removes the invokable that is passed in. More...
 
virtual void RemoveInvokable (const std::string &invokableName)
 Removes the invokable described by invokableName. More...
 
trManager::InvokableGetInvokable (const std::string &name)
 Gets a registered invokable. More...
 
void GetInvokables (std::vector< trManager::Invokable *> &toFill)
 Gets the list of invokables. More...
 
void GetInvokables (std::vector< const trManager::Invokable *> &toFill) const
 Gets the invokables. More...
 
virtual bool AddChild (trManager::EntityBase &child)
 Adds a child to this Entity. More...
 
virtual bool RemoveChild (trManager::EntityBase &child)
 Removes the child from this Entity. More...
 
virtual bool RemoveAllChildren ()
 Removes all of the entities children . More...
 
virtual std::vector< trBase::SmrtPtr< trManager::EntityBase > > * GetChildren ()
 
virtual const std::vector< trBase::SmrtPtr< trManager::EntityBase > > * GetChildren () const
 
virtual const trManager::EntityBaseFindChild (const trBase::UniqueId &childId)
 Finds a child of this Entity in the children list. More...
 
virtual int GetNumOfChildren ()
 Gets the children of this Entity has. More...
 
virtual void SetParent (trManager::EntityBase &parent)
 Sets the hierarchal parent of this Entity. More...
 
virtual void ForgetParent ()
 Forgets the hierarchal parent of this Entiry. More...
 
trManager::EntityBaseGetParent ()
 Gets the parent of this hierarchal Entity. More...
 
const trManager::EntityBaseGetParent () const
 Gets the parent of this hierarchal Entity. More...
 
virtual void OnParentRemoved (trManager::EntityBase &parent)
 Convenience function that will be called by the system when the Entities parent is removed. More...
 
virtual void OnParentSet (trManager::EntityBase &parent)
 Convenience function that will be called by the system when a new parent is added or set to the Entity. More...
 
virtual void Emancipate ()
 Removes the hierarchal parent of this Entity, and removes this Entity from the parent. More...
 
virtual bool RemoveFromHierarchy ()
 Removes from this entity from the hierarchy tree attaching its children to its parent. More...
 
- Public Member Functions inherited from trBase::Base
 Base (const std::string &name=CLASS_TYPE)
 Holds the class type name for efficient comparisons. More...
 
virtual void SetName (const std::string &name)
 Sets this instances name. More...
 
virtual const std::string & GetName ()
 Returns this instances name. More...
 
virtual const std::string & GetName () const
 Returns this instances name. More...
 
virtual void SetUUID (const trBase::UniqueId &id)
 Overwrites the default internal UUID with the passed in one. More...
 
virtual const trBase::UniqueIdGetUUID (void)
 Returns the instances Universally Unique ID. More...
 
- Public Member Functions inherited from trBase::SmrtClass
 SmrtClass ()
 Adds an easy and swappable access to the base class. More...
 
 SmrtClass (bool threadSafeRefUnref)
 Constructor. More...
 
 SmrtClass (const SmrtClass &inst)
 Copy constructor. More...
 
virtual bool GetThreadSafeRefUnref ()
 Get whether a mutex is used to ensure Ref() and UnRef() are thread safe. More...
 
OpenThreads::Mutex * GetRefMutex () const
 Get the mutex used to ensure thread safety of Ref()/UnRef(). More...
 
int Ref () const
 Increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
int Unref () const
 Decrement the reference count by one, indicating that a pointer to this object is no longer referencing it. More...
 
int UnRefNoDelete () const
 Decrement the reference count by one, indicating that a pointer to this object is no longer referencing it. More...
 
int ReferenceCount () const
 Return the number of pointers currently referencing this object. More...
 

Static Public Attributes

static const trUtil::RefStr CLASS_TYPE
 Adds an easy and swappable access to the base class. More...
 
- Static Public Attributes inherited from trManager::EntityBase
static const trUtil::RefStr CLASS_TYPE
 Adds an easy and swappable access to the base class. More...
 
static const trUtil::RefStr ON_MESSAGE_INVOKABLE
 Holds the class type name for efficient comparisons. More...
 
static const trUtil::RefStr ON_TICK_INVOKABLE
 Invokable for general messages. More...
 
static const trUtil::RefStr ON_TICK_REMOTE_INVOKABLE
 Invokable for Tick messages. More...
 
- Static Public Attributes inherited from trBase::Base
static const trUtil::RefStr CLASS_TYPE = trUtil::RefStr("trBase::Base")
 Adds an easy and swappable access to the base class. More...
 

Protected Member Functions

 ~ActorBase ()
 dtor. More...
 
virtual void ActorModuleTick (const trManager::MessageBase &tickMsg)
 Sends the passed in message Tick Message to all attached Actor Modules. More...
 
- Protected Member Functions inherited from trManager::EntityBase
 ~EntityBase ()
 
- Protected Member Functions inherited from trBase::Base
 ~Base ()
 Base destructor. More...
 
- Protected Member Functions inherited from trBase::SmrtClass
 ~SmrtClass ()
 

Private Types

using ActorModules = std::vector< trBase::SmrtPtr< trManager::EntityBase > >
 ActorModules = std::vector<trBase::SmrtPtr<trManager::EntityBase>> More...
 

Private Attributes

ActorModules mActorModules
 
ActorModules mActModReAttachStore
 

Additional Inherited Members

- Static Public Member Functions inherited from trBase::SmrtClass
static OpenThreads::Mutex * GetGlobalReferencedMutex ()
 Get the optional global Referenced mutex, this can be shared between all trBase::SmrtClass. More...
 
- Protected Attributes inherited from trManager::EntityBase
trBase::ObsrvrPtr< trManager::SystemManagermSysMan
 
trUtil::EnumerationPointer< const trManager::EntityTypemEntityType
 
trUtil::HashMap< std::string, trBase::SmrtPtr< trManager::Invokable > > mInvokables
 

Detailed Description

A base class for all actors in the entity system.

Definition at line 41 of file ActorBase.h.

Member Typedef Documentation

◆ ActorModules

ActorModules = std::vector<trBase::SmrtPtr<trManager::EntityBase>>

Defines an alias representing the actor modules.

Definition at line 250 of file ActorBase.h.

◆ BaseClass

Constructor & Destructor Documentation

◆ ActorBase()

trManager::ActorBase::ActorBase ( const std::string &  name = CLASS_TYPE)

Holds the class type name for efficient comparisons.

ctor.

Parameters
name(Optional) The name.

Definition at line 35 of file ActorBase.cpp.

References trManager::EntityType::ACTOR, BuildInvokables(), and trManager::EntityBase::mEntityType.

Here is the call graph for this function:

◆ ~ActorBase()

trManager::ActorBase::~ActorBase ( )
protected

dtor.

Definition at line 42 of file ActorBase.cpp.

Member Function Documentation

◆ ActorModuleTick()

void trManager::ActorBase::ActorModuleTick ( const trManager::MessageBase tickMsg)
protectedvirtual

Sends the passed in message Tick Message to all attached Actor Modules.

It is the developers responsibility to make sure you are passing a TickMessage and nothing else.

Parameters
tickMsgMessage describing the tick.

Definition at line 47 of file ActorBase.cpp.

References mActorModules.

◆ AddActorModule()

bool trManager::ActorBase::AddActorModule ( trManager::EntityBase actorModule)
virtual

Adds an Actor Module to the current Actor.

NOTE: If this actor is never registered with the System Manager, you manually need to remove attached Actor Modules, or there could be a memory leak. Use RemoveAllActorModules() to remove all at once or RemoveActorModule(...) to remove them one at a time.

Parameters
[in,out]actorModuleThe actor module.
Returns
True if it succeeds, false if it fails.

Definition at line 174 of file ActorBase.cpp.

References trManager::EntityType::ACTOR_MODULE, trManager::EntityBase::GetEntityType(), trUtil::EnumerationString::GetName(), LOG_E, mActorModules, and trManager::EntityBase::SetParent().

Referenced by OnAddedToSysMan().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ BuildInvokables()

void trManager::ActorBase::BuildInvokables ( )
virtual

Builds the default invokables for this class.

Reimplemented in trManager::DirectorBase, and trManager::ActorModuleBase.

Definition at line 125 of file ActorBase.cpp.

References trManager::EntityBase::AddInvokable(), trUtil::MakeFunctor(), trManager::EntityBase::ON_TICK_INVOKABLE, trManager::EntityBase::ON_TICK_REMOTE_INVOKABLE, OnTick(), and OnTickRemote().

Referenced by ActorBase().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindActorModule()

trManager::EntityBase * trManager::ActorBase::FindActorModule ( const trBase::UniqueId id)
virtual

Finds and returns the Actor Module cast down to Entity.

Parameters
idThe identifier.
Returns
Null if it fails, else the found actor module.

Definition at line 260 of file ActorBase.cpp.

References mActorModules.

Referenced by RemoveActorModule().

Here is the caller graph for this function:

◆ GetType()

virtual const std::string& trManager::ActorBase::GetType ( ) const
overridepure virtual

Returns the class type.

Implements trManager::EntityBase.

Implemented in trManager::DirectorBase, trCore::SystemDirector, and trManager::ActorModuleBase.

◆ OnAddedToSysMan()

void trManager::ActorBase::OnAddedToSysMan ( )
overridevirtual

Called by the System Manager when EntityBase Registration is complete.

Reimplemented from trManager::EntityBase.

Definition at line 276 of file ActorBase.cpp.

References AddActorModule(), mActModReAttachStore, and trManager::EntityBase::OnAddedToSysMan().

Here is the call graph for this function:

◆ OnRemovedFromSysMan()

void trManager::ActorBase::OnRemovedFromSysMan ( )
overridevirtual

Called by the System Manager after removing and Unregistering the EntityBase.

Reimplemented from trManager::EntityBase.

Definition at line 291 of file ActorBase.cpp.

References mActModReAttachStore, mActorModules, trManager::EntityBase::OnRemovedFromSysMan(), and RemoveAllActorModules().

Here is the call graph for this function:

◆ OnTick()

void trManager::ActorBase::OnTick ( const trManager::MessageBase msg)
pure virtual

Convenience function that will receive Tick Messages from the System Manager This does not happen automatically, each class needs to register for the message.

Parameters
msgThe message.

Implements trManager::EntityBase.

Implemented in trManager::DirectorBase, and trManager::ActorModuleBase.

Referenced by BuildInvokables().

Here is the caller graph for this function:

◆ OnTickRemote()

void trManager::ActorBase::OnTickRemote ( const trManager::MessageBase msg)
virtual

Convenience function that will receive a Network Tick Message from the System Manager This does not happen automatically, each class needs to register for the message.

Parameters
msgThe message.

Implements trManager::EntityBase.

Definition at line 132 of file ActorBase.cpp.

Referenced by BuildInvokables().

Here is the caller graph for this function:

◆ RegisterForMessage()

void trManager::ActorBase::RegisterForMessage ( const std::string &  messageType,
const std::string &  invokableName 
)
virtual

Registers an actor for messages.

Parameters
[in,out]listeningActorThe listening actor.
messageTypeType of the message.
invokableNameName of the invokable.

Definition at line 57 of file ActorBase.cpp.

References trBase::Base::GetName(), trManager::EntityBase::IsRegistered(), LOG_E, LOG_W, and trManager::EntityBase::mSysMan.

Here is the call graph for this function:

◆ RegisterForMessagesAboutEntity()

void trManager::ActorBase::RegisterForMessagesAboutEntity ( const trBase::UniqueId aboutEntityId,
const std::string &  invokableName 
)
virtual

Registers for messages about a specific actor.

Parameters
aboutEntityIdIdentifier for the about entity.
invokableNameName of the invokable.

Definition at line 91 of file ActorBase.cpp.

References trBase::Base::GetName(), trManager::EntityBase::IsRegistered(), LOG_E, LOG_W, and trManager::EntityBase::mSysMan.

Here is the call graph for this function:

◆ RemoveActorModule() [1/2]

bool trManager::ActorBase::RemoveActorModule ( trManager::EntityBase actorModule)
virtual

Removes the given Actor Module from the current Actor.

Parameters
[in,out]actorModuleThe actor module.
Returns
True if it succeeds, false if it fails.

Definition at line 195 of file ActorBase.cpp.

References trManager::EntityType::ACTOR_MODULE, trManager::EntityBase::GetEntityType(), trUtil::EnumerationString::GetName(), LOG_E, and mActorModules.

Referenced by RemoveActorModule(), and RemoveAllActorModules().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RemoveActorModule() [2/2]

bool trManager::ActorBase::RemoveActorModule ( const trBase::UniqueId id)
virtual

Removes the given Actor Module from the current Actor.

Parameters
idThe identifier.
Returns
True if it succeeds, false if it fails.

Definition at line 230 of file ActorBase.cpp.

References FindActorModule(), and RemoveActorModule().

Here is the call graph for this function:

◆ RemoveAllActorModules()

bool trManager::ActorBase::RemoveAllActorModules ( )
virtual

Definition at line 244 of file ActorBase.cpp.

References trManager::EntityBase::GetEntityType(), trBase::Base::GetName(), LOG_E, mActorModules, and RemoveActorModule().

Referenced by OnRemovedFromSysMan().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SendMessage()

bool trManager::ActorBase::SendMessage ( const trManager::MessageBase message)
virtual

Send a message to an Actor, Actor Module, or a Director.

Parameters
messageThe message.
Returns
True if it succeeds, false if it fails.

Definition at line 136 of file ActorBase.cpp.

References trBase::Base::GetName(), trManager::EntityBase::IsRegistered(), LOG_E, LOG_W, and trManager::EntityBase::mSysMan.

Referenced by trCore::SystemDirector::CameraSynch(), trCore::SystemDirector::EventTraversal(), trCore::SystemDirector::Frame(), trCore::SystemDirector::FrameSynch(), trCore::SystemDirector::PostEventTraversal(), trCore::SystemDirector::PostFrame(), trCore::SystemDirector::PreFrame(), trCore::SystemDirector::SetTimeScale(), and trCore::SystemDirector::ShutDown().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SendNetworkMessage()

bool trManager::ActorBase::SendNetworkMessage ( const trManager::MessageBase message)
virtual

Send a Network message to an Actor, Actor Module, or a Director.

Parameters
messageThe message.
Returns
True if it succeeds, false if it fails.

Definition at line 155 of file ActorBase.cpp.

References trBase::Base::GetName(), trManager::EntityBase::IsRegistered(), LOG_E, LOG_W, and trManager::EntityBase::mSysMan.

Here is the call graph for this function:

◆ UnRegisterFromMessage()

void trManager::ActorBase::UnRegisterFromMessage ( const std::string &  messageType)
virtual

Unregister an actor that is listening for a given message.

Parameters
[in,out]listeningActorThe listening actor.
messageTypeType of the message.

Definition at line 74 of file ActorBase.cpp.

References trBase::Base::GetName(), trManager::EntityBase::IsRegistered(), LOG_E, LOG_W, and trManager::EntityBase::mSysMan.

Here is the call graph for this function:

◆ UnregisterFromMessagesAboutEntity()

void trManager::ActorBase::UnregisterFromMessagesAboutEntity ( const trBase::UniqueId aboutEntityId)
virtual

Unregisters from messages about a specific actor.

Parameters
aboutEntityIdIdentifier for the about entity.

Definition at line 108 of file ActorBase.cpp.

References trBase::Base::GetName(), trManager::EntityBase::IsRegistered(), LOG_E, LOG_W, and trManager::EntityBase::mSysMan.

Here is the call graph for this function:

Member Data Documentation

◆ CLASS_TYPE

const trUtil::RefStr trManager::ActorBase::CLASS_TYPE
static

Adds an easy and swappable access to the base class.

Definition at line 47 of file ActorBase.h.

◆ mActModReAttachStore

ActorModules trManager::ActorBase::mActModReAttachStore
private

Definition at line 254 of file ActorBase.h.

Referenced by OnAddedToSysMan(), and OnRemovedFromSysMan().

◆ mActorModules

ActorModules trManager::ActorBase::mActorModules
private

The documentation for this class was generated from the following files: