|
Cogs.Core
|
BufferView provides a typed, reference-counted, span of an underlying buffer resource. More...
#include <Buffer.h>
Public Member Functions | |
| BufferView ()=default | |
| Default constructor. A default view has no underlying resource. | |
| BufferView (BufferResource *b) | |
| Construct a buffer view to the given buffer resource b. | |
| BufferView (const ResourceBufferHandle &other) | |
| Construct a buffer view from the given untyped handle. | |
| size_t | size () const |
| Gets the size of the buffer in number of elements of type T. | |
| bool | empty () const |
| Gets if the buffer is empty. | |
| void | resize (size_t size) |
| Resize the buffer to accomodate size number of elements of type T. | |
| T * | data () |
| Get a pointer to the underlying data. Returns nullptr if no storage is allocated. | |
| const T * | data () const |
| T * | map () |
| Map the buffer contents, providing write access until unmapped. | |
| void | unmap () |
| Unmap the buffer storage. | |
| T * | begin () |
| Get an iterator to the first element of type T in the buffer. | |
| T * | end () |
| Get an iterator pointing to one past the final element of type T in the buffer. | |
| uint8_t | getGeneration () const |
| Get the generation counter. | |
| T & | operator[] (size_t index) |
| Access the element of type T at index. | |
| const T & | operator[] (size_t index) const |
| Access the element of type T at index. | |
Public Member Functions inherited from Cogs::Core::ResourceHandle_t< BufferResource > | |
| ResourceHandle_t ()=default | |
| Default construct a resource handle. | |
| ResourceHandle_t (ResourceBase *resource) | |
| Constructs a handle from the given resource pointer. | |
| ResourceHandle_t (const ResourceHandle_t &other) | |
| Copy construct a handle. | |
| ResourceHandle_t (ResourceHandle_t &&other) noexcept | |
| Move construct a handle from the given r-value. | |
| ResourceHandle_t (const ResourceHandleBase &other) | |
| ResourceHandle_t & | operator= (const ResourceHandle_t &other) |
| Copy assign the handle from the given other handle. | |
| BufferResource * | resolve () const |
| Resolve the handle, returning a pointer to the actual resource. | |
| BufferResource * | operator-> () const |
| Pointer operator, returns the held resource. | |
Public Member Functions inherited from Cogs::Core::ResourceHandleBase | |
| ResourceHandleBase ()=default | |
| Constructs an empty handle, holding no resource. | |
| ResourceHandleBase (ResourceBase *resource) | |
| Constructs a handle with the given integer handle and resource pointer pair. | |
| ResourceHandleBase (const ResourceHandleBase &other) | |
| Copy constructs a handle from the given other handle. | |
| ResourceHandleBase (ResourceHandleBase &&other) noexcept | |
| Move constructs a handle from the given other handle. | |
| ~ResourceHandleBase () | |
| Destructs a handle, and if a resource is held, releases the reference to this resource. | |
| ResourceHandleBase & | operator= (const ResourceHandleBase &other) |
| Assign the handle from the given other handle. | |
| bool | operator== (const ResourceHandleBase &other) const |
| Compares this instance against the contents of other. | |
| bool | operator!= (const ResourceHandleBase &other) const |
| Compares this instance against other for inequality. | |
| operator bool () const | |
| Implicit bool conversion operator. | |
| ResourceBase * | operator-> () |
| const ResourceBase * | operator-> () const |
| ResourceBase * | get () |
| const ResourceBase * | get () const |
| void | reset (ResourceBase *otherResource) |
| Reset the contents of this instance to the given handle and resource. | |
| ResourceId | getId () const |
| Get the resource id of the held resource. | |
| size_t | hash (size_t hashValue=Cogs::hash()) const |
Additional Inherited Members | |
Static Public Attributes inherited from Cogs::Core::ResourceHandle_t< BufferResource > | |
| static const ResourceHandle_t | NoHandle |
| Handle representing a default (or none if default not present) resource. | |
Static Public Attributes inherited from Cogs::Core::ResourceHandleBase | |
| static const ResourceHandleBase | NoHandle = Cogs::Core::ResourceHandleBase(nullptr) |
| Provided as shorthand for empty resource handles. | |
Protected Member Functions inherited from Cogs::Core::ResourceHandleBase | |
| void | resetInternal (ResourceBase *otherResource) |
| Reset the contents of this instance to the given handle and resource. | |
Protected Attributes inherited from Cogs::Core::ResourceHandleBase | |
| ResourceBase * | resource = nullptr |
| Pointer to held resource. | |
BufferView provides a typed, reference-counted, span of an underlying buffer resource.
TODO: Reconsider naming, as "view" is typically used for immutable storage.
|
inline |
|
inline |
Construct a buffer view from the given untyped handle.
Definition at line 126 of file Buffer.h.
References Cogs::Core::ResourceHandle_t< BufferResource >::operator=().
|
inline |
Get an iterator to the first element of type T in the buffer.
Definition at line 148 of file Buffer.h.
References Cogs::Core::BufferView< T >::data().
|
inline |
Get a pointer to the underlying data. Returns nullptr if no storage is allocated.
Definition at line 138 of file Buffer.h.
References Cogs::Core::BufferResource::data(), and Cogs::Core::ResourceHandle_t< BufferResource >::resolve().
Referenced by Cogs::Core::BufferView< T >::begin(), Cogs::Core::BufferView< T >::end(), and Cogs::Core::BufferView< T >::operator[]().
|
inline |
|
inline |
Gets if the buffer is empty.
Definition at line 132 of file Buffer.h.
References Cogs::Core::BufferResource::empty(), and Cogs::Core::ResourceHandle_t< BufferResource >::resolve().
|
inline |
Get an iterator pointing to one past the final element of type T in the buffer.
Definition at line 151 of file Buffer.h.
References Cogs::Core::BufferView< T >::data(), and Cogs::Core::BufferView< T >::size().
|
inline |
Get the generation counter.
Definition at line 154 of file Buffer.h.
References Cogs::Core::ResourceHandle_t< BufferResource >::resolve().
|
inline |
Map the buffer contents, providing write access until unmapped.
Definition at line 142 of file Buffer.h.
References Cogs::Core::BufferResource::map(), and Cogs::Core::ResourceHandle_t< BufferResource >::resolve().
|
inline |
Access the element of type T at index.
Definition at line 157 of file Buffer.h.
References Cogs::Core::BufferView< T >::data(), Cogs::Core::ResourceHandle_t< BufferResource >::resolve(), and Cogs::Core::BufferView< T >::size().
|
inline |
Access the element of type T at index.
Definition at line 164 of file Buffer.h.
References Cogs::Core::BufferView< T >::data(), Cogs::Core::ResourceHandle_t< BufferResource >::resolve(), and Cogs::Core::BufferView< T >::size().
|
inline |
Resize the buffer to accomodate size number of elements of type T.
Definition at line 135 of file Buffer.h.
References Cogs::Core::BufferResource::resize(), Cogs::Core::ResourceHandle_t< BufferResource >::resolve(), and Cogs::Core::BufferView< T >::size().
|
inline |
Gets the size of the buffer in number of elements of type T.
Definition at line 129 of file Buffer.h.
References Cogs::Core::ResourceHandle_t< BufferResource >::resolve(), and Cogs::Core::BufferResource::size().
Referenced by Cogs::Core::BufferView< T >::end(), Cogs::Core::BufferView< T >::operator[](), Cogs::Core::VectorField::VectorFieldPick::pickCamera(), and Cogs::Core::BufferView< T >::resize().
|
inline |
Unmap the buffer storage.
Definition at line 145 of file Buffer.h.
References Cogs::Core::ResourceHandle_t< BufferResource >::resolve(), and Cogs::Core::BufferResource::unmap().