Mountain  1.0.0
Simple C++ 2D Game Framework
event.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Mountain/core.hpp"
4 
5 #include <functional>
6 
8 
11 
12 namespace Mountain
13 {
24  template <typename... Args>
25  class Event
26  {
27  public:
29  using FunctionT = void(Args...);
30  using StdFunctionT = std::function<FunctionT>;
31 
34  void Invoke(Args... args) const;
35 
37  void Clear();
38 
40  void operator()(Args... args) const;
41 
45  Event& operator+=(StdFunctionT func);
46 
50  Event& operator-=(const StdFunctionT& func);
51 
52  private:
53  List<StdFunctionT> m_Functions;
54  };
55 }
56 
57 #include "Mountain/utils/event.inl"
Encapsulates a delegate system similar to its C# implementation.
Definition: event.hpp:25
Defines the Mountain::List class.
void(Args...) FunctionT
Signature of the event function.
Definition: event.hpp:29
void Invoke(Args... args) const
Invokes the currently registered events with the provided parameters.
void Clear()
Clears the event list.
Event & operator+=(StdFunctionT func)
Adds a function to the event list.
void operator()(Args... args) const
Invokes the currently registered events with the provided parameters. Effectively the same as calling...
Event & operator-=(const StdFunctionT &func)
Removes a function from the event list.
Contains all declarations of the Mountain Framework.
Definition: audio.hpp:22