SOFA API  b3f2f2a4
Open source framework for multi-physics simuation
sofa::defaulttype::DataTypeInfoDynamicWrapper< Info > Class Template Reference

#include <DataTypeInfoDynamicWrapper.h>

wrap a DataTypeInfo type_traits in an AbstractTypeInfo More...

Inheritance diagram for sofa::defaulttype::DataTypeInfoDynamicWrapper< Info >:

Detailed Description

template<class Info>
class sofa::defaulttype::DataTypeInfoDynamicWrapper< Info >

wrap a DataTypeInfo type_traits in an AbstractTypeInfo

Example of use:

class MyType {};
template<>
class DataTypeInfo<MyType> { }
AbstractTypeInfo* nfo = DataTypeInfoDynamicWrapper<DataTypeInfo<MyType>>();
TypeInfoRegistry::Set(TypeInfoId::getNewId<MyType>(), info);
AbstractTypeInfo()
Definition: AbstractTypeInfo.h:175
static int Set(const TypeInfoId &tid, AbstractTypeInfo *info, const std::string &compilationTarget)
Definition: TypeInfoRegistry.cpp:86

Public Member Functions

const AbstractTypeInfoBaseType () const override
 
const AbstractTypeInfoValueType () const override
 
const TypeInfoIdgetBaseTypeId () const override
 
const TypeInfoIdgetValueTypeId () const override
 
std::string name () const override
 Returns the name of this type. More...
 
std::string getTypeName () const override
 
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
 
sofa::Size size () const override
 
sofa::Size byteSize () const override
 
sofa::Size size (const void *data) const override
 
bool setSize (void *data, sofa::Size size) const override
 Resize data to size elements, if relevant. More...
 
long long getIntegerValue (const void *data, Index index) const override
 
double getScalarValue (const void *data, Index index) const override
 
virtual std::string getTextValue (const void *data, Index index) const override
 Get the value at index of data as a string. More...
 
void setIntegerValue (void *data, Index index, long long value) const override
 Set the value at index of data from an integer value. More...
 
void setScalarValue (void *data, Index index, double value) const override
 Set the value at index of data from a scalar value. More...
 
virtual void setTextValue (void *data, Index 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...
 
- Public Member Functions inherited from sofa::defaulttype::AbstractTypeInfo
const std::string & getCompilationTarget () const
 
void setCompilationTarget (const std::string &target)
 

Static Public Member Functions

static AbstractTypeInfoget ()
 

Protected Member Functions

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

Constructor details

◆ DataTypeInfoDynamicWrapper()

template<class Info >
sofa::defaulttype::DataTypeInfoDynamicWrapper< Info >::DataTypeInfoDynamicWrapper ( )
inlineprotected

Function details

◆ BaseType()

template<class Info >
const AbstractTypeInfo* sofa::defaulttype::DataTypeInfoDynamicWrapper< Info >::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.

◆ byteSize()

template<class Info >
sofa::Size sofa::defaulttype::DataTypeInfoDynamicWrapper< Info >::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.

◆ Container()

template<class Info >
bool sofa::defaulttype::DataTypeInfoDynamicWrapper< Info >::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.

◆ CopyOnWrite()

template<class Info >
bool sofa::defaulttype::DataTypeInfoDynamicWrapper< Info >::CopyOnWrite ( ) const
inlineoverridevirtual

True iff this type uses copy-on-write.

Implements sofa::defaulttype::AbstractTypeInfo.

◆ FixedSize()

template<class Info >
bool sofa::defaulttype::DataTypeInfoDynamicWrapper< Info >::FixedSize ( ) const
inlineoverridevirtual

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

Implements sofa::defaulttype::AbstractTypeInfo.

◆ get()

template<class Info >
static AbstractTypeInfo* sofa::defaulttype::DataTypeInfoDynamicWrapper< Info >::get ( )
inlinestatic

◆ getBaseTypeId()

template<class Info >
const TypeInfoId& sofa::defaulttype::DataTypeInfoDynamicWrapper< Info >::getBaseTypeId ( ) const
inlineoverridevirtual

◆ getIntegerValue()

template<class Info >
long long sofa::defaulttype::DataTypeInfoDynamicWrapper< Info >::getIntegerValue ( const void *  data,
Index  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.

◆ getScalarValue()

template<class Info >
double sofa::defaulttype::DataTypeInfoDynamicWrapper< Info >::getScalarValue ( const void *  data,
Index  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.

◆ getTextValue()

template<class Info >
virtual std::string sofa::defaulttype::DataTypeInfoDynamicWrapper< Info >::getTextValue ( const void *  data,
Index  index 
) const
inlineoverridevirtual

Get the value at index of data as a string.

Implements sofa::defaulttype::AbstractTypeInfo.

◆ getTypeName()

template<class Info >
std::string sofa::defaulttype::DataTypeInfoDynamicWrapper< Info >::getTypeName ( ) const
inlineoverridevirtual

◆ getValuePtr() [1/2]

template<class Info >
const void* sofa::defaulttype::DataTypeInfoDynamicWrapper< Info >::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.

◆ getValuePtr() [2/2]

template<class Info >
void* sofa::defaulttype::DataTypeInfoDynamicWrapper< Info >::getValuePtr ( void *  type) const
inlineoverridevirtual

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

Implements sofa::defaulttype::AbstractTypeInfo.

◆ getValueTypeId()

template<class Info >
const TypeInfoId& sofa::defaulttype::DataTypeInfoDynamicWrapper< Info >::getValueTypeId ( ) const
inlineoverridevirtual

◆ Integer()

template<class Info >
bool sofa::defaulttype::DataTypeInfoDynamicWrapper< Info >::Integer ( ) const
inlineoverridevirtual

True iff this type uses integer values.

Implements sofa::defaulttype::AbstractTypeInfo.

◆ name()

template<class Info >
std::string sofa::defaulttype::DataTypeInfoDynamicWrapper< Info >::name ( ) const
inlineoverridevirtual

Returns the name of this type.

Implements sofa::defaulttype::AbstractTypeInfo.

◆ Scalar()

template<class Info >
bool sofa::defaulttype::DataTypeInfoDynamicWrapper< Info >::Scalar ( ) const
inlineoverridevirtual

True iff this type uses scalar values.

Implements sofa::defaulttype::AbstractTypeInfo.

◆ setIntegerValue()

template<class Info >
void sofa::defaulttype::DataTypeInfoDynamicWrapper< Info >::setIntegerValue ( void *  data,
Index  index,
long long  value 
) const
inlineoverridevirtual

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

Implements sofa::defaulttype::AbstractTypeInfo.

◆ setScalarValue()

template<class Info >
void sofa::defaulttype::DataTypeInfoDynamicWrapper< Info >::setScalarValue ( void *  data,
Index  index,
double  value 
) const
inlineoverridevirtual

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

Implements sofa::defaulttype::AbstractTypeInfo.

◆ setSize()

template<class Info >
bool sofa::defaulttype::DataTypeInfoDynamicWrapper< Info >::setSize ( void *  data,
sofa::Size  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.

◆ setTextValue()

template<class Info >
virtual void sofa::defaulttype::DataTypeInfoDynamicWrapper< Info >::setTextValue ( void *  data,
Index  index,
const std::string &  value 
) const
inlineoverridevirtual

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

Implements sofa::defaulttype::AbstractTypeInfo.

◆ SimpleCopy()

template<class Info >
bool sofa::defaulttype::DataTypeInfoDynamicWrapper< Info >::SimpleCopy ( ) const
inlineoverridevirtual

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

Implements sofa::defaulttype::AbstractTypeInfo.

◆ SimpleLayout()

template<class Info >
bool sofa::defaulttype::DataTypeInfoDynamicWrapper< Info >::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.

◆ size() [1/2]

template<class Info >
sofa::Size sofa::defaulttype::DataTypeInfoDynamicWrapper< Info >::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.

◆ size() [2/2]

template<class Info >
sofa::Size sofa::defaulttype::DataTypeInfoDynamicWrapper< Info >::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.

◆ Text()

template<class Info >
bool sofa::defaulttype::DataTypeInfoDynamicWrapper< Info >::Text ( ) const
inlineoverridevirtual

True iff this type uses text values.

Implements sofa::defaulttype::AbstractTypeInfo.

◆ type_info()

template<class Info >
virtual const std::type_info* sofa::defaulttype::DataTypeInfoDynamicWrapper< Info >::type_info ( ) const
inlineoverridevirtual

Get the type_info for this type.

Implements sofa::defaulttype::AbstractTypeInfo.

◆ ValidInfo()

template<class Info >
bool sofa::defaulttype::DataTypeInfoDynamicWrapper< Info >::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.

◆ ValueType()

template<class Info >
const AbstractTypeInfo* sofa::defaulttype::DataTypeInfoDynamicWrapper< Info >::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.

◆ ZeroConstructor()

template<class Info >
bool sofa::defaulttype::DataTypeInfoDynamicWrapper< Info >::ZeroConstructor ( ) const
inlineoverridevirtual

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

Implements sofa::defaulttype::AbstractTypeInfo.