Skip to content

Commit

Permalink
refactor: SourceLink uses custom Acts::Any (#1740)
Browse files Browse the repository at this point in the history
This should be a transparent change in terms of the interface.
  • Loading branch information
paulgessinger committed Dec 13, 2022
1 parent 4e60261 commit d4aac95
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions Core/include/Acts/EventData/SourceLink.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
#pragma once

#include "Acts/Geometry/GeometryIdentifier.hpp"
#include "Acts/MagneticField/detail/SmallObjectCache.hpp"
#include "Acts/Utilities/Any.hpp"
#include "Acts/Utilities/TypeTraits.hpp"

#include <any>
#include <cassert>
#include <iostream>
#include <type_traits>
Expand All @@ -26,7 +25,7 @@ using geometry_id_t = decltype(std::declval<T>().geometryId());
} // namespace detail_sl

class SourceLink final {
using any_type = std::any;
using any_type = AnyBase<16>;

public:
/// Getter for the geometry identifier
Expand Down Expand Up @@ -77,23 +76,15 @@ class SourceLink final {
/// @return Reference to the stored source link
template <typename T>
T& get() {
T* val = std::any_cast<T>(&m_upstream);
if (val == nullptr) {
throw std::bad_any_cast{};
}
return *val;
return m_upstream.as<T>();
}

/// Concrete source link class getter, const version
/// @tparam T The source link type to retrieve
/// @return Const reference to the stored source link
template <typename T>
const T& get() const {
const T* val = std::any_cast<const T>(&m_upstream);
if (val == nullptr) {
throw std::bad_any_cast{};
}
return *val;
return m_upstream.as<T>();
}

private:
Expand Down

0 comments on commit d4aac95

Please sign in to comment.