Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 10:10:57

0001 //------------------------------- -*- C++ -*- -------------------------------//
0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details
0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0004 //---------------------------------------------------------------------------//
0005 //! \file celeritas/io/EventIOInterface.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <vector>
0010 
0011 #include "corecel/Macros.hh"
0012 #include "corecel/Types.hh"
0013 
0014 namespace celeritas
0015 {
0016 struct Primary;
0017 //---------------------------------------------------------------------------//
0018 /*!
0019  * Abstract base class for writing all primaries from an event.
0020  */
0021 class EventWriterInterface
0022 {
0023   public:
0024     //!@{
0025     //! \name Type aliases
0026     using VecPrimary = std::vector<Primary>;
0027     using argument_type = VecPrimary const&;
0028     //!@}
0029 
0030   public:
0031     virtual ~EventWriterInterface() = default;
0032 
0033     //! Write all primaries from a single event
0034     virtual void operator()(argument_type primaries) = 0;
0035 
0036   protected:
0037     //!@{
0038     //! Allow construction and assignment only through daughter classes
0039     EventWriterInterface() = default;
0040     CELER_DEFAULT_COPY_MOVE(EventWriterInterface);
0041     //!@}
0042 };
0043 
0044 //---------------------------------------------------------------------------//
0045 /*!
0046  * Abstract base class for reading all primaries from an event.
0047  */
0048 class EventReaderInterface
0049 {
0050   public:
0051     //!@{
0052     //! \name Type aliases
0053     using VecPrimary = std::vector<Primary>;
0054     using result_type = VecPrimary;
0055     //!@}
0056 
0057   public:
0058     virtual ~EventReaderInterface() = default;
0059 
0060     //! Read all primaries from a single event
0061     virtual result_type operator()() = 0;
0062 
0063     //! Get total number of events
0064     virtual size_type num_events() const = 0;
0065 
0066   protected:
0067     //!@{
0068     //! Allow construction and assignment only through daughter classes
0069     EventReaderInterface() = default;
0070     CELER_DEFAULT_COPY_MOVE(EventReaderInterface);
0071     //!@}
0072 };
0073 
0074 //---------------------------------------------------------------------------//
0075 }  // namespace celeritas