Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Sofa/framework/Core/src/sofa/core/objectmodel/BaseData.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,14 @@ class SOFA_CORE_API BaseData : public DDGNode
template<class T>
static std::string typeName()
{
if (defaulttype::DataTypeInfo<T>::ValidInfo)
if constexpr (defaulttype::DataTypeInfo<T>::ValidInfo)
{
return defaulttype::DataTypeName<T>::name();
}
return decodeTypeName(typeid(T));
else
{
return decodeTypeName(typeid(T));
}
}

protected:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ struct FixedArrayTypeInfo

static sofa::Size size(const DataType& data)
{
if (FixedSize)
if constexpr (FixedSize)
return size();
else
{
Expand All @@ -78,11 +78,14 @@ struct FixedArrayTypeInfo

static bool setSize(DataType& data, sofa::Size size)
{
if (!FixedSize)
if constexpr (!FixedSize)
{
size /= data.size();
for (sofa::Size i=0; i<data.size(); ++i)
if( !BaseTypeInfo::setSize(data[(sofa::Size)i], size) ) return false;
for (sofa::Size i = 0; i < data.size(); ++i)
{
if (!BaseTypeInfo::setSize(data[(sofa::Size)i], size))
return false;
}
return true;
}
return false;
Expand All @@ -95,7 +98,7 @@ struct FixedArrayTypeInfo
{
BaseTypeInfo::getValue(data[(sofa::Size)index], 0, value);
}
else if (BaseTypeInfo::FixedSize)
else if constexpr (BaseTypeInfo::FixedSize)
{
BaseTypeInfo::getValue(data[(sofa::Size)(index/BaseTypeInfo::size())], (sofa::Size)(index%BaseTypeInfo::size()), value);
}
Expand All @@ -122,7 +125,7 @@ struct FixedArrayTypeInfo
{
BaseTypeInfo::setValue(data[(sofa::Size)index], 0, value);
}
else if (BaseTypeInfo::FixedSize)
else if constexpr (BaseTypeInfo::FixedSize)
{
BaseTypeInfo::setValue(data[(sofa::Size)(index/BaseTypeInfo::size())], (sofa::Size)(index%BaseTypeInfo::size()), value);
}
Expand All @@ -148,7 +151,7 @@ struct FixedArrayTypeInfo
{
BaseTypeInfo::getValueString(data[(sofa::Size)index], 0, value);
}
else if (BaseTypeInfo::FixedSize)
else if constexpr (BaseTypeInfo::FixedSize)
{
BaseTypeInfo::getValueString(data[(sofa::Size)(index/BaseTypeInfo::size())], (sofa::Size)(index%BaseTypeInfo::size()), value);
}
Expand All @@ -174,7 +177,7 @@ struct FixedArrayTypeInfo
{
BaseTypeInfo::setValueString(data[(sofa::Size)index], 0, value);
}
else if (BaseTypeInfo::FixedSize)
else if constexpr (BaseTypeInfo::FixedSize)
{
BaseTypeInfo::setValueString(data[(sofa::Size)(index/BaseTypeInfo::size())], (sofa::Size)(index%BaseTypeInfo::size()), value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ struct SetTypeInfo

static sofa::Size size(const DataType& data)
{
if (BaseTypeInfo::FixedSize)
if constexpr (BaseTypeInfo::FixedSize)
return sofa::Size(data.size()*BaseTypeInfo::size());
else
{
Expand All @@ -80,7 +80,7 @@ struct SetTypeInfo
template <typename T>
static void getValue(const DataType &data, sofa::Size index, T& value)
{
if (BaseTypeInfo::FixedSize)
if constexpr (BaseTypeInfo::FixedSize)
{
typename DataType::const_iterator it = data.begin();
for (sofa::Size i=0; i<index/BaseTypeInfo::size(); ++i) ++it;
Expand Down Expand Up @@ -119,7 +119,7 @@ struct SetTypeInfo

static void getValueString(const DataType &data, sofa::Size index, std::string& value)
{
if (BaseTypeInfo::FixedSize)
if constexpr (BaseTypeInfo::FixedSize)
{
typename DataType::const_iterator it = data.begin();
for (sofa::Size i=0; i<index/BaseTypeInfo::size(); ++i) ++it;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct VectorTypeInfo

static sofa::Size size(const DataType& data)
{
if (BaseTypeInfo::FixedSize)
if constexpr (BaseTypeInfo::FixedSize)
return sofa::Size(data.size()*BaseTypeInfo::size());
else
{
Expand All @@ -77,7 +77,7 @@ struct VectorTypeInfo

static bool setSize(DataType& data, sofa::Size size)
{
if (BaseTypeInfo::FixedSize)
if constexpr (BaseTypeInfo::FixedSize)
{
data.resize(size/BaseTypeInfo::size());
return true;
Expand All @@ -92,7 +92,7 @@ struct VectorTypeInfo
{
BaseTypeInfo::getValue(data[index], 0, value);
}
else if (BaseTypeInfo::FixedSize)
else if constexpr (BaseTypeInfo::FixedSize)
{
BaseTypeInfo::getValue(data[(index/BaseTypeInfo::size())], (index%BaseTypeInfo::size()), value);
}
Expand All @@ -119,7 +119,7 @@ struct VectorTypeInfo
{
BaseTypeInfo::setValue(data[index], 0, value);
}
else if (BaseTypeInfo::FixedSize)
else if constexpr (BaseTypeInfo::FixedSize)
{
BaseTypeInfo::setValue(data[(index/BaseTypeInfo::size())], (index%BaseTypeInfo::size()), value);
}
Expand All @@ -145,7 +145,7 @@ struct VectorTypeInfo
{
BaseTypeInfo::getValueString(data[index], 0, value);
}
else if (BaseTypeInfo::FixedSize)
else if constexpr (BaseTypeInfo::FixedSize)
{
BaseTypeInfo::getValueString(data[(index/BaseTypeInfo::size())], (index%BaseTypeInfo::size()), value);
}
Expand All @@ -171,7 +171,7 @@ struct VectorTypeInfo
{
BaseTypeInfo::setValueString(data[index], 0, value);
}
else if (BaseTypeInfo::FixedSize)
else if constexpr (BaseTypeInfo::FixedSize)
{
BaseTypeInfo::setValueString(data[(index/BaseTypeInfo::size())], (index%BaseTypeInfo::size()), value);
}
Expand Down
Loading