Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:54:49

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