SOFA API  6dc60b15
Open source framework for multi-physics simuation
sofa::defaulttype::VirtualTypeInfo< TDataType > Class Template Reference

#include <DataTypeInfo.h>

Abstract type traits class. More...

Inheritance diagram for sofa::defaulttype::VirtualTypeInfo< TDataType >:

Detailed Description

template<class TDataType>
class sofa::defaulttype::VirtualTypeInfo< TDataType >

Abstract type traits class.

Public Member Functions

const AbstractTypeInfoBaseType () const override
 
const AbstractTypeInfoValueType () const override
 
virtual std::string name () const override
 Returns the name of this type. More...
 
bool ValidInfo () const override
 
bool FixedSize () const override
 
bool ZeroConstructor () const override
 True iff the default constructor of this type is equivalent to setting the memory to 0. More...
 
bool SimpleCopy () const override
 True iff copying the data can be done with a memcpy(). More...
 
bool SimpleLayout () const override
 
bool Integer () const override
 True iff this type uses integer values. More...
 
bool Scalar () const override
 True iff this type uses scalar values. More...
 
bool Text () const override
 True iff this type uses text values. More...
 
bool CopyOnWrite () const override
 True iff this type uses copy-on-write. More...
 
bool Container () const override
 
size_t size () const override
 
size_t byteSize () const override
 
size_t size (const void *data) const override
 
bool setSize (void *data, size_t size) const override
 Resize data to size elements, if relevant. More...
 
long long getIntegerValue (const void *data, size_t index) const override
 
double getScalarValue (const void *data, size_t index) const override
 
virtual std::string getTextValue (const void *data, size_t index) const override
 Get the value at index of data as a string. More...
 
void setIntegerValue (void *data, size_t index, long long value) const override
 Set the value at index of data from an integer value. More...
 
void setScalarValue (void *data, size_t index, double value) const override
 Set the value at index of data from a scalar value. More...
 
virtual void setTextValue (void *data, size_t index, const std::string &value) const override
 Set the value at index of data from a string value. More...
 
const void * getValuePtr (const void *data) const override
 
void * getValuePtr (void *data) const override
 
virtual const std::type_info * type_info () const override
 Get the type_info for this type. More...
 

Static Public Member Functions

static VirtualTypeInfoget ()
 

Protected Member Functions

 VirtualTypeInfo ()
 
- Protected Member Functions inherited from sofa::defaulttype::AbstractTypeInfo
 AbstractTypeInfo ()
 
virtual ~AbstractTypeInfo ()
 

Constructor details

template<class TDataType >
sofa::defaulttype::VirtualTypeInfo< TDataType >::VirtualTypeInfo ( )
inlineprotected

Function details

template<class TDataType >
const AbstractTypeInfo* sofa::defaulttype::VirtualTypeInfo< TDataType >::BaseType ( ) const
inlineoverridevirtual

If the type is a container, returns the TypeInfo for the type of the values inside this container. For example, if the type is fixed_array<fixed_array<int, 2> 3>, it returns the TypeInfo for fixed_array<int, 2>.

Implements sofa::defaulttype::AbstractTypeInfo.

template<class TDataType >
size_t sofa::defaulttype::VirtualTypeInfo< TDataType >::byteSize ( ) const
inlineoverridevirtual

The size in bytes of the ValueType For example, the size of a fixed_array<fixed_array<int, 2>, 3>` is 4 on most systems, as it is the byte size of the smallest dimension in the array (int -> 32bit)

Implements sofa::defaulttype::AbstractTypeInfo.

template<class TDataType >
bool sofa::defaulttype::VirtualTypeInfo< TDataType >::Container ( ) const
inlineoverridevirtual

True iff this type is a container of some sort.

That is, if it can contain several values. In particular, strings are not considered containers.

Implements sofa::defaulttype::AbstractTypeInfo.

template<class TDataType >
bool sofa::defaulttype::VirtualTypeInfo< TDataType >::CopyOnWrite ( ) const
inlineoverridevirtual

True iff this type uses copy-on-write.

Implements sofa::defaulttype::AbstractTypeInfo.

template<class TDataType >
bool sofa::defaulttype::VirtualTypeInfo< TDataType >::FixedSize ( ) const
inlineoverridevirtual

True iff this type has a fixed size. (It cannot be resized)

Implements sofa::defaulttype::AbstractTypeInfo.

template<class TDataType >
static VirtualTypeInfo* sofa::defaulttype::VirtualTypeInfo< TDataType >::get ( )
inlinestatic
template<class TDataType >
long long sofa::defaulttype::VirtualTypeInfo< TDataType >::getIntegerValue ( const void *  data,
size_t  index 
) const
inlineoverridevirtual

Get the value at index of data as an integer. Relevant only if this type can be casted to long long.

Implements sofa::defaulttype::AbstractTypeInfo.

template<class TDataType >
double sofa::defaulttype::VirtualTypeInfo< TDataType >::getScalarValue ( const void *  data,
size_t  index 
) const
inlineoverridevirtual

Get the value at index of data as a scalar. Relevant only if this type can be casted to double.

Implements sofa::defaulttype::AbstractTypeInfo.

template<class TDataType >
virtual std::string sofa::defaulttype::VirtualTypeInfo< TDataType >::getTextValue ( const void *  data,
size_t  index 
) const
inlineoverridevirtual

Get the value at index of data as a string.

Implements sofa::defaulttype::AbstractTypeInfo.

template<class TDataType >
const void* sofa::defaulttype::VirtualTypeInfo< TDataType >::getValuePtr ( const void *  type) const
inlineoverridevirtual

Get a read pointer to the underlying memory Relevant only if this type is SimpleLayout

Implements sofa::defaulttype::AbstractTypeInfo.

template<class TDataType >
void* sofa::defaulttype::VirtualTypeInfo< TDataType >::getValuePtr ( void *  type) const
inlineoverridevirtual

Get a write pointer to the underlying memory Relevant only if this type is SimpleLayout

Implements sofa::defaulttype::AbstractTypeInfo.

template<class TDataType >
bool sofa::defaulttype::VirtualTypeInfo< TDataType >::Integer ( ) const
inlineoverridevirtual

True iff this type uses integer values.

Implements sofa::defaulttype::AbstractTypeInfo.

template<class TDataType >
virtual std::string sofa::defaulttype::VirtualTypeInfo< TDataType >::name ( ) const
inlineoverridevirtual

Returns the name of this type.

Implements sofa::defaulttype::AbstractTypeInfo.

template<class TDataType >
bool sofa::defaulttype::VirtualTypeInfo< TDataType >::Scalar ( ) const
inlineoverridevirtual

True iff this type uses scalar values.

Implements sofa::defaulttype::AbstractTypeInfo.

template<class TDataType >
void sofa::defaulttype::VirtualTypeInfo< TDataType >::setIntegerValue ( void *  data,
size_t  index,
long long  value 
) const
inlineoverridevirtual

Set the value at index of data from an integer value.

Implements sofa::defaulttype::AbstractTypeInfo.

template<class TDataType >
void sofa::defaulttype::VirtualTypeInfo< TDataType >::setScalarValue ( void *  data,
size_t  index,
double  value 
) const
inlineoverridevirtual

Set the value at index of data from a scalar value.

Implements sofa::defaulttype::AbstractTypeInfo.

template<class TDataType >
bool sofa::defaulttype::VirtualTypeInfo< TDataType >::setSize ( void *  data,
size_t  size 
) const
inlineoverridevirtual

Resize data to size elements, if relevant.

But resizing is not always relevant, for example:

  • nothing happens if FixedSize() is true;
  • sets can't be resized; they are cleared instead;
  • nothing happens for vectors containing resizable values (i.e. when BaseType()::FixedSize() is false), because of the "single index" abstraction;

Returns true iff the data was resizable

Implements sofa::defaulttype::AbstractTypeInfo.

template<class TDataType >
virtual void sofa::defaulttype::VirtualTypeInfo< TDataType >::setTextValue ( void *  data,
size_t  index,
const std::string &  value 
) const
inlineoverridevirtual

Set the value at index of data from a string value.

Implements sofa::defaulttype::AbstractTypeInfo.

template<class TDataType >
bool sofa::defaulttype::VirtualTypeInfo< TDataType >::SimpleCopy ( ) const
inlineoverridevirtual

True iff copying the data can be done with a memcpy().

Implements sofa::defaulttype::AbstractTypeInfo.

template<class TDataType >
bool sofa::defaulttype::VirtualTypeInfo< TDataType >::SimpleLayout ( ) const
inlineoverridevirtual

True iff the layout in memory is simply N values of the same base type. It means that you can use the abstract index system to iterate over the elements of the type. (It doesn't mean that the BaseType is of a fixed size)

Implements sofa::defaulttype::AbstractTypeInfo.

template<class TDataType >
size_t sofa::defaulttype::VirtualTypeInfo< TDataType >::size ( ) const
inlineoverridevirtual

The size of this type, in number of elements. For example, the size of a fixed_array<fixed_array<int, 2>, 3> is 6, and those six elements are conceptually numbered from 0 to 5. This is relevant only if FixedSize() is true. I FixedSize() is false, the return value will be equivalent to the one of byteSize()

Implements sofa::defaulttype::AbstractTypeInfo.

template<class TDataType >
size_t sofa::defaulttype::VirtualTypeInfo< TDataType >::size ( const void *  data) const
inlineoverridevirtual

The size of data, in number of iterable elements (For containers, that'll be the number of elements in the 1st dimension). For example, with type == `

Implements sofa::defaulttype::AbstractTypeInfo.

template<class TDataType >
bool sofa::defaulttype::VirtualTypeInfo< TDataType >::Text ( ) const
inlineoverridevirtual

True iff this type uses text values.

Implements sofa::defaulttype::AbstractTypeInfo.

template<class TDataType >
virtual const std::type_info* sofa::defaulttype::VirtualTypeInfo< TDataType >::type_info ( ) const
inlineoverridevirtual

Get the type_info for this type.

Implements sofa::defaulttype::AbstractTypeInfo.

template<class TDataType >
bool sofa::defaulttype::VirtualTypeInfo< TDataType >::ValidInfo ( ) const
inlineoverridevirtual

True iff the TypeInfo for this type contains valid information. A Type is considered "Valid" if there's at least one specialization of the ValueType

Implements sofa::defaulttype::AbstractTypeInfo.

template<class TDataType >
const AbstractTypeInfo* sofa::defaulttype::VirtualTypeInfo< TDataType >::ValueType ( ) const
inlineoverridevirtual

Returns the TypeInfo for the type of the values accessible by the get*Value() functions. For example, if the type is fixed_array<fixed_array<int, 2> 3>, it returns the TypeInfo for int.

Implements sofa::defaulttype::AbstractTypeInfo.

template<class TDataType >
bool sofa::defaulttype::VirtualTypeInfo< TDataType >::ZeroConstructor ( ) const
inlineoverridevirtual

True iff the default constructor of this type is equivalent to setting the memory to 0.

Implements sofa::defaulttype::AbstractTypeInfo.