Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
buffer-provider.hpp
Go to the documentation of this file.
1/*
2 BUFFER-PROVIDER.hpp - Abstraction for Buffer management during playback/render
3
4 Copyright (C)
5 2011, Hermann Vosseler <Ichthyostega@web.de>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12*/
13
32#ifndef STEAM_ENGINE_BUFFR_PROVIDER_H
33#define STEAM_ENGINE_BUFFR_PROVIDER_H
34
35
36#include "lib/error.hpp"
37#include "lib/symbol.hpp"
38#include "lib/hash-value.h"
40//#include "steam/engine/engine-ctx.hpp"
43#include "lib/nocopy.hpp"
44
45#include <utility>
46#include <memory>
47
48
49namespace steam {
50namespace engine {
51
52 using lib::Literal;
53 using std::unique_ptr;
54 using std::forward;
55
56
57 class BufferMetadata;
58
59
60 LUMIERA_ERROR_DECLARE (BUFFER_MANAGEMENT);
61
62
77 {
78 unique_ptr<BufferMetadata> meta_;
79
80
81 protected: /* === for Implementation by concrete providers === */
82
85
86 BufferProvider (Literal implementationID);
87
88 virtual uint prepareBuffers (uint count, HashVal typeID) =0;
89
90 virtual BuffHandle provideLockedBuffer (HashVal typeID) =0;
91 virtual void mark_emitted (HashVal, LocalTag const&) =0;
92 virtual void detachBuffer (HashVal, LocalTag const&, Buff&) =0;
93
94
95 public:
96 virtual ~BufferProvider();
97
98
99 uint announce (uint count, BuffDescr const&);
100
102 void emitBuffer (BuffHandle const&);
103 void releaseBuffer (BuffHandle const&);
104
105 template<typename BU, typename...ARGS>
106 BuffHandle lockBufferFor (ARGS ...args);
107
109 void attachTypeHandler (BuffHandle const& target, BuffDescr const& reference);
110
111 void emergencyCleanup (BuffHandle const& target, bool invokeDtor =false);
112
113
115 BuffDescr getDescriptorFor(size_t storageSize=0);
116 BuffDescr getDescriptorFor(size_t storageSize, TypeHandler specialTreatment);
117
118 template<typename BU, typename...ARGS>
119 BuffDescr getDescriptor (ARGS ...args);
120
121
122
123 /* === API for BuffHandle internal access === */
124
125 bool verifyValidity (BuffDescr const&) const;
126 size_t getBufferSize (HashVal typeID) const;
127
128 protected:
129 BuffHandle buildHandle (HashVal typeID, Buff* storage, LocalTag const& =LocalTag::UNKNOWN);
130
131 bool was_created_by_this_provider (BuffDescr const&) const;
132 };
133
134
135
136
137 /* === Implementation === */
138
146 template<typename BU, typename...ARGS>
149 {
150 BuffDescr attach_object_automatically = getDescriptor<BU> (forward<ARGS> (args)...);
151 return lockBuffer (attach_object_automatically);
152 }
153
154
159 template<typename BU, typename...ARGS>
162 {
163 return getDescriptorFor (sizeof(BU), TypeHandler::create<BU> (forward<ARGS> (args)...));
164 }
165
166
167}} // namespace steam::engine
168#endif /*STEAM_ENGINE_BUFFR_PROVIDER_H*/
A marker data type used in metadata / buffer management of the render engine.
A front-end to support the buffer management within the render nodes.
Inline string literal.
Definition symbol.hpp:78
placeholder type for the contents of a data buffer.
An opaque descriptor to identify the type and further properties of a data buffer.
Handle for a buffer for processing data, abstracting away the actual implementation.
Interface: a facility providing and managing working buffers for media calculations.
uint announce(uint count, BuffDescr const &)
BufferProvider API: declare in advance the need for working buffers.
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 was_created_by_this_provider(BuffDescr const &) const
virtual uint prepareBuffers(uint count, HashVal typeID)=0
BuffHandle lockBufferFor(ARGS ...args)
convenience shortcut: prepare and claim ("lock") a buffer suitable to hold an object of the given typ...
bool verifyValidity(BuffDescr const &) const
void emergencyCleanup(BuffHandle const &target, bool invokeDtor=false)
void emitBuffer(BuffHandle const &)
BufferProvider API: state transition to emitted state.
virtual ~BufferProvider()
this is an ABC
unique_ptr< BufferMetadata > meta_
BuffDescr getDescriptor(ARGS ...args)
define a "buffer type" for automatically creating an instance of the template type embedded into the ...
BuffDescr getDescriptorFor(size_t storageSize=0)
describe the kind of buffer managed by this provider
virtual void detachBuffer(HashVal, LocalTag const &, Buff &)=0
void attachTypeHandler(BuffHandle const &target, BuffDescr const &reference)
allow for attaching and owing an object within an already created buffer
virtual void mark_emitted(HashVal, LocalTag const &)=0
size_t getBufferSize(HashVal typeID) const
BuffHandle lockBuffer(BuffDescr const &)
BufferProvider API: retrieve a single buffer for exclusive use.
void releaseBuffer(BuffHandle const &)
BufferProvider API: declare done and detach.
virtual BuffHandle provideLockedBuffer(HashVal typeID)=0
an opaque mark to be used by the BufferProvider implementation.
static const LocalTag UNKNOWN
Marker when no distinct local key is given.
Any copy and copy construction prohibited.
Definition nocopy.hpp:38
#define LUMIERA_ERROR_DECLARE(err)
Forward declare an error constant.
Definition error.h:62
Lumiera error handling (C++ interface).
Hash value types and utilities.
unsigned int uint
Definition integral.hpp:29
Steam-Layer implementation namespace root.
Mix-Ins to allow or prohibit various degrees of copying and cloning.
A pair of functors to maintain a datastructure within a buffer.
Marker types to indicate a literal string and a Symbol.
Helper holding a pair of type-build-up and destruction functors.