Loading...
Searching...
No Matches
ASSA::SigHandlersList Class Reference

SigHandlersList class. More...

`#include <SigHandlersList.h>`

## Classes

struct | CompSHL

## Public Types

typedef EventHandler * | key_type
typedef EventHandler * | data_type
typedef set< key_type, CompSHL > | set_t
typedef set< key_type, CompSHL >::iterator | iterator

## Public Member Functions

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

## Static Public Member Functions

static SigHandlersList * | instance (int signum_)
| Retrieve a pointer to the list of event handlers listening to signum_ signal delivery.

## Static Public Attributes

static SigHandlersList * | m_instance [NSIG]
| Static map of signal numbers to SigHandlerLists.

## Protected Member Functions

| SigHandlersList ()
| SigHandlersList (const SigHandlersList &map_)
SigHandlersList & | operator= (const SigHandlersList &map_)

## Private Attributes

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

## 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

typedef EventHandler* ASSA::SigHandlersList::data_type

Definition at line 69 of file SigHandlersList.h.

## iterator

typedef set<key_type,CompSHL>::iterator ASSA::SigHandlersList::iterator

Definition at line 82 of file SigHandlersList.h.

## key_type

typedef EventHandler* ASSA::SigHandlersList::key_type

Definition at line 68 of file SigHandlersList.h.

## set_t

typedef set< key_type, CompSHL > ASSA::SigHandlersList::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.

{
trace_with_mask("SigHandlersList::~SigHandlersList", SIGHAND);
erase ();
delete m_set;
m_set = NULL;
}
trace_with_mask
#define trace_with_mask(s, m)
trace_with_mask() is used to trace function call chain in C++ program.
Definition Logger.h:437
ASSA::SigHandlersList::m_set
set_t * m_set
Set of all event handlers registered for this signal.
Definition SigHandlersList.h:163
ASSA::SigHandlersList::erase
void erase()
Empty event handlers' list.
Definition SigHandlersList.h:280
ASSA::SIGHAND
@ 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 | ( |  | ) |

inline protected

Definition at line 181 of file SigHandlersList.h.

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

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.

{
trace_with_mask("SigHandlersList::begin()", SIGHAND);
return m_set->begin ();
}

References m_set, ASSA::SIGHAND, and trace_with_mask.

## 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.

{
trace_with_mask("SigHandlersList::cfunc_handler", SIGHAND);
return m_cfhp;
}

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.

{
trace_with_mask("SigHandlersList::cfunc_handler", SIGHAND);
CFUNC_Handler* old_cfhp = m_cfhp;
m_cfhp = cfhp_;
m_seen_cfh = cfhp_ == NULL ? false : true;
return old_cfhp;
}

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

## empty()

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

inline

Is list empty.

Definition at line 218 of file SigHandlersList.h.

{
trace_with_mask("SigHandlersList::empty", SIGHAND);
// true if map is empty, false otherwise
return m_set->empty ();
}

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.

{
trace_with_mask("SigHandlersList::end", SIGHAND);
return m_set->end ();
}

References m_set, ASSA::SIGHAND, and trace_with_mask.

## erase() [1/3]

void ASSA::SigHandlersList::erase | ( |  | ) |

inline

Empty event handlers' list.

Definition at line 279 of file SigHandlersList.h.

{
// empty the map
trace_with_mask("SigHandlersList::erase(void)", SIGHAND);
m_set->erase (m_set->begin(), m_set->end());
}

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.

{
// return number of erased elements
trace_with_mask("SigHandlersList::erase(key_)", SIGHAND);
m_set->erase (key_);
}

References m_set, ASSA::SIGHAND, and trace_with_mask.

## 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.

{
// erase element pointed by iterator
trace_with_mask("SigHandlersList::erase(it_)", SIGHAND);
m_set->erase(it_);
}

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.

{
trace_with_mask("SigHandlersList::find", SIGHAND);
return m_set->find (key_);
}

References m_set, ASSA::SIGHAND, and trace_with_mask.

## 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.

{
trace_with_mask("SigHandlersList::insert", SIGHAND);
/*---
Insert 'eh_' into the set. set::insert() returns a 'pair' object.
If the set doesn't contain an element that matches 'eh_', insert a
copy of 'eh_' and returns a 'pair' whose first element is an
iterator positioned at the new element and second element is
'true'.
If the set already contains an element that matches 'eh_', returns
a pair whose first element is an iterator positioned at the
existing element and second element is false!
---*/
set_t::const_iterator it = m_set->find (eh_);
/*--- Not in the set ---*/
if (it == m_set->end ()) {
return (m_set->insert (eh_)).second;
}
/*--- Already in the set ---*/
return true;
}

References m_set, ASSA::SIGHAND, and trace_with_mask.

## instance()

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

inline static

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

Definition at line 202 of file SigHandlersList.h.

{
trace_with_mask("SigHandlersList::instance", SIGHAND);
DL((APP, "m_instance[%d] = 0x%x\n", signum_,
SigHandlersList::m_instance[signum_]));
if (SigHandlersList::m_instance[signum_] == 0) {
DL((APP, "new SigHandlersList allocated\n"));
SigHandlersList::m_instance[signum_] = new SigHandlersList();
}
return SigHandlersList::m_instance[signum_];
}
DL
#define DL(X)
A macro for writing debug message to the Logger.
Definition Logger.h:273
ASSA::SigHandlersList::m_instance
static SigHandlersList * m_instance[NSIG]
Static map of signal numbers to SigHandlerLists.
Definition SigHandlersList.h:159
ASSA::SigHandlersList::SigHandlersList
SigHandlersList()
Definition SigHandlersList.h:182
ASSA::APP
@ 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.

{
trace_with_mask("SigHandlersList::seen_cfunc_handler", SIGHAND);
return m_seen_cfh;
}

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.

{
trace_with_mask("SigHandlersList::seen_cfunc_handler", SIGHAND);
m_seen_cfh = ft_;
}

References m_seen_cfh, ASSA::SIGHAND, and trace_with_mask.

## size()

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

inline

Size of the list.

Definition at line 229 of file SigHandlersList.h.

{
trace_with_mask("SigHandlersList::size", SIGHAND);
// return number of elements in the map
return m_set->size ();
}

References m_set, ASSA::SIGHAND, and trace_with_mask.

## 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(), and 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(), seen_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(), erase(), erase(), find(), insert(), SigHandlersList(), size(), and ~SigHandlersList().

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

- SigHandlersList.h
- SigHandlers.cpp