CyberEngineMkIII
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
CYB::Engine::Core Class Reference

An instance of this object is the entirety of the engine. More...

#include <CYBCore.hpp>

Inheritance diagram for CYB::Engine::Core:
Inheritance graph
[legend]
Collaboration diagram for CYB::Engine::Core:
Collaboration graph
[legend]

Public Member Functions

ContextCurrentContext (void) noexcept
 Get the current Context. More...
 
void SetCurrentContext (Context &ANewContext) noexcept
 Set the current Context. More...
 
void DefaultContext (void) noexcept
 Set the current Context to FEngineContext. More...
 
unsigned long long ThreadID (void) noexcept
 Possibly assign and return the current thread's serial ID for this execution. More...
 

Static Public Member Functions

static CoreGetCore (void) noexcept
 Retrieve the Core singleton. More...
 
static void Run (const unsigned int ANumArguments, const oschar_t *const *const AArguments) noexcept
 Runs the engine and self terminates. More...
 

Public Attributes

API::EngineInformation FEngineInformation
 Information describing the engine.
 
Platform::Modules::Manager FModuleManager
 Loads and contains required modules.
 
CYB::Engine::Helpers::CommandLine FCommandLine
 The parsed command line handler.
 

Private Member Functions

 Core (const unsigned int ANumArguments, const oschar_t *const *const AArguments)
 Constructs the engine components. More...
 
 ~Core ()
 Cleans up the engine and terminates the process.
 
bool LaunchUnit (void) noexcept
 Run the main unit. More...
 

Private Attributes

Platform::System::Console FConsole
 The console.
 
std::atomic_uint_fast64_t FThreadCounter
 The number of threads created.
 
Logger FLogger
 The engine's primary Logger.
 
Memory::Heap FHeap
 The engine's primary Heap.
 
Context FEngineContext
 The engine Context.
 

Static Private Attributes

static thread_local ContextFCurrentContext
 The current Context in use.
 
static thread_local unsigned
long long 
FThreadID
 ID of the checking thread.
 

Additional Inherited Members

- Protected Member Functions inherited from CYB::API::Singleton< Core >
 Singleton (const bool AInit) noexcept
 Optionally initialize the singleton with the current object. More...
 
 ~Singleton ()
 Destroy a singleton and nullify it's pointer.
 
- Static Protected Attributes inherited from CYB::API::Singleton< Core >
static Core * FSingleton
 The singleton object.
 

Detailed Description

An instance of this object is the entirety of the engine.

Definition at line 11 of file CYBCore.hpp.

Constructor & Destructor Documentation

CYB::Engine::Core::Core ( const unsigned int  ANumArguments,
const oschar_t *const *const  AArguments 
)
private

Constructs the engine components.

Parameters
ANumArgumentsThe number of command line arguments
AArgumentsThe command line arguments
Thread Safety
This function should only be called once
Exceptions
CYB::Exception::InternalError code: CYB::Exception::Internal::MEMORY_RESERVATION_FAILURE. Thrown if a heap's memory could not be reserved
CYB::Exception::InternalError code: CYB::Exception::Internal::MEMORY_COMMITAL_FAILURE. Thrown if a heap's memory could not be committed

Definition at line 27 of file CYBCore.cpp.

27  :
28  Singleton<Core>(true),
30  FThreadCounter(0),
34  FCommandLine(ANumArguments, AArguments)
35 {
36  FLogger.Log(API::String::Static(u8"Core created"), Logger::Level::DEV);
37  static_cast<void>(ANumArguments);
38  static_cast<void>(AArguments);
39 }
Logger FLogger
The engine's primary Logger.
Definition: CYBCore.hpp:26
CYB::Engine::Helpers::CommandLine FCommandLine
The parsed command line handler.
Definition: CYBCore.hpp:31
Memory::Heap FHeap
The engine's primary Heap.
Definition: CYBCore.hpp:28
void Log(const API::String::CStyle &AMessage, const Level ALevel) finaloverride
Log a message. Will be written to a text file on the Path returned by CurrentLog. ...
Definition: CYBLogger.cpp:197
Platform::System::Console FConsole
The console.
Definition: CYBCore.hpp:22
The inital amount of memory to be commited by the engine heap.
Context FEngineContext
The engine Context.
Definition: CYBCore.hpp:29
std::atomic_uint_fast64_t FThreadCounter
The number of threads created.
Definition: CYBCore.hpp:24
static API::EngineInformation CreateEngineInformation(void) noexcept
Creates the correct CYB::API::EngineInformation struct.
Debug messages, enabled/disabled by default in engine debug/release builds respectively.
API::EngineInformation FEngineInformation
Information describing the engine.
Definition: CYBCore.hpp:18

Here is the call graph for this function:

Member Function Documentation

CYB::Engine::Context & CYB::Engine::Core::CurrentContext ( void  )
noexcept

Get the current Context.

Returns
A reference to the current context
Thread Safety
This function requires no thread safety

Definition at line 57 of file CYBCore.cpp.

57  {
58  return *FCurrentContext;
59 }
static thread_local Context * FCurrentContext
The current Context in use.
Definition: CYBCore.hpp:14

Here is the caller graph for this function:

void CYB::Engine::Core::DefaultContext ( void  )
noexcept

Set the current Context to FEngineContext.

Thread Safety
This function requires no thread safety

Definition at line 65 of file CYBCore.cpp.

65  {
67 }
Context FEngineContext
The engine Context.
Definition: CYBCore.hpp:29
void MakeCurrent(void) noexcept
Set the current thread's Context singleton to this Context.
Definition: CYBInterop.cpp:47

Here is the caller graph for this function:

CYB::Engine::Core & CYB::Engine::Core::GetCore ( void  )
staticnoexcept

Retrieve the Core singleton.

Returns
A reference to the Core singleton
Thread Safety
This function requires no thread safety

Definition at line 45 of file CYBCore.cpp.

45  {
46  return *FSingleton;
47 }
static Core * FSingleton
The singleton object.
Definition: Singleton.hpp:13

Here is the caller graph for this function:

bool CYB::Engine::Core::LaunchUnit ( void  )
privatenoexcept

Run the main unit.

Returns
true if the Unit should be launch again, false otherwise
Thread Safety
This function must be synchronized at the object level
void CYB::Engine::Core::Run ( const unsigned int  ANumArguments,
const oschar_t *const *const  AArguments 
)
staticnoexcept

Runs the engine and self terminates.

Parameters
ANumArgumentsThe number of command line arguments
AArgumentsThe command line arguments
Thread Safety
This function should only be called once

Definition at line 49 of file CYBCore.cpp.

49  {
50  try {
51  Core CyberEngineMarkIII(ANumArguments, AArguments);
52  }
53  catch (...) {}
55 }
Core(const unsigned int ANumArguments, const oschar_t *const *const AArguments)
Constructs the engine components.
Definition: CYBCore.cpp:27
static Process GetSelf(void) noexcept
Get's the Process representing the current execution.
Definition: CYBProcess.cpp:12
void Terminate(void)
Terminates the Process with exit code 0.

Here is the call graph for this function:

Here is the caller graph for this function:

void CYB::Engine::Core::SetCurrentContext ( Context ANewContext)
noexcept

Set the current Context.

Parameters
ANewContextThe new context
Thread Safety
This function requires no thread safety

Definition at line 61 of file CYBCore.cpp.

61  {
62  FCurrentContext = &ANewContext;
63 }
static thread_local Context * FCurrentContext
The current Context in use.
Definition: CYBCore.hpp:14

Here is the caller graph for this function:

unsigned long long CYB::Engine::Core::ThreadID ( void  )
noexcept

Possibly assign and return the current thread's serial ID for this execution.

Returns
The current thread's serial ID for this execution
Thread Safety
This function requires no thread safety

Definition at line 73 of file CYBCore.cpp.

73  {
74  if (FThreadID == 0)
75  FThreadID = FThreadCounter.fetch_add(1, std::memory_order_relaxed) + 1;
76  return FThreadID;
77 }
static thread_local unsigned long long FThreadID
ID of the checking thread.
Definition: CYBCore.hpp:15
std::atomic_uint_fast64_t FThreadCounter
The number of threads created.
Definition: CYBCore.hpp:24

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