File indexing completed on 2025-10-13 08:15:40
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 class ITrackingGeometryVisitor {
0030 public:
0031 virtual ~ITrackingGeometryVisitor() = 0;
0032
0033
0034 explicit ITrackingGeometryVisitor(bool visitDepthFirst = false)
0035 : m_visitDepthFirst(visitDepthFirst) {}
0036
0037
0038
0039
0040 bool visitDepthFirst() const { return m_visitDepthFirst; }
0041
0042 private:
0043
0044
0045 bool m_visitDepthFirst{false};
0046 };
0047
0048
0049
0050
0051
0052
0053
0054 class TrackingGeometryVisitor : public ITrackingGeometryVisitor {
0055 public:
0056
0057
0058 using ITrackingGeometryVisitor::ITrackingGeometryVisitor;
0059
0060 ~TrackingGeometryVisitor() override;
0061
0062
0063
0064
0065 virtual void visitVolume(const TrackingVolume& volume);
0066
0067
0068
0069
0070 virtual void visitPortal(const Portal& portal);
0071
0072
0073
0074
0075 virtual void visitSurface(const Surface& surface);
0076
0077
0078
0079
0080
0081 virtual void visitLayer(const Layer& layer);
0082
0083
0084
0085
0086 virtual void visitBoundarySurface(
0087 const BoundarySurfaceT<TrackingVolume>& boundary);
0088 };
0089
0090
0091
0092
0093
0094
0095 class TrackingGeometryMutableVisitor : public ITrackingGeometryVisitor {
0096 public:
0097
0098
0099 using ITrackingGeometryVisitor::ITrackingGeometryVisitor;
0100
0101 ~TrackingGeometryMutableVisitor() override;
0102
0103
0104
0105
0106 virtual void visitVolume(TrackingVolume& volume);
0107
0108
0109
0110
0111 virtual void visitPortal(Portal& portal);
0112
0113
0114
0115
0116 virtual void visitSurface(Surface& surface);
0117
0118
0119
0120
0121
0122 virtual void visitLayer(Layer& layer);
0123
0124
0125
0126
0127 virtual void visitBoundarySurface(BoundarySurfaceT<TrackingVolume>& boundary);
0128 };
0129
0130 namespace detail {
0131
0132 template <typename Callable>
0133 consteval bool callableWithAnyMutable() {
0134 return std::is_invocable_v<Callable, Surface&> ||
0135 std::is_invocable_v<Callable, TrackingVolume&> ||
0136 std::is_invocable_v<Callable, BoundarySurfaceT<TrackingVolume>&> ||
0137 std::is_invocable_v<Callable, Layer&> ||
0138 std::is_invocable_v<Callable, Portal&>;
0139 }
0140
0141 template <typename Callable>
0142 consteval bool callableWithAnyConst() {
0143 return std::is_invocable_v<Callable, const Surface&> ||
0144 std::is_invocable_v<Callable, const TrackingVolume&> ||
0145 std::is_invocable_v<Callable,
0146 const BoundarySurfaceT<TrackingVolume>&> ||
0147 std::is_invocable_v<Callable, const Layer&> ||
0148 std::is_invocable_v<Callable, const Portal&>;
0149 }
0150
0151 template <typename Callable>
0152 consteval bool callableWithAny() {
0153 return callableWithAnyMutable<Callable>() || callableWithAnyConst<Callable>();
0154 }
0155
0156 template <typename Callable>
0157 requires(callableWithAnyConst<Callable>())
0158 class TrackingGeometryLambdaVisitor : public TrackingGeometryVisitor {
0159 public:
0160 explicit TrackingGeometryLambdaVisitor(Callable callable)
0161 : m_callable(std::move(callable)) {}
0162
0163 void visitSurface(const Surface& surface) override {
0164 if constexpr (std::is_invocable_v<Callable, const Surface&>) {
0165 m_callable(surface);
0166 }
0167 }
0168
0169 void visitVolume(const TrackingVolume& volume) override {
0170 if constexpr (std::is_invocable_v<Callable, const TrackingVolume&>) {
0171 m_callable(volume);
0172 }
0173 }
0174
0175 void visitBoundarySurface(
0176 const BoundarySurfaceT<TrackingVolume>& boundary) override {
0177 if constexpr (std::is_invocable_v<
0178 Callable, const BoundarySurfaceT<TrackingVolume>&>) {
0179 m_callable(boundary);
0180 }
0181 }
0182
0183 void visitLayer(const Layer& layer) override {
0184 if constexpr (std::is_invocable_v<Callable, const Layer&>) {
0185 m_callable(layer);
0186 }
0187 }
0188
0189 void visitPortal(const Portal& portal) override {
0190 if constexpr (std::is_invocable_v<Callable, const Portal&>) {
0191 m_callable(portal);
0192 }
0193 }
0194
0195 private:
0196 Callable m_callable;
0197 };
0198
0199 template <typename Callable>
0200 requires(callableWithAnyMutable<Callable>())
0201 class TrackingGeometryLambdaMutableVisitor
0202 : public TrackingGeometryMutableVisitor {
0203 public:
0204 explicit TrackingGeometryLambdaMutableVisitor(Callable callable)
0205 : m_callable(std::move(callable)) {}
0206
0207 void visitSurface(Surface& surface) override {
0208 if constexpr (std::is_invocable_v<Callable, Surface&>) {
0209 m_callable(surface);
0210 }
0211 }
0212
0213 void visitVolume(TrackingVolume& volume) override {
0214 if constexpr (std::is_invocable_v<Callable, TrackingVolume&>) {
0215 m_callable(volume);
0216 }
0217 }
0218
0219 void visitBoundarySurface(
0220 BoundarySurfaceT<TrackingVolume>& boundary) override {
0221 if constexpr (std::is_invocable_v<Callable,
0222 BoundarySurfaceT<TrackingVolume>&>) {
0223 m_callable(boundary);
0224 }
0225 }
0226
0227 void visitLayer(Layer& layer) override {
0228 if constexpr (std::is_invocable_v<Callable, Layer&>) {
0229 m_callable(layer);
0230 }
0231 }
0232
0233 void visitPortal(Portal& portal) override {
0234 if constexpr (std::is_invocable_v<Callable, Portal&>) {
0235 m_callable(portal);
0236 }
0237 }
0238
0239 private:
0240 Callable m_callable;
0241 };
0242
0243 }
0244
0245 }