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
3
#include "
commrat/messages.hpp
"
4
#include <array>
5
#include <cstddef>
6
#include <iostream>
7
8
namespace
commrat
{
9
10
// ============================================================================
11
// Phase 6.10: Input Metadata Storage and Accessors
12
// ============================================================================
13
19
struct
InputMetadataStorage
{
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
35
template
<
typename
T>
36
struct
InputMetadata
{
37
uint64_t
timestamp
;
38
uint32_t
sequence_number
;
39
uint32_t
message_id
;
40
bool
is_new_data
;
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
53
template
<
typename
T,
typename
... Types>
54
static
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
messages.hpp
commrat
CommRaT - Modern C++ Real-Time Communication Framework.
commrat::find_type_index
static constexpr std::size_t find_type_index()
Find index of type T in input tuple.
Definition
input_metadata.hpp:54
commrat::InputMetadataStorage
Storage for input message metadata.
Definition
input_metadata.hpp:19
commrat::InputMetadataStorage::is_new_data
bool is_new_data
Definition
input_metadata.hpp:23
commrat::InputMetadataStorage::timestamp
uint64_t timestamp
Definition
input_metadata.hpp:20
commrat::InputMetadataStorage::is_valid
bool is_valid
Definition
input_metadata.hpp:24
commrat::InputMetadataStorage::sequence_number
uint32_t sequence_number
Definition
input_metadata.hpp:21
commrat::InputMetadataStorage::message_id
uint32_t message_id
Definition
input_metadata.hpp:22
commrat::InputMetadata
Input metadata structure returned by accessor methods.
Definition
input_metadata.hpp:36
commrat::InputMetadata::message_id
uint32_t message_id
Message type ID.
Definition
input_metadata.hpp:39
commrat::InputMetadata::is_new_data
bool is_new_data
True if freshly received, false if stale/reused.
Definition
input_metadata.hpp:40
commrat::InputMetadata::is_valid
bool is_valid
True if getData succeeded, false if failed.
Definition
input_metadata.hpp:41
commrat::InputMetadata::sequence_number
uint32_t sequence_number
Message sequence number.
Definition
input_metadata.hpp:38
commrat::InputMetadata::timestamp
uint64_t timestamp
Message timestamp (from TimsHeader)
Definition
input_metadata.hpp:37
commrat::InputMetadata::type_name
static constexpr const char * type_name()
Definition
input_metadata.hpp:44
commrat
module
metadata
input_metadata.hpp
Generated by
1.9.8