TrueReality  v0.1.1912
DirectorBase.cpp
Go to the documentation of this file.
1 /*
2 * True Reality Open Source Game and Simulation Engine
3 * Copyright © 2021 Acid Rain Studios LLC
4 *
5 * This library is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Lesser General Public License as published by the Free
7 * Software Foundation; either version 3.0 of the License, or (at your option)
8 * any later version.
9 *
10 * This library is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this library; if not, write to the Free Software Foundation, Inc.,
17 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * @author Maxim Serebrennik
20 */
21 
22 #include <trManager/DirectorBase.h>
23 
24 #include <trManager/Invokable.h>
25 #include <trBase/SmrtPtr.h>
26 #include <trUtil/Functor.h>
27 #include <trUtil/Logging/Log.h>
28 
29 namespace trManager
30 {
31  const trUtil::RefStr DirectorBase::CLASS_TYPE = trUtil::RefStr("trManager::DirectorBase");
32 
34  DirectorBase::DirectorBase(const std::string& name) : BaseClass(name)
35  {
39  }
40 
43  {
44  }
45 
48  {
49  if (first.Valid() && second.Valid())
50  {
52  {
53  // The lower the value, the higher the priority
54  return (static_cast<trManager::DirectorBase*>(first.Get())->GetDirectorPriority().GetID() < static_cast<trManager::DirectorBase*>(second.Get())->GetDirectorPriority().GetID());
55  }
56  else
57  {
58  LOG_E("One of the pointers is not a Director, priority comparison failed.")
59  return false;
60  }
61  }
62  else
63  {
64  LOG_E("Invalid pointer, priority comparison failed.")
65  return false;
66  }
67  }
68 
71  {
72  //Do Nothing
73  }
74 
77  {
78  //Do Nothing
79  }
80 
83  {
85  }
86 
89  {
90  return mDirectorPriority;
91  }
92 
95  {
96  mDirectorPriority = priority;
97  }
98 }
virtual void BuildInvokables() override
Builds the default invokables for this class.
Sets the priority for a Director instance.
virtual trManager::DirectorPriority & GetDirectorPriority() const
Returns the Directors message priority.
An Invokable is a queriable method interface that can be added to a trManager::ActorBase Invoking the...
Definition: Invokable.h:84
A string wrapper that will make sure that all of the strings with the same value will point to the sa...
Definition: RefStr.h:50
A director base.
Definition: DirectorBase.h:39
trUtil::EnumerationPointer< const trManager::EntityType > mEntityType
Definition: EntityBase.h:352
DirectorBase(const std::string &name=CLASS_TYPE)
Holds the class type name for efficient comparisons.
virtual void OnMessage(const trManager::MessageBase &msg)
Function that is used by the Systems Manager to deliver all messages to the Director.
virtual void SetDirectorPriority(trUtil::EnumerationPointer< trManager::DirectorPriority > priority)
Sets the Directors message priority.
trUtil::EnumerationPointer< trManager::DirectorPriority > mDirectorPriority
Definition: DirectorBase.h:130
static const trUtil::RefStr CLASS_TYPE
Adds an easy and swappable access to the base class.
Definition: DirectorBase.h:44
static bool CompareComponentPriority(const trBase::SmrtPtr< trManager::EntityBase > &first, const trBase::SmrtPtr< trManager::EntityBase > &second)
Local function used to compare priorities of Directors.
This class is part of the internal garbage collection system.
Definition: SmrtClass.h:38
Functor< typename trUtil::FunTraits< CallType >::ResultType, typename trUtil::FunTraits< CallType >::TypeListType > MakeFunctor(CallType fun)
Constructor.
Definition: Functor.h:288
static DirectorPriority NORMAL
Normal priority.
virtual void AddInvokable(trManager::Invokable &newInvokable)
Adds an invokable that can receive a message.
Definition: EntityBase.cpp:66
static const trUtil::RefStr ON_MESSAGE_INVOKABLE
Holds the class type name for efficient comparisons.
Definition: EntityBase.h:54
#define LOG_E(msg)
Log an ERROR message.
Definition: Log.h:165
bool Valid() const
Returns True if the smart pointer has a valid internal pointer set.
Definition: SmrtPtr.h:103
static const EntityType DIRECTOR
Definition: EntityType.h:43
T * Get() const
Returns the stored internal pointer.
Definition: SmrtPtr.h:73
const EntityType & GetEntityType()
Returns the Entity Type, which is usually a Director, Actor, or an Actor module.
Definition: EntityBase.cpp:42
unsigned int GetID() const
Returns the Numeric value of the Enum.
virtual void OnTick(const trManager::MessageBase &msg)
Function that will receive Tick Messages from the System Manager.
This is the base class for all the messages in TR.
Definition: MessageBase.h:40