libpromeki 1.0.0-alpha
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
clockdomain.h
Go to the documentation of this file.
1
8#pragma once
9
10
11#include <promeki/config.h>
12#if PROMEKI_ENABLE_CORE
13#include <cstdint>
14#include <promeki/function.h>
15#include <promeki/namespace.h>
16#include <promeki/string.h>
18#include <promeki/list.h>
19#include <promeki/enums_clock.h>
20
21PROMEKI_NAMESPACE_BEGIN
22
23class Metadata;
24
80class ClockDomain {
81 public:
83 using ID = StringRegistry<"ClockDomain">::Item;
84
86 using IDList = ::promeki::List<ID>;
87
95 struct Data;
96
98 static const ID Synthetic;
99
101 static const ID SystemMonotonic;
102
122 static const ID Ptp;
123
137 using WallClockProvider = ::promeki::Function<int64_t()>;
138
152 static ID registerDomain(const String &name, const String &description,
153 const ClockEpoch &epoch = ClockEpoch::Correlated);
154
163 static void setDomainMetadata(const ID &id, const Metadata &metadata);
164
188 static void setNowProvider(const ID &id, WallClockProvider provider);
189
203 static int64_t nowUtcNs(const ID &id);
204
206 static bool hasNowProvider(const ID &id);
207
212 static IDList registeredIDs();
213
219 static ClockDomain lookup(const String &name);
220
222 ClockDomain() = default;
223
228 ClockDomain(const ID &id);
229
234 bool isValid() const;
235
240 ID id() const;
241
246 const String &name() const;
247
252 const String &description() const;
253
259 const ClockEpoch &epoch() const;
260
268 const Metadata &metadata() const;
269
276 bool isCrossStreamComparable() const;
277
284 bool isCrossMachineComparable() const;
285
293 int64_t nowUtcNs() const;
294
296 bool hasNowProvider() const;
297
306 String toString() const;
307
316 const Data *data() const { return d; }
317
319 bool operator==(const ClockDomain &other) const { return d == other.d; }
320
322 bool operator!=(const ClockDomain &other) const { return d != other.d; }
323
324 private:
325 const Data *d = nullptr;
326 static const Data *lookupData(const ID &id);
327};
328
329PROMEKI_NAMESPACE_END
330
331PROMEKI_FORMAT_VIA_TOSTRING(promeki::ClockDomain);
332
333#endif // PROMEKI_ENABLE_CORE