libASPL
|
#include <aspl/Dispatcher.hpp>
Public Member Functions | |
Dispatcher (std::shared_ptr< Tracer > tracer={}, AudioObjectID hintMaximumID=1000) | |
Construct dispatcher. Use tracer if you want to debug dispatcher itself, it is quite verbose. | |
Dispatcher (const Dispatcher &)=delete | |
Dispatcher & | operator= (const Dispatcher &)=delete |
std::shared_ptr< Object > | FindObject (AudioObjectID objectID) const |
Find registered object by ID. Returns null if there is no such object. | |
AudioObjectID | RegisterObject (Object &object, AudioObjectID objectID=kAudioObjectUnknown) |
Register new object. If objectID is kAudioObjectUnknown (zero), a new ID is allocated. Otherwise, given ID is used. | |
void | UnregisterObject (AudioObjectID objectID) |
Unregister previously registered object. It's guaranteed that after this method returns, the registered object is not accessed by dispatcher anymore and can be destroyed. | |
Object dispatcher.
Every object registers itself here in its constructor, and unregisters in destructor.
Dispatcher allocates object identifiers and maps identifiers to objects. Freed identifiers are reused.
The allocation algorithm tries to delay identifier reuse for a while, to give you a chance to catch bugs with looking up recently freed objects.
Dispatcher stores weak references to objects and thus does not affect their reference counter.
Definition at line 39 of file Dispatcher.hpp.
aspl::Dispatcher::Dispatcher | ( | std::shared_ptr< Tracer > | tracer = {}, |
AudioObjectID | hintMaximumID = 1000 ) |
Construct dispatcher. Use tracer if you want to debug dispatcher itself, it is quite verbose.
std::shared_ptr< Object > aspl::Dispatcher::FindObject | ( | AudioObjectID | objectID | ) | const |
Find registered object by ID. Returns null if there is no such object.
AudioObjectID aspl::Dispatcher::RegisterObject | ( | Object & | object, |
AudioObjectID | objectID = kAudioObjectUnknown ) |
Register new object. If objectID is kAudioObjectUnknown (zero), a new ID is allocated. Otherwise, given ID is used.
void aspl::Dispatcher::UnregisterObject | ( | AudioObjectID | objectID | ) |
Unregister previously registered object. It's guaranteed that after this method returns, the registered object is not accessed by dispatcher anymore and can be destroyed.