sculpto
event.h
Go to the documentation of this file.
1/*!****************************************************************//*!*
2 * \file base_event.h
3 * \brief Base event class definiton module.
4 *
5 * \author Sabitov Kirill
6 * \date 24 June 2022
7 *********************************************************************/
8
9#pragma once
10
11#include "sclpch.h"
13
14#define SCL_MAKE_EVENT(name) \
15 public: \
16 static constexpr string_id StaticType = SCL_STRING_ID(#name); \
17 inline u32 GetType() const override { return StaticType; } \
18 inline const char *GetName() const override { return #name; }
19
20namespace scl
21{
23 class event
24 {
25 public:
27 bool Handled { false };
28
30 virtual ~event() = default;
31
32 /*!*
33 * Get type of specific event function.
34 *
35 * \param None.
36 * \return type of specific event.
37 */
38 inline virtual u32 GetType() const = 0;
39
40 /*!*
41 * Get string name of event.
42 *
43 * \param None.
44 * \return name of event type as string.
45 */
46 inline virtual const char *GetName() const = 0;
47
48 /*!*
49 * Convert event to string (for debug).
50 *
51 * \param None.
52 * \return string representation of event.
53 */
54 inline virtual std::string ToString() const { return GetName(); };
55 };
56
57 inline std::ostream& operator<<(std::ostream& os, const event& e)
58 {
59 return os << e.ToString();
60 }
61}
virtual ~event()=default
virtual std::string ToString() const
Definition: event.h:54
virtual u32 GetType() const =0
virtual const char * GetName() const =0
bool Handled
Definition: event.h:27
Definition: base.h:33
uint32_t u32
Definition: math_common.h:21
std::ostream & operator<<(std::ostream &os, const event &e)
Definition: event.h:57
Sculpto library prehompiled header. Defines common definitions, includes commonly used modules.
String id generating by CRC32 algoritm implemetation module. Can be used both in compiletime anr runt...