Capycore Engine  0.1.0
A simple and lightweight game engine written in C++ based on the Unity API architecture.
Loading...
Searching...
No Matches
i_backend_system.h
Go to the documentation of this file.
1#pragma once
2
4
5#include <functional>
6#include <string>
7#include <unordered_map>
8#include <vector>
9
10using BackendCallback = std::function<void(void* event_data)>;
11
21 public:
22 virtual ~IBackendSystem() = default;
23
25 std::unordered_map<SystemEvent, std::vector<BackendCallback>>*
26 listeners) = 0;
27
34 virtual void poll_events() = 0;
35
46 virtual void init_frame_timer() = 0;
47
54 virtual void update_frame_time(float time_scale) = 0;
55
60 [[nodiscard]] virtual float delta_time() const = 0;
61
67 [[nodiscard]] virtual float frames_per_second() const = 0;
68
73 [[nodiscard]] virtual std::string get_clipboard_text() = 0;
74
78 virtual void set_cursor_to_arrow() = 0;
79
83 virtual void set_cursor_to_hand() = 0;
84
88 virtual void set_cursor_to_ibeam() = 0;
89
93 virtual void set_cursor_to_crosshair() = 0;
94
98 virtual void set_cursor_to_wait() = 0;
99
100 protected:
101 uint64_t last_{0};
102 double freq_{0.0f};
103 float delta_time_{0.0f};
104
106 float fps_{0.0f};
107 float accumulated_time_{0.0f};
108};
Interface for backend system implementations handling low-level events.
Definition i_backend_system.h:20
virtual float frames_per_second() const =0
Retrieves the frames per second (FPS) based on the updated frame time.
virtual void set_cursor_to_wait()=0
Sets the cursor to the wait (hourglass) shape.
double freq_
Definition i_backend_system.h:102
uint64_t last_
Definition i_backend_system.h:101
float accumulated_time_
Definition i_backend_system.h:107
virtual float delta_time() const =0
Retrieves the time elapsed since the last frame.
virtual std::string get_clipboard_text()=0
Sets the current text to the system clipboard.
virtual void poll_events()=0
Polls for new events from the backend system.
virtual ~IBackendSystem()=default
virtual void update_frame_time(float time_scale)=0
Updates the frame time based on the elapsed time since the last frame.
virtual void set_cursor_to_crosshair()=0
Sets the cursor to the crosshair shape.
int frame_count_
Definition i_backend_system.h:105
virtual void set_cursor_to_hand()=0
Sets the cursor to the hand shape.
float fps_
Definition i_backend_system.h:106
virtual void initialize_listeners(std::unordered_map< SystemEvent, std::vector< BackendCallback > > *listeners)=0
virtual void init_frame_timer()=0
Initializes the internal timer for frame time calculation.
virtual void set_cursor_to_ibeam()=0
Sets the cursor to the I-beam shape.
float delta_time_
Definition i_backend_system.h:103
virtual void set_cursor_to_arrow()=0
Sets the cursor to the standard arrow shape.
std::function< void(void *event_data)> BackendCallback
Definition i_backend_system.h:10
SystemEvent
Definition system_event.h:5