Project
Loading...
Searching...
No Matches
PixelLaneData.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.
11#ifndef ALICEO2_FOCAL_PIXELLANEDATA_H
12#define ALICEO2_FOCAL_PIXELLANEDATA_H
13
14#include <array>
15#include <cstdint>
16#include <exception>
17#include <iosfwd>
18#include <string>
19#include <vector>
20
21#include <gsl/span>
22
23namespace o2::focal
24{
25
27{
28 public:
29 PixelLanePayload() = default;
30 ~PixelLanePayload() = default;
31
32 void reset();
33 void append(gsl::span<const uint8_t> payloadwords);
34 void append(uint8_t word);
35 gsl::span<const uint8_t> getPayload() const;
36
37 void print(std::ostream& stream) const;
38
39 private:
40 void printWordType(uint8_t word, std::ostream& stream) const;
41 std::vector<uint8_t> mPayload;
42};
43
45{
46 public:
47 static constexpr std::size_t NLANES = 28;
48
49 class LaneIndexException : public std::exception
50 {
51 public:
52 LaneIndexException(int index) : std::exception(), mIndex(index), mMessage()
53 {
54 mMessage = "Invalid lane " + std::to_string(mIndex) + " max " + std::to_string(PixelLaneHandler::NLANES);
55 }
56 ~LaneIndexException() noexcept final = default;
57
58 const char* what() const noexcept final { return mMessage.data(); }
59 void print(std::ostream& stream) const;
60
61 std::size_t getIndex() const noexcept { return mIndex; }
62
63 private:
64 std::size_t mIndex;
65 std::string mMessage;
66 };
67
68 PixelLaneHandler() = default;
69 ~PixelLaneHandler() = default;
70
71 PixelLanePayload& operator[](std::size_t index) { return getLane(index); }
72 const PixelLanePayload& operator[](std::size_t index) const { return getLane(index); }
73
74 void reset();
75 void resetLane(std::size_t laneID);
76
77 PixelLanePayload& getLane(std::size_t index);
78 const PixelLanePayload& getLane(std::size_t index) const;
79
80 private:
81 void handleLaneIndex(std::size_t laneIndex) const;
82 std::array<PixelLanePayload, NLANES> mLaneData;
83};
84
85std::ostream& operator<<(std::ostream& stream, const PixelLaneHandler::LaneIndexException& except);
86std::ostream& operator<<(std::ostream& stream, const PixelLanePayload& payload);
87
88} // namespace o2::focal
89
90#endif // ALICEO2_FOCAL_PIXELLANEDATA_H
void print() const
const char * what() const noexcept final
PixelLanePayload & getLane(std::size_t index)
static constexpr std::size_t NLANES
void resetLane(std::size_t laneID)
const PixelLanePayload & operator[](std::size_t index) const
PixelLanePayload & operator[](std::size_t index)
gsl::span< const uint8_t > getPayload() const
void append(gsl::span< const uint8_t > payloadwords)
GLuint index
Definition glcorearb.h:781
GLuint GLuint stream
Definition glcorearb.h:1806
std::ostream & operator<<(std::ostream &in, const IndexExceptionEvent &error)
Defining DataPointCompositeObject explicitly as copiable.
std::string to_string(gsl::span< T, Size > span)
Definition common.h:52