CoriEngine
Loading...
Searching...
No Matches
Cori::Core::Application Class Reference

Main Application object, there can only be one Application object. Basically a root of the program. More...

#include <Application.hpp>

Public Member Functions

 Application (const char *windowName)
virtual ~Application ()
void Run ()
 Run loop, internal.

Static Public Member Functions

static std::expected< void, CoriError<> > PushLayer (Layer *layer)
 Pushes a Layer to the LayerStack.
static std::expected< void, CoriError<> > PushOverlay (Layer *overlay)
 Pushes an overlay Layer to the LayerStack.
static void PopLayer ()
 Pops the Layer from the LayerStack.
static void PopOverlay ()
 Pops the overlay Layer from the LayerStack.
static void SetBackgroundColor (const glm::vec4 &color)
 Setts the background color of the rendering canvas.
static WindowGetWindow ()
 Getter for the main Window.
static GameTimerGetGameTimer ()
 Getter for the GameTimer.
static void EmitEvent (Event &event)
 Emits the event and propagates it thought the LayerStack.
template<class F, class... Args>
static std::future< std::invoke_result_t< F, Args... > > SubmitMainTask (F &&f, Args &&... args)
 Submits a task to be executed on the main thread.
template<class F, class... Args>
static std::future< std::invoke_result_t< F, Args... > > SubmitWorkerTask (F &&f, Args &&... args)
 Submits a task to be executed on the worker thread.
static uint16_t GetWorkerCount ()
 Returns a number of available worker threads.

Detailed Description

Main Application object, there can only be one Application object. Basically a root of the program.

Definition at line 23 of file Application.hpp.

Constructor & Destructor Documentation

◆ Application()

Cori::Core::Application::Application ( const char * windowName)
explicit

Definition at line 16 of file Application.cpp.

Here is the call graph for this function:

◆ ~Application()

Cori::Core::Application::~Application ( )
virtual

Definition at line 43 of file Application.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ EmitEvent()

void Cori::Core::Application::EmitEvent ( Event & event)
static

Emits the event and propagates it thought the LayerStack.

Parameters
eventEvent reference to emit.

Definition at line 51 of file Application.cpp.

◆ GetGameTimer()

GameTimer & Cori::Core::Application::GetGameTimer ( )
inlinestatic

Getter for the GameTimer.

Returns
Non const reference to the GameTimer.

Definition at line 84 of file Application.hpp.

◆ GetWindow()

Window & Cori::Core::Application::GetWindow ( )
inlinestatic

Getter for the main Window.

Returns
Non const reference to the main Window.

Definition at line 78 of file Application.hpp.

◆ GetWorkerCount()

uint16_t Cori::Core::Application::GetWorkerCount ( )
static

Returns a number of available worker threads.

Returns
Worker threads count.

Definition at line 55 of file Application.cpp.

◆ PopLayer()

void Cori::Core::Application::PopLayer ( )
static

Pops the Layer from the LayerStack.

The Layer to be popped is the last that was pushed to the LayerStack. If there is nothing to pop, nothing will happen.

Note
All operations with the LayerStack are processed at the end of the frame.

Definition at line 91 of file Application.cpp.

◆ PopOverlay()

void Cori::Core::Application::PopOverlay ( )
static

Pops the overlay Layer from the LayerStack.

The overlay Layer to be popped is the last that was pushed to the LayerStack. If there is nothing to pop, nothing will happen.

Note
All operations with the LayerStack are processed at the end of the frame.

Definition at line 95 of file Application.cpp.

◆ PushLayer()

std::expected< void, CoriError<> > Cori::Core::Application::PushLayer ( Layer * layer)
staticnodiscard

Pushes a Layer to the LayerStack.

Parameters
layerRawptr to the created Layer.

LayerStack manages the lifetime of the Layer. Duplicate Layer names are forbidden and will result in a CoriError.

Note
All operations with the LayerStack are processed at the end of the frame.
Returns
Expected object with void on success or CoriError<> on failure.

Definition at line 83 of file Application.cpp.

◆ PushOverlay()

std::expected< void, CoriError<> > Cori::Core::Application::PushOverlay ( Layer * overlay)
staticnodiscard

Pushes an overlay Layer to the LayerStack.

Parameters
overlayRawptr to the created overlay Layer.

LayerStack manages the lifetime of the overlay Layer. Overlay Layers are always on the top of the LayerStack and always above regular Layers, thus are updated before regular Layers. Duplicate Layer names are forbidden and will result in a CoriError.

Note
All operations with the LayerStack are processed at the end of the frame.
Returns
Expected object with void on success or CoriError<> on failure.

Definition at line 87 of file Application.cpp.

◆ Run()

void Cori::Core::Application::Run ( )

Run loop, internal.

Definition at line 103 of file Application.cpp.

Here is the call graph for this function:

◆ SetBackgroundColor()

void Cori::Core::Application::SetBackgroundColor ( const glm::vec4 & color)
static

Setts the background color of the rendering canvas.

Parameters
colorNormalized RGBA color.

Definition at line 99 of file Application.cpp.

◆ SubmitMainTask()

template<class F, class... Args>
std::future< std::invoke_result_t< F, Args... > > Cori::Core::Application::SubmitMainTask ( F && f,
Args &&... args )
inlinestatic

Submits a task to be executed on the main thread.

Submitted tasks will be processed in the very beginning of the next frame.
It is safe to call this function from any thread.

Template Parameters
FAuto deduced callable type.
ArgsAuto deduced callable argument types.
Parameters
fTask callable, no specific signature required.
argsArguments that will be passed to the callable task upon execution.
Returns
Future that will hold the result of invoke result of the passed callable.

Definition at line 103 of file Application.hpp.

◆ SubmitWorkerTask()

template<class F, class... Args>
std::future< std::invoke_result_t< F, Args... > > Cori::Core::Application::SubmitWorkerTask ( F && f,
Args &&... args )
inlinestatic

Submits a task to be executed on the worker thread.

It is safe to call this function from any thread.

Template Parameters
FAuto deduced callable type.
ArgsAuto deduced callable argument types.
Parameters
fTask callable, no specific signature required.
argsArguments that will be passed to the callable task upon execution.
Returns
Future that will hold the result of invoke result of the passed callable.

Definition at line 117 of file Application.hpp.


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