1// Observable Library
2// Copyright (c) 2016 David Capello
3//
4// This file is released under the terms of the MIT license.
5// Read LICENSE.txt for more information.
6
7#ifndef OBS_OBSERVABLE_H_INCLUDED
8#define OBS_OBSERVABLE_H_INCLUDED
9#pragma once
10
11#include "obs/observers.h"
12
13namespace obs {
14
15template<typename Observer>
16class observable {
17public:
18
19 void add_observer(Observer* observer) {
20 m_observers.add_observer(observer);
21 }
22
23 void remove_observer(Observer* observer) {
24 m_observers.remove_observer(observer);
25 }
26
27 void notify_observers(void (Observer::*method)()) {
28 m_observers.notify_observers(method);
29 }
30
31 template<typename ...Args>
32 void notify_observers(void (Observer::*method)(Args...), Args ...args) {
33 m_observers.template notify_observers<Args...>(method, std::forward<Args>(args)...);
34 }
35
36private:
37 observers<Observer> m_observers;
38};
39
40} // namespace obs
41
42#endif
43