File indexing completed on 2025-01-30 10:17:09
0001
0002
0003
0004
0005
0006
0007
0008 #pragma once
0009
0010 #include "corecel/data/Collection.hh"
0011
0012 #include "../OrangeData.hh"
0013 #include "../OrangeTypes.hh"
0014
0015 namespace celeritas
0016 {
0017 namespace detail
0018 {
0019
0020
0021
0022
0023 class LevelStateAccessor
0024 {
0025 public:
0026
0027
0028 using StateRef = NativeRef<OrangeStateData>;
0029
0030
0031 public:
0032
0033 inline CELER_FUNCTION LevelStateAccessor(StateRef const* states,
0034 TrackSlotId tid,
0035 LevelId level_id);
0036
0037
0038 inline CELER_FUNCTION LevelStateAccessor&
0039 operator=(LevelStateAccessor const& other);
0040
0041
0042
0043 CELER_FUNCTION LocalVolumeId& vol()
0044 {
0045 return states_->vol[OpaqueId<LocalVolumeId>{index_}];
0046 }
0047
0048 CELER_FUNCTION Real3& pos()
0049 {
0050 return states_->pos[OpaqueId<Real3>{index_}];
0051 }
0052
0053 CELER_FUNCTION Real3& dir()
0054 {
0055 return states_->dir[OpaqueId<Real3>{index_}];
0056 }
0057
0058 CELER_FUNCTION UniverseId& universe()
0059 {
0060 return states_->universe[OpaqueId<UniverseId>{index_}];
0061 }
0062
0063
0064
0065 CELER_FUNCTION LocalVolumeId const& vol() const
0066 {
0067 return states_->vol[OpaqueId<LocalVolumeId>{index_}];
0068 }
0069
0070 CELER_FUNCTION Real3 const& pos() const
0071 {
0072 return states_->pos[OpaqueId<Real3>{index_}];
0073 }
0074
0075 CELER_FUNCTION Real3 const& dir() const
0076 {
0077 return states_->dir[OpaqueId<Real3>{index_}];
0078 }
0079
0080 CELER_FUNCTION UniverseId const& universe() const
0081 {
0082 return states_->universe[OpaqueId<UniverseId>{index_}];
0083 }
0084
0085 private:
0086 StateRef const* const states_;
0087 size_type const index_;
0088 };
0089
0090
0091
0092
0093
0094
0095
0096 CELER_FUNCTION
0097 LevelStateAccessor::LevelStateAccessor(StateRef const* states,
0098 TrackSlotId tid,
0099 LevelId level_id)
0100 : states_(states), index_(tid.get() * states_->max_depth + level_id.get())
0101 {
0102 CELER_EXPECT(level_id < states->max_depth);
0103 }
0104
0105
0106
0107
0108
0109 CELER_FUNCTION LevelStateAccessor&
0110 LevelStateAccessor::operator=(LevelStateAccessor const& other)
0111 {
0112 this->vol() = other.vol();
0113 this->pos() = other.pos();
0114 this->dir() = other.dir();
0115 this->universe() = other.universe();
0116
0117 return *this;
0118 }
0119
0120
0121 }
0122 }