37 const uint DEFAULT_DESCRIPTOR = 0;
63 return meta_->isLocked (bufferID);
70 return BuffDescr (*
this, meta_->key (storageSize));
77 return BuffDescr (*
this, meta_->key (storageSize, specialTreatment));
82 BufferProvider::getBufferSize (
HashVal typeID)
const 85 return typeKey.storageSize();
120 uint actually_possible = prepareBuffers (count, type);
121 if (!actually_possible)
122 throw error::State (
"unable to fulfil request for buffers" 123 ,LUMIERA_ERROR_BUFFER_MANAGEMENT);
124 return actually_possible;
143 REQUIRE (was_created_by_this_provider (type));
145 return provideLockedBuffer (type);
165 mark_emitted (metaEntry.parentKey(), metaEntry.localTag());
183 detachBuffer (metaEntry.parentKey(), metaEntry.localTag(), *handle);
184 meta_->release (metaEntry);
208 throw error::Logic{
"unable to attach an object because buffer isn't locked for use" 211 metaEntry.useTypeHandlerFrom (refEntry);
226 metaEntry.invalidate (invokeDtor);
227 detachBuffer (metaEntry.parentKey(), metaEntry.localTag(), *target);
228 meta_->release (metaEntry);
235 BufferProvider::was_created_by_this_provider (
BuffDescr const& descr)
const 237 return isSameAdr (
this, descr.provider_);
247 BuffDescr::verifyValidity()
const 250 return provider_->verifyValidity(*
this);
255 BuffDescr::determineBufferSize()
const 258 return provider_->getBufferSize (*
this);
266 return provider_->announce(count, *
this);
271 BuffDescr::lockBuffer()
274 return provider_->lockBuffer(*
this);
282 descriptor_.provider_->emitBuffer(*
this);
287 BuffHandle::release()
292 descriptor_.provider_->releaseBuffer(*
this);
300 BuffHandle::emergencyCleanup()
302 descriptor_.provider_->emergencyCleanup(*
this);
322 if (!this->isValid())
323 throw error::Logic (
"attaching an object requires an buffer in locked state", LERR_(LIFECYCLE));
324 if (this->size() < type.determineBufferSize())
325 throw error::Logic (
"insufficient buffer size to hold an instance of that type");
327 descriptor_.provider_->attachTypeHandler(*
this, type);
allocated buffer, no longer in use
bool verifyValidity(BuffDescr const &) const
uint announce(uint count, BuffDescr const &)
BufferProvider API: declare in advance the need for working buffers.
#define ERROR_LOG_AND_IGNORE(_FLAG_, _OP_DESCR_)
convenience shortcut for a sequence of catch blocks just logging and consuming an error...
void attachTypeHandler(BuffHandle const &target, BuffDescr const &reference)
allow for attaching and owing an object within an already created buffer
AnyPair entry(Query< TY > const &query, typename WrapReturn< TY >::Wrapper &obj)
helper to simplify creating mock table entries, wrapped correctly
void releaseBuffer(BuffHandle const &)
BufferProvider API: declare done and detach.
inline string literal This is a marker type to indicate that
bool isTypeKey() const
is this Entry just an (abstract) placeholder for a type?
void emergencyCleanup(BuffHandle const &target, bool invokeDtor=false)
An opaque descriptor to identify the type and further properties of a data buffer.
an opaque mark to be used by the BufferProvider implementation.
allocated buffer, returned from client
Entry & mark(BufferState newState)
Buffer state machine.
Steam-Layer implementation namespace root.
BuffDescr getDescriptorFor(size_t storageSize=0)
describe the kind of buffer managed by this provider
Derived specific exceptions within Lumiera's exception hierarchy.
uint announce(uint count)
convenience shortcut to start a buffer handling cycle
static const TypeHandler RAW
Marker for the default case: raw buffer without type handling.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
BuffHandle lockBuffer(BuffDescr const &)
BufferProvider API: retrieve a single buffer for exclusive use.
bool isLocked() const
is this Entry currently associated to a concrete buffer? Is this buffer in use?
BufferProvider(Literal implementationID)
build a new provider instance, managing a family of buffers.
Lumiera error handling (C++ interface).
static const LocalTag UNKNOWN
Marker when no distinct local key is given.
Handle for a buffer for processing data, abstracting away the actual implementation.
size_t HashVal
a STL compatible hash value
virtual ~BufferProvider()
this is an ABC
A pair of functors to maintain a datastructure within a buffer.
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 resul...
bool isSameAdr(A const &a, B const &b)
compare plain object address identity, disregarding type.
void emitBuffer(BuffHandle const &)
BufferProvider API: state transition to emitted state.
placeholder type for the contents of a data buffer.
A complete metadata Entry, based on a Key.
#define LUMIERA_ERROR_DEFINE(err, msg)
Definition and initialisation of an error constant.
Abstraction to represent buffer management and lifecycle within the render engine.