Skip to content

Commit f5958ad

Browse files
committed
Feature/const (#380)
* Added const to appropriate DataArray functions * NeighborList::writeH5Data needed some additional changes since it was trying to modify a member variable * Added const to appropriate Geometry functions * LinkedDataContainerSelectionWidget needed the IGeometry include to work * Added const to DynamicTableData::getTableData() * Added const to appropriate functions in AM, DC, and DCA classes Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
1 parent 4cb6eec commit f5958ad

45 files changed

Lines changed: 894 additions & 896 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Source/SIMPLib/Common/SIMPLibSetGetMacros.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public:
221221
}
222222

223223
#define SIMPL_CLASS_VERSION(vers) \
224-
int getClassVersion() override \
224+
int getClassVersion() const override \
225225
{ \
226226
return vers; \
227227
}

Source/SIMPLib/DataArrays/DataArray.hpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ class DataArray : public IDataArray
319319
* @param allocate Will all the memory be allocated at time of construction
320320
* @return
321321
*/
322-
IDataArray::Pointer createNewArray(size_t numTuples, int rank, const size_t* compDims, const QString& name, bool allocate) override
322+
IDataArray::Pointer createNewArray(size_t numTuples, int rank, const size_t* compDims, const QString& name, bool allocate) const override
323323
{
324324
IDataArray::Pointer p = DataArray<T>::CreateArray(numTuples, rank, compDims, name, allocate);
325325
return p;
@@ -333,7 +333,7 @@ class DataArray : public IDataArray
333333
* @param allocate Will all the memory be allocated at time of construction
334334
* @return Std::Shared_Ptr wrapping an instance of DataArrayTemplate<T>
335335
*/
336-
IDataArray::Pointer createNewArray(size_t numTuples, const comp_dims_type& compDims, const QString& name, bool allocate) override
336+
IDataArray::Pointer createNewArray(size_t numTuples, const comp_dims_type& compDims, const QString& name, bool allocate) const override
337337
{
338338
IDataArray::Pointer p = DataArray<T>::CreateArray(numTuples, compDims, name, allocate);
339339
return p;
@@ -427,7 +427,7 @@ class DataArray : public IDataArray
427427
* @param forceNoAllocate
428428
* @return
429429
*/
430-
IDataArray::Pointer deepCopy(bool forceNoAllocate = false) override
430+
IDataArray::Pointer deepCopy(bool forceNoAllocate = false) const override
431431
{
432432
bool allocate = m_IsAllocated;
433433
if(forceNoAllocate)
@@ -451,7 +451,7 @@ class DataArray : public IDataArray
451451
* @return
452452
*/
453453

454-
SIMPL::NumericTypes::Type getType()
454+
SIMPL::NumericTypes::Type getType() const
455455
{
456456
T value = static_cast<T>(0x00);
457457
if(typeid(value) == typeid(int8_t))
@@ -512,7 +512,7 @@ class DataArray : public IDataArray
512512
* can be a primitive like char, float, int or the name of a class.
513513
* @return
514514
*/
515-
void getXdmfTypeAndSize(QString& xdmfTypeName, int& precision) override
515+
void getXdmfTypeAndSize(QString& xdmfTypeName, int& precision) const override
516516
{
517517
T value = static_cast<T>(0x00);
518518
xdmfTypeName = "UNKNOWN";
@@ -650,7 +650,7 @@ class DataArray : public IDataArray
650650
* @brief copyIntoArray
651651
* @param dest
652652
*/
653-
bool copyIntoArray(Pointer dest)
653+
bool copyIntoArray(Pointer dest) const
654654
{
655655
if(m_IsAllocated && dest->isAllocated() && m_Array && dest->getPointer(0))
656656
{
@@ -665,7 +665,7 @@ class DataArray : public IDataArray
665665
* @brief isAllocated
666666
* @return
667667
*/
668-
bool isAllocated() override
668+
bool isAllocated() const override
669669
{
670670
return m_IsAllocated;
671671
}
@@ -903,23 +903,23 @@ class DataArray : public IDataArray
903903
* 4 = 32 bit integer/Float
904904
* 8 = 64 bit integer/Double
905905
*/
906-
size_t getTypeSize() override
906+
size_t getTypeSize() const override
907907
{
908908
return sizeof(T);
909909
}
910910

911911
/**
912912
* @brief Returns the number of elements in the internal array.
913913
*/
914-
size_t getNumberOfTuples() override
914+
size_t getNumberOfTuples() const override
915915
{
916916
return m_NumTuples;
917917
}
918918

919919
/**
920920
* @brief Returns the total number of elements that make up this array. Equal to NumTuples * NumComponents
921921
*/
922-
size_t getSize() override
922+
size_t getSize() const override
923923
{
924924
return m_Size;
925925
}
@@ -929,7 +929,7 @@ class DataArray : public IDataArray
929929
* at each tuple then this will return a single element QVector. If you have a 1x3 array (like EUler Angles) then
930930
* this will return a 3 Element QVector.
931931
*/
932-
comp_dims_type getComponentDimensions() override
932+
comp_dims_type getComponentDimensions() const override
933933
{
934934
return m_CompDims;
935935
}
@@ -939,7 +939,7 @@ class DataArray : public IDataArray
939939
* 3 element component (vector) then this will be 3. If you are storing a small image of size 80x60
940940
* at each Tuple (like EBSD Kikuchi patterns) then the result would be 4800.
941941
*/
942-
int getNumberOfComponents() override
942+
int getNumberOfComponents() const override
943943
{
944944
return m_NumComponents;
945945
}
@@ -965,7 +965,7 @@ class DataArray : public IDataArray
965965
* @brief Returns a list of the contents of DataArray (For Python Binding)
966966
* @return std::list. Possibly empty
967967
*/
968-
std::list<T> getArray()
968+
std::list<T> getArray() const
969969
{
970970
return std::list<T>(m_Array, m_Array + (m_Size * sizeof(T)) / sizeof(T));
971971
}
@@ -994,7 +994,7 @@ class DataArray : public IDataArray
994994
* @param i The index to return the pointer to.
995995
* @return The pointer to the index
996996
*/
997-
virtual T* getPointer(size_t i)
997+
virtual T* getPointer(size_t i) const
998998
{
999999
#ifndef NDEBUG
10001000
if(m_Size > 0)
@@ -1010,7 +1010,7 @@ class DataArray : public IDataArray
10101010
* @param i The index to return the value at
10111011
* @return The value at index i
10121012
*/
1013-
virtual T getValue(size_t i)
1013+
virtual T getValue(size_t i) const
10141014
{
10151015
#ifndef NDEBUG
10161016
if(m_Size > 0)
@@ -1039,7 +1039,7 @@ class DataArray : public IDataArray
10391039

10401040
//----------------------------------------------------------------------------
10411041
// These can be overridden for more efficiency
1042-
T getComponent(size_t i, int j)
1042+
T getComponent(size_t i, int j) const
10431043
{
10441044
#ifndef NDEBUG
10451045
if(m_Size > 0)
@@ -1131,7 +1131,7 @@ class DataArray : public IDataArray
11311131
* @brief getTuplePointer Returns the pointer to a specific tuple
11321132
* @param tupleIndex The index of tuple
11331133
*/
1134-
T* getTuplePointer(size_t tupleIndex)
1134+
T* getTuplePointer(size_t tupleIndex) const
11351135
{
11361136
#ifndef NDEBUG
11371137
if(m_Size > 0)
@@ -1162,7 +1162,7 @@ class DataArray : public IDataArray
11621162
* @param i
11631163
* @param delimiter
11641164
*/
1165-
void printTuple(QTextStream& out, size_t i, char delimiter = ',') override
1165+
void printTuple(QTextStream& out, size_t i, char delimiter = ',') const override
11661166
{
11671167
int precision = out.realNumberPrecision();
11681168
T value = static_cast<T>(0x00);
@@ -1192,7 +1192,7 @@ class DataArray : public IDataArray
11921192
* @param i
11931193
* @param j
11941194
*/
1195-
void printComponent(QTextStream& out, size_t i, int j) override
1195+
void printComponent(QTextStream& out, size_t i, int j) const override
11961196
{
11971197
out << m_Array[i * m_NumComponents + j];
11981198
}
@@ -1203,7 +1203,7 @@ class DataArray : public IDataArray
12031203
* from
12041204
* @return The HDF5 native type for the value
12051205
*/
1206-
QString getFullNameOfClass()
1206+
QString getFullNameOfClass() const
12071207
{
12081208
QString theType = getTypeAsString();
12091209
theType = "DataArray<" + theType + ">";
@@ -1214,7 +1214,7 @@ class DataArray : public IDataArray
12141214
* @brief getTypeAsString
12151215
* @return
12161216
*/
1217-
QString getTypeAsString() override
1217+
QString getTypeAsString() const override
12181218
{
12191219
T value = static_cast<T>(0);
12201220
if(typeid(value) == typeid(float))
@@ -1369,7 +1369,7 @@ class DataArray : public IDataArray
13691369
* @param parentId
13701370
* @return
13711371
*/
1372-
int writeH5Data(hid_t parentId, comp_dims_type tDims) override
1372+
int writeH5Data(hid_t parentId, comp_dims_type tDims) const override
13731373
{
13741374
if(m_Array == nullptr)
13751375
{
@@ -1384,7 +1384,7 @@ class DataArray : public IDataArray
13841384
* @param volDims
13851385
* @return
13861386
*/
1387-
int writeXdmfAttribute(QTextStream& out, int64_t* volDims, const QString& hdfFileName, const QString& groupPath, const QString& label) override
1387+
int writeXdmfAttribute(QTextStream& out, int64_t* volDims, const QString& hdfFileName, const QString& groupPath, const QString& label) const override
13881388
{
13891389
if(m_Array == nullptr)
13901390
{
@@ -1443,7 +1443,7 @@ class DataArray : public IDataArray
14431443
* @return Returns a formatted string that contains general infomation about
14441444
* the instance of the object.
14451445
*/
1446-
QString getInfoString(SIMPL::InfoStringFormat format) override
1446+
QString getInfoString(SIMPL::InfoStringFormat format) const override
14471447
{
14481448

14491449
QLocale usa(QLocale::English, QLocale::UnitedStates);

Source/SIMPLib/DataArrays/DynamicListArray.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class DynamicListArray
119119
* @brief size
120120
* @return
121121
*/
122-
size_t size()
122+
size_t size() const
123123
{
124124
return m_Size;
125125
}
@@ -129,7 +129,7 @@ class DynamicListArray
129129
* @param forceNoAllocate
130130
* @return
131131
*/
132-
Pointer deepCopy(bool forceNoAllocate = false)
132+
Pointer deepCopy(bool forceNoAllocate = false) const
133133
{
134134
DynamicListArray::Pointer copy = DynamicListArray::New();
135135
std::vector<T> linkCounts(m_Size, 0);
@@ -171,7 +171,7 @@ class DynamicListArray
171171
* @param ptId
172172
* @return
173173
*/
174-
ElementList& getElementList(size_t ptId)
174+
ElementList& getElementList(size_t ptId) const
175175
{
176176
return this->m_Array[ptId];
177177
}
@@ -232,7 +232,7 @@ class DynamicListArray
232232
* @param ptId
233233
* @return
234234
*/
235-
T getNumberOfElements(size_t ptId)
235+
T getNumberOfElements(size_t ptId) const
236236
{
237237
return this->m_Array[ptId].ncells;
238238
}
@@ -242,7 +242,7 @@ class DynamicListArray
242242
* @param ptId
243243
* @return
244244
*/
245-
K* getElementListPointer(size_t ptId)
245+
K* getElementListPointer(size_t ptId) const
246246
{
247247
return this->m_Array[ptId].cells;
248248
}

0 commit comments

Comments
 (0)