TrueReality  v0.1.1912
AppBase.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 #include <trApp/AppBase.h>
22 
24 #include <trCore/SystemControls.h>
25 
26 namespace trApp
27 {
28  const trUtil::RefStr AppBase::CLASS_TYPE = trUtil::RefStr("trApp::AppBase");
29 
31  AppBase::AppBase(const std::string& name) : BaseClass(name)
32  {
33  //Create an instance of the System Manager
35 
36  //Create and register the System Director
38 
39  //We want the System Director to get and handle all messages before any other Director.
41  }
42 
45  {
46  }
47 
49  const std::string& AppBase::GetType() const
50  {
51  return CLASS_TYPE;
52  }
53 
55  void AppBase::Run()
56  {
57  mSysDirector->Run();
58  }
59 
62  {
63  //Create a System Control Shutdown message
65 
66  //Send message
67  mSysMan->SendMessage(*msg);
68  }
69 }
virtual void Run()
Starts the application loop.
Definition: AppBase.cpp:55
static DirectorPriority HIGHEST
Highest possible priority.
static trManager::SystemManager & GetInstance()
Holds the class type name for efficient comparisons.
Smart pointer for handling referenced counted objects.
Definition: SmrtPtr.h:36
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
Definition: AppBase.h:31
virtual void Quit()
Stops the application loop and exits the application.
Definition: AppBase.cpp:61
virtual bool RegisterDirector(trManager::EntityBase &director, trManager::DirectorPriority &priority=trManager::DirectorPriority::NORMAL)
Adds a director to the list of components the system manager will communicate with.
virtual const std::string & GetType() const override
Gets the type.
Definition: AppBase.cpp:49
AppBase(const std::string &name=CLASS_TYPE)
Holds the class type name for efficient comparisons.
Definition: AppBase.cpp:31
A System director.
This is a Base class that carries the Class name and Unique ID of all the derived classes...
Definition: trBase/Base.h:36
trBase::SmrtPtr< trCore::SystemDirector > mSysDirector
Definition: AppBase.h:91
trBase::SmrtPtr< trManager::SystemManager > mSysMan
Definition: AppBase.h:79
virtual bool SendMessage(const trManager::MessageBase &message)
Send a message to an Actor, Actor Module, or a Director.
virtual void Run()
Runs the systems game loop.
~AppBase()
Destructor.
Definition: AppBase.cpp:44
static const SystemControls SHUT_DOWN
Shuts down the system loop and exits the program.
A message that lets the system know what state to enable and setup.
static const trUtil::RefStr CLASS_TYPE
Adds an easy and swappable access to the base class.
Definition: AppBase.h:43