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