Catos Engine (Source) 0.0.1
Lightweight Game engine
Loading...
Searching...
No Matches
application.h
Go to the documentation of this file.
1//
2// Created by allos on 5/5/2024.
3//
4
5
6#pragma once
7#include "types.h"
8#include "type_utils.h"
9
10#include <unordered_map>
11
12
13namespace catos {
14
15
20 str applicationTitle = "Catos Application";
21 };
22
23
25 class App {
26
27 public:
28
30 App(AppCreationInfo* creationInfo);
31 ~App();
32
34 bool is_alive();
35
36
37
38
40 template<typename A>
41 void bind(const void* instance) {
42 _instance_register[type_utils::get_type_hash<A>()] = instance;
43 };
44
46 template<typename A>
47 A* get() {
48 return (A*) (_instance_register[type_utils::get_type_hash<A>()]);
49 }
50
51
54
55
56 private:
57
58 void init_registry();
59
60
61 AppCreationInfo* _info;
62 bool _is_alive = false;
63
64 std::unordered_map<size_t, const void* > _instance_register;
65 };
66
67}
unsigned int uint
Definition types.h:14
std::string_view str
Definition types.h:12
Definition application.h:13
size_t get_type_hash()
Definition type_utils.h:14
A struct that holds all info the application needs at launch.
Definition application.h:17
str applicationTitle
Definition application.h:20
uint version
MAJOR | MINOR | PATCH?
Definition application.h:19
Main class that holds all information.
Definition application.h:25
App(AppCreationInfo *creationInfo)
Initializes the Application (Also registers all "known" class to the registry)
Definition application.cpp:9
A * get()
Returns the registered instance.
Definition application.h:47
AppCreationInfo * getAppInfo()
Returns a pointer to the info with what the application is made.
Definition application.cpp:43
void bind(const void *instance)
Used to bind an instance to an type.
Definition application.h:41
bool is_alive()
Returns if the app is still running.
Definition application.cpp:39
~App()
Definition application.cpp:18