Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making methods const where possible #906

Merged
merged 2 commits into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions doc/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Next version
* Develop advisory tests on merge for MOAB, double-down and Geant4 (#870, #898, #899, #904)
* Adding flags to CI to ensure compatibility with MOOSE apps (#902)
* Fixing order of attribute initialization in the metadata class (#903)
* Adding const identifier to cross-reference methods (#906)

**Fixed:**
* Patch to compile with Geant4 10.6 (#803)
Expand Down
6 changes: 3 additions & 3 deletions src/dagmc/DagMC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -870,11 +870,11 @@ ErrorCode DagMC::next_vol(EntityHandle surface, EntityHandle old_volume,

/* SECTION III: Indexing & Cross-referencing */

EntityHandle DagMC::entity_by_id(int dimension, int id) {
EntityHandle DagMC::entity_by_id(int dimension, int id) const {
return GTT->entity_by_id(dimension, id);
}

int DagMC::id_by_index(int dimension, int index) {
int DagMC::id_by_index(int dimension, int index) const {
EntityHandle h = entity_by_index(dimension, index);
if (!h) return 0;

Expand All @@ -883,7 +883,7 @@ int DagMC::id_by_index(int dimension, int index) {
return result;
}

int DagMC::get_entity_id(EntityHandle this_ent) {
int DagMC::get_entity_id(EntityHandle this_ent) const {
return GTT->global_id(this_ent);
}

Expand Down
18 changes: 9 additions & 9 deletions src/dagmc/DagMC.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,16 +263,16 @@ class DagMC {
*/

/** map from dimension & global ID to EntityHandle */
EntityHandle entity_by_id(int dimension, int id);
EntityHandle entity_by_id(int dimension, int id) const;
/** map from dimension & base-1 ordinal index to EntityHandle */
EntityHandle entity_by_index(int dimension, int index);
EntityHandle entity_by_index(int dimension, int index) const;
/** map from dimension & base-1 ordinal index to global ID */
int id_by_index(int dimension, int index);
int id_by_index(int dimension, int index) const;
/** PPHW: Missing dim & global ID ==> base-1 ordinal index */
/** map from EntityHandle to base-1 ordinal index */
int index_by_handle(EntityHandle handle);
int index_by_handle(EntityHandle handle) const;
/** map from EntityHandle to global ID */
int get_entity_id(EntityHandle this_ent);
int get_entity_id(EntityHandle this_ent) const;

/**\brief get number of geometric sets corresponding to geometry of specified
*dimension
Expand All @@ -282,7 +282,7 @@ class DagMC {
*the dimensionality of the entities in question \return integer number of
*entities of that dimension
*/
unsigned int num_entities(int dimension);
unsigned int num_entities(int dimension) const;

private:
/** get all group sets on the model */
Expand Down Expand Up @@ -564,18 +564,18 @@ class DagMC {

}; // end DagMC

inline EntityHandle DagMC::entity_by_index(int dimension, int index) {
inline EntityHandle DagMC::entity_by_index(int dimension, int index) const {
assert(2 <= dimension && 3 >= dimension &&
(unsigned)index < entHandles[dimension].size());
return entHandles[dimension][index];
}

inline int DagMC::index_by_handle(EntityHandle handle) {
inline int DagMC::index_by_handle(EntityHandle handle) const {
assert(handle - setOffset < entIndices.size());
return entIndices[handle - setOffset];
}

inline unsigned int DagMC::num_entities(int dimension) {
inline unsigned int DagMC::num_entities(int dimension) const {
assert(vertex_handle_idx <= dimension && groups_handle_idx >= dimension);
return entHandles[dimension].size() - 1;
}
Expand Down