mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-09-21 20:06:40 +00:00
# Atlas updates: better unit ownership control; fixed bottom-bar display; fixed iterator problem in undo; renamed 'd' to 'msg' for consistency
This was SVN commit r3836.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
#ifndef OBSERVABLE_H__
|
||||
#define OBSERVABLE_H__
|
||||
|
||||
#include <boost/signals.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
typedef boost::signals::connection ObservableConnection;
|
||||
|
||||
template <typename T> class Observable : public T
|
||||
{
|
||||
public:
|
||||
template<typename C> ObservableConnection RegisterObserver(int order, void (C::*callback) (const T&), C* obj)
|
||||
{
|
||||
return m_Signal.connect(order, boost::bind(std::mem_fun(callback), obj, _1));
|
||||
}
|
||||
void RemoveObserver(ObservableConnection handle)
|
||||
{
|
||||
handle.disconnect();
|
||||
}
|
||||
void NotifyObservers()
|
||||
{
|
||||
m_Signal(*this);
|
||||
}
|
||||
private:
|
||||
boost::signal<void (const T&)> m_Signal;
|
||||
};
|
||||
|
||||
#endif // OBSERVABLE_H__
|
||||
Reference in New Issue
Block a user