Project
Loading...
Searching...
No Matches
TimeFrame.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
12#ifndef ALICEO2_TIMEFRAME_H
13#define ALICEO2_TIMEFRAME_H
14
15#include <fairmq/Parts.h>
16#include "TObject.h" // for ClassDef
17#include "Headers/TimeStamp.h"
18
19namespace o2
20{
21namespace dataformats
22{
23
25typedef std::pair<o2::header::DataHeader, PartPosition> IndexElement;
26
27// helper struct so that we can
28// stream messages using ROOT
30 MessageSizePair() : size(0), buffer(nullptr) {}
31 MessageSizePair(size_t s, char* b) : size(s), buffer(b) {}
32 Int_t size; // size of buffer in bytes (must be Int_t due to ROOT requirement)
33 char* buffer; //[size]
34};
35
36// a class encapsulating a TimeFrame as sent out by EPN
38{
39 public:
40 TimeFrame() : mParts() {} // in principle just for ROOT IO
41 // constructor taking fair::mq::Parts
42 // might offer another constructor not depending on FairMQ ... directly taking buffers?
43 // FIXME: take care of ownership later
44 TimeFrame(fair::mq::Parts& parts) : mParts()
45 {
46 for (int i = 0; i < parts.Size(); ++i) {
47 mParts.emplace_back(parts[i].GetSize(), (char*)parts[i].GetData());
48 }
49 }
50
51 // return TimeStamp (starttime) of this TimeFrame
52 o2::header::TimeStamp const& GetTimeStamp() const { return mTimeStamp; }
53
54 // return duration of this TimeFrame
55 // allow user to ask for specific unit (needs to be std::chrono unit)
56 template <typename TimeUnit>
57 std::chrono::duration<typename TimeUnit::duration> GetDuration() const
58 {
59 // FIXME: implement
60 return 0.;
61 }
62
63 // from how many flps we received data
64 int GetNumFlps() const
65 { /* FIXME: implement */
66 return 0;
67 }
68 // is this TimeFrame complete
69 bool IsComplete() const
70 { /* FIXME: implement */
71 return false;
72 }
73 // return the number of message parts in this TimeFrame
74 size_t GetNumParts() const { return mParts.size(); }
75 // access to the raw data
76 MessageSizePair& GetPart(size_t i) { return mParts[i]; }
77 // Get total payload size in bytes
78 size_t GetPayloadSize() const
79 { /* FIXME: implement */
80 return 0;
81 }
82 // Get payload size of part i
83 size_t GetPayloadSize(size_t i) const
84 { /* FIXME: implement */
85 return 0;
86 }
87
88 private:
89 // FIXME: enable this when we have a dictionary for TimeStamp etc
90 o2::header::TimeStamp mTimeStamp;
91
92 size_t mEpnId; // EPN origin of TimeFrame
93 std::vector<MessageSizePair> mParts; // the message parts as accumulated by the EPN
94
95 // FIXME: add Index data structure
96 // Index mIndex; // index structure into parts
97
98 ClassDefNV(TimeFrame, 1);
99};
100} // namespace dataformats
101} // namespace o2
102
103#endif // ALICEO2_TIMEFRAME_H
int32_t i
A std chrono implementation of LHC clock and timestamp.
MessageSizePair & GetPart(size_t i)
Definition TimeFrame.h:76
size_t GetNumParts() const
Definition TimeFrame.h:74
o2::header::TimeStamp const & GetTimeStamp() const
Definition TimeFrame.h:52
std::chrono::duration< typename TimeUnit::duration > GetDuration() const
Definition TimeFrame.h:57
size_t GetPayloadSize() const
Definition TimeFrame.h:78
TimeFrame(fair::mq::Parts &parts)
Definition TimeFrame.h:44
size_t GetPayloadSize(size_t i) const
Definition TimeFrame.h:83
GLuint buffer
Definition glcorearb.h:655
GLsizeiptr size
Definition glcorearb.h:659
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
std::pair< o2::header::DataHeader, PartPosition > IndexElement
Definition TimeFrame.h:25
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
MessageSizePair(size_t s, char *b)
Definition TimeFrame.h:31