CommRaT 2.0.0
C++20 Real-Time Messaging Framework
Loading...
Searching...
No Matches
input_metadata.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <array>
5#include <cstddef>
6#include <iostream>
7
8namespace commrat {
9
10// ============================================================================
11// Phase 6.10: Input Metadata Storage and Accessors
12// ============================================================================
13
20 uint64_t timestamp{0}; // Message timestamp (from TimsHeader)
21 uint32_t sequence_number{0}; // Message sequence number (from TimsHeader)
22 uint32_t message_id{0}; // Message type ID (from TimsHeader)
23 bool is_new_data{false}; // True if fresh, false if stale/reused
24 bool is_valid{false}; // True if getData succeeded, false if failed
25};
26
35template<typename T>
37 uint64_t timestamp;
38 uint32_t sequence_number;
39 uint32_t message_id;
41 bool is_valid;
42
43 // Helper to get input type (for debugging/logging)
44 static constexpr const char* type_name() { return typeid(T).name(); }
45};
46
53template<typename T, typename... Types>
54static constexpr std::size_t find_type_index() {
55 constexpr std::size_t count = ((std::is_same_v<T, Types> ? 1 : 0) + ...);
56 static_assert(count > 0, "Type not found in inputs - check your input specification");
57 static_assert(count == 1, "Type appears multiple times in inputs - use index-based access instead");
58
59 // Find index where type matches
60 std::size_t index = 0;
61 bool found = false;
62 ((std::is_same_v<T, Types> ? (found = true) : (found ? true : (++index, false))), ...);
63 return index;
64}
65
66} // namespace commrat
CommRaT - Modern C++ Real-Time Communication Framework.
static constexpr std::size_t find_type_index()
Find index of type T in input tuple.
Storage for input message metadata.
Input metadata structure returned by accessor methods.
uint32_t message_id
Message type ID.
bool is_new_data
True if freshly received, false if stale/reused.
bool is_valid
True if getData succeeded, false if failed.
uint32_t sequence_number
Message sequence number.
uint64_t timestamp
Message timestamp (from TimsHeader)
static constexpr const char * type_name()