Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
testframe.hpp
Go to the documentation of this file.
1/*
2 TESTFRAME.hpp - test data frame (stub) for checking Render engine functionality
3
4 Copyright (C)
5 2011, 2024 Hermann Vosseler <Ichthyostega@web.de>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12*/
13
33#ifndef STEAM_ENGINE_TESTFRAME_H
34#define STEAM_ENGINE_TESTFRAME_H
35
36
37#include "lib/integral.hpp"
38#include "lib/hash-value.h"
39
40#include <array>
41
42
43namespace steam {
44namespace engine {
45namespace test {
46
47 using lib::HashVal;
48
69 {
73
74 static constexpr size_t BUFFSIZ = 1024;
75 using _Arr = std::array<char,BUFFSIZ>;
76 using _A64 = std::array<uint64_t, BUFFSIZ/sizeof(uint64_t)>;
77
78 struct Meta
79 {
80 HashVal _MARK_;
81 HashVal checksum;
82 uint64_t distinction;
84
85 Meta (uint seq, uint family);
86 bool isPlausible() const;
87 bool operator== (Meta const&) const;
88 };
89
91 alignas(uint64_t)
92 std::byte buffer_[sizeof(_Arr)];
93
96
97 public:
99 static void reseed();
100
101 ~TestFrame();
102 TestFrame (uint seq=0, uint family=0);
103 TestFrame (TestFrame const&);
105
107 HashVal markChecksum();
108 HashVal getChecksum();
109
115 static bool isAlive (void* memLocation);
116
119 static bool isDead (void* memLocation);
120
121 bool isAlive() const;
122 bool isDead() const;
123 bool isSane() const;
124 bool isValid() const;
125 bool isPristine() const;
126
127 bool operator== (void* memLocation) const;
128
129 friend bool operator== (TestFrame const& f1, TestFrame const& f2) { return f1.contentEquals(f2); }
130 friend bool operator!= (TestFrame const& f1, TestFrame const& f2) { return !f1.contentEquals(f2); }
131
133 _Arr& data() { return * std::launder (reinterpret_cast<_Arr* > (&buffer_)); }
134 _Arr const& data() const { return * std::launder (reinterpret_cast<_Arr const*> (&buffer_)); }
135 _A64& data64() { return * std::launder (reinterpret_cast<_A64* > (&buffer_)); }
136 _A64 const& data64() const { return * std::launder (reinterpret_cast<_A64 const*> (&buffer_)); }
137
138 private:
139 void buildData();
140 Meta& accessHeader();
141 Meta const& accessHeader() const;
142 bool contentEquals (TestFrame const& o) const;
143 bool matchDistinction() const;
144 StageOfLife currStage() const;
145 HashVal computeChecksum() const;
146 bool hasValidChecksum() const;
147 };
148
149
150
158 TestFrame& testData (uint seqNr =0, uint chanNr =0);
159
160
161}}} // namespace steam::engine::test
162#endif
Mock data frame for simulated rendering.
Definition testframe.hpp:69
void buildData()
Generate baseline data content based on the Meta::distinction seed.
_Arr const & data() const
HashVal getChecksum()
access current checksum without recomputing.
static constexpr size_t BUFFSIZ
Definition testframe.hpp:74
bool matchDistinction() const
verify the current data was not touched since initialisation
StageOfLife currStage() const
HashVal markChecksum()
recompute and store checksum based on current contents
TestFrame & operator=(TestFrame const &)
friend bool operator==(TestFrame const &f1, TestFrame const &f2)
_Arr & data()
Array-style direct access to the payload data.
std::array< char, BUFFSIZ > _Arr
Definition testframe.hpp:75
Meta header_
Metadata record located behind the data buffer.
Definition testframe.hpp:95
static void reseed()
discard all cached testData and recalibrate data generation
bool contentEquals(TestFrame const &o) const
std::byte buffer_[sizeof(_Arr)]
inline storage buffer for the payload media data
Definition testframe.hpp:92
_A64 const & data64() const
std::array< uint64_t, BUFFSIZ/sizeof(uint64_t)> _A64
Definition testframe.hpp:76
friend bool operator!=(TestFrame const &f1, TestFrame const &f2)
Hash value types and utilities.
Inclusion for common place integral types and constants.
unsigned int uint
Definition integral.hpp:29
size_t HashVal
a STL compatible hash value
Definition hash-value.h:52
Steam-Layer implementation namespace root.
Test runner and basic definitions for tests.
bool isPlausible() const
Sanity check on the metadata header.