The Open Master Hearing Aid (openMHA)  openMHA
Open community platform for hearing aid algorithm research
MHAEvents::patchbay_t< receiver_t > Class Template Reference

Patchbay which connects any event emitter with any member function of the parameter class. More...

Public Member Functions

 ~patchbay_t ()
 
void connect (emitter_t *, receiver_t *, void(receiver_t::*)())
 Connect a receiver member function void (receiver_t::*)() with an event emitter. More...
 
void connect (emitter_t *, receiver_t *, void(receiver_t::*)(const std::string &))
 Connect a receiver member function void (receiver_t::*)(const std::string&) with an event emitter. More...
 
void connect (emitter_t *, receiver_t *, void(receiver_t::*)(const std::string &, unsigned int, unsigned int))
 

Private Attributes

std::list< connector_t< receiver_t > * > cons
 

Detailed Description

template<class receiver_t>
class MHAEvents::patchbay_t< receiver_t >

Patchbay which connects any event emitter with any member function of the parameter class.

The connections created by the connect() function are hold until the destructor is called. To avoid access to invalid function pointers, it is required to destruct the patchbay before the receiver, usually by declaring the patchbay as a member of the receiver.

The receiver can be any claas or structure; the event callback can be either a member function without arguments or with const std::string& argument.

Constructor & Destructor Documentation

◆ ~patchbay_t()

template<class receiver_t >
MHAEvents::patchbay_t< receiver_t >::~patchbay_t

Member Function Documentation

◆ connect() [1/3]

template<class receiver_t >
void MHAEvents::patchbay_t< receiver_t >::connect ( emitter_t e,
receiver_t *  r,
void(receiver_t::*)()  rfun 
)

Connect a receiver member function void (receiver_t::*)() with an event emitter.

Create a connection.

The connection is removed when the patchbay is destructed.

Parameters
ePointer to an event emitter
rPointer to the receiver
rfunPointer to a member function of the receiver class

◆ connect() [2/3]

template<class receiver_t >
void MHAEvents::patchbay_t< receiver_t >::connect ( emitter_t e,
receiver_t *  r,
void(receiver_t::*)(const std::string &)  rfun 
)

Connect a receiver member function void (receiver_t::*)(const std::string&) with an event emitter.

Create a connection.

The connection is removed when the patchbay is destructed.

Parameters
ePointer to an event emitter
rPointer to the receiver
rfunPointer to a member function of the receiver class

◆ connect() [3/3]

template<class receiver_t >
void MHAEvents::patchbay_t< receiver_t >::connect ( emitter_t e,
receiver_t *  r,
void(receiver_t::*)(const std::string &, unsigned int, unsigned int)  rfun 
)

Member Data Documentation

◆ cons

template<class receiver_t >
std::list<connector_t<receiver_t>*> MHAEvents::patchbay_t< receiver_t >::cons
private

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