File indexing completed on 2025-01-18 10:13:52
0001
0002
0003
0004 #ifndef VECGEOM_BASE_CONTAINER3D_H_
0005 #define VECGEOM_BASE_CONTAINER3D_H_
0006
0007 #include "VecGeom/base/Global.h"
0008
0009 #include "VecGeom/base/Vector3D.h"
0010
0011 namespace vecgeom {
0012 inline namespace VECGEOM_IMPL_NAMESPACE {
0013
0014 template <class Implementation>
0015 class Container3D;
0016
0017 template <template <typename> class ImplementationType, typename T>
0018 class Container3D<ImplementationType<T>> {
0019
0020 protected:
0021 VECCORE_ATT_HOST_DEVICE
0022 Container3D() {}
0023
0024 VECCORE_ATT_HOST_DEVICE
0025 ~Container3D() {}
0026
0027 private:
0028 typedef ImplementationType<T> Implementation;
0029
0030 VECCORE_ATT_HOST_DEVICE
0031 VECGEOM_FORCE_INLINE
0032 Implementation &implementation() { return *static_cast<Implementation *>(this); }
0033
0034 VECCORE_ATT_HOST_DEVICE
0035 VECGEOM_FORCE_INLINE
0036 Implementation &implementation_const() const { return *static_cast<Implementation const *>(this); }
0037
0038 typedef T value_type;
0039
0040 VECCORE_ATT_HOST_DEVICE
0041 VECGEOM_FORCE_INLINE
0042 size_t size() const { return implementation_const().size(); }
0043
0044 VECCORE_ATT_HOST_DEVICE
0045 VECGEOM_FORCE_INLINE
0046 size_t capacity() const { return implementation_const().capacity(); }
0047
0048 VECGEOM_FORCE_INLINE
0049 void resize() { implementation().resize(); }
0050
0051 VECGEOM_FORCE_INLINE
0052 void reserve() { implementation().reserve(); }
0053
0054 VECGEOM_FORCE_INLINE
0055 void clear() { implementation().clear(); }
0056
0057 VECCORE_ATT_HOST_DEVICE
0058 VECGEOM_FORCE_INLINE
0059 Vector3D<value_type> operator[](size_t index) const { return implementation_const().operator[](index); }
0060
0061 VECCORE_ATT_HOST_DEVICE
0062 VECGEOM_FORCE_INLINE
0063 value_type const &x(size_t index) const { return implementation_const().x(index); }
0064
0065 VECCORE_ATT_HOST_DEVICE
0066 VECGEOM_FORCE_INLINE
0067 value_type &x(size_t index) { return implementation().x(index); }
0068
0069 VECCORE_ATT_HOST_DEVICE
0070 VECGEOM_FORCE_INLINE
0071 value_type const &y(size_t index) const { return implementation_const().y(index); }
0072
0073 VECCORE_ATT_HOST_DEVICE
0074 VECGEOM_FORCE_INLINE
0075 value_type &y(size_t index) { return implementation().y(index); }
0076
0077 VECCORE_ATT_HOST_DEVICE
0078 VECGEOM_FORCE_INLINE
0079 value_type z(size_t index) const { return implementation_const().z(index); }
0080
0081 VECCORE_ATT_HOST_DEVICE
0082 VECGEOM_FORCE_INLINE
0083 value_type &z(size_t index) { return implementation().z(index); }
0084
0085 VECCORE_ATT_HOST_DEVICE
0086 VECGEOM_FORCE_INLINE
0087 void set(size_t index, value_type xval, value_type yval, value_type zval)
0088 {
0089 implementation().set(index, xval, yval, zval);
0090 }
0091
0092 VECCORE_ATT_HOST_DEVICE
0093 VECGEOM_FORCE_INLINE
0094 void set(size_t index, Vector3D<value_type> const &vec) { implementation().set(index, vec); }
0095
0096 VECCORE_ATT_HOST_DEVICE
0097 VECGEOM_FORCE_INLINE
0098 void push_back(const value_type xval, const value_type yval, const value_type zval)
0099 {
0100 implementation().push_back(xval, yval, zval);
0101 }
0102
0103 VECCORE_ATT_HOST_DEVICE
0104 VECGEOM_FORCE_INLINE
0105 void push_back(Vector3D<value_type> const &vec) { implementation().push_back(vec); }
0106 };
0107 }
0108 }
0109
0110 #endif