TrueReality  v0.1.1912
trCore::SystemDirector Class Reference

A System director. More...

#include <SystemDirector.h>

Inheritance diagram for trCore::SystemDirector:
Collaboration diagram for trCore::SystemDirector:

Public Types

using BaseClass = trManager::DirectorBase
 
- Public Types inherited from trManager::DirectorBase
using BaseClass = trManager::ActorBase
 
- Public Types inherited from trManager::ActorBase
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

 SystemDirector (const std::string name=CLASS_TYPE)
 Hold the minimum time scale the system can use for positive and negaive time. More...
 
virtual const std::string & GetType () const override
 Gets the class type. More...
 
virtual void OnMessage (const trManager::MessageBase &msg)
 This function receives messages coming from the System Manager. More...
 
virtual void Run ()
 Runs the systems game loop. More...
 
virtual void RunOnce ()
 Advanced the game loop by one frame. More...
 
virtual bool IsRunning ()
 Query if this object is running. More...
 
virtual void ShutDown ()
 Shuts down this object and frees any resources it is using. More...
 
trManager::TimingStructure GetTimeStructure ()
 Gets a copy of the internal time structure. More...
 
- Public Member Functions inherited from trManager::DirectorBase
 DirectorBase (const std::string &name=CLASS_TYPE)
 Holds the class type name for efficient comparisons. More...
 
virtual void OnTick (const trManager::MessageBase &msg)
 Function that will receive Tick Messages from the System Manager. More...
 
virtual void BuildInvokables () override
 Builds the default invokables for this class. More...
 
virtual trManager::DirectorPriorityGetDirectorPriority () const
 Returns the Directors message priority. More...
 
virtual void SetDirectorPriority (trUtil::EnumerationPointer< trManager::DirectorPriority > priority)
 Sets the Directors message priority. More...
 
- Public Member Functions inherited from trManager::ActorBase
 ActorBase (const std::string &name=CLASS_TYPE)
 Holds the class type name for efficient comparisons. 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 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 = trUtil::RefStr("trCore::SystemDirector")
 Adds an easy and swappable access to the base class. More...
 
static const double MAX_TIME_SCALE = 1048576
 Holds the class type name for efficient comparisons. More...
 
static const double MIN_TIME_SCALE = 0.03125
 Hold the maximum time scale the system can use for positive and negaive time. More...
 
- Static Public Attributes inherited from trManager::DirectorBase
static const trUtil::RefStr CLASS_TYPE = trUtil::RefStr("trManager::DirectorBase")
 Adds an easy and swappable access to the base class. More...
 
- Static Public Attributes inherited from trManager::ActorBase
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

 ~SystemDirector ()
 Destructor. More...
 
virtual void UpdateTiming (trManager::TimingStructure &timeStruct, double dt)
 Updates the system timing incrementing it by dt. More...
 
virtual void EventTraversal (const trManager::TimingStructure &timeStruct)
 Event traversal event function. More...
 
virtual void PostEventTraversal (const trManager::TimingStructure &timeStruct)
 Post event traversal event function. More...
 
virtual void PreFrame (const trManager::TimingStructure &timeStruct)
 Pre frame event function. More...
 
virtual void CameraSynch (const trManager::TimingStructure &timeStruct)
 Camera synchronization event function. More...
 
virtual void FrameSynch (const trManager::TimingStructure &timeStruct)
 Frame synchronization event function. More...
 
virtual void Frame (const trManager::TimingStructure &timeStruct)
 Frame event function. More...
 
virtual void PostFrame (const trManager::TimingStructure &timeStruct)
 Post frame event function. More...
 
virtual void SetTimeScale (const double timeScale)
 Sets the system time scale. More...
 
virtual void IncrementTimeScale ()
 Increment the system time scale. More...
 
virtual void DecrementTimeScale ()
 Decrement the system time scale. More...
 
virtual void CheckForShutdown ()
 Checks for a shutdown, and cleares the System Manager if in process. More...
 
- Protected Member Functions inherited from trManager::DirectorBase
 ~DirectorBase ()
 dtor. More...
 
- Protected Member Functions inherited from trManager::ActorBase
 ~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 Attributes

bool mIsRunning = false
 
bool mIsShuttingDown = false
 
bool mIsPaused = false
 
trUtil::Timer mSystemTimer
 
trManager::TimingStructure mTimeStruct
 

Additional Inherited Members

- Static Public Member Functions inherited from trManager::DirectorBase
static bool CompareComponentPriority (const trBase::SmrtPtr< trManager::EntityBase > &first, const trBase::SmrtPtr< trManager::EntityBase > &second)
 Local function used to compare priorities of Directors. More...
 
- 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 System director.

This Director does all the timing for TR. It controls the frame loop and keeps track of real and sim time.

Definition at line 39 of file SystemDirector.h.

Member Typedef Documentation

◆ BaseClass

Constructor & Destructor Documentation

◆ SystemDirector()

trCore::SystemDirector::SystemDirector ( const std::string  name = CLASS_TYPE)

Hold the minimum time scale the system can use for positive and negaive time.

Hold the minimum time scale the system can use for positive and negative time (1/32).

Constructor.

Parameters
name(Optional) The instances name.

Definition at line 47 of file SystemDirector.cpp.

◆ ~SystemDirector()

trCore::SystemDirector::~SystemDirector ( )
protected

Destructor.

Definition at line 52 of file SystemDirector.cpp.

Member Function Documentation

◆ CameraSynch()

void trCore::SystemDirector::CameraSynch ( const trManager::TimingStructure timeStruct)
protectedvirtual

Camera synchronization event function.

Sends out a CameraSynchEvent Message.

Parameters
timeStructThe simulation time structure.

Definition at line 261 of file SystemDirector.cpp.

References trCore::SystemEvents::CAMERA_SYNCH, trBase::Base::GetUUID(), LOG_D, trManager::EntityBase::mSysMan, and trManager::ActorBase::SendMessage().

Referenced by Run(), and RunOnce().

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

◆ CheckForShutdown()

void trCore::SystemDirector::CheckForShutdown ( )
protectedvirtual

Checks for a shutdown, and cleares the System Manager if in process.

Definition at line 408 of file SystemDirector.cpp.

References mIsShuttingDown, and trManager::EntityBase::mSysMan.

Referenced by PostFrame().

Here is the caller graph for this function:

◆ DecrementTimeScale()

void trCore::SystemDirector::DecrementTimeScale ( )
protectedvirtual

Decrement the system time scale.

Definition at line 384 of file SystemDirector.cpp.

References LOG_D, MIN_TIME_SCALE, mTimeStruct, SetTimeScale(), and trManager::TimingStructure::timeScale.

Referenced by OnMessage().

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

◆ EventTraversal()

void trCore::SystemDirector::EventTraversal ( const trManager::TimingStructure timeStruct)
protectedvirtual

Event traversal event function.

Sends out an EventTraversalEvent Message.

Parameters
timeStructThe simulation time structure.

Definition at line 210 of file SystemDirector.cpp.

References trCore::SystemEvents::EVENT_TRAVERSAL, trBase::Base::GetUUID(), LOG_D, trManager::EntityBase::mSysMan, and trManager::ActorBase::SendMessage().

Referenced by Run(), and RunOnce().

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

◆ Frame()

void trCore::SystemDirector::Frame ( const trManager::TimingStructure timeStruct)
protectedvirtual

Frame event function.

Sends out FrameEvent Message.

Parameters
timeStructThe simulation time structure.

Definition at line 295 of file SystemDirector.cpp.

References trCore::SystemEvents::FRAME, trBase::Base::GetUUID(), LOG_D, trManager::EntityBase::mSysMan, and trManager::ActorBase::SendMessage().

Referenced by Run(), and RunOnce().

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

◆ FrameSynch()

void trCore::SystemDirector::FrameSynch ( const trManager::TimingStructure timeStruct)
protectedvirtual

Frame synchronization event function.

Sends out a FrameSynchEvent Message.

Parameters
timeStructThe simulation time structure.

Definition at line 278 of file SystemDirector.cpp.

References trCore::SystemEvents::FRAME_SYNCH, trBase::Base::GetUUID(), LOG_D, trManager::EntityBase::mSysMan, and trManager::ActorBase::SendMessage().

Referenced by Run(), and RunOnce().

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

◆ GetTimeStructure()

trManager::TimingStructure trCore::SystemDirector::GetTimeStructure ( )

Gets a copy of the internal time structure.

Returns
The time structure.

Definition at line 185 of file SystemDirector.cpp.

References mTimeStruct.

◆ GetType()

const std::string & trCore::SystemDirector::GetType ( ) const
overridevirtual

Gets the class type.

Returns
The type.

Implements trManager::DirectorBase.

Definition at line 57 of file SystemDirector.cpp.

References CLASS_TYPE.

◆ IncrementTimeScale()

void trCore::SystemDirector::IncrementTimeScale ( )
protectedvirtual

Increment the system time scale.

Definition at line 360 of file SystemDirector.cpp.

References LOG_D, MIN_TIME_SCALE, mTimeStruct, SetTimeScale(), and trManager::TimingStructure::timeScale.

Referenced by OnMessage().

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

◆ IsRunning()

bool trCore::SystemDirector::IsRunning ( )
virtual

Query if this object is running.

Returns
True if running, false if not.

Definition at line 168 of file SystemDirector.cpp.

References mIsRunning.

◆ OnMessage()

◆ PostEventTraversal()

void trCore::SystemDirector::PostEventTraversal ( const trManager::TimingStructure timeStruct)
protectedvirtual

Post event traversal event function.

Sends out a PostEventTraversalEvent Message.

Parameters
timeStructThe simulation time structure.

Definition at line 227 of file SystemDirector.cpp.

References trBase::Base::GetUUID(), LOG_D, trManager::EntityBase::mSysMan, trCore::SystemEvents::POST_EVENT_TRAVERSAL, and trManager::ActorBase::SendMessage().

Referenced by Run(), and RunOnce().

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

◆ PostFrame()

void trCore::SystemDirector::PostFrame ( const trManager::TimingStructure timeStruct)
protectedvirtual

Post frame event function.

Sends out PostFrameEvent Message.

Parameters
timeStructThe simulation time structure.

Definition at line 312 of file SystemDirector.cpp.

References CheckForShutdown(), trBase::Base::GetUUID(), LOG_D, trManager::EntityBase::mSysMan, trCore::SystemEvents::POST_FRAME, and trManager::ActorBase::SendMessage().

Referenced by Run(), and RunOnce().

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

◆ PreFrame()

void trCore::SystemDirector::PreFrame ( const trManager::TimingStructure timeStruct)
protectedvirtual

Pre frame event function.

Sends out a PreFrameEvent Message. Sends out a Tick() Message.

Parameters
timeStructThe simulation time structure.

Definition at line 244 of file SystemDirector.cpp.

References trBase::Base::GetUUID(), LOG_D, trManager::EntityBase::mSysMan, trCore::SystemEvents::PRE_FRAME, and trManager::ActorBase::SendMessage().

Referenced by Run(), and RunOnce().

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

◆ Run()

void trCore::SystemDirector::Run ( )
virtual

◆ RunOnce()

void trCore::SystemDirector::RunOnce ( )
virtual

◆ SetTimeScale()

void trCore::SystemDirector::SetTimeScale ( const double  timeScale)
protectedvirtual

Sets the system time scale.

Parameters
timeScaleThe time scale.

Definition at line 335 of file SystemDirector.cpp.

References trBase::Base::GetUUID(), LOG_D, MAX_TIME_SCALE, MIN_TIME_SCALE, mTimeStruct, trManager::ActorBase::SendMessage(), trCore::SystemEvents::TIME_SCALE_CHANGED, and trManager::TimingStructure::timeScale.

Referenced by DecrementTimeScale(), IncrementTimeScale(), and OnMessage().

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

◆ ShutDown()

void trCore::SystemDirector::ShutDown ( )
virtual

Shuts down this object and frees any resources it is using.

Definition at line 174 of file SystemDirector.cpp.

References trBase::Base::GetUUID(), LOG_D, mIsRunning, mIsShuttingDown, trManager::ActorBase::SendMessage(), and trCore::SystemEvents::SHUTTING_DOWN.

Referenced by OnMessage().

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

◆ UpdateTiming()

void trCore::SystemDirector::UpdateTiming ( trManager::TimingStructure timeStruct,
double  dt 
)
protectedvirtual

Updates the system timing incrementing it by dt.

Parameters
[in,out]timeStructThe time structure.
dtThe delta time between frames.

Definition at line 191 of file SystemDirector.cpp.

References trManager::TimingStructure::deltaRealTime, trManager::TimingStructure::deltaSimTime, trManager::TimingStructure::frameNumber, mIsPaused, trManager::TimingStructure::realTime, trManager::TimingStructure::simTime, and trManager::TimingStructure::timeScale.

Referenced by Run(), and RunOnce().

Here is the caller graph for this function:

Member Data Documentation

◆ CLASS_TYPE

const trUtil::RefStr trCore::SystemDirector::CLASS_TYPE = trUtil::RefStr("trCore::SystemDirector")
static

Adds an easy and swappable access to the base class.

Definition at line 44 of file SystemDirector.h.

Referenced by GetType().

◆ MAX_TIME_SCALE

const double trCore::SystemDirector::MAX_TIME_SCALE = 1048576
static

Holds the class type name for efficient comparisons.

Definition at line 46 of file SystemDirector.h.

Referenced by SetTimeScale().

◆ MIN_TIME_SCALE

const double trCore::SystemDirector::MIN_TIME_SCALE = 0.03125
static

Hold the maximum time scale the system can use for positive and negaive time.

Hold the maximum time scale the system can use for positive and negative time (2^20).

Definition at line 47 of file SystemDirector.h.

Referenced by DecrementTimeScale(), IncrementTimeScale(), and SetTimeScale().

◆ mIsPaused

bool trCore::SystemDirector::mIsPaused = false
private

Definition at line 232 of file SystemDirector.h.

Referenced by OnMessage(), and UpdateTiming().

◆ mIsRunning

bool trCore::SystemDirector::mIsRunning = false
private

Definition at line 230 of file SystemDirector.h.

Referenced by IsRunning(), Run(), RunOnce(), and ShutDown().

◆ mIsShuttingDown

bool trCore::SystemDirector::mIsShuttingDown = false
private

Definition at line 231 of file SystemDirector.h.

Referenced by CheckForShutdown(), and ShutDown().

◆ mSystemTimer

trUtil::Timer trCore::SystemDirector::mSystemTimer
private

Definition at line 233 of file SystemDirector.h.

Referenced by Run(), and RunOnce().

◆ mTimeStruct

trManager::TimingStructure trCore::SystemDirector::mTimeStruct
private

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