BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ModelView::SignalBase< T, U > Class Template Reference

Container to hold callbacks in the context of ModelMapper. More...

Inheritance diagram for ModelView::SignalBase< T, U >:
[legend]

Public Member Functions

 SignalBase ()=default
 
void connect (T callback, U client)
 
template<typename... Args>
void operator() (Args... args)
 Notify clients using given list of arguments. More...
 
void remove_client (U client)
 Remove client from the list to call back. More...
 

Private Attributes

std::list< std::pair< T, U > > m_callbacks
 

Detailed Description

template<typename T, typename U>
class ModelView::SignalBase< T, U >

Container to hold callbacks in the context of ModelMapper.

Definition at line 31 of file callbackcontainer.h.

Constructor & Destructor Documentation

◆ SignalBase()

template<typename T , typename U >
ModelView::SignalBase< T, U >::SignalBase ( )
default

Member Function Documentation

◆ connect()

template<typename T , typename U >
void ModelView::SignalBase< T, U >::connect ( callback,
client 
)

Definition at line 45 of file callbackcontainer.h.

46 {
47  m_callbacks.push_back(std::make_pair(callback, client));
48 }
std::list< std::pair< T, U > > m_callbacks

Referenced by TEST_F().

◆ operator()()

template<typename T , typename U >
template<typename... Args>
void ModelView::SignalBase< T, U >::operator() ( Args...  args)

Notify clients using given list of arguments.

Definition at line 53 of file callbackcontainer.h.

54 {
55  for (const auto& f : m_callbacks) {
56  f.first(args...);
57  }
58 }

◆ remove_client()

template<typename T , typename U >
void ModelView::SignalBase< T, U >::remove_client ( client)

Remove client from the list to call back.

Definition at line 62 of file callbackcontainer.h.

63 {
64  m_callbacks.remove_if(
65  [client](const std::pair<T, U>& x) -> bool { return (x.second == client ? true : false); });
66 }

Referenced by TEST_F(), ModelView::ItemMapper::ItemMapperImpl::unsubscribe(), and ModelMapper::ModelMapperImpl::unsubscribe().

Member Data Documentation

◆ m_callbacks

template<typename T , typename U >
std::list<std::pair<T, U> > ModelView::SignalBase< T, U >::m_callbacks
private

Definition at line 42 of file callbackcontainer.h.


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