Project
Loading...
Searching...
No Matches
Road.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
15
16#ifndef TRACKINGCA_INCLUDE_ROAD_H
17#define TRACKINGCA_INCLUDE_ROAD_H
18
19#include <array>
20
22#include "GPUCommonDef.h"
23
24namespace o2::its
25{
26
27template <unsigned char maxRoadSize>
28class Road final
29{
30 public:
31 GPUhdDefault() Road() = default;
32 GPUhd() Road(int cellLayer, int cellId) : Road() { addCell(cellLayer, cellId); }
33
34 GPUhdDefault() Road(const Road&) = default;
35 GPUhdDefault() Road(Road&&) noexcept = default;
36 GPUhdDefault() ~Road() = default;
37
38 GPUhdDefault() Road& operator=(const Road&) = default;
39 GPUhdDefault() Road& operator=(Road&&) noexcept = default;
40
41 GPUhdi() uint8_t getRoadSize() const { return mRoadSize; }
42 GPUhdi() bool isFakeRoad() const { return mIsFakeRoad; }
43 GPUhdi() void setFakeRoad(const bool fake) { mIsFakeRoad = fake; }
44 GPUhdi() int& operator[](const int& i) { return mCellIds[i]; }
45 GPUhdi() int operator[](const int& i) const { return mCellIds[i]; }
46
47 GPUhd() void resetRoad()
48 {
49 for (int i = 0; i < maxRoadSize; i++) {
50 mCellIds[i] = constants::UnusedIndex;
51 }
52 mRoadSize = 0;
53 }
54
55 GPUhd() void addCell(int cellLayer, int cellId)
56 {
57 if (mCellIds[cellLayer] == constants::UnusedIndex) {
58 ++mRoadSize;
59 }
60
61 mCellIds[cellLayer] = cellId;
62 }
63
64 private:
65 std::array<int, maxRoadSize> mCellIds = constants::helpers::initArray<int, maxRoadSize, constants::UnusedIndex>();
66 unsigned char mRoadSize{0};
67 bool mIsFakeRoad{false};
68};
69
70} // namespace o2::its
71
72#endif
int32_t i
GPUhdDefault() Road(const Road &)=default
GPUhd() void resetRoad()
Definition Road.h:47
GPUhdi() int operator[](const int &i) const
Definition Road.h:45
GPUhdi() bool isFakeRoad() const
Definition Road.h:42
GPUhd() Road(int cellLayer
GPUhdi() int &operator[](const int &i)
Definition Road.h:44
GPUhd() void addCell(int cellLayer
GPUhdi() void setFakeRoad(const bool fake)
Definition Road.h:43
int cellId
Definition Road.h:32
GPUhdDefault() Road()=default
GPUhdi() uint8_t getRoadSize() const
Definition Road.h:41
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)