[#BloombergLP-ball-FilteringObserver]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/ball.adoc[ball]::FilteringObserver
:relfileprefix: ../../
:mrdocs:

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&period; The callback must be convertible to&colon; &grave; bsl&colon;&colon;function&lt;bool(const Record&amp;, const Context&amp;)&gt; &grave; 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&period; If the callback returns `false`, then the `Record` and `Context` are ignored (i&period;e&period;, they are filtered out by this observer)&period;

== Synopsis

Declared in `&lt;ball&lowbar;filteringobserver&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class FilteringObserver
    : public xref:BloombergLP/ball/Observer.adoc[Observer]
----

== Base Classes

[cols="1,4"]
|===
| Name| Description
| `xref:BloombergLP/ball/Observer.adoc[Observer]`
| This class provides a protocol for receiving and processing log record output&period;
|===

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/ball/FilteringObserver/RecordFilterCallback.adoc[`RecordFilterCallback`] 
| `RecordFilterCallback` is the type of a user&hyphen;supplied callback functor used to filter the supplied `Record` and `Context` objects based on the user&hyphen;defined criteria provided by the functor&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/ball/FilteringObserver/2constructor.adoc[`FilteringObserver`]         [.small]#[constructor]#
| Create a filtering observer that conditionally passes log records to the specified `observer` based on the specified `recordFilterCallback`&period; Optionally specify a `basicAllocator` used to supply memory&period; If `basicAllocator` is 0, the currently installed default allocator is used&period; The behavior is undefined if `observer` is 0 or a cycle is created among observers&period;
| xref:BloombergLP/ball/FilteringObserver/2destructor.adoc[`&#126;FilteringObserver`] [.small]#[destructor]# [.small]#[virtual]#
| Destroy this object&period;
| xref:BloombergLP/ball/FilteringObserver/publish-0e.adoc[`publish`] 
| `publish` overloads
| xref:BloombergLP/ball/FilteringObserver/releaseRecords.adoc[`releaseRecords`]  [.small]#[virtual]#
| Discard any shared reference to a `Record` object that was supplied to the `publish` method, and is held by this observer&period; Note that this operation should be called if resources underlying the previously provided shared&hyphen;pointers must be released&period;
| xref:BloombergLP/ball/FilteringObserver/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;FilteringObserver, UsesBslmaAllocator&gt;`] 
| Declare that this type uses a `bslma` allocator&period;
|===


== Using Declarations

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/ball/FilteringObserver/publish-0c.adoc[`publish`] 
| Bring `Observer&colon;&colon;publish` overloads into scope&period;
|===



[.small]#Created with https://www.mrdocs.com[MrDocs]#
