|
BDE 4.39.x Production Release
|
#include <ball_filteringobserver.h>
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).
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) | |
| ~FilteringObserver () BSLS_KEYWORD_OVERRIDE | |
| void | publish (const bsl::shared_ptr< const Record > &record, const Context &context) BSLS_KEYWORD_OVERRIDE |
| void | releaseRecords () BSLS_KEYWORD_OVERRIDE |
| virtual void | publish (const Record &record, const Context &context) |
| virtual void | publish (const bsl::shared_ptr< const Record > &record, const Context &context) |
Public Member Functions inherited from ball::Observer | |
| virtual | ~Observer () |
| typedef bsl::function<bool(const Record&, const Context&)> ball::FilteringObserver::RecordFilterCallback |
|
inline |
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.
observer is 0 or a cycle is created among observers. | ball::FilteringObserver::~FilteringObserver | ( | ) |
Destroy this object.
| ball::FilteringObserver::BSLMF_NESTED_TRAIT_DECLARATION | ( | FilteringObserver | , |
| bslma::UsesBslmaAllocator | |||
| ) |
|
virtual |
Process the specified log record having the specified publishing context. The exact definition of publish depends on the implementing class, though the intention is that the log record (whose publication has occurred according to context) be distributed in a human or machine readable form.
Reimplemented from ball::Observer.
|
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.
record or context is modified during the execution of this method. Reimplemented from ball::Observer.
Process the specified log record having the specified publishing context.
publish overload instead. Reimplemented from ball::Observer.
|
inlinevirtual |
Discard any shared reference to a Record object that was supplied to the publish method, and is held by this observer.
Reimplemented from ball::Observer.