|
BDE 4.39.x Production Release
|
Provide a broadcast observer that forwards to other observers.
Provide a broadcast observer that forwards to other observers.
This component provides a concrete implementation of the ball::Observer protocol for receiving and processing log records:
ball::BroadcastObserver is a concrete class derived from ball::Observer that processes the log records it receives through its publish method by forwarding them to other concrete observers. ball::BroadcastObserver maintains a registry of named observers to which it forwards log records. Clients of ball::BroadcastObserver register observers using the registerObserver method and unregister observers with the deregisterObserver method. Once registered, an observer receives all log records that its associated broadcast observer receives.
ball::BroadcastObserver is thread-safe, meaning that multiple threads may share the same instance, or may have their own instances (see bsldoc_glossary ).
In this section we show intended use of this component.
In this example, we will show how ball::BroadcastObserver can be used to implement delayed observer configuration.
First, we define an elided custom observer that conforms to the ball::Observer protocol and supports a configure method:
Then, we create a shared pointer to a ConfigurableObserver object and register it with a broadcast observer:
Finally, we can retrieve the registered observer and configure it:
Note that there is an alternative way to obtain a shared pointer to the registered observer: