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

#include <ball_filteringobserver.h>

Inheritance diagram for ball::FilteringObserver:
ball::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
 Destroy this object.
 
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 ()
 Destroy this observer.
 

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:

bsl::function<bool(const Record&, const Context&)>
Definition ball_context.h:295
Definition ball_record.h:178
Forward declaration.
Definition bslstl_function.h:934

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 ball_filteringobserver

Member Typedef Documentation

◆ RecordFilterCallback

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

◆ FilteringObserver()

ball::FilteringObserver::FilteringObserver ( const bsl::shared_ptr< Observer > &  observer,
const RecordFilterCallback recordFilterCallback,
bslma::Allocator basicAllocator = 0 
)
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. The behavior is undefined if observer is 0 or a cycle is created among observers.

◆ ~FilteringObserver()

ball::FilteringObserver::~FilteringObserver ( )

Member Function Documentation

◆ BSLMF_NESTED_TRAIT_DECLARATION()

ball::FilteringObserver::BSLMF_NESTED_TRAIT_DECLARATION ( FilteringObserver  ,
bslma::UsesBslmaAllocator   
)

◆ publish() [1/3]

virtual void ball::Observer::publish ( const bsl::shared_ptr< const Record > &  record,
const Context context 
)
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.

◆ publish() [2/3]

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.

◆ publish() [3/3]

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

Process the specified log record having the specified publishing context.

Deprecated:
Use the alternative publish overload instead.

Reimplemented from ball::Observer.

◆ releaseRecords()

void ball::FilteringObserver::releaseRecords ( )
inlinevirtual

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.


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