Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:09:42

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 corecel/sys/ActionGroups.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <memory>
0010 #include <vector>
0011 
0012 #include "ActionInterface.hh"
0013 
0014 namespace celeritas
0015 {
0016 //---------------------------------------------------------------------------//
0017 class ActionRegistry;
0018 
0019 //---------------------------------------------------------------------------//
0020 /*!
0021  * Group and sequence actions to be used over the lifetime of a run.
0022  *
0023  * This class improves runtime performance by caching the correct base classes
0024  * of the virtual action hierarchy. It sorts step actions by increasing \c
0025  * StepActionOrder, then by increasing action ID. Other actions are sorted
0026  * solely by action ID.
0027  *
0028  * Because actions can inherit from multiple action types, the sum of actions
0029  * from these partitions may be \em greater than the number of actions in the
0030  * registry.
0031  */
0032 template<class P, template<MemSpace M> class S>
0033 class ActionGroups
0034 {
0035   public:
0036     //!@{
0037     //! \name Type aliases
0038     using BeginRunActionT = BeginRunActionInterface<P, S>;
0039     using StepActionT = StepActionInterface<P, S>;
0040     using SPBeginAction = std::shared_ptr<BeginRunActionT>;
0041     using SPConstStepAction = std::shared_ptr<StepActionT const>;
0042     using VecBeginAction = std::vector<SPBeginAction>;
0043     using VecStepAction = std::vector<SPConstStepAction>;
0044     //!@}
0045 
0046   public:
0047     // Construct from an action registry and sequence options
0048     explicit ActionGroups(ActionRegistry const&);
0049 
0050     //! Get the set of beginning-of-run actions
0051     VecBeginAction const& begin_run() const { return begin_run_; }
0052 
0053     //! Get the ordered vector of actions within a step
0054     VecStepAction const& step() const { return step_actions_; }
0055 
0056   private:
0057     VecBeginAction begin_run_;
0058     VecStepAction step_actions_;
0059 };
0060 
0061 //---------------------------------------------------------------------------//
0062 }  // namespace celeritas