ImageRegionObserverStorage Class Reference
#include <imageregionobserver_helpers.h>
This class is a convenience wrapper to manage the lifetime of and access to long-living observers. It is only recommended to be used if smarter observer lifetime management is not feasible. It can be easily placed into or along-side image data owning classes. Observers are lazily registered on first fetch to avoid overhead if they are not used for a particular instance.
Classes |
|
| struct | StoredObserver |
Public Types |
|
| using | AddObserverFunc = Delegate < Result < void >(const Id &observerId, const ImageRegionObserverRef &observer)> |
| using | InitializeObserversFunc = Delegate < Result < void >(const AddObserverFunc &addObserver)> |
公共成员函数 |
|
| template<typename T_ObserverRef > | |
| Result < T_ObserverRef > | GetObserver (const Id &observerId) const |
| Result < void > | 初始化 (const InitializeObserversFunc &initializeObservers, Bool lazyRegistration) |
| const ImageRegionObservableHandlerRef & | GetObservableHandler () const |
| Bool | IsInitialized () const |
Private Attributes |
|
| Bool | _isInitialized |
| LazyInitThreaded | _lazyRegistration |
| HashMap < Id , StoredObserver > | _observers |
| ImageRegionObservableHandlerRef | _observableHandler |
| using AddObserverFunc = Delegate < Result <void>(const Id & observerId, const ImageRegionObserverRef& observer)> |
Gives access to adding an observer under a unique id.
| [in] | observerId | The identifier of the observer. This identifier must be unique. |
| [in] | observer | The observer to add. |
| using InitializeObserversFunc = Delegate < Result <void>(const AddObserverFunc & addObserver)> |
Gives access to the addition of an observer collection.
| [in] | addObserver | The add function for an observer. |
| Result <T_ObserverRef> GetObserver | ( | const Id & | observerId | ) | const |
Returns an observer that has added under a particular id. The first call to the method will trigger the lazy registration of all added observers.
| Result <void> Initialize | ( | const InitializeObserversFunc & | initializeObservers , |
| Bool | lazyRegistration | ||
| ) |
Initializes the observable and creates a collection of long-living observers.
| [in] | initializeObservers | The function that adds the observers. |
| [in] | lazyRegistration | Determines whether the added observers should be lazily registered, or immediately. |
| const ImageRegionObservableHandlerRef& GetObservableHandler | ( | ) | const |
Returns the handler to the observable, giving access to the registrar of observers and notification dispatch.
| Bool IsInitialized | ( | ) | const |
Returns true if the observer storage is initialized.
|
private |
|
mutable private |
the initialization state.
|
mutable private |
the lazy execute-once registration function.
| ImageRegionObservableHandlerRef _observableHandler | private |
the collection of managed observers.