|
| BufferRAM (const DataFormatBase *format, BufferUsage usage=BufferUsage::Static, BufferTarget target=BufferTarget::Data) |
|
| BufferRAM (const BufferRAM &rhs)=default |
|
BufferRAM & | operator= (const BufferRAM &that)=default |
|
virtual BufferRAM * | clone () const override=0 |
|
virtual void * | getData ()=0 |
|
virtual const void * | getData () const =0 |
|
virtual void | reserve (size_t size)=0 |
|
virtual void | clear ()=0 |
|
virtual double | getAsDouble (const size_t &pos) const =0 |
|
virtual dvec2 | getAsDVec2 (const size_t &pos) const =0 |
|
virtual dvec3 | getAsDVec3 (const size_t &pos) const =0 |
|
virtual dvec4 | getAsDVec4 (const size_t &pos) const =0 |
|
virtual void | setFromDouble (const size_t &pos, double val)=0 |
|
virtual void | setFromDVec2 (const size_t &pos, dvec2 val)=0 |
|
virtual void | setFromDVec3 (const size_t &pos, dvec3 val)=0 |
|
virtual void | setFromDVec4 (const size_t &pos, dvec4 val)=0 |
|
virtual double | getAsNormalizedDouble (const size_t &pos) const =0 |
|
virtual dvec2 | getAsNormalizedDVec2 (const size_t &pos) const =0 |
|
virtual dvec3 | getAsNormalizedDVec3 (const size_t &pos) const =0 |
|
virtual dvec4 | getAsNormalizedDVec4 (const size_t &pos) const =0 |
|
virtual void | setFromNormalizedDouble (const size_t &pos, double val)=0 |
|
virtual void | setFromNormalizedDVec2 (const size_t &pos, dvec2 val)=0 |
|
virtual void | setFromNormalizedDVec3 (const size_t &pos, dvec3 val)=0 |
|
virtual void | setFromNormalizedDVec4 (const size_t &pos, dvec4 val)=0 |
|
virtual std::type_index | getTypeIndex () const override final |
|
template<typename Result , template< class > class Predicate = dispatching::filter::All, typename Callable , typename... Args> |
auto | dispatch (Callable &&callable, Args &&... args) -> Result |
|
template<typename Result , template< class > class Predicate = dispatching::filter::All, typename Callable , typename... Args> |
auto | dispatch (Callable &&callable, Args &&... args) const -> Result |
|
virtual void | setSize (size_t size)=0 |
|
virtual size_t | getSize () const =0 |
|
virtual size_t | getSizeOfElement () const |
|
BufferUsage | getBufferUsage () const |
|
BufferTarget | getBufferTarget () const |
|
const DataFormatBase * | getDataFormat () const |
|
std::string | getDataFormatString () const |
|
DataFormatId | getDataFormatId () const |
|
void | setOwner (BufferBase *owner) |
|
BufferBase * | getOwner () |
|
const BufferBase * | getOwner () const |
|
bool | isValid () const |
|
void | setValid (bool valid) |
|
template<typename Result , template< class > class Predicate, typename Callable , typename... Args>
auto inviwo::BufferRAM::dispatch |
( |
Callable && |
callable, |
|
|
Args &&... |
args |
|
) |
| -> Result |
Dispatch functionality to retrieve the actual underlaying BufferRamPrecision. The dispatcher takes a generic lambda as argument. Code will be instantiated for all the DataFormat types by default. But by suppling the template Predicate
argument the list of formats to instantiate can be filtered. Hence if one knows that only Vector types are applicable there is no need to write generic code that also works for scalars.
Example of counting the number of elements larger then 0:
BufferRam* bufferram = ...;
auto count = bufferram->dispatch<size_t, dispatching::filter::Vecs>([](auto brprecision) {
std::vector<ValueType>& data = brprecision->getDataContainer();
return std::count_if(data.begin(), data.end(), [](auto x){return x > ValueType{0};});
});
Template arguments:
- Result the return type of the lambda.
- Predicate A type that is used to filter the list of types to consider in the dispatching. The
dispatching::filter
namespace have a few standard ones predefined.
Predicates:
- All Matches all formats, default.
- Floats Matches all floating point types. float, double, half, vec2, dvec3,...
- Integers Matches all integer types, i.e. int, ivec2, uvec3...
- Scalars Matches all scalar types, i.e. int, char, long, float, ...
- Vecs Matches all glm vector types, i.e. vec3, ivec3, uvec4,...
- VecNs Matches all glm vector types of length N. N = 2,3,4.
- FloatNs Matches all floating point glm vector types of length N. N = 2,3,4.
- Parameters
-
callable | This should be a generic lambda or a struct with a generic call operator. it will be called with the specific BufferRamPresision<T> as the first argument and any additional arguments (args ) appended to that. |
args | Any additional arguments that should be passed on to the lambda. |
- Exceptions
-