3#include <Core/Utils/Log.hpp>
32template <
typename... Args>
47 for (
const auto& o : m_observers ) {
55 m_observers.insert( { ++m_currentId, observer } );
64 return attach( bind( observer,
object ) );
67 inline void notify( Args... p )
const {
68 for (
const auto& o : m_observers )
77 inline void detach(
int observerId ) { m_observers.erase( observerId ); }
81 template <
typename R,
typename T,
typename U>
82 std::function<R( Args... )> bind( R ( T::*f )( Args... ), U p ) {
83 return [p, f]( Args... args ) -> R {
return ( p->*f )( args... ); };
87 int m_currentId { 0 };
90class RA_CORE_API ObservableVoid :
public Observable<>
int attach(Observer observer)
Observable()=default
Default constructor ... do nothing ;)
void detachAll()
Detach all observers.
void notify(Args... p) const
Notify (i.e. call) each attached observer with argument p.
void detach(int observerId)
int attachMember(T *object, void(T::*observer)(Args...))
void copyObserversTo(Observable &other) const
explicit copy of all attached observers the other Observable
hepler function to manage enum as underlying types in VariableSet