|
||||
File indexing completed on 2025-01-18 09:54:46
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/data/AuxInterface.hh 0007 //---------------------------------------------------------------------------// 0008 #pragma once 0009 0010 #include <memory> 0011 #include <string_view> 0012 0013 #include "corecel/Macros.hh" 0014 #include "corecel/OpaqueId.hh" 0015 #include "corecel/Types.hh" 0016 #include "corecel/sys/ThreadId.hh" 0017 0018 namespace celeritas 0019 { 0020 //---------------------------------------------------------------------------// 0021 // TYPES 0022 //---------------------------------------------------------------------------// 0023 0024 //! Index for auxiliary data 0025 using AuxId = OpaqueId<struct Aux_>; 0026 0027 //---------------------------------------------------------------------------// 0028 // INTERFACES 0029 //---------------------------------------------------------------------------// 0030 /*! 0031 * Auxiliary state data owned by a single stream. 0032 * 0033 * This interface class is strictly to allow polymorphism and dynamic casting. 0034 */ 0035 class AuxStateInterface 0036 { 0037 public: 0038 //@{ 0039 //! \name Type aliases 0040 using SPState = std::shared_ptr<AuxStateInterface>; 0041 //@} 0042 0043 public: 0044 // Virtual destructor for polymorphism 0045 virtual ~AuxStateInterface(); 0046 0047 protected: 0048 //!@{ 0049 //! Allow construction and assignment only through daughter classes 0050 AuxStateInterface() = default; 0051 CELER_DEFAULT_COPY_MOVE(AuxStateInterface); 0052 //!@} 0053 }; 0054 0055 //---------------------------------------------------------------------------// 0056 /*! 0057 * Base class for extensible shared data that has associated state. 0058 * 0059 * Auxiliary data can be added to a \c AuxParamsInterface at runtime to be 0060 * passed among multiple classes, and then \c dynamic_cast to the expected 0061 * type. It needs to supply a factory function for creating the a state 0062 * instance for multithreaded data on a particular stream and a given memory 0063 * space. 0064 */ 0065 class AuxParamsInterface 0066 { 0067 public: 0068 //@{ 0069 //! \name Type aliases 0070 using UPState = std::unique_ptr<AuxStateInterface>; 0071 //@} 0072 0073 public: 0074 // Virtual destructor for polymorphism 0075 virtual ~AuxParamsInterface(); 0076 0077 //! Index of this class instance in its registry 0078 virtual AuxId aux_id() const = 0; 0079 0080 //! Label for the auxiliary data 0081 virtual std::string_view label() const = 0; 0082 0083 //! Factory function for building multithread state for a stream 0084 virtual UPState create_state(MemSpace, StreamId, size_type size) const = 0; 0085 0086 protected: 0087 //!@{ 0088 //! Allow construction and assignment only through daughter classes 0089 AuxParamsInterface() = default; 0090 CELER_DEFAULT_COPY_MOVE(AuxParamsInterface); 0091 //!@} 0092 }; 0093 0094 //---------------------------------------------------------------------------// 0095 } // namespace celeritas
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |