Radium Engine  1.5.20
Loading...
Searching...
No Matches
Ra::Core::Utils::Attrib< T > Class Template Reference

#include <Core/Utils/Attribs.hpp>

+ Inheritance diagram for Ra::Core::Utils::Attrib< T >:
+ Collaboration diagram for Ra::Core::Utils::Attrib< T >:

Public Types

using value_type = T
 
using Container = VectorArray<T>
 

Public Member Functions

 Attrib (const std::string &name)
 
void resize (size_t s) override
 Resize the container (value_type must have a default ctor).
 
ContainergetDataWithLock ()
 
const Containerdata () const
 Read-only acccess to the attribute content.
 
bool isFloat () const override
 Return true if the attribute content is of Scalar type, false otherwise.
 
bool isVector2 () const override
 Return true if the attribute content is of Vector2 type, false otherwise.
 
bool isVector3 () const override
 Return true if the attribute content is of Vector3 type, false otherwise.
 
bool isVector4 () const override
 Return true if the attribute content is of Vector4 type, false otherwise.
 
template<typename U >
bool isType ()
 check if attrib is a given type, as in attr.isType<MyMatrix>()
 
std::unique_ptr< AttribBaseclone () override
 
size_t getSize () const override
 
size_t getNumberOfComponents () const override
 
int getStride () const override
 
size_t getBufferSize () const override
 
const void * dataPtr () const override
 
void setData (const Container &data)
 
void setData (Container &&data)
 
- Public Member Functions inherited from Ra::Core::Utils::AttribBase
 AttribBase (const std::string &name)
 
 AttribBase (const AttribBase &)=delete
 
AttribBaseoperator= (const AttribBase &)=delete
 
std::string getName () const
 Return the attribute's name.
 
void setName (const std::string &name)
 Set the attribute's name.
 
bool operator== (const AttribBase &rhs)
 Return true if *this and rhs have the same name.
 
template<typename T >
Attrib< T > & cast ()
 Downcast from AttribBase to Attrib<T>.
 
template<typename T >
const Attrib< T > & cast () const
 Downcast from AttribBase to Attrib<T>.
 
bool isLocked () const
 
void unlock ()
 Unlock data so another one can gain write access.
 
- Public Member Functions inherited from Ra::Core::Utils::ContainerIntrospectionInterface
virtual ~ContainerIntrospectionInterface ()
 only needed for correct abstract dtor call.
 

Additional Inherited Members

- Protected Member Functions inherited from Ra::Core::Utils::AttribBase
void lock (bool isLocked=true)
 

Detailed Description

template<typename T>
class Ra::Core::Utils::Attrib< T >

An Attrib stores an element of type T for each entry.

Definition at line 91 of file Attribs.hpp.

Member Typedef Documentation

◆ Container

template<typename T >
using Ra::Core::Utils::Attrib< T >::Container = VectorArray<T>

Definition at line 95 of file Attribs.hpp.

◆ value_type

template<typename T >
using Ra::Core::Utils::Attrib< T >::value_type = T

Definition at line 94 of file Attribs.hpp.

Constructor & Destructor Documentation

◆ Attrib()

template<typename T >
Ra::Core::Utils::Attrib< T >::Attrib ( const std::string & name)
explicit

Definition at line 487 of file Attribs.hpp.

◆ ~Attrib()

template<typename T >
Ra::Core::Utils::Attrib< T >::~Attrib ( )
virtual

Definition at line 491 of file Attribs.hpp.

Member Function Documentation

◆ clone()

template<typename T >
std::unique_ptr< AttribBase > Ra::Core::Utils::Attrib< T >::clone ( )
inlineoverridevirtual

Implements Ra::Core::Utils::AttribBase.

Definition at line 133 of file Attribs.hpp.

◆ data()

template<typename T >
const Attrib< T >::Container & Ra::Core::Utils::Attrib< T >::data ( ) const
inline

Read-only acccess to the attribute content.

Definition at line 524 of file Attribs.hpp.

◆ dataPtr()

template<typename T >
const void * Ra::Core::Utils::Attrib< T >::dataPtr ( ) const
overridevirtual
Returns
a const pointer to the raw data

Implements Ra::Core::Utils::ContainerIntrospectionInterface.

Definition at line 505 of file Attribs.hpp.

◆ getBufferSize()

template<typename T >
size_t Ra::Core::Utils::Attrib< T >::getBufferSize ( ) const
overridevirtual
Returns
the size in byte of container

Implements Ra::Core::Utils::ContainerIntrospectionInterface.

Definition at line 539 of file Attribs.hpp.

◆ getDataWithLock()

template<typename T >
Attrib< T >::Container & Ra::Core::Utils::Attrib< T >::getDataWithLock ( )
inline

Read-write access to the attribute content. lock the content, when done call unlock()

Definition at line 499 of file Attribs.hpp.

◆ getNumberOfComponents()

template<typename T >
size_t Ra::Core::Utils::Attrib< T >::getNumberOfComponents ( ) const
overridevirtual

Return the number of components of one element (i.e. for glVertexAttribPointer size argument )

See also
https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glVertexAttribPointer.xhtml
Returns
the number of components of one element (i.e. faces, vector)

Implements Ra::Core::Utils::ContainerIntrospectionInterface.

Definition at line 571 of file Attribs.hpp.

◆ getSize()

template<typename T >
size_t Ra::Core::Utils::Attrib< T >::getSize ( ) const
overridevirtual

ContainerIntrosectionInterface implementation

Implements Ra::Core::Utils::ContainerIntrospectionInterface.

Definition at line 529 of file Attribs.hpp.

◆ getStride()

template<typename T >
int Ra::Core::Utils::Attrib< T >::getStride ( ) const
overridevirtual
Returns
the stride, in bytes, from one attribute address to the next one.
Warning
it's meaningful only if the attrib do not contain heap allocated data. Such attrib could not be easily sent to the GPU, and getStride is meaningless.

Implements Ra::Core::Utils::ContainerIntrospectionInterface.

Definition at line 534 of file Attribs.hpp.

◆ isFloat()

template<typename T >
bool Ra::Core::Utils::Attrib< T >::isFloat ( ) const
overridevirtual

Return true if the attribute content is of Scalar type, false otherwise.

Implements Ra::Core::Utils::AttribBase.

Definition at line 544 of file Attribs.hpp.

◆ isType()

template<typename T >
template<typename U >
bool Ra::Core::Utils::Attrib< T >::isType ( )

check if attrib is a given type, as in attr.isType<MyMatrix>()

Definition at line 565 of file Attribs.hpp.

◆ isVector2()

template<typename T >
bool Ra::Core::Utils::Attrib< T >::isVector2 ( ) const
overridevirtual

Return true if the attribute content is of Vector2 type, false otherwise.

Implements Ra::Core::Utils::AttribBase.

Definition at line 549 of file Attribs.hpp.

◆ isVector3()

template<typename T >
bool Ra::Core::Utils::Attrib< T >::isVector3 ( ) const
overridevirtual

Return true if the attribute content is of Vector3 type, false otherwise.

Implements Ra::Core::Utils::AttribBase.

Definition at line 554 of file Attribs.hpp.

◆ isVector4()

template<typename T >
bool Ra::Core::Utils::Attrib< T >::isVector4 ( ) const
overridevirtual

Return true if the attribute content is of Vector4 type, false otherwise.

Implements Ra::Core::Utils::AttribBase.

Definition at line 559 of file Attribs.hpp.

◆ resize()

template<typename T >
void Ra::Core::Utils::Attrib< T >::resize ( size_t s)
overridevirtual

Resize the container (value_type must have a default ctor).

Implements Ra::Core::Utils::AttribBase.

Definition at line 495 of file Attribs.hpp.

+ Here is the call graph for this function:

◆ setData() [1/2]

template<typename T >
void Ra::Core::Utils::Attrib< T >::setData ( const Container & data)

setAttribData, attrib mustn't be locked (it's asserted).

Definition at line 510 of file Attribs.hpp.

◆ setData() [2/2]

template<typename T >
void Ra::Core::Utils::Attrib< T >::setData ( Container && data)

Definition at line 517 of file Attribs.hpp.


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