fatalmind::ResourcePoolStreamLogger Class Reference

#include <ResourcePoolStreamLogger.hh>

Inherits fatalmind::ResourcePoolEventObserver.

List of all members.


Detailed Description

A logging Event observer impelementation.

This ResourcePoolEventLogger implementation writes all events to a ostream provided on construction (e.g. std::cout).

Please refer to the select.cc example to see it's usage.

Examples:

select.cc.


Public Types

typedef unsigned int event_t

Public Member Functions

 ResourcePoolStreamLogger (std::ostream &a_os)
virtual void event (event_t eventID, const std::string &resourceID=NoResourceID, const std::string &message="N/A")
virtual void event (event_t eventID, const std::string &resourceID=NoResourceID, const std::string &message="")
 The callback to notify an observer about an event.
bool isEvent (event_t eventID)
const std::string & getEventName (const event_t event) const
 Translates the numeric EventID to a string representation.
const event_t getEvent (const std::string &value) const
 Translates the event name to the EventID.
const event_t registerEvent (const std::string &value)
 Registers a new named event.
const event_t getEventMask (const std::string &value) const
 Translates an EventID Mask expression into it's binary representation.
event_t setLogEvents (event_t events)
void setDefaultEventMask ()
 To be used after initialization, will fetch the default from the env.
gc_ptr< EventReader > getReader (const event_t event, const std::string &r)

Static Public Attributes

static
ResourcePoolStreamLogger 
defaultLogger
static const std::string NoResourceID = "N/A"
static struct
fatalmind::ResourcePoolEventObserver::Events 
Event
 Symbol names for the defined events.

Protected Member Functions

virtual Clone * DoClone () const

Protected Attributes

event_t logevents

Member Function Documentation

void fatalmind::ResourcePoolEventObserver::event ( event_t  eventID,
const std::string &  resourceID = NoResourceID,
const std::string &  message = "" 
) [virtual, inherited]

The callback to notify an observer about an event.

This method is called by ResourcePool upon the defined events (if they are enabled, see ResourcePool::setLogEvents). The implementation can do whatever it likes, but must take into consideration that it is synchronously called and might therefore block ResourcePool's processing.

The call to this method is not protected by any means to avoid reentrant access. Multi-Thread applications MUST take there own measures to prevent uncoordinated data manipulation.

const ResourcePoolEventObserver::event_t fatalmind::ResourcePoolEventObserver::getEvent ( const std::string &  value  )  const [inherited]

Translates the event name to the EventID.

This method is inteded for seldom usage (since the implementation is ruther expansive). Use this method to to build the EventID mask which is set with ResourcePool::setLogEvents.

Returns:
The Mapped EventID, or Event.NONE if it could not be mapped.

const ResourcePoolEventObserver::event_t fatalmind::ResourcePoolEventObserver::registerEvent ( const std::string &  value  )  [inherited]

Registers a new named event.

Intended to be used by library authors.

Returns:
The newly (automatically assigned) EventID or an existing EventID (if the name was already used) or Event.NONE if it was not possible to map that event.

const ResourcePoolEventObserver::event_t fatalmind::ResourcePoolEventObserver::getEventMask ( const std::string &  value  )  const [inherited]

Translates an EventID Mask expression into it's binary representation.

pool.setLogEvents(logger.getEventMask("INCREMENT_POOL | DOWNSIZE_POOL")); is equivalent (but much slower) then pool.setLogEvents(logger.Event.INCREMENT_POOL | logger.Event.DOWNSIZE_POOL));

void fatalmind::ResourcePoolEventObserver::setDefaultEventMask (  )  [inherited]

To be used after initialization, will fetch the default from the env.

e.g. after you register new events, to refetch it from the env


The documentation for this class was generated from the following files:
Generated on Mon Nov 9 16:21:24 2009 for ResourcePool by  doxygen 1.5.3