ASSA::SigHandlersList Class Reference

SigHandlersList class. More...

#include <SigHandlersList.h>

Collaboration diagram for ASSA::SigHandlersList:

Collaboration graph
[legend]
List of all members.

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.
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_Handlercfunc_handler (CFUNC_Handler *cfp_)
 Save 3rd party C function handler to remember.
CFUNC_Handlercfunc_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 SigHandlersListinstance (int signum_)
 Retrieve a pointer to the list of event handlers listening to signum_ signal delivery.

Static Public Attributes

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

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.
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_Handlerm_cfhp
 Pointer to the 3rd party signal handler in the set.

Classes

struct  CompSHL

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

typedef EventHandler* ASSA::SigHandlersList::data_type
 

Definition at line 69 of file SigHandlersList.h.

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

Definition at line 82 of file SigHandlersList.h.

typedef EventHandler* ASSA::SigHandlersList::key_type
 

Definition at line 68 of file SigHandlersList.h.

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

Definition at line 81 of file SigHandlersList.h.


Constructor & Destructor Documentation

ASSA::SigHandlersList::~SigHandlersList  )  [inline]
 

Destructor.

Definition at line 192 of file SigHandlersList.h.

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

00193 {
00194     trace_with_mask("SigHandlersList::~SigHandlersList", SIGHAND);
00195 
00196     erase ();
00197     delete m_set;
00198     m_set = NULL;
00199 }

ASSA::SigHandlersList::SigHandlersList  )  [inline, protected]
 

Definition at line 182 of file SigHandlersList.h.

References m_set, ASSA::SIGHAND, and trace_with_mask.

Referenced by instance().

00183     : m_seen_cfh (false), m_cfhp (NULL)
00184 {
00185     trace_with_mask("SigHandlersList::SigHandlersList", SIGHAND);
00186 
00187     m_set = new set_t;
00188 }

ASSA::SigHandlersList::SigHandlersList const SigHandlersList map_  )  [protected]
 


Member Function Documentation

SigHandlersList::iterator ASSA::SigHandlersList::begin  )  [inline]
 

Return an iterator pointing to the beginning of the list.

Definition at line 300 of file SigHandlersList.h.

References m_set, ASSA::SIGHAND, and trace_with_mask.

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

00301 {
00302     trace_with_mask("SigHandlersList::begin()", SIGHAND);
00303 
00304     return m_set->begin ();
00305 }

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 340 of file SigHandlersList.h.

References m_cfhp, ASSA::SIGHAND, and trace_with_mask.

00341 {
00342     trace_with_mask("SigHandlersList::cfunc_handler", SIGHAND);
00343     
00344     return m_cfhp;
00345 }

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 328 of file SigHandlersList.h.

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

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

00329 {
00330     trace_with_mask("SigHandlersList::cfunc_handler", SIGHAND);
00331     
00332     CFUNC_Handler* old_cfhp = m_cfhp;
00333     m_cfhp = cfhp_;
00334     m_seen_cfh = cfhp_ == NULL ? false : true;
00335     return old_cfhp;
00336 }

bool ASSA::SigHandlersList::empty  )  const [inline]
 

Is list empty.

Definition at line 219 of file SigHandlersList.h.

References m_set, ASSA::SIGHAND, and trace_with_mask.

00220 {
00221     trace_with_mask("SigHandlersList::empty", SIGHAND);
00222 
00223     // true if map is empty, false otherwise
00224 
00225     return m_set->empty ();
00226 }

SigHandlersList::iterator ASSA::SigHandlersList::end  )  [inline]
 

Return an iterator pointing to the end of the list.

Definition at line 309 of file SigHandlersList.h.

References m_set, ASSA::SIGHAND, and trace_with_mask.

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

00310 {
00311     trace_with_mask("SigHandlersList::end", SIGHAND);
00312 
00313     return m_set->end ();
00314 }

void ASSA::SigHandlersList::erase  )  [inline]
 

Empty event handlers' list.

Definition at line 280 of file SigHandlersList.h.

References m_set, ASSA::SIGHAND, and trace_with_mask.

Referenced by ~SigHandlersList().

00281 {
00282     // empty the map
00283     trace_with_mask("SigHandlersList::erase(void)", SIGHAND);
00284 
00285     m_set->erase (m_set->begin(), m_set->end());
00286 }

void ASSA::SigHandlersList::erase iterator  it_  )  [inline]
 

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

Definition at line 290 of file SigHandlersList.h.

References m_set, ASSA::SIGHAND, and trace_with_mask.

00291 {
00292     // erase element pointed by iterator
00293     trace_with_mask("SigHandlersList::erase(it_)", SIGHAND);
00294 
00295     m_set->erase(it_);
00296 }

void ASSA::SigHandlersList::erase const key_type  key_  )  [inline]
 

Find and remove event handler key_ from the list.

Definition at line 270 of file SigHandlersList.h.

References m_set, ASSA::SIGHAND, and trace_with_mask.

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

00271 {
00272     // return number of erased elements
00273     trace_with_mask("SigHandlersList::erase(key_)", SIGHAND);
00274     
00275     m_set->erase (key_);
00276 }

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 318 of file SigHandlersList.h.

References m_set, ASSA::SIGHAND, and trace_with_mask.

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

00319 {
00320     trace_with_mask("SigHandlersList::find", SIGHAND);
00321 
00322     return m_set->find (key_);
00323 }

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 241 of file SigHandlersList.h.

References m_set, ASSA::SIGHAND, and trace_with_mask.

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

00242 {
00243     trace_with_mask("SigHandlersList::insert", SIGHAND);
00244 
00245     /*---
00246       Insert 'eh_' into the set. set::insert() returns a 'pair' object.
00247 
00248       If the set doesn't contain an element that matches 'eh_', insert a 
00249       copy of 'eh_' and returns a 'pair' whose first element is an
00250       iterator positioned at the new element and second element is
00251       'true'.
00252 
00253       If the set already contains an element that matches 'eh_', returns
00254       a pair whose first element is an iterator positioned at the
00255       existing element and second element is false!
00256       ---*/
00257 
00258     set_t::const_iterator it = m_set->find (eh_);
00259 
00260     /*--- Not in the set ---*/
00261     if (it == m_set->end ()) { 
00262         return (m_set->insert (eh_)).second;
00263     }
00264     /*--- Already in the set ---*/
00265     return true;
00266 }

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 203 of file SigHandlersList.h.

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().

00204 {
00205     trace_with_mask("SigHandlersList::instance", SIGHAND);
00206 
00207     DL((APP, "m_instance[%d] = 0x%x\n", signum_,
00208         SigHandlersList::m_instance[signum_]));
00209 
00210     if (SigHandlersList::m_instance[signum_] == 0) {
00211         DL((APP, "new SigHandlersList allocated\n"));
00212         SigHandlersList::m_instance[signum_] = new SigHandlersList();
00213     }
00214     return SigHandlersList::m_instance[signum_];
00215 }

SigHandlersList& ASSA::SigHandlersList::operator= const SigHandlersList map_  )  [protected]
 

bool ASSA::SigHandlersList::seen_cfunc_handler  )  const [inline]
 

Returns:
TRUE if we've seen 3rd party C function handler; FALSE otherwise.

Definition at line 358 of file SigHandlersList.h.

References m_seen_cfh, ASSA::SIGHAND, and trace_with_mask.

00359 {
00360     trace_with_mask("SigHandlersList::seen_cfunc_handler", SIGHAND);
00361 
00362     return m_seen_cfh;
00363 }

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 349 of file SigHandlersList.h.

References m_seen_cfh, ASSA::SIGHAND, and trace_with_mask.

00350 {
00351     trace_with_mask("SigHandlersList::seen_cfunc_handler", SIGHAND);
00352 
00353     m_seen_cfh = ft_;
00354 }

size_t ASSA::SigHandlersList::size  )  const [inline]
 

Size of the list.

Definition at line 230 of file SigHandlersList.h.

References m_set, ASSA::SIGHAND, and trace_with_mask.

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

00231 {
00232     trace_with_mask("SigHandlersList::size", SIGHAND);
00233 
00234     // return number of elements in the map
00235 
00236     return m_set->size ();
00237 }


Member Data Documentation

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().

SigHandlersList * SigHandlersList::m_instance [static]
 

Static map of signal numbers to SigHandlerLists.

Definition at line 159 of file SigHandlersList.h.

Referenced by instance().

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().

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:
Generated on Sun Aug 13 15:08:21 2006 for libassa by  doxygen 1.4.6