diff --git a/Examples/Framework/CMakeLists.txt b/Examples/Framework/CMakeLists.txt index 692db8f2f15..efe06302800 100644 --- a/Examples/Framework/CMakeLists.txt +++ b/Examples/Framework/CMakeLists.txt @@ -13,6 +13,7 @@ add_library( src/Framework/WhiteBoard.cpp src/Framework/RandomNumbers.cpp src/Framework/Sequencer.cpp + src/Framework/DataHandle.cpp src/Utilities/EventDataTransforms.cpp src/Utilities/Paths.cpp src/Utilities/Options.cpp diff --git a/Examples/Framework/include/ActsExamples/Framework/DataHandle.hpp b/Examples/Framework/include/ActsExamples/Framework/DataHandle.hpp index 2aaa469446c..eebe8cae749 100644 --- a/Examples/Framework/include/ActsExamples/Framework/DataHandle.hpp +++ b/Examples/Framework/include/ActsExamples/Framework/DataHandle.hpp @@ -8,11 +8,9 @@ #pragma once -#include "Acts/Utilities/ThrowAssert.hpp" #include "ActsExamples/Framework/SequenceElement.hpp" #include "ActsExamples/Framework/WhiteBoard.hpp" -#include #include #include @@ -54,14 +52,33 @@ class DataHandleBase { std::optional m_key{}; }; -template -class ReadDataHandle; +class WriteDataHandleBase : public DataHandleBase { + protected: + WriteDataHandleBase(SequenceElement* parent, const std::string& name) + : DataHandleBase{parent, name} {} + + public: + void initialize(const std::string& key); + + bool isCompatible(const DataHandleBase& other) const final; +}; + +class ReadDataHandleBase : public DataHandleBase { + protected: + ReadDataHandleBase(SequenceElement* parent, const std::string& name) + : DataHandleBase{parent, name} {} + + public: + void initialize(const std::string& key); + + bool isCompatible(const DataHandleBase& other) const final; +}; template -class WriteDataHandle final : public DataHandleBase { +class WriteDataHandle final : public WriteDataHandleBase { public: WriteDataHandle(SequenceElement* parent, const std::string& name) - : DataHandleBase{parent, name} { + : WriteDataHandleBase{parent, name} { m_parent->registerWriteHandle(*this); } @@ -77,37 +94,17 @@ class WriteDataHandle final : public DataHandleBase { wb.add(m_key.value(), std::move(value)); } - void initialize(const std::string& key) { - if (key.empty()) { - throw std::invalid_argument{"Write handle '" + fullName() + - "' cannot receive empty key"}; - } - m_key = key; - } - - bool isCompatible(const DataHandleBase& other) const override { - return dynamic_cast*>(&other) != nullptr; - } - const std::type_info& typeInfo() const override { return typeid(T); }; }; template -class ReadDataHandle final : public DataHandleBase { +class ReadDataHandle final : public ReadDataHandleBase { public: ReadDataHandle(SequenceElement* parent, const std::string& name) - : DataHandleBase{parent, name} { + : ReadDataHandleBase{parent, name} { m_parent->registerReadHandle(*this); } - void initialize(const std::string& key) { - if (key.empty()) { - throw std::invalid_argument{"Read handle '" + fullName() + - "' cannot receive empty key"}; - } - m_key = key; - } - const T& operator()(const AlgorithmContext& ctx) const { return (*this)(ctx.eventStore); } @@ -120,10 +117,6 @@ class ReadDataHandle final : public DataHandleBase { return wb.get(m_key.value()); } - bool isCompatible(const DataHandleBase& other) const override { - return dynamic_cast*>(&other) != nullptr; - } - const std::type_info& typeInfo() const override { return typeid(T); }; }; diff --git a/Examples/Framework/include/ActsExamples/Framework/Sequencer.hpp b/Examples/Framework/include/ActsExamples/Framework/Sequencer.hpp index 91f229a8c0b..a8f2ad27950 100644 --- a/Examples/Framework/include/ActsExamples/Framework/Sequencer.hpp +++ b/Examples/Framework/include/ActsExamples/Framework/Sequencer.hpp @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include diff --git a/Examples/Framework/src/Framework/DataHandle.cpp b/Examples/Framework/src/Framework/DataHandle.cpp new file mode 100644 index 00000000000..621b6201d0f --- /dev/null +++ b/Examples/Framework/src/Framework/DataHandle.cpp @@ -0,0 +1,39 @@ +// This file is part of the ACTS project. +// +// Copyright (C) 2016 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 https://mozilla.org/MPL/2.0/. + +#include "ActsExamples/Framework/DataHandle.hpp" + +namespace ActsExamples { + +void WriteDataHandleBase::initialize(const std::string& key) { + if (key.empty()) { + throw std::invalid_argument{"Write handle '" + fullName() + + "' cannot receive empty key"}; + } + m_key = key; +} + +bool WriteDataHandleBase::isCompatible(const DataHandleBase& other) const { + return dynamic_cast(&other) != nullptr && + typeInfo() == other.typeInfo(); +} + +void ReadDataHandleBase::initialize(const std::string& key) { + if (key.empty()) { + throw std::invalid_argument{"Read handle '" + fullName() + + "' cannot receive empty key"}; + } + m_key = key; +} + +bool ReadDataHandleBase::isCompatible(const DataHandleBase& other) const { + return dynamic_cast(&other) != nullptr && + typeInfo() == other.typeInfo(); +} + +} // namespace ActsExamples diff --git a/Examples/Python/CMakeLists.txt b/Examples/Python/CMakeLists.txt index c932b3ef081..0a834ae546f 100644 --- a/Examples/Python/CMakeLists.txt +++ b/Examples/Python/CMakeLists.txt @@ -66,6 +66,10 @@ target_link_libraries( ActsExamplesDetectorTelescope ActsExamplesUtilities ActsExamplesAmbiguityResolution + ActsExamplesTruthTracking + ActsExamplesDigitization + ActsExamplesPropagation + ActsExamplesMaterialMapping ) set(py_files