Commit 23bd9bba authored by David C. Lonie's avatar David C. Lonie

const ReferenceType --> ConstReferenceType.

The old syntax means the referrer type (not the referee type)
should be const, which is not valid. The new typedef provides
the intended behavior.
parent 01124e2d
Pipeline #8759 passed with stage
......@@ -205,7 +205,7 @@ private:
{
if (mask->GetComponentValue(tupleIdx, compIdx) != 0)
{
const typename ArrayT::ReferenceType val =
typename ArrayT::ConstReferenceType val =
array->GetComponentValue(tupleIdx, compIdx);
Result[0] = std::min(Result[0], static_cast<double>(val));
Result[1] = std::max(Result[1], static_cast<double>(val));
......@@ -225,7 +225,7 @@ private:
{
for (int compIdx = 0; compIdx < numComps; ++compIdx)
{
const typename ArrayT::ReferenceType val =
typename ArrayT::ConstReferenceType val =
array->GetComponentValue(tupleIdx, compIdx);
Result[0] = std::min(Result[0], static_cast<double>(val));
Result[1] = std::max(Result[1], static_cast<double>(val));
......
......@@ -212,7 +212,7 @@ int Test_constRefT_GetValue_valueIdx_const()
// Verify:
for (vtkIdType i = 0; i < comps * tuples; ++i)
{
const typename ArrayT::ReferenceType test = array->GetValue(i);
typename ArrayT::ConstReferenceType test = array->GetValue(i);
ScalarT ref = static_cast<ScalarT>(i % 16);
if (test != ref)
{
......@@ -367,7 +367,7 @@ int Test_void_SetTupleValue_tupleIdx_tuple()
for (int c = 0; c < comps; ++c)
{
ScalarT ref = static_cast<ScalarT>(((t * comps) + c) % 17);
const typename ArrayT::ReferenceType test =
typename ArrayT::ConstReferenceType test =
source->GetComponentValue(t, c);
if (ref != test)
{
......@@ -541,7 +541,7 @@ int Test_RefT_GetValueReference_valueIdx()
// Verify:
for (vtkIdType i = 0; i < comps * tuples; ++i)
{
const typename ArrayT::ReferenceType test = array->GetValueReference(i);
typename ArrayT::ConstReferenceType test = array->GetValueReference(i);
ScalarT ref = static_cast<ScalarT>(i % 16);
if (test != ref)
{
......
......@@ -37,6 +37,7 @@ public:
vtkTemplateTypeMacro(SelfType, GenericDataArrayType)
typedef typename Superclass::ValueType ValueType;
typedef typename Superclass::ReferenceType ReferenceType;
typedef typename Superclass::ConstReferenceType ConstReferenceType;
// Description:
// Legacy support for array-of-structs value iteration.
......@@ -51,7 +52,7 @@ public:
// Methods that are needed to be implemented by every vtkGenericDataArray
// subclass.
// **************************************************************************
inline const ReferenceType GetValue(vtkIdType valueIdx) const
inline ConstReferenceType GetValue(vtkIdType valueIdx) const
{
return this->Buffer.GetBuffer()[valueIdx];
}
......@@ -62,7 +63,7 @@ public:
this->Buffer.GetBuffer() + valueIdx + this->NumberOfComponents,
tuple);
}
inline const ReferenceType GetComponentValue(vtkIdType index, int comp) const
inline ConstReferenceType GetComponentValue(vtkIdType index, int comp) const
{
return this->Buffer.GetBuffer()[this->NumberOfComponents*index + comp];
}
......
......@@ -26,21 +26,21 @@
#include <cassert>
template<class DerivedT,
class ValueTypeT,
class ReferenceTypeT=ValueTypeT&>
class ValueTypeT>
class vtkGenericDataArray : public vtkDataArray
{
typedef
vtkGenericDataArray<DerivedT, ValueTypeT, ReferenceTypeT> SelfType;
vtkGenericDataArray<DerivedT, ValueTypeT> SelfType;
public:
vtkTemplateTypeMacro(SelfType, vtkDataArray)
typedef ValueTypeT ValueType;
typedef ReferenceTypeT ReferenceType;
typedef ValueTypeT ValueType;
typedef ValueTypeT& ReferenceType;
typedef const ValueTypeT& ConstReferenceType;
//----------------------------------------------------------------------------
// Methods that must be defined by the subclasses.
// Let's call these GenericDataArray concept methods.
inline const ReferenceType GetValue(vtkIdType valueIdx) const
inline ConstReferenceType GetValue(vtkIdType valueIdx) const
{
// TODO this method shadows a non-const method in vtkDataArrayTemplate
// that returns a value. Prolly won't matter for most cases, but we should
......@@ -51,8 +51,8 @@ public:
{
static_cast<const DerivedT*>(this)->GetTupleValue(tupleIdx, tuple);
}
inline const ReferenceType GetComponentValue(vtkIdType tupleIdx,
int comp) const
inline ConstReferenceType GetComponentValue(vtkIdType tupleIdx,
int comp) const
{
return static_cast<const DerivedT*>(this)->GetComponentValue(tupleIdx,
comp);
......@@ -331,7 +331,7 @@ public:
// traditional VTK memory layout (array-of-structures).
ReferenceType GetValueReference(vtkIdType idx)
{
return this->GetValue(idx);
return const_cast<ReferenceType>(this->GetValue(idx));
}
// Description:
......
......@@ -22,8 +22,8 @@
#include "vtkVariantCast.h"
#define vtkGenericDataArrayT(returnType) \
template <class DerivedT, class ValueTypeT, class ReferenceTypeT> \
returnType vtkGenericDataArray<DerivedT, ValueTypeT, ReferenceTypeT>
template <class DerivedT, class ValueTypeT> \
returnType vtkGenericDataArray<DerivedT, ValueTypeT>
//-----------------------------------------------------------------------------
vtkGenericDataArrayT(double *)::GetTuple(vtkIdType i)
......
......@@ -41,6 +41,7 @@ public:
vtkTemplateTypeMacro(vtkMappedDataArray<Scalar>, vtkTypedDataArray<Scalar>)
typedef typename Superclass::ValueType ValueType;
typedef typename Superclass::ReferenceType ReferenceType;
typedef typename Superclass::ConstReferenceType ConstReferenceType;
// Description:
// Perform a fast, safe cast from a vtkAbstractArray to a vtkMappedDataArray.
......
......@@ -36,6 +36,7 @@ public:
vtkTemplateTypeMacro(vtkPeriodicDataArray<Scalar>, vtkMappedDataArray<Scalar>)
typedef typename Superclass::ValueType ValueType;
typedef typename Superclass::ReferenceType ReferenceType;
typedef typename Superclass::ConstReferenceType ConstReferenceType;
virtual void PrintSelf(ostream &os, vtkIndent indent);
// Description:
......@@ -99,7 +100,7 @@ public:
// Get value at index idx.
// Warning, it internally call GetTupleValue,
// so it is an inneficcient way if reading all data
const ReferenceType GetValue(vtkIdType idx) const;
ConstReferenceType GetValue(vtkIdType idx) const;
// Description:
// Get value at index idx as reference.
......
......@@ -345,7 +345,7 @@ template <class Scalar> void vtkPeriodicDataArray<Scalar>
//------------------------------------------------------------------------------
template <class Scalar>
const typename vtkPeriodicDataArray<Scalar>::ReferenceType
typename vtkPeriodicDataArray<Scalar>::ConstReferenceType
vtkPeriodicDataArray<Scalar>::GetValue(vtkIdType idx) const
{
return const_cast<vtkPeriodicDataArray<Scalar>*>(this)->GetValueReference(idx);
......
......@@ -31,8 +31,9 @@ public:
GenericDataArrayType;
typedef vtkSoADataArrayTemplate<ValueTypeT> SelfType;
vtkTemplateTypeMacro(SelfType, GenericDataArrayType)
typedef typename GenericDataArrayType::ValueType ValueType;
typedef typename GenericDataArrayType::ReferenceType ReferenceType;
typedef typename Superclass::ValueType ValueType;
typedef typename Superclass::ReferenceType ReferenceType;
typedef typename Superclass::ConstReferenceType ConstReferenceType;
static vtkSoADataArrayTemplate* New();
......@@ -40,7 +41,7 @@ public:
// Methods that are needed to be implemented by every vtkGenericDataArray
// subclass.
// **************************************************************************
inline const ReferenceType GetValue(vtkIdType valueIdx) const
inline ConstReferenceType GetValue(vtkIdType valueIdx) const
{
vtkIdType tupleIdx;
int comp;
......@@ -54,8 +55,8 @@ public:
tuple[cc] = this->Data[cc].GetBuffer()[tupleIdx];
}
}
inline const ReferenceType GetComponentValue(vtkIdType tupleIdx,
int comp) const
inline ConstReferenceType GetComponentValue(vtkIdType tupleIdx,
int comp) const
{
return this->Data[comp].GetBuffer()[tupleIdx];
}
......
......@@ -45,6 +45,7 @@ public:
vtkTemplateTypeMacro(vtkTypedDataArray<Scalar>, GenericDataArrayType)
typedef typename Superclass::ValueType ValueType;
typedef typename Superclass::ReferenceType ReferenceType;
typedef typename Superclass::ConstReferenceType ConstReferenceType;
// Description:
// Typedef to a suitable iterator class.
......@@ -111,7 +112,7 @@ public:
// Description:
// Get the data at a particular index.
virtual const ReferenceType GetValue(vtkIdType idx) const = 0;
virtual ConstReferenceType GetValue(vtkIdType idx) const = 0;
// Description:
// Get a reference to the scalar value at a particular index.
......@@ -134,7 +135,7 @@ public:
// Insert data at a specified position in the array.
virtual void InsertValue(vtkIdType idx, ValueType v) = 0;
virtual const ReferenceType GetComponentValue(vtkIdType tupleIdx, int comp) const;
virtual ConstReferenceType GetComponentValue(vtkIdType tupleIdx, int comp) const;
virtual void SetComponentValue(vtkIdType tupleIdx, int comp, ValueType v);
// Description:
......
......@@ -77,7 +77,7 @@ void vtkTypedDataArray<Scalar>::SetNumberOfValues(vtkIdType number)
//------------------------------------------------------------------------------
template <typename Scalar> inline
const typename vtkTypedDataArray<Scalar>::ReferenceType
typename vtkTypedDataArray<Scalar>::ConstReferenceType
vtkTypedDataArray<Scalar>::GetComponentValue(vtkIdType tupleIdx, int comp) const
{
return this->GetValue(tupleIdx * this->NumberOfComponents + comp);
......
......@@ -42,6 +42,7 @@ public:
typedef typename Superclass::ValueType ValueType;
typedef typename Superclass::ReferenceType ReferenceType;
typedef typename Superclass::ConstReferenceType ConstReferenceType;
// Description:
// Set the raw scalar arrays for the coordinate set. This class takes
......@@ -63,7 +64,7 @@ public:
void GetTuple(vtkIdType i, double *tuple);
vtkIdType LookupTypedValue(Scalar value);
void LookupTypedValue(Scalar value, vtkIdList *ids);
const ReferenceType GetValue(vtkIdType idx) const;
ConstReferenceType GetValue(vtkIdType idx) const;
ReferenceType GetValueReference(vtkIdType idx);
void GetTupleValue(vtkIdType idx, Scalar *t) const;
......
......@@ -203,7 +203,7 @@ template <class Scalar> void vtkCPExodusIINodalCoordinatesTemplate<Scalar>
//------------------------------------------------------------------------------
template <class Scalar>
const typename vtkCPExodusIINodalCoordinatesTemplate<Scalar>::ReferenceType
typename vtkCPExodusIINodalCoordinatesTemplate<Scalar>::ConstReferenceType
vtkCPExodusIINodalCoordinatesTemplate<Scalar>::GetValue(vtkIdType idx) const
{
return const_cast<vtkCPExodusIINodalCoordinatesTemplate<Scalar>*>(
......
......@@ -40,6 +40,7 @@ public:
typedef typename Superclass::ValueType ValueType;
typedef typename Superclass::ReferenceType ReferenceType;
typedef typename Superclass::ConstReferenceType ConstReferenceType;
// Description:
// Set the arrays to be used and the number of tuples in each array.
......@@ -63,7 +64,7 @@ public:
void GetTuple(vtkIdType i, double *tuple);
vtkIdType LookupTypedValue(Scalar value);
void LookupTypedValue(Scalar value, vtkIdList *ids);
const ReferenceType GetValue(vtkIdType idx) const;
ConstReferenceType GetValue(vtkIdType idx) const;
ReferenceType GetValueReference(vtkIdType idx);
void GetTupleValue(vtkIdType idx, Scalar *t) const;
......
......@@ -239,7 +239,7 @@ template <class Scalar> void vtkCPExodusIIResultsArrayTemplate<Scalar>
//------------------------------------------------------------------------------
template <class Scalar>
const typename vtkCPExodusIIResultsArrayTemplate<Scalar>::ReferenceType
typename vtkCPExodusIIResultsArrayTemplate<Scalar>::ConstReferenceType
vtkCPExodusIIResultsArrayTemplate<Scalar>::GetValue(vtkIdType idx) const
{
return const_cast<vtkCPExodusIIResultsArrayTemplate<Scalar>*>(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment