PxCrypt v0.2.2
Encrypt data within an image
Loading...
Searching...
No Matches
ch_sequence_generator.h
1#ifndef CH_SEQUENCE_GENERATOR_H
2#define CH_SEQUENCE_GENERATOR_H
3
4// Standard Library Includes
5#include <array>
6
7// Qt Includes
8#include <QRandomGenerator>
9#include <QVarLengthArray>
10
11// Project Includes
12#include "codec/encdec.h"
13
14namespace PxCryptPrivate
15{
16
17class ChSequenceGenerator
18{
19//-Aliases----------------------------------------------------------------------------------------------------------
20private:
21 using ChannelTracker = QVarLengthArray<Channel, 3>;
22
23//-Inner Class------------------------------------------------------------------------------------------------------
24public:
25 class State;
26
27//-Class Variables------------------------------------------------------------------------------------------------------
28private:
29 static constexpr std::array<Channel, 3> ALL_CHANNELS{Channel::Red, Channel::Green, Channel::Blue};
30
31//-Instance Variables------------------------------------------------------------------------------------------------------
32private:
33 QRandomGenerator mGenerator;
34 ChannelTracker mUnusedChannels;
35
36//-Constructor---------------------------------------------------------------------------------------------------------
37public:
38 ChSequenceGenerator(QByteArrayView seed);
39 ChSequenceGenerator(const State& state);
40
41//-Instance Functions----------------------------------------------------------------------------------------------
42private:
43 void reset();
44
45public:
46 bool pixelExhausted() const;
47 State state() const;
48
49 Channel next();
50
51//-Operators----------------------------------------------------------------------------------------------------------------
52public:
53 bool operator==(const State& state) const;
54};
55
56class ChSequenceGenerator::State
57{
58//-Instance Variables------------------------------------------------------------------------------------------------------
59private:
61 ChannelTracker mChannels;
62
63//-Constructor-------------------------------------------------------------------------------------------------------------
64public:
65 State(const QRandomGenerator& rng, const ChannelTracker& channels);
66
67//-Instance Functions------------------------------------------------------------------------------------------------------
68public:
69 QRandomGenerator rng() const;
70 ChannelTracker channels() const;
71};
72
73}
74
75#endif // CH_SEQUENCE_GENERATOR_H
QTextStream & reset(QTextStream &stream)