Lumiera  0.pre.03
»edit your freedom«
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 
43 namespace steam {
44 namespace engine {
45 namespace test {
46 
47  using lib::HashVal;
48 
68  class TestFrame
69  {
70  enum StageOfLife {
71  CREATED, EMITTED, DISCARDED
72  };
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;
83  StageOfLife stage;
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&);
104  TestFrame& operator= (TestFrame const&);
105 
108 
114  static bool isAlive (void* memLocation);
115 
118  static bool isDead (void* memLocation);
119 
120  bool isAlive() const;
121  bool isDead() const;
122  bool isSane() const;
123  bool isValid() const;
124  bool isPristine() const;
125 
126  bool operator== (void* memLocation) const;
127 
128  friend bool operator== (TestFrame const& f1, TestFrame const& f2) { return f1.contentEquals(f2); }
129  friend bool operator!= (TestFrame const& f1, TestFrame const& f2) { return !f1.contentEquals(f2); }
130 
132  _Arr& data() { return * std::launder (reinterpret_cast<_Arr* > (&buffer_)); }
133  _Arr const& data() const { return * std::launder (reinterpret_cast<_Arr const*> (&buffer_)); }
134  _A64& data64() { return * std::launder (reinterpret_cast<_A64* > (&buffer_)); }
135  _A64 const& data64() const { return * std::launder (reinterpret_cast<_A64 const*> (&buffer_)); }
136 
137  private:
138  void buildData();
139  Meta& accessHeader();
140  Meta const& accessHeader() const;
141  bool contentEquals (TestFrame const& o) const;
142  bool matchDistinction() const;
143  StageOfLife currStage() const;
144  HashVal computeChecksum() const;
145  bool hasValidChecksum() const;
146  };
147 
148 
149 
157  TestFrame& testData (uint seqNr =0, uint chanNr =0);
158 
159 
160 }}} // namespace steam::engine::test
161 #endif
Mock data frame for simulated rendering.
Definition: testframe.hpp:68
Definition: run.hpp:40
_Arr & data()
Array-style direct access to the payload data.
Definition: testframe.hpp:132
Meta header_
Metadata record located behind the data buffer.
Definition: testframe.hpp:95
void buildData()
Generate baseline data content based on the Meta::distinction seed.
Definition: testframe.cpp:330
bool isPlausible() const
Sanity check on the metadata header.
Definition: testframe.cpp:271
std::byte buffer_[sizeof(_Arr)]
inline storage buffer for the payload media data
Definition: testframe.hpp:92
Steam-Layer implementation namespace root.
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:37
Hash value types and utilities.
bool matchDistinction() const
verify the current data was not touched since initialisation
Definition: testframe.cpp:342
size_t HashVal
a STL compatible hash value
Definition: hash-value.h:52
static void reseed()
discard all cached #testData and recalibrate data generation
Definition: testframe.cpp:204
HashVal markChecksum()
recompute and store checksum based on current contents
Definition: testframe.cpp:364
TestFrame & testData(uint seqNr, uint chanNr)
Helper to access a specific frame of test data at a fixed memory location.
Definition: testframe.cpp:186
HashVal computeChecksum() const
Definition: testframe.cpp:353