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>

class BroadcastObserver
    : public Observer

Base Classes

Name

Description

Observer

This class provides a protocol for receiving and processing log record output.

Type Aliases

Name

Description

ObserverRegistry

This typedef is an alias for the type of the registry maintained by this observer.

Member Functions

Name

Description

BroadcastObserver [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.

~BroadcastObserver [destructor] [virtual]

Destroy this broadcast observer. Note that this method has no effect on the lifetime of observers registered with this observer, if any.

deregisterAllObservers

Remove all observers from the registry of this broadcast observer.

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.

findObserver

findObserver overloads

numRegisteredObservers

Return the number of observers registered with this broadcast observer.

publish

publish overloads

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.

releaseRecords [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.

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

Name

Description

publish

Import the base‐class publish overloads.

Created with MrDocs