The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Types | Public Member Functions | Private Attributes | List of all members
gui2::tnotifier< FUNCTOR > Class Template Reference

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

#include <notifiee.hpp>

Public Types

typedef FUNCTOR tfunctor
 

Public Member Functions

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

Private Attributes

std::map< tnotifiee< tfunctor >
*, tfunctor
notifiees_
 List of registered callbacks. More...
 

Detailed Description

template<class FUNCTOR>
class gui2::tnotifier< 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 24 of file notifiee.hpp.

Member Typedef Documentation

template<class FUNCTOR>
typedef FUNCTOR gui2::tnotifier< FUNCTOR >::tfunctor

Definition at line 37 of file notifier.hpp.

Constructor & Destructor Documentation

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

Definition at line 39 of file notifier.hpp.

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

Definition at line 43 of file notifier.hpp.

Member Function Documentation

template<class FUNCTOR>
void gui2::tnotifier< FUNCTOR >::connect_notifiee ( tnotifiee< tfunctor > &  notifiee,
tfunctor  functor 
)
inline

Connects a callback.

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

Definition at line 61 of file notifier.hpp.

template<class FUNCTOR>
void gui2::tnotifier< FUNCTOR >::disconnect_notifiee ( tnotifiee< tfunctor > &  notifiee)
inline

Disconnects a callback.

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

Definition at line 77 of file notifier.hpp.

Referenced by gui2::tnotifiee< tfunctor >::~tnotifiee().

template<class FUNCTOR>
const std::map<tnotifiee<tfunctor>*, tfunctor>& gui2::tnotifier< FUNCTOR >::notifiees ( ) const
inline

Definition at line 94 of file notifier.hpp.

Member Data Documentation

template<class FUNCTOR>
std::map<tnotifiee<tfunctor>*, tfunctor> gui2::tnotifier< FUNCTOR >::notifiees_
private

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