Quick Links: |
#include <ball_multiplexobserver.h>
Public Member Functions | |
MultiplexObserver (bslma::Allocator *basicAllocator=0) | |
virtual | ~MultiplexObserver () |
virtual void | publish (const Record &record, const Context &context) |
virtual void | publish (const bsl::shared_ptr< const Record > &record, const Context &context) |
virtual void | releaseRecords () |
int | registerObserver (Observer *observer) |
int | deregisterObserver (Observer *observer) |
int | numRegisteredObservers () const |
This class provides a multiplexing implementation of the Observer
protocol. Other concrete observers may be registered with a multiplexing observer (registerObserver
method) and later unregistered (deregisterObserver
method). The publish
method of this class forwards the log records that it receives to the publish
method of each registered observer.
See Component ball_multiplexobserver
ball::MultiplexObserver::MultiplexObserver | ( | bslma::Allocator * | basicAllocator = 0 |
) | [explicit] |
Create a multiplexing observer having no registered observers. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used.
virtual ball::MultiplexObserver::~MultiplexObserver | ( | ) | [virtual] |
Destroy this multiplexing observer. Note that this method has no effect on the lifetime of observers registered with this observer, if any.
virtual void ball::MultiplexObserver::publish | ( | const Record & | record, | |
const Context & | context | |||
) | [virtual] |
Process the specified log record
having the specified publishing context
by forwarding record
and context
to each of the observers registered with this multiplexing observer.
DEPRECATED: Use the alternative publish
overload instead.
Reimplemented from ball::Observer.
virtual void ball::MultiplexObserver::publish | ( | const bsl::shared_ptr< const Record > & | record, | |
const Context & | context | |||
) | [virtual] |
Process the specified log record
having the specified publishing context
. This concrete publish implementations processes the record
by forwarding record
and context
to each of the observers registered with this multiplexing observer.
Reimplemented from ball::Observer.
virtual void ball::MultiplexObserver::releaseRecords | ( | ) | [virtual] |
Discard any shared reference to a Record
object that was supplied to the publish
method, and is held by this observer. This implementation processes releaseRecords
by calling releaseRecords
on each of the registered observers. Note that this operation should be called if resources underlying the previously provided shared pointers must be released.
Reimplemented from ball::Observer.
int ball::MultiplexObserver::registerObserver | ( | Observer * | observer | ) |
Add the specified observer
to the registry of this multiplexing observer. Return 0 if observer
is non-null and was not already registered with this multiplexing observer, and a non-zero value (with no effect) otherwise. Henceforth, this multiplexing observer will forward each record it receives through its publish
method, including the record's context, to the publish
method of observer
, until observer
is deregistered. The behavior is undefined unless observer
remains valid until it is deregistered from this multiplexing observer or until this observer is destroyed.
int ball::MultiplexObserver::deregisterObserver | ( | Observer * | observer | ) |
Remove the specified observer
from the registry of this multiplexing observer. Return 0 if observer
is non-null and was registered with this multiplexing observer, and a non-zero value (with no effect) otherwise. Henceforth, observer
will no longer receive log records from this multiplexing observer.
int ball::MultiplexObserver::numRegisteredObservers | ( | ) | const |
Return the number of observers registered with this multiplexing observer.