File indexing completed on 2025-02-23 09:13:58
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include <type_traits>
0012 #include <utility>
0013
0014 namespace Acts {
0015
0016 class TrackingVolume;
0017 class Portal;
0018 class Surface;
0019 class Layer;
0020
0021 template <typename T>
0022 class BoundarySurfaceT;
0023
0024
0025
0026
0027
0028
0029
0030 class TrackingGeometryVisitor {
0031 public:
0032 virtual ~TrackingGeometryVisitor() = 0;
0033
0034
0035
0036
0037 virtual void visitVolume(const TrackingVolume& volume);
0038
0039
0040
0041
0042 virtual void visitPortal(const Portal& portal);
0043
0044
0045
0046
0047 virtual void visitSurface(const Surface& surface);
0048
0049
0050
0051
0052
0053 virtual void visitLayer(const Layer& layer);
0054
0055
0056
0057
0058 virtual void visitBoundarySurface(
0059 const BoundarySurfaceT<TrackingVolume>& boundary);
0060 };
0061
0062
0063
0064
0065
0066
0067 class TrackingGeometryMutableVisitor {
0068 public:
0069 virtual ~TrackingGeometryMutableVisitor();
0070
0071
0072
0073
0074 virtual void visitVolume(TrackingVolume& volume);
0075
0076
0077
0078
0079 virtual void visitPortal(Portal& portal);
0080
0081
0082
0083
0084 virtual void visitSurface(Surface& surface);
0085
0086
0087
0088
0089
0090 virtual void visitLayer(Layer& layer);
0091
0092
0093
0094
0095 virtual void visitBoundarySurface(BoundarySurfaceT<TrackingVolume>& boundary);
0096 };
0097
0098 namespace detail {
0099
0100 template <typename Callable>
0101 consteval bool callableWithAnyMutable() {
0102 return std::is_invocable_v<Callable, Surface&> ||
0103 std::is_invocable_v<Callable, TrackingVolume&> ||
0104 std::is_invocable_v<Callable, BoundarySurfaceT<TrackingVolume>&> ||
0105 std::is_invocable_v<Callable, Layer&> ||
0106 std::is_invocable_v<Callable, Portal&>;
0107 }
0108
0109 template <typename Callable>
0110 consteval bool callableWithAnyConst() {
0111 return std::is_invocable_v<Callable, const Surface&> ||
0112 std::is_invocable_v<Callable, const TrackingVolume&> ||
0113 std::is_invocable_v<Callable,
0114 const BoundarySurfaceT<TrackingVolume>&> ||
0115 std::is_invocable_v<Callable, const Layer&> ||
0116 std::is_invocable_v<Callable, const Portal&>;
0117 }
0118
0119 template <typename Callable>
0120 consteval bool callableWithAny() {
0121 return callableWithAnyMutable<Callable>() || callableWithAnyConst<Callable>();
0122 }
0123
0124 template <typename Callable>
0125 requires(callableWithAnyConst<Callable>())
0126 class TrackingGeometryLambdaVisitor : public TrackingGeometryVisitor {
0127 public:
0128 explicit TrackingGeometryLambdaVisitor(Callable callable)
0129 : m_callable(std::move(callable)) {}
0130
0131 void visitSurface(const Surface& surface) override {
0132 if constexpr (std::is_invocable_v<Callable, const Surface&>) {
0133 m_callable(surface);
0134 }
0135 }
0136
0137 void visitVolume(const TrackingVolume& volume) override {
0138 if constexpr (std::is_invocable_v<Callable, const TrackingVolume&>) {
0139 m_callable(volume);
0140 }
0141 }
0142
0143 void visitBoundarySurface(
0144 const BoundarySurfaceT<TrackingVolume>& boundary) override {
0145 if constexpr (std::is_invocable_v<
0146 Callable, const BoundarySurfaceT<TrackingVolume>&>) {
0147 m_callable(boundary);
0148 }
0149 }
0150
0151 void visitLayer(const Layer& layer) override {
0152 if constexpr (std::is_invocable_v<Callable, const Layer&>) {
0153 m_callable(layer);
0154 }
0155 }
0156
0157 void visitPortal(const Portal& portal) override {
0158 if constexpr (std::is_invocable_v<Callable, const Portal&>) {
0159 m_callable(portal);
0160 }
0161 }
0162
0163 private:
0164 Callable m_callable;
0165 };
0166
0167 template <typename Callable>
0168 requires(callableWithAnyMutable<Callable>())
0169 class TrackingGeometryLambdaMutableVisitor
0170 : public TrackingGeometryMutableVisitor {
0171 public:
0172 explicit TrackingGeometryLambdaMutableVisitor(Callable callable)
0173 : m_callable(std::move(callable)) {}
0174
0175 void visitSurface(Surface& surface) override {
0176 if constexpr (std::is_invocable_v<Callable, Surface&>) {
0177 m_callable(surface);
0178 }
0179 }
0180
0181 void visitVolume(TrackingVolume& volume) override {
0182 if constexpr (std::is_invocable_v<Callable, TrackingVolume&>) {
0183 m_callable(volume);
0184 }
0185 }
0186
0187 void visitBoundarySurface(
0188 BoundarySurfaceT<TrackingVolume>& boundary) override {
0189 if constexpr (std::is_invocable_v<Callable,
0190 BoundarySurfaceT<TrackingVolume>&>) {
0191 m_callable(boundary);
0192 }
0193 }
0194
0195 void visitLayer(Layer& layer) override {
0196 if constexpr (std::is_invocable_v<Callable, Layer&>) {
0197 m_callable(layer);
0198 }
0199 }
0200
0201 void visitPortal(Portal& portal) override {
0202 if constexpr (std::is_invocable_v<Callable, Portal&>) {
0203 m_callable(portal);
0204 }
0205 }
0206
0207 private:
0208 Callable m_callable;
0209 };
0210
0211 }
0212
0213 }