Quick Links:

bal | bbl | bdl | bsl

Public Types | Public Member Functions

ball::FilteringObserver Class Reference

#include <ball_filteringobserver.h>

Inheritance diagram for ball::FilteringObserver:
ball::Observer

List of all members.

Public Types

typedef bsl::function< bool(const
Record &, const Context &)> 
RecordFilterCallback

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (FilteringObserver, bslma::UsesBslmaAllocator)
 FilteringObserver (const bsl::shared_ptr< Observer > &observer, const RecordFilterCallback &recordFilterCallback, bslma::Allocator *basicAllocator=0)
virtual ~FilteringObserver ()
virtual void publish (const bsl::shared_ptr< const Record > &record, const Context &context)
virtual void releaseRecords ()
virtual void publish (const Record &record, const Context &context)

Detailed Description

This class provides a concrete implementation of the Observer protocol that filters the Record and Context objects passed to its publish method based on a callback (function or functor) supplied at construction. The callback must be convertible to:

If the callback returns true for the Record and Context, then they are forwarded to the publish method of an observer also supplied at construction. If the callback returns false, then the Record and Context are ignored (i.e., they are filtered out by this observer).

See Component ball_filteringobserver


Member Typedef Documentation

RecordFilterCallback is the type of a user-supplied callback functor used to filter the supplied Record and Context objects based on the user-defined criteria provided by the functor.


Constructor & Destructor Documentation

ball::FilteringObserver::FilteringObserver ( const bsl::shared_ptr< Observer > &  observer,
const RecordFilterCallback recordFilterCallback,
bslma::Allocator basicAllocator = 0 
)

Create a filtering observer that conditionally passes log records to the specified observer based on the specified recordFilterCallback. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. The behavior is undefined if observer is 0 or a cycle is created among observers.

virtual ball::FilteringObserver::~FilteringObserver (  )  [virtual]

Destroy this filtering observer.


Member Function Documentation

ball::FilteringObserver::BSLMF_NESTED_TRAIT_DECLARATION ( FilteringObserver  ,
bslma::UsesBslmaAllocator   
)
virtual void ball::FilteringObserver::publish ( const bsl::shared_ptr< const Record > &  record,
const Context context 
) [virtual]

Process the specified log record having the specified publishing context. Forward record and context to the publish method of the observer supplied at construction if the filter callback supplied at construction returns true for record and context, and ignore (filter out) record and context otherwise. The behavior is undefined if record or context is modified during the execution of this method.

Reimplemented from ball::Observer.

virtual void ball::FilteringObserver::releaseRecords (  )  [virtual]

Discard any shared reference to a Record object that was supplied to the publish method, and is held by this observer. Note that this operation should be called if resources underlying the previously provided shared-pointers must be released.

Reimplemented from ball::Observer.

virtual void ball::Observer::publish ( const Record record,
const Context context 
) [virtual, inherited]

Process the specified log record having the specified publishing context.

DEPRECATED: Use the alternative publish overload instead.

Reimplemented in ball::FileObserver, ball::FileObserver2, ball::MultiplexObserver, ball::ObserverAdapter, and ball::TestObserver.


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