libassa  3.5.1
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Attributes | List of all members
ASSA::SigHandlersList Class Reference

SigHandlersList class. More...

#include <SigHandlersList.h>

Classes

struct  CompSHL
 

Public Types

typedef EventHandlerkey_type
 
typedef EventHandlerdata_type
 
typedef set< key_type, CompSHLset_t
 
typedef set< key_type, CompSHL >::iterator iterator
 

Public Member Functions

 ~SigHandlersList ()
 Destructor. More...
 
bool empty () const
 Is list empty. More...
 
size_t size () const
 Size of the list. More...
 
bool insert (data_type data_)
 Add an event handler data_ to the list. More...
 
void erase (const key_type key_)
 Find and remove event handler key_ from the list. More...
 
void erase (iterator it_)
 Remove an event handler pointed by iterator it_ from the list. More...
 
void erase ()
 Empty event handlers' list. More...
 
iterator begin ()
 Return an iterator pointing to the beginning of the list. More...
 
iterator end ()
 Return an iterator pointing to the end of the list. More...
 
iterator find (const key_type key_)
 Find event handler by its pointer key_. More...
 
CFUNC_Handlercfunc_handler (CFUNC_Handler *cfp_)
 Save 3rd party C function handler to remember. More...
 
CFUNC_Handlercfunc_handler () const
 Retrieve pointer to 3rd party C function handler. More...
 
void seen_cfunc_handler (bool ft_)
 Indicate whether 3rd party C function handler was installed. More...
 
bool seen_cfunc_handler () const
 

Static Public Member Functions

static SigHandlersListinstance (int signum_)
 Retrieve a pointer to the list of event handlers listening to signum_ signal delivery. More...
 

Static Public Attributes

static SigHandlersListm_instance [NSIG]
 Static map of signal numbers to SigHandlerLists. More...
 

Protected Member Functions

 SigHandlersList ()
 
 SigHandlersList (const SigHandlersList &map_)
 
SigHandlersListoperator= (const SigHandlersList &map_)
 

Private Attributes

set_tm_set
 Set of all event handlers registered for this signal. More...
 
int m_seen_cfh
 If true this flag indicates that 3rd party event handler has already been installed prior taking control by SigHandlers manager. More...
 
CFUNC_Handlerm_cfhp
 Pointer to the 3rd party signal handler in the set. More...
 

Detailed Description

SigHandlersList class.

SigHandlersList class is used by SigHandlers class to keep track of EventHandlers installed to be called on signal's delivery. It is sort of global process map of signal numbers into corresponding sets of EventHandlers that are listening for signal delivery.

Definition at line 65 of file SigHandlersList.h.

Member Typedef Documentation

◆ data_type

Definition at line 69 of file SigHandlersList.h.

◆ iterator

Definition at line 82 of file SigHandlersList.h.

◆ key_type

Definition at line 68 of file SigHandlersList.h.

◆ set_t

Definition at line 81 of file SigHandlersList.h.

Constructor & Destructor Documentation

◆ ~SigHandlersList()

ASSA::SigHandlersList::~SigHandlersList ( )
inline

Destructor.

Definition at line 191 of file SigHandlersList.h.

193 {
194  trace_with_mask("SigHandlersList::~SigHandlersList", SIGHAND);
195 
196  erase ();
197  delete m_set;
198  m_set = NULL;
199 }
#define trace_with_mask(s, m)
trace_with_mask() is used to trace function call chain in C++ program.
Definition: Logger.h:437
set_t * m_set
Set of all event handlers registered for this signal.
void erase()
Empty event handlers' list.
@ SIGHAND
Class SigHandler(s) messages
Definition: LogMask.h:38

References erase(), m_set, ASSA::SIGHAND, and trace_with_mask.

◆ SigHandlersList() [1/2]

ASSA::SigHandlersList::SigHandlersList ( )
inlineprotected

Definition at line 181 of file SigHandlersList.h.

183  : m_seen_cfh (false), m_cfhp (NULL)
184 {
185  trace_with_mask("SigHandlersList::SigHandlersList", SIGHAND);
186 
187  m_set = new set_t;
188 }
int m_seen_cfh
If true this flag indicates that 3rd party event handler has already been installed prior taking cont...
CFUNC_Handler * m_cfhp
Pointer to the 3rd party signal handler in the set.
set< key_type, CompSHL > set_t

References m_set, ASSA::SIGHAND, and trace_with_mask.

Referenced by instance().

◆ SigHandlersList() [2/2]

ASSA::SigHandlersList::SigHandlersList ( const SigHandlersList map_)
protected

Member Function Documentation

◆ begin()

SigHandlersList::iterator ASSA::SigHandlersList::begin ( )
inline

Return an iterator pointing to the beginning of the list.

Definition at line 299 of file SigHandlersList.h.

301 {
302  trace_with_mask("SigHandlersList::begin()", SIGHAND);
303 
304  return m_set->begin ();
305 }

References m_set, ASSA::SIGHAND, and trace_with_mask.

Referenced by ASSA::SigHandlers::dispatch().

◆ cfunc_handler() [1/2]

CFUNC_Handler * ASSA::SigHandlersList::cfunc_handler ( ) const
inline

Retrieve pointer to 3rd party C function handler.

Returns
3rd party C function handler.

Definition at line 339 of file SigHandlersList.h.

341 {
342  trace_with_mask("SigHandlersList::cfunc_handler", SIGHAND);
343 
344  return m_cfhp;
345 }

References m_cfhp, ASSA::SIGHAND, and trace_with_mask.

◆ cfunc_handler() [2/2]

CFUNC_Handler * ASSA::SigHandlersList::cfunc_handler ( CFUNC_Handler cfp_)
inline

Save 3rd party C function handler to remember.

Parameters
cfp_New 3rd party C function handler. If it is NULL, then seen_cfh flag is set to FALSE.
Returns
old 3rd party C function handler.

Definition at line 327 of file SigHandlersList.h.

329 {
330  trace_with_mask("SigHandlersList::cfunc_handler", SIGHAND);
331 
332  CFUNC_Handler* old_cfhp = m_cfhp;
333  m_cfhp = cfhp_;
334  m_seen_cfh = cfhp_ == NULL ? false : true;
335  return old_cfhp;
336 }

References m_cfhp, m_seen_cfh, ASSA::SIGHAND, and trace_with_mask.

Referenced by ASSA::SigHandlers::install(), and ASSA::SigHandlers::remove().

◆ empty()

bool ASSA::SigHandlersList::empty ( ) const
inline

Is list empty.

Definition at line 218 of file SigHandlersList.h.

220 {
221  trace_with_mask("SigHandlersList::empty", SIGHAND);
222 
223  // true if map is empty, false otherwise
224 
225  return m_set->empty ();
226 }

References m_set, ASSA::SIGHAND, and trace_with_mask.

◆ end()

SigHandlersList::iterator ASSA::SigHandlersList::end ( )
inline

Return an iterator pointing to the end of the list.

Definition at line 308 of file SigHandlersList.h.

310 {
311  trace_with_mask("SigHandlersList::end", SIGHAND);
312 
313  return m_set->end ();
314 }

References m_set, ASSA::SIGHAND, and trace_with_mask.

Referenced by ASSA::SigHandlers::dispatch(), and ASSA::SigHandlers::remove().

◆ erase() [1/3]

void ASSA::SigHandlersList::erase ( )
inline

Empty event handlers' list.

Definition at line 279 of file SigHandlersList.h.

281 {
282  // empty the map
283  trace_with_mask("SigHandlersList::erase(void)", SIGHAND);
284 
285  m_set->erase (m_set->begin(), m_set->end());
286 }

References m_set, ASSA::SIGHAND, and trace_with_mask.

Referenced by ~SigHandlersList().

◆ erase() [2/3]

void ASSA::SigHandlersList::erase ( const key_type  key_)
inline

Find and remove event handler key_ from the list.

Definition at line 269 of file SigHandlersList.h.

271 {
272  // return number of erased elements
273  trace_with_mask("SigHandlersList::erase(key_)", SIGHAND);
274 
275  m_set->erase (key_);
276 }

References m_set, ASSA::SIGHAND, and trace_with_mask.

Referenced by ASSA::SigHandlers::dispatch(), ASSA::SigHandlers::install(), and ASSA::SigHandlers::remove().

◆ erase() [3/3]

void ASSA::SigHandlersList::erase ( iterator  it_)
inline

Remove an event handler pointed by iterator it_ from the list.

Definition at line 289 of file SigHandlersList.h.

291 {
292  // erase element pointed by iterator
293  trace_with_mask("SigHandlersList::erase(it_)", SIGHAND);
294 
295  m_set->erase(it_);
296 }

References m_set, ASSA::SIGHAND, and trace_with_mask.

◆ find()

SigHandlersList::iterator ASSA::SigHandlersList::find ( const key_type  key_)
inline

Find event handler by its pointer key_.

Returns
Iterator to the element.

Definition at line 317 of file SigHandlersList.h.

319 {
320  trace_with_mask("SigHandlersList::find", SIGHAND);
321 
322  return m_set->find (key_);
323 }

References m_set, ASSA::SIGHAND, and trace_with_mask.

Referenced by ASSA::SigHandlers::remove().

◆ insert()

bool ASSA::SigHandlersList::insert ( data_type  data_)
inline

Add an event handler data_ to the list.

Returns
TRUE on success, FALSE on error.

Definition at line 240 of file SigHandlersList.h.

242 {
243  trace_with_mask("SigHandlersList::insert", SIGHAND);
244 
245  /*---
246  Insert 'eh_' into the set. set::insert() returns a 'pair' object.
247 
248  If the set doesn't contain an element that matches 'eh_', insert a
249  copy of 'eh_' and returns a 'pair' whose first element is an
250  iterator positioned at the new element and second element is
251  'true'.
252 
253  If the set already contains an element that matches 'eh_', returns
254  a pair whose first element is an iterator positioned at the
255  existing element and second element is false!
256  ---*/
257 
258  set_t::const_iterator it = m_set->find (eh_);
259 
260  /*--- Not in the set ---*/
261  if (it == m_set->end ()) {
262  return (m_set->insert (eh_)).second;
263  }
264  /*--- Already in the set ---*/
265  return true;
266 }

References m_set, ASSA::SIGHAND, and trace_with_mask.

Referenced by ASSA::SigHandlers::install().

◆ instance()

SigHandlersList * ASSA::SigHandlersList::instance ( int  signum_)
inlinestatic

Retrieve a pointer to the list of event handlers listening to signum_ signal delivery.

Definition at line 202 of file SigHandlersList.h.

204 {
205  trace_with_mask("SigHandlersList::instance", SIGHAND);
206 
207  DL((APP, "m_instance[%d] = 0x%x\n", signum_,
208  SigHandlersList::m_instance[signum_]));
209 
210  if (SigHandlersList::m_instance[signum_] == 0) {
211  DL((APP, "new SigHandlersList allocated\n"));
213  }
214  return SigHandlersList::m_instance[signum_];
215 }
#define DL(X)
A macro for writing debug message to the Logger.
Definition: Logger.h:273
static SigHandlersList * m_instance[NSIG]
Static map of signal numbers to SigHandlerLists.
@ APP
Application-level messages
Definition: LogMask.h:27

References ASSA::APP, DL, m_instance, ASSA::SIGHAND, SigHandlersList(), and trace_with_mask.

Referenced by ASSA::SigHandlers::dispatch(), ASSA::SigHandlers::install(), and ASSA::SigHandlers::remove().

◆ operator=()

SigHandlersList& ASSA::SigHandlersList::operator= ( const SigHandlersList map_)
protected

◆ seen_cfunc_handler() [1/2]

bool ASSA::SigHandlersList::seen_cfunc_handler ( ) const
inline
Returns
TRUE if we've seen 3rd party C function handler; FALSE otherwise.

Definition at line 357 of file SigHandlersList.h.

359 {
360  trace_with_mask("SigHandlersList::seen_cfunc_handler", SIGHAND);
361 
362  return m_seen_cfh;
363 }

References m_seen_cfh, ASSA::SIGHAND, and trace_with_mask.

◆ seen_cfunc_handler() [2/2]

void ASSA::SigHandlersList::seen_cfunc_handler ( bool  ft_)
inline

Indicate whether 3rd party C function handler was installed.

Parameters
ft_TRUE if was, FALSE if not.

Definition at line 348 of file SigHandlersList.h.

350 {
351  trace_with_mask("SigHandlersList::seen_cfunc_handler", SIGHAND);
352 
353  m_seen_cfh = ft_;
354 }

References m_seen_cfh, ASSA::SIGHAND, and trace_with_mask.

Referenced by ASSA::SigHandlers::install(), and ASSA::SigHandlers::remove().

◆ size()

size_t ASSA::SigHandlersList::size ( ) const
inline

Size of the list.

Definition at line 229 of file SigHandlersList.h.

231 {
232  trace_with_mask("SigHandlersList::size", SIGHAND);
233 
234  // return number of elements in the map
235 
236  return m_set->size ();
237 }

References m_set, ASSA::SIGHAND, and trace_with_mask.

Referenced by ASSA::SigHandlers::install(), and ASSA::SigHandlers::remove().

Member Data Documentation

◆ m_cfhp

CFUNC_Handler* ASSA::SigHandlersList::m_cfhp
private

Pointer to the 3rd party signal handler in the set.

Definition at line 173 of file SigHandlersList.h.

Referenced by cfunc_handler().

◆ m_instance

SigHandlersList * SigHandlersList::m_instance
static

Static map of signal numbers to SigHandlerLists.

Definition at line 159 of file SigHandlersList.h.

Referenced by instance().

◆ m_seen_cfh

int ASSA::SigHandlersList::m_seen_cfh
private

If true this flag indicates that 3rd party event handler has already been installed prior taking control by SigHandlers manager.

Definition at line 169 of file SigHandlersList.h.

Referenced by cfunc_handler(), and seen_cfunc_handler().

◆ m_set

set_t* ASSA::SigHandlersList::m_set
private

Set of all event handlers registered for this signal.

Definition at line 163 of file SigHandlersList.h.

Referenced by begin(), empty(), end(), erase(), find(), insert(), SigHandlersList(), size(), and ~SigHandlersList().


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