The Battle for Wesnoth  1.19.7+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 <notifier.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 34 of file notifier.hpp.

Member Typedef Documentation

◆ functor_t

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

Definition at line 37 of file notifier.hpp.

Constructor & Destructor Documentation

◆ notifier()

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

Definition at line 39 of file notifier.hpp.

◆ ~notifier()

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

Definition at line 43 of file notifier.hpp.

References gui2::notifier< FUNCTOR >::notifiees_.

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 61 of file notifier.hpp.

References gui2::notifier< FUNCTOR >::notifiees_, and gui2::notifiee< FUNCTOR >::notifier_.

◆ 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 77 of file notifier.hpp.

References gui2::notifier< FUNCTOR >::notifiees_, and gui2::notifiee< FUNCTOR >::notifier_.

Referenced by gui2::notifiee< FUNCTOR >::~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.

References gui2::notifier< FUNCTOR >::notifiees_.

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: