SDOM - Simple SDL Document Object Model
A lightweight, extensible Document Object Model for SDL-based applications.
Loading...
Searching...
No Matches
SDOM_EventTypeHash.hpp
Go to the documentation of this file.
1/*** SDOM_EventTypeHash.hpp ****************************
2 * ___ ___ ___ __ __ ___ _ _____ _ _ _ _
3 * / __| \ / _ \| \/ | | __|_ _____ _ _| ||_ _| _ _ __ ___| || |__ _ __| |_ | |_ _ __ _ __
4 * \__ \ |) | (_) | |\/| | | _|\ V / -_) ' \ _|| || || | '_ \/ -_) __ / _` (_-< ' \ _| ' \| '_ \ '_ \
5 * |___/___/ \___/|_| |_|_|___|\_/\___|_||_\__||_| \_, | .__/\___|_||_\__,_/__/_||_(_)_||_| .__/ .__/
6 * |___| |__/|_| |_| |_|
7 *
8 * The SDOM_EventTypeHash struct provides a custom hash functor for the EventType class,
9 * enabling efficient use of EventType objects as keys in unordered associative containers such
10 * as std::unordered_map and std::unordered_set. By hashing the event type’s name, this functor
11 * ensures that event types can be quickly and uniquely identified within hash-based data
12 * structures. This is essential for fast event lookup, registration, and dispatching within
13 * the SDOM event system, supporting scalable and performant event-driven programming.
14 *
15 *
16 * This software is provided 'as-is', without any express or implied
17 * warranty. In no event will the authors be held liable for any damages
18 * arising from the use of this software.
19 *
20 * Permission is granted to anyone to use this software for any purpose,
21 * including commercial applications, and to alter it and redistribute it
22 * freely, subject to the following restrictions:
23 *
24 * 1. The origin of this software must not be misrepresented; you must not
25 * claim that you wrote the original software. If you use this software
26 * in a product, an acknowledgment in the product documentation would be
27 * appreciated but is not required.
28 * 2. Altered source versions must be plainly marked as such, and must not be
29 * misrepresented as being the original software.
30 * 3. This notice may not be removed or altered from any source distribution.
31 *
32 * Released under the ZLIB License.
33 * Original Author: Jay Faries (warte67)
34 *
35 ******************/
36
37#ifndef SDOM_EVENT_TYPE_HASH_HPP
38#define SDOM_EVENT_TYPE_HASH_HPP
39
40#include <SDOM/SDOM_Event.hpp>
42
43namespace SDOM {
44
45 class Event;
46 class EventType;
47
48 // Custom hash functor for SDOM::EventType to be used in unordered containers
50 std::size_t operator()(const EventType& eventType) const noexcept {
51 return std::hash<std::string>()(eventType.getName());
52 }
53 };
54
55} // namespace SDOM
56
57#endif // SDOM_EVENT_TYPE_HASH_HPP
Definition SDOM_EventType.hpp:49
Contains all core classes and utilities for the SDOM library.
Definition lua_BindHelpers.hpp:7
Definition SDOM_EventTypeHash.hpp:49
std::size_t operator()(const EventType &eventType) const noexcept
Definition SDOM_EventTypeHash.hpp:50