-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Use enum class for MaterialUpdateStage (#1205)
This change is motivated by arithmetic between non-class enums and other types that are not the same enum being deprecated in C++20. This mainly affects `NavigationDirection`, but I took the chance to update the `MaterialUpdateStage` enum to make it an enum class.
- Loading branch information
1 parent
f7c32a8
commit 8016339
Showing
13 changed files
with
179 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
target_sources( | ||
ActsCore | ||
PRIVATE | ||
Common.cpp | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// This file is part of the Acts project. | ||
// | ||
// Copyright (C) 2022 CERN for the benefit of the Acts project | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
#include "Acts/Definitions/Common.hpp" | ||
|
||
#include <ostream> | ||
|
||
namespace Acts { | ||
|
||
std::ostream& operator<<(std::ostream& os, MaterialUpdateStage matUpdate) { | ||
switch (matUpdate) { | ||
case MaterialUpdateStage::PreUpdate: | ||
os << "PreUpdate (-1)"; | ||
break; | ||
case MaterialUpdateStage::PostUpdate: | ||
os << "PostUpdate (1)"; | ||
break; | ||
case MaterialUpdateStage::FullUpdate: | ||
os << "FullUpdate (0)"; | ||
break; | ||
default: | ||
assert(false && "Invalid material update stage (shouldn't happen)"); | ||
std::abort(); | ||
} | ||
return os; | ||
} | ||
|
||
} // namespace Acts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// This file is part of the Acts project. | ||
// | ||
// Copyright (C) 2022 CERN for the benefit of the Acts project | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
#include <boost/test/unit_test.hpp> | ||
|
||
#include "Acts/Definitions/Algebra.hpp" | ||
#include "Acts/Material/ISurfaceMaterial.hpp" | ||
|
||
#include <climits> | ||
|
||
namespace Acts { | ||
|
||
namespace Test { | ||
|
||
class SurfaceMaterialStub : public ISurfaceMaterial { | ||
using ISurfaceMaterial::ISurfaceMaterial; | ||
|
||
ISurfaceMaterial& operator*=(double /*scale*/) override { return *this; }; | ||
|
||
const MaterialSlab& materialSlab(const Vector2& /*lp*/) const override { | ||
return m_fullMaterial; | ||
} | ||
|
||
const MaterialSlab& materialSlab(const Vector3& /*gp*/) const override { | ||
return m_fullMaterial; | ||
} | ||
|
||
const MaterialSlab& materialSlab(size_t /*bin0*/, | ||
size_t /*bin1*/) const override { | ||
return m_fullMaterial; | ||
} | ||
|
||
std::ostream& toStream(std::ostream& sl) const override { | ||
sl << "SurfaceMaterialStub"; | ||
return sl; | ||
}; | ||
|
||
MaterialSlab m_fullMaterial{}; | ||
}; | ||
|
||
/// Test the constructors | ||
BOOST_AUTO_TEST_CASE(ISurfaceMaterial_factor_test) { | ||
double splitFactor = 42.0; | ||
SurfaceMaterialStub stub{splitFactor}; | ||
|
||
BOOST_CHECK_EQUAL(stub.factor(NavigationDirection::forward, | ||
MaterialUpdateStage::FullUpdate), | ||
1.0); | ||
|
||
BOOST_CHECK_EQUAL(stub.factor(NavigationDirection::backward, | ||
MaterialUpdateStage::FullUpdate), | ||
1.0); | ||
|
||
BOOST_CHECK_EQUAL(stub.factor(NavigationDirection::forward, | ||
MaterialUpdateStage::PostUpdate), | ||
splitFactor); | ||
|
||
BOOST_CHECK_EQUAL(stub.factor(NavigationDirection::backward, | ||
MaterialUpdateStage::PreUpdate), | ||
splitFactor); | ||
|
||
BOOST_CHECK_EQUAL( | ||
stub.factor(NavigationDirection::forward, MaterialUpdateStage::PreUpdate), | ||
1 - splitFactor); | ||
|
||
BOOST_CHECK_EQUAL(stub.factor(NavigationDirection::backward, | ||
MaterialUpdateStage::PostUpdate), | ||
1 - splitFactor); | ||
} | ||
|
||
} // namespace Test | ||
} // namespace Acts |