ToyMaker Game Engine 0.0.2
ToyMaker is a game engine developed and maintained by Zoheb Shujauddin.
Loading...
Searching...
No Matches
ToyMaker::Application Class Reference

Class that handles setup for the rest of the engine and application. More...

#include <application.hpp>

Classes

class  getByPath_Helper
 Base template for engine object getter, used by Application::getObject(). More...
 
struct  getByPath_Helper< TObject, typename std::enable_if_t< SceneNodeCore::getByPath_Helper< TObject >::s_valid > >
 

Public Member Functions

 ~Application ()
 Destroys the application object.
 
void execute ()
 Runs the application loop after setup.
 
template<typename TObject>
TObject getObject (const std::string &path="")
 Gets an object of a specific type by its scene path.
 
SignalTrackergetSignalTracker ()
 Gets the signal tracker associated with the application.
 

Static Public Member Functions

static ApplicationgetInstance ()
 Gets the (sole) instance of Application for this project.
 
static std::shared_ptr< Applicationinstantiate (const std::string &projectPath)
 Creates the single Application object used by the project and returns a reference to it.
 

Private Member Functions

 Application (const std::string &projectPath)
 Constructs a new Application object.
 
void initialize (const nlohmann::json &windowProperties)
 Initializes this project's 3rd party packages, creates an application window.
 
void cleanup ()
 Clean up of 3rd party packages and window resources, if required.
 

Private Attributes

SignalTracker mSignalTracker {}
 The signal tracker associated with this object, which broadcasts Application events and receives events Application is interested in.
 
uint32_t mSimulationStep { 1000/30 }
 The simulation step for the application specified in the app's project file.
 
InputManager mInputManager {}
 The input manager associated with this object.
 
std::weak_ptr< SceneSystemmSceneSystem {}
 A pointer to this project's scene system, valid throughout the project.
 

Static Private Attributes

static std::weak_ptr< Applications_pInstance {}
 A pointer to the (sole) instance of the Application for this project.
 
static bool s_instantiated { false }
 A small static helper variable to determine whether application instantiation has occurred, preventing it from recurring at a later time.
 

Detailed Description

Class that handles setup for the rest of the engine and application.

This class is responsible for initializing the various packages used by the engine, reading window and other project configurations from project.json, and loading and initializing the default or first scene in the project.

Here's an example of a valid project json file:

{
"window_configuration": {
"application_title": "Game of Ur",
"window_width": 800,
"window_height": 600
},
"root_viewport_render_configuration": {
"base_dimensions": [1366, 768],
"update_mode": "on-render-cap-fps",
"resize_type": "texture-dimensions",
"resize_mode": "fixed-aspect",
"render_type": "addition",
"fps_cap": 60,
"render_scale": 1.0
},
"simulation_step": 33,
"input_map_path": "input_bindings.json",
"root_scene_path": "ur_root.json"
}

Constructor & Destructor Documentation

◆ Application()

Application::Application ( const std::string & projectPath)
private

Constructs a new Application object.

Parameters
projectPathThe path to the project JSON file containing the parameters to be used by this Application.

Member Function Documentation

◆ getInstance()

Application & Application::getInstance ( )
static

Gets the (sole) instance of Application for this project.

Returns
Application& A reference to this project's Application object.

◆ getObject()

template<typename TObject>
TObject ToyMaker::Application::getObject ( const std::string & path = "")

Gets an object of a specific type by its scene path.

Template Parameters
TObjectThe type of object being retrieved.
Parameters
pathThe path to that object.
Returns
TObject The object retrieved.

◆ getSignalTracker()

SignalTracker & ToyMaker::Application::getSignalTracker ( )
inline

Gets the signal tracker associated with the application.

Returns
SignalTracker& A reference to the application's SignalTracker.
See also
mSignalTracker

◆ initialize()

void Application::initialize ( const nlohmann::json & windowProperties)
private

Initializes this project's 3rd party packages, creates an application window.

Parameters
windowPropertiesThe properties of the window desired by the application.

◆ instantiate()

std::shared_ptr< Application > Application::instantiate ( const std::string & projectPath)
static

Creates the single Application object used by the project and returns a reference to it.

Parameters
projectPathThe path to the file containing project level configuration data.
Returns
std::shared_ptr<Application> A reference to the instantiated application object.

Member Data Documentation

◆ mInputManager

InputManager ToyMaker::Application::mInputManager {}
private

The input manager associated with this object.

Responsible for receiving and translating SDL events into a form useable by the application.


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