BDE 4.14.0 Production release
Loading...
Searching...
No Matches
ball::MultiplexObserver Class Reference

#include <ball_multiplexobserver.h>

Inheritance diagram for ball::MultiplexObserver:
ball::Observer

Public Member Functions

 MultiplexObserver (bslma::Allocator *basicAllocator=0)
 
 ~MultiplexObserver () BSLS_KEYWORD_OVERRIDE
 
void publish (const Record &record, const Context &context) BSLS_KEYWORD_OVERRIDE
 
void publish (const bsl::shared_ptr< const Record > &record, const Context &context) BSLS_KEYWORD_OVERRIDE
 
void releaseRecords () BSLS_KEYWORD_OVERRIDE
 
int registerObserver (Observer *observer)
 
int deregisterObserver (Observer *observer)
 
int numRegisteredObservers () const
 
- Public Member Functions inherited from ball::Observer
virtual ~Observer ()
 Destroy this observer.
 

Detailed Description

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 ball_multiplexobserver

Constructor & Destructor Documentation

◆ MultiplexObserver()

ball::MultiplexObserver::MultiplexObserver ( bslma::Allocator basicAllocator = 0)
inlineexplicit

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.

◆ ~MultiplexObserver()

ball::MultiplexObserver::~MultiplexObserver ( )

Destroy this multiplexing observer. Note that this method has no effect on the lifetime of observers registered with this observer, if any.

Member Function Documentation

◆ deregisterObserver()

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.

◆ numRegisteredObservers()

int ball::MultiplexObserver::numRegisteredObservers ( ) const
inline

Return the number of observers registered with this multiplexing observer.

◆ publish() [1/2]

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.

◆ publish() [2/2]

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.

◆ registerObserver()

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.

◆ releaseRecords()

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.


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