gdata
Loading...
Searching...
No Matches
gFrameHeader.h
Go to the documentation of this file.
1#pragma once
2
11#include "glogger.h"
12#include <atomic>
13#include <string>
14
16public:
23 GFrameHeader(long int frameID_, double frameDuration_, std::shared_ptr<GLogger> logger)
24 : frameID(frameID_), frameDuration(frameDuration_), log(logger) { log->debug(CONSTRUCTOR, "GFrameHeader id ", frameID); }
25
29 ~GFrameHeader() { if (log) log->debug(DESTRUCTOR, "GFrameHeader id ", frameID); }
30
31
32 static std::unique_ptr<GFrameHeader> create(std::shared_ptr<GLogger> logger) {
33 double fd = 33.33; // Example frame duration (units could be ms or other)
34 int eventNumber = globalFrameCounter.fetch_add(1, std::memory_order_relaxed);
35 return std::make_unique<GFrameHeader>(eventNumber, fd, logger);
36 }
37
38
43 [[nodiscard]] inline long int getFrameID() const { return frameID; }
44
49 [[nodiscard]] inline long int getTime() const { return time_ns(); }
50
51private:
52 long int frameID;
53 double frameDuration;
54 std::shared_ptr<GLogger> log{};
55
60 [[nodiscard]] long int time_ns() const { return frameID * frameDuration; }
61
63 static std::atomic<int> globalFrameCounter;
64};
static std::unique_ptr< GFrameHeader > create(std::shared_ptr< GLogger > logger)
GFrameHeader(long int frameID_, double frameDuration_, std::shared_ptr< GLogger > logger)
Constructs a GFrameDataCollectionHeader.
~GFrameHeader()
Destructor for GFrameDataCollectionHeader.
long int getFrameID() const
Gets the frame ID.
long int getTime() const
Gets the computed time from frame ID and duration.