Lumiera
0.pre.03
»edit your freedom«
|
#include "steam/engine/buffer-provider.hpp"
Interface: a facility providing and managing working buffers for media calculations.
The pointer to actual buffer storage can be retrieved by
as of 6/2011 buffer management within the engine is still a bit vague
as of 11/11 thread safety within the engine remains to be clarified ///////////////////////////TICKET #854
Definition at line 75 of file buffer-provider.hpp.
Public Member Functions | |
virtual | ~BufferProvider () |
this is an ABC | |
uint | announce (uint count, BuffDescr const &) |
BufferProvider API: declare in advance the need for working buffers. More... | |
void | attachTypeHandler (BuffHandle const &target, BuffDescr const &reference) |
allow for attaching and owing an object within an already created buffer More... | |
void | emergencyCleanup (BuffHandle const &target, bool invokeDtor=false) |
void | emitBuffer (BuffHandle const &) |
BufferProvider API: state transition to emitted state. More... | |
size_t | getBufferSize (HashVal typeID) const |
template<typename BU , typename... ARGS> | |
BuffDescr | getDescriptor (ARGS ...args) |
define a "buffer type" for automatically creating an instance of the template type embedded into the buffer and destroying that embedded object when releasing the buffer. | |
BuffDescr | getDescriptorFor (size_t storageSize=0) |
describe the kind of buffer managed by this provider | |
BuffDescr | getDescriptorFor (size_t storageSize, TypeHandler specialTreatment) |
BuffHandle | lockBuffer (BuffDescr const &) |
BufferProvider API: retrieve a single buffer for exclusive use. More... | |
template<typename BU , typename... ARGS> | |
BuffHandle | lockBufferFor (ARGS ...args) |
convenience shortcut: prepare and claim ("lock") a buffer suitable to hold an object of the given type. More... | |
void | releaseBuffer (BuffHandle const &) |
BufferProvider API: declare done and detach. More... | |
bool | verifyValidity (BuffDescr const &) const |
Protected Types | |
using | Buff = StreamType::ImplFacade::DataBuffer |
placeholder marker type for an actual data buffer | |
Protected Member Functions | |
BufferProvider (Literal implementationID) | |
build a new provider instance, managing a family of buffers. More... | |
BuffHandle | buildHandle (HashVal typeID, Buff *storage, LocalTag const &=LocalTag::UNKNOWN) |
callback from implementation to build and enrol a BufferHandle, to be returned to the client as result of the lockBuffer call. More... | |
virtual void | detachBuffer (HashVal, LocalTag const &, Buff &)=0 |
virtual void | mark_emitted (HashVal, LocalTag const &)=0 |
virtual uint | prepareBuffers (uint count, HashVal typeID)=0 |
virtual BuffHandle | provideLockedBuffer (HashVal typeID)=0 |
bool | was_created_by_this_provider (BuffDescr const &) const |
Private Attributes | |
unique_ptr< BufferMetadata > | meta_ |
Additional Inherited Members | |
Private Member Functions inherited from NonCopyable | |
NonCopyable (NonCopyable const &)=delete | |
NonCopyable & | operator= (NonCopyable const &)=delete |
|
protected |
build a new provider instance, managing a family of buffers.
The metadata of these buffers is organised hierarchically based on chained hash values, using the #implementationID as a seed.
implementationID | symbolic ID setting these family of buffers apart. |
Definition at line 49 of file buffer-provider.cpp.
uint announce | ( | uint | count, |
BuffDescr const & | type | ||
) |
BufferProvider API: declare in advance the need for working buffers.
This optional call allows client code to ensure the availability of the necessary working space, prior to starting the actual operations. The client may reasonably assume to get the actual number of buffers, as indicated by the return value. A provider may be able to handle various kinds of buffers (e.g. of differing size), which are distinguished by the type embodied into the BuffDescr.
error::State | when no buffer of this kind can be provided |
Definition at line 118 of file buffer-provider.cpp.
BuffHandle lockBuffer | ( | BuffDescr const & | type | ) |
BufferProvider API: retrieve a single buffer for exclusive use.
This call actually claims a buffer of this type and marks it for use by client code. The returned handle allows for convenient access, but provides no automatic tracking or memory management. The client is explicitly responsible to invoke releaseBuffer (which can be done directly on the BuffHandle).
error::State | when unable to provide this buffer |
Definition at line 141 of file buffer-provider.cpp.
Referenced by BufferProvider::lockBufferFor().
void emitBuffer | ( | BuffHandle const & | handle | ) |
BufferProvider API: state transition to emitted state.
Client code may signal a state transition through this optional operation. The actual meaning of an "emitted" buffer is implementation defined; similarly, some back-ends may actually do something when emitting a buffer (e.g. commit data to cache), while others just set a flag or do nothing at all. This state transition may be invoked at most once per locked buffer.
error::Fatal | in case of invalid state transition sequence. Only a locked buffer may be emitted, and at most once. |
Definition at line 162 of file buffer-provider.cpp.
References steam::engine::EMITTED, and Entry::mark().
void releaseBuffer | ( | BuffHandle const & | handle | ) |
BufferProvider API: declare done and detach.
Client code is required to release each previously locked buffer eventually.
Definition at line 179 of file buffer-provider.cpp.
References ERROR_LOG_AND_IGNORE, steam::engine::FREE, and Entry::mark().
BuffHandle lockBufferFor | ( | ARGS ... | args | ) |
convenience shortcut: prepare and claim ("lock") a buffer suitable to hold an object of the given type.
Definition at line 148 of file buffer-provider.hpp.
References BufferProvider::lockBuffer().
void attachTypeHandler | ( | BuffHandle const & | target, |
BuffDescr const & | reference | ||
) |
allow for attaching and owing an object within an already created buffer
Definition at line 201 of file buffer-provider.cpp.
References Entry::isLocked(), and Entry::isTypeKey().
void emergencyCleanup | ( | BuffHandle const & | target, |
bool | invokeDtor = false |
||
) |
abort normal lifecycle, reset the underlying buffer and detach from it. This allows to break out of normal usage and reset the handle to invalid state
invokeDtor | if possibly the clean-up function of an TypeHandler registered with the buffer metadata should be invoked prior to resetting the metadata state. Default is not to invoke anything |
Definition at line 223 of file buffer-provider.cpp.
References ERROR_LOG_AND_IGNORE.
bool verifyValidity | ( | BuffDescr const & | bufferID | ) | const |
verify the given descriptor.
Definition at line 61 of file buffer-provider.cpp.
|
protected |
callback from implementation to build and enrol a BufferHandle, to be returned to the client as result of the lockBuffer call.
Performs the necessary metadata state transition leading from an abstract buffer type to a metadata::Entry corresponding to an actual buffer, which is locked for exclusive use by one client.
Definition at line 96 of file buffer-provider.cpp.
References steam::mobject::session::query::anonymous_namespace{fake-configrules.cpp}::entry().