|
TrueReality
v0.1.1912
|
This serves as the base class for the Entity class and removes a circular dependency between Entity and System Manager. More...
#include <EntityBase.h>


Public Types | |
| 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 | |
| EntityBase (const std::string &name=CLASS_TYPE) | |
| Invokable for Tick Remote messages. More... | |
| virtual const std::string & | GetType () const override=0 |
| Returns the class type. More... | |
| const EntityType & | GetEntityType () |
| 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 void | OnAddedToSysMan () |
| Called by the System Manager when EntityBase Registration is complete. More... | |
| virtual void | OnRemovedFromSysMan () |
| Called by the System Manager after removing and Unregistering the EntityBase. 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::Invokable * | GetInvokable (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 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)=0 |
| 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 | 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::EntityBase * | FindChild (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::EntityBase * | GetParent () |
| Gets the parent of this hierarchal Entity. More... | |
| const trManager::EntityBase * | GetParent () 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::UniqueId & | GetUUID (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 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 | |
| ~EntityBase () | |
Protected Member Functions inherited from trBase::Base | |
| ~Base () | |
| Base destructor. More... | |
Protected Member Functions inherited from trBase::SmrtClass | |
| ~SmrtClass () | |
Protected Attributes | |
| trBase::ObsrvrPtr< trManager::SystemManager > | mSysMan |
| trUtil::EnumerationPointer< const trManager::EntityType > | mEntityType |
| trUtil::HashMap< std::string, trBase::SmrtPtr< trManager::Invokable > > | mInvokables |
Private Attributes | |
| bool | mIsRegistered = false |
| std::vector< trBase::SmrtPtr< trManager::EntityBase > > | mChildren |
| trBase::SmrtPtr< trManager::EntityBase > | mParent |
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... | |
This serves as the base class for the Entity class and removes a circular dependency between Entity and System Manager.
Definition at line 46 of file EntityBase.h.
Definition at line 50 of file EntityBase.h.
| trManager::EntityBase::EntityBase | ( | const std::string & | name = CLASS_TYPE | ) |
Invokable for Tick Remote messages.
Constructor.
| name | (Optional) The name. |
Definition at line 36 of file EntityBase.cpp.
References trManager::EntityType::INVALID, and mEntityType.
|
protected |
Definition at line 337 of file EntityBase.cpp.
|
virtual |
Adds a child to this Entity.
| [in,out] | child | The child. |
Definition at line 143 of file EntityBase.cpp.
References trManager::EntityType::ACTOR, GetEntityType(), trUtil::EnumerationString::GetName(), trBase::Base::GetName(), GetParent(), LOG_E, mChildren, and SetParent().
Referenced by RemoveFromHierarchy().


|
virtual |
Adds an invokable that can receive a message.
| [in,out] | newInvokable | The new invokable. |
Definition at line 66 of file EntityBase.cpp.
References trBase::Base::GetName(), trManager::Invokable::GetName(), LOG_D, LOG_W, and mInvokables.
Referenced by trManager::DirectorBase::BuildInvokables(), and trManager::ActorBase::BuildInvokables().


|
virtual |
Removes the hierarchal parent of this Entity, and removes this Entity from the parent.
| [in,out] | parent | The parent. |
Definition at line 286 of file EntityBase.cpp.
References ForgetParent(), trBase::Base::GetName(), LOG_W, mParent, RemoveChild(), and trBase::SmrtPtr< T >::Valid().
Referenced by RemoveChild().


|
virtual |
Finds a child of this Entity in the children list.
| childId | Identifier for the child. |
Definition at line 214 of file EntityBase.cpp.
References trBase::Base::GetUUID(), and mChildren.

|
virtual |
Forgets the hierarchal parent of this Entiry.
This is for system use only. Used Emancipate() if you want to disconnect your entity.
Definition at line 253 of file EntityBase.cpp.
References mParent, and OnParentRemoved().
Referenced by Emancipate(), and RemoveFromHierarchy().


|
virtual |
Definition at line 202 of file EntityBase.cpp.
References mChildren.
|
virtual |
Definition at line 208 of file EntityBase.cpp.
References mChildren.
| const EntityType & trManager::EntityBase::GetEntityType | ( | ) |
Returns the Entity Type, which is usually a Director, Actor, or an Actor module.
Definition at line 42 of file EntityBase.cpp.
References mEntityType.
Referenced by trManager::ActorBase::AddActorModule(), AddChild(), trManager::DirectorBase::CompareComponentPriority(), trManager::SystemManager::RegisterDirector(), trManager::SystemManager::RegisterForMessage(), trManager::ActorBase::RemoveActorModule(), trManager::ActorBase::RemoveAllActorModules(), trManager::SystemManager::UnregisterDirector(), trManager::SystemManager::UnregisterDirectorFromGlobalMessages(), and trManager::SystemManager::UnregisterFromMessage().

| trManager::Invokable * trManager::EntityBase::GetInvokable | ( | const std::string & | name | ) |
Gets a registered invokable.
| name | The name. |
Definition at line 102 of file EntityBase.cpp.
References mInvokables.
Referenced by trManager::SystemManager::CallInvokable(), and trManager::SystemManager::SendGlobalyRegisteredMessage().

| void trManager::EntityBase::GetInvokables | ( | std::vector< trManager::Invokable *> & | toFill | ) |
Gets the list of invokables.
| [in,out] | toFill | [in,out] If non-null, to fill. |
Definition at line 117 of file EntityBase.cpp.
References mInvokables.
| void trManager::EntityBase::GetInvokables | ( | std::vector< const trManager::Invokable *> & | toFill | ) | const |
Gets the invokables.
| toFill | to fill. |
Definition at line 130 of file EntityBase.cpp.
References mInvokables.
|
virtual |
Gets the children of this Entity has.
Definition at line 230 of file EntityBase.cpp.
References mChildren.
| trManager::EntityBase * trManager::EntityBase::GetParent | ( | ) |
Gets the parent of this hierarchal Entity.
Definition at line 264 of file EntityBase.cpp.
References trBase::SmrtPtr< T >::Get(), and mParent.
Referenced by AddChild(), and RemoveChild().


| const trManager::EntityBase * trManager::EntityBase::GetParent | ( | ) | const |
Gets the parent of this hierarchal Entity.
Definition at line 270 of file EntityBase.cpp.
References trBase::SmrtPtr< T >::Get(), and mParent.

|
overridepure virtual |
Returns the class type.
Implements trBase::Base.
Implemented in trManager::DirectorBase, trCore::SystemDirector, trManager::ActorModuleBase, and trManager::ActorBase.
Referenced by trManager::SystemManager::RegisterActor(), trManager::SystemManager::RegisterDirector(), trManager::SystemManager::UnregisterActor(), and trManager::SystemManager::UnregisterDirector().

|
virtual |
Returns True if the Instance is registered with a System Manager.
Definition at line 107 of file EntityBase.h.
Referenced by trManager::ActorBase::RegisterForMessage(), trManager::ActorBase::RegisterForMessagesAboutEntity(), trCore::SystemDirector::Run(), trCore::SystemDirector::RunOnce(), trManager::SystemManager::SendGlobalyRegisteredMessage(), trManager::ActorBase::SendMessage(), trManager::ActorBase::SendNetworkMessage(), SetSystemManager(), trManager::ActorBase::UnRegisterFromMessage(), and trManager::ActorBase::UnregisterFromMessagesAboutEntity().

|
inlinevirtual |
Called by the System Manager when EntityBase Registration is complete.
Reimplemented in trManager::ActorBase.
Definition at line 100 of file EntityBase.h.
Referenced by trManager::ActorBase::OnAddedToSysMan(), trManager::SystemManager::RegisterActor(), and trManager::SystemManager::RegisterDirector().

|
virtual |
Convenience function that will be called by the system when the Entities parent is removed.
Overwrite to capture the event.
| [in,out] | parent | The parent. |
Definition at line 276 of file EntityBase.cpp.
Referenced by ForgetParent().

|
virtual |
Convenience function that will be called by the system when a new parent is added or set to the Entity.
Overwrite to capture the event.
| [in,out] | parent | The parent. |
Definition at line 281 of file EntityBase.cpp.
Referenced by SetParent().

|
inlinevirtual |
Called by the System Manager after removing and Unregistering the EntityBase.
Reimplemented in trManager::ActorBase.
Definition at line 107 of file EntityBase.h.
Referenced by trManager::ActorBase::OnRemovedFromSysMan().

|
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.
| msg | The message. |
Implemented in trManager::ActorBase, trManager::DirectorBase, and trManager::ActorModuleBase.
|
pure 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.
| msg | The message. |
Implemented in trManager::ActorBase.
|
virtual |
Removes all of the entities children .
Definition at line 189 of file EntityBase.cpp.
References mChildren.
|
virtual |
Removes the child from this Entity.
| [in,out] | child | The child. |
Definition at line 168 of file EntityBase.cpp.
References Emancipate(), GetParent(), and mChildren.
Referenced by Emancipate().


|
virtual |
Removes from this entity from the hierarchy tree attaching its children to its parent.
Does nothing if this entity does not have a parent.
Definition at line 305 of file EntityBase.cpp.
References AddChild(), ForgetParent(), trBase::Base::GetName(), LOG_E, mChildren, mParent, and trBase::SmrtPtr< T >::Valid().

|
virtual |
Removes the invokable that is passed in.
| [in,out] | invokable | If non-null, the invokable. |
Definition at line 81 of file EntityBase.cpp.
References trManager::Invokable::GetName().

|
virtual |
Removes the invokable described by invokableName.
| invokableName | Name of the invokable. |
Definition at line 87 of file EntityBase.cpp.
References LOG_W, and mInvokables.
|
virtual |
Sets the hierarchal parent of this Entity.
This is for system use only. Use AddChild() if you want to attach entities.
| [in,out] | parent | The parent. |
Definition at line 236 of file EntityBase.cpp.
References trBase::Base::GetName(), LOG_E, mParent, OnParentSet(), and trBase::SmrtPtr< T >::Valid().
Referenced by trManager::ActorBase::AddActorModule(), and AddChild().


|
virtual |
Is set to True by the System Manager when the class instance is registered with it.
This function should not be called by the user.
| isRegistered | True if this object is registered. |
Definition at line 60 of file EntityBase.cpp.
References mIsRegistered.
Referenced by trManager::SystemManager::RegisterActor(), and trManager::SystemManager::RegisterDirector().

|
virtual |
This method is used by the System Manager to pass the Entity an instance if itself when it is registered.
The user should not use this function.
| [in,out] | sysMan | If non-null, manager for system. |
Definition at line 48 of file EntityBase.cpp.
References IsRegistered(), mIsRegistered, and mSysMan.
Referenced by trManager::SystemManager::RegisterActor(), and trManager::SystemManager::RegisterDirector().


|
static |
Adds an easy and swappable access to the base class.
Definition at line 52 of file EntityBase.h.
|
private |
Definition at line 360 of file EntityBase.h.
Referenced by AddChild(), FindChild(), GetChildren(), GetNumOfChildren(), RemoveAllChildren(), RemoveChild(), and RemoveFromHierarchy().
|
protected |
Definition at line 352 of file EntityBase.h.
Referenced by trManager::ActorBase::ActorBase(), trManager::ActorModuleBase::ActorModuleBase(), trManager::DirectorBase::DirectorBase(), EntityBase(), and GetEntityType().
|
protected |
Definition at line 353 of file EntityBase.h.
Referenced by AddInvokable(), GetInvokable(), GetInvokables(), and RemoveInvokable().
|
private |
Definition at line 359 of file EntityBase.h.
Referenced by SetRegistration(), and SetSystemManager().
|
private |
Definition at line 361 of file EntityBase.h.
Referenced by Emancipate(), ForgetParent(), GetParent(), RemoveFromHierarchy(), and SetParent().
|
protected |
Definition at line 351 of file EntityBase.h.
Referenced by trCore::SystemDirector::CameraSynch(), trCore::SystemDirector::CheckForShutdown(), trCore::SystemDirector::EventTraversal(), trCore::SystemDirector::Frame(), trCore::SystemDirector::FrameSynch(), trCore::SystemDirector::PostEventTraversal(), trCore::SystemDirector::PostFrame(), trCore::SystemDirector::PreFrame(), trManager::ActorBase::RegisterForMessage(), trManager::ActorBase::RegisterForMessagesAboutEntity(), trManager::ActorBase::SendMessage(), trManager::ActorBase::SendNetworkMessage(), SetSystemManager(), trManager::ActorBase::UnRegisterFromMessage(), and trManager::ActorBase::UnregisterFromMessagesAboutEntity().
|
static |
Holds the class type name for efficient comparisons.
Definition at line 54 of file EntityBase.h.
Referenced by trManager::DirectorBase::BuildInvokables(), and trManager::SystemManager::SendMessageToDirectors().
|
static |
Invokable for general messages.
Definition at line 55 of file EntityBase.h.
Referenced by trManager::ActorBase::BuildInvokables().
|
static |
Invokable for Tick messages.
Definition at line 56 of file EntityBase.h.
Referenced by trManager::ActorBase::BuildInvokables().