The Battle for Wesnoth  1.15.1+dev
Public Types | Public Member Functions | Private Attributes | List of all members
gui2::notifier< FUNCTOR > Class Template Reference

Helper class to implement callbacks with lifetime management. More...

#include <notifiee.hpp>

Public Types

typedef FUNCTOR functor_t
 

Public Member Functions

 notifier ()
 
 ~notifier ()
 
void connect_notifiee (notifiee< functor_t > &target, functor_t functor)
 Connects a callback. More...
 
void disconnect_notifiee (notifiee< functor_t > &target)
 Disconnects a callback. More...
 
const std::map< notifiee< functor_t > *, functor_t > & notifiees () const
 

Private Attributes

std::map< notifiee< functor_t > *, functor_tnotifiees_
 List of registered callbacks. More...
 

Detailed Description

template<class FUNCTOR>
class gui2::notifier< FUNCTOR >

Helper class to implement callbacks with lifetime management.

This part manages the connecting and disconnecting of the callbacks.

Subclasses should implement a way to call all callback.

Definition at line 23 of file notifiee.hpp.

Member Typedef Documentation

◆ functor_t

template<class FUNCTOR>
typedef FUNCTOR gui2::notifier< FUNCTOR >::functor_t

Definition at line 36 of file notifier.hpp.

Constructor & Destructor Documentation

◆ notifier()

template<class FUNCTOR>
gui2::notifier< FUNCTOR >::notifier ( )
inline

Definition at line 38 of file notifier.hpp.

◆ ~notifier()

template<class FUNCTOR>
gui2::notifier< FUNCTOR >::~notifier ( )
inline

Definition at line 42 of file notifier.hpp.

Member Function Documentation

◆ connect_notifiee()

template<class FUNCTOR>
void gui2::notifier< FUNCTOR >::connect_notifiee ( notifiee< functor_t > &  target,
functor_t  functor 
)
inline

Connects a callback.

Parameters
targetThe notifiee controlling the lifetime of the callback.
functorThe callback to call.

Definition at line 60 of file notifier.hpp.

◆ disconnect_notifiee()

template<class FUNCTOR>
void gui2::notifier< FUNCTOR >::disconnect_notifiee ( notifiee< functor_t > &  target)
inline

Disconnects a callback.

Parameters
targetThe notifiee controlling the lifetime of the callback. Uses since its address is an unique key.

Definition at line 76 of file notifier.hpp.

Referenced by gui2::notifiee< functor_t >::~notifiee().

◆ notifiees()

template<class FUNCTOR>
const std::map<notifiee<functor_t>*, functor_t>& gui2::notifier< FUNCTOR >::notifiees ( ) const
inline

Definition at line 93 of file notifier.hpp.

Member Data Documentation

◆ notifiees_

template<class FUNCTOR>
std::map<notifiee<functor_t>*, functor_t> gui2::notifier< FUNCTOR >::notifiees_
private

The documentation for this class was generated from the following files: