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