Cogs.Core
Public Member Functions | Public Attributes | Private Attributes | List of all members
Cogs::Core::MappedStream< Element > Struct Template Referencefinal

Wrapper for mapped stream data automatically updating the Mesh resource mapped from when destructed. More...

#include <Mesh.h>

Public Member Functions

 MappedStream (struct Mesh *mesh, Element *data, VertexDataType::EVertexDataType type)
 Constructs a MappedStream from the given mesh for updating the mesh.
 
 MappedStream (MappedStream &other)=delete
 Disabled copy constructor.
 
 MappedStream (MappedStream &&other)
 Move construct the wrapper from other.
 
 ~MappedStream ()
 Destructs the mapped stream wrapper.
 
constexpr Element & operator[] (const size_t index)
 Access the Element at the given index.
 
constexpr const Element & operator[] (const size_t index) const
 
constexpr bool isValid () const
 Returns true if stream mapping successful.
 
constexpr VertexDataType::EVertexDataType getDataType () const
 

Public Attributes

Element * data
 Pointer to the element data mapped from the Mesh data stream.
 

Private Attributes

struct Meshmesh
 Pointer to the mapped mesh.
 
VertexDataType::EVertexDataType type
 Type index of the mesh data stream.
 

Detailed Description

template<typename Element>
struct Cogs::Core::MappedStream< Element >

Wrapper for mapped stream data automatically updating the Mesh resource mapped from when destructed.

MappedStream instances are returned when mapping Mesh data streams and provide easy scoped access to the mapped data.

Use

See also
MappedStreamReadOnly to only access existing data. Avoid unnecessary GPU updates.
Template Parameters
Typeof elements contained in the stream, e.g glm::vec3 for position data.

Definition at line 125 of file Mesh.h.

Constructor & Destructor Documentation

◆ MappedStream() [1/2]

template<typename Element >
Cogs::Core::MappedStream< Element >::MappedStream ( struct Mesh mesh,
Element *  data,
VertexDataType::EVertexDataType  type 
)
inline

Constructs a MappedStream from the given mesh for updating the mesh.

Parameters
meshMesh resource the data is mapped from. Notified when this wrapper is destructed that the mapped data is done being modified.
dataPointer to the mapped mesh data stream.
typeIndex of the vertex data stream in the Mesh.

Definition at line 135 of file Mesh.h.

◆ MappedStream() [2/2]

template<typename Element >
Cogs::Core::MappedStream< Element >::MappedStream ( MappedStream< Element > &&  other)
inline

Move construct the wrapper from other.

Definition at line 142 of file Mesh.h.

◆ ~MappedStream()

template<typename Element >
Cogs::Core::MappedStream< Element >::~MappedStream

Destructs the mapped stream wrapper.

If the mesh pointer field is valid (the wrapper has not been move constructed from), notifies the Mesh resource that the data pointed to is done being modified, and unmaps the data.

Definition at line 1110 of file Mesh.h.

Member Function Documentation

◆ getDataType()

template<typename Element >
constexpr VertexDataType::EVertexDataType Cogs::Core::MappedStream< Element >::getDataType ( ) const
inlineconstexpr

Definition at line 177 of file Mesh.h.

◆ isValid()

template<typename Element >
constexpr bool Cogs::Core::MappedStream< Element >::isValid ( ) const
inlineconstexpr

Returns true if stream mapping successful.

Definition at line 175 of file Mesh.h.

◆ operator[]() [1/2]

template<typename Element >
constexpr Element & Cogs::Core::MappedStream< Element >::operator[] ( const size_t  index)
inlineconstexpr

Access the Element at the given index.

Parameters
indexIndex of the element to access. Must be inside the range [start, start + count) given to Mesh::map().
Returns
A reference to the element instance at index.

Definition at line 164 of file Mesh.h.

◆ operator[]() [2/2]

template<typename Element >
constexpr const Element & Cogs::Core::MappedStream< Element >::operator[] ( const size_t  index) const
inlineconstexpr

Definition at line 169 of file Mesh.h.

Member Data Documentation

◆ data

template<typename Element >
Element* Cogs::Core::MappedStream< Element >::data

Pointer to the element data mapped from the Mesh data stream.

Definition at line 180 of file Mesh.h.

◆ mesh

template<typename Element >
struct Mesh* Cogs::Core::MappedStream< Element >::mesh
private

Pointer to the mapped mesh.

Definition at line 184 of file Mesh.h.

◆ type

template<typename Element >
VertexDataType::EVertexDataType Cogs::Core::MappedStream< Element >::type
private

Type index of the mesh data stream.

Definition at line 187 of file Mesh.h.


The documentation for this struct was generated from the following file: