[#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. Other concrete observers may be registered and named with this broadcast observer (`registerObserver` method), retrieved (`findObserver` method), and unregistered (`deregisterObserver` method). The `publish` method of this class forwards the log records that it receives to the `publish` method of each registered observer. == Synopsis Declared in `<ball_broadcastobserver.h>` [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. |=== == 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. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/ball/BroadcastObserver/2constructor.adoc[`BroadcastObserver`] [.small]#[constructor]# | Create a broadcast observer having no registered observers. Optionally specify a `basicAllocator` used to supply memory. If `basicAllocator` is 0, the currently installed default allocator is used. | xref:BloombergLP/ball/BroadcastObserver/2destructor.adoc[`~BroadcastObserver`] [.small]#[destructor]# [.small]#[virtual]# | Destroy this broadcast observer. Note that this method has no effect on the lifetime of observers registered with this observer, if any. | xref:BloombergLP/ball/BroadcastObserver/deregisterAllObservers.adoc[`deregisterAllObservers`] | Remove all observers from the registry of this broadcast observer. | xref:BloombergLP/ball/BroadcastObserver/deregisterObserver.adoc[`deregisterObserver`] | Remove the observer having the specified `observerName` from the registry of this broadcast observer. Return 0 if the observer having `observerName` was successfully deregistered, and a non‐zero value (with no effect) otherwise. Henceforth, the observer that had `observerName` will no longer receive log records from this observer. | 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. | 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. Return 0 if `observer` was successfully registered, and a non‐zero value (with no effect) otherwise. Henceforth, this observer will forward each record it receives through its `publish` method, including the record's context, to the `publish` method of `observer`, until `observer` is deregistered. The behavior is undefined if a cyclic reference is created among registered observers. Note that this method will fail if an observer having `observerName` is already registered. | 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. This implementation processes `releaseRecords` by calling `releaseRecords` on each of the registered observers. Note that this operation should be called if resources underlying the previously provided shared pointers must be released. | xref:BloombergLP/ball/BroadcastObserver/visitObservers-0d.adoc[`visitObservers`] | Invoke the specified `visitor` functor of (template parameter) `t_VISITOR` type on each element in the registry of this broadcast observer, supplying that functor modifiable access to each observer. `visitor` must be a functor that can be called as if it had the following signature: ` void operator()(const bsl::shared_ptr<Observer>& observer, const bsl::string_view& observerName); ` |=== == Using Declarations [cols="1,4"] |=== | Name| Description | xref:BloombergLP/ball/BroadcastObserver/publish-08.adoc[`publish`] | Import the base‐class `publish` overloads. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#