Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-24 09:42:28

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "ActsExamples/Framework/AlgorithmContext.hpp"
0012 #include "ActsExamples/Framework/ProcessCode.hpp"
0013 #include "ActsExamples/Framework/SequenceElement.hpp"
0014 
0015 #include <string>
0016 #include <utility>
0017 
0018 namespace ActsExamples {
0019 
0020 /// Event data reader interface.
0021 ///
0022 /// Read data from disk and add it to the event store. The reader can have
0023 /// internal state and implementations are responsible to handle concurrent
0024 /// calls.
0025 class IReader : public SequenceElement {
0026  public:
0027   /// Provide range of available events or [0,
0028   /// std::numeric_limits<std::size_t>::max()) if undefined.
0029   ///
0030   /// The upper limit is exclusive, i.e. [0,3) means events 0, 1, and 2.
0031   virtual std::pair<std::size_t, std::size_t> availableEvents() const = 0;
0032 
0033   /// Read data for the requested event and write it into the event store.
0034   ///
0035   /// As a result of the parallelization and/or skipping events, this method
0036   /// will most likely not be called in order. Implementations must use the
0037   /// event number provided to select the proper data to be read.
0038   virtual ProcessCode read(const AlgorithmContext& context) = 0;
0039 
0040   /// Instructs this reader to skip over a fixed number of events
0041   /// @param events
0042   /// @return Process code indicating if the skip was successful
0043   virtual ProcessCode skip(std::size_t /*events*/) {
0044     return ProcessCode::SUCCESS;
0045   }
0046 
0047   /// Internal execute method forwards to the read method as mutable
0048   /// @param context The algorithm context
0049   ProcessCode internalExecute(const AlgorithmContext& context) final {
0050     return read(context);
0051   }
0052 
0053   /// Fulfill the algorithm interface
0054   ProcessCode initialize() override { return ProcessCode::SUCCESS; }
0055 
0056   /// Fulfill the algorithm interface
0057   ProcessCode finalize() override { return ProcessCode::SUCCESS; }
0058 
0059   /// Return the type for debug output
0060   std::string_view typeName() const override { return "Reader"; }
0061 };
0062 
0063 }  // namespace ActsExamples