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

This class provides a broadcasting implementation of the `Observer` protocol&period; Other concrete observers may be registered and named with this broadcast observer (`registerObserver` method), retrieved (`findObserver` method), and unregistered (`deregisterObserver` method)&period; The `publish` method of this class forwards the log records that it receives to the `publish` method of each registered observer&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class BroadcastObserver
    : 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/BroadcastObserver/ObserverRegistry.adoc[`ObserverRegistry`] 
| This `typedef` is an alias for the type of the registry maintained by this observer&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/ball/BroadcastObserver/2constructor.adoc[`BroadcastObserver`]         [.small]#[constructor]#
| Create a broadcast observer having no registered observers&period; Optionally specify a `basicAllocator` used to supply memory&period; If `basicAllocator` is 0, the currently installed default allocator is used&period;
| xref:BloombergLP/ball/BroadcastObserver/2destructor.adoc[`&#126;BroadcastObserver`] [.small]#[destructor]# [.small]#[virtual]#
| Destroy this broadcast observer&period; Note that this method has no effect on the lifetime of observers registered with this observer, if any&period;
| xref:BloombergLP/ball/BroadcastObserver/deregisterAllObservers.adoc[`deregisterAllObservers`] 
| Remove all observers from the registry of this broadcast observer&period;
| xref:BloombergLP/ball/BroadcastObserver/deregisterObserver.adoc[`deregisterObserver`] 
| Remove the observer having the specified `observerName` from the registry of this broadcast observer&period; Return 0 if the observer having `observerName` was successfully deregistered, and a non&hyphen;zero value (with no effect) otherwise&period; Henceforth, the observer that had `observerName` will no longer receive log records from this observer&period;
| xref:BloombergLP/ball/BroadcastObserver/findObserver-09.adoc[`findObserver`] 
| `findObserver` overloads
| xref:BloombergLP/ball/BroadcastObserver/numRegisteredObservers.adoc[`numRegisteredObservers`] 
| Return the number of observers registered with this broadcast observer&period;
| xref:BloombergLP/ball/BroadcastObserver/publish-06.adoc[`publish`] 
| `publish` overloads
| xref:BloombergLP/ball/BroadcastObserver/registerObserver.adoc[`registerObserver`] 
| Add the specified `observer` with the specified `observerName` to the registry of this broadcast observer&period; Return 0 if `observer` was successfully registered, and a non&hyphen;zero value (with no effect) otherwise&period; Henceforth, this observer will forward each record it receives through its `publish` method, including the record&apos;s context, to the `publish` method of `observer`, until `observer` is deregistered&period; The behavior is undefined if a cyclic reference is created among registered observers&period; Note that this method will fail if an observer having `observerName` is already registered&period;
| xref:BloombergLP/ball/BroadcastObserver/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; This implementation processes `releaseRecords` by calling `releaseRecords` on each of the registered observers&period; Note that this operation should be called if resources underlying the previously provided shared pointers must be released&period;
| xref:BloombergLP/ball/BroadcastObserver/visitObservers-0d.adoc[`visitObservers`] 
| Invoke the specified `visitor` functor of (template parameter) `t&lowbar;VISITOR` type on each element in the registry of this broadcast observer, supplying that functor modifiable access to each observer&period; `visitor` must be a functor that can be called as if it had the following signature&colon; &grave; void operator()(const bsl&colon;&colon;shared&lowbar;ptr&lt;Observer&gt;&amp; observer, const bsl&colon;&colon;string&lowbar;view&amp; observerName)&semi; &grave;
|===


== Using Declarations

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/ball/BroadcastObserver/publish-08.adoc[`publish`] 
| Import the base&hyphen;class `publish` overloads&period;
|===



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