EnigmaMachineCore 0.1.0
A modular Enigma Machine simulation in C++20
Loading...
Searching...
No Matches
Rotor.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "EnigmaMachineConfig.hpp" // For RotorConfig
4#include "Transformer.hpp"
5
17class Rotor : public Transformer {
18private:
21
27
35 int initRotorPosition(int offset = 0);
36
37public:
44 explicit Rotor(const RotorConfig& config);
45 explicit Rotor(RotorConfig&& config);
46 ~Rotor() override = default;
47
57 AlphabetIndex transform(AlphabetIndex position, bool reverse = false) const override;
58
66 AlphabetIndex transformForward(AlphabetIndex position) const override;
67
75 AlphabetIndex transformReverse(AlphabetIndex position) const override;
76
84 int rotate() override;
85
91 void setPosition(int position) override;
92
98 int getPosition() const override;
99
106 bool isNotchPosition(int position) const;
107};
Header file for the Transformer class.
Class representing a rotor in the Enigma machine. This class inherits from the Transformer class and ...
Definition Rotor.hpp:17
~Rotor() override=default
void initReverseLookupTable()
Generates the reverse transformation lookup table.
Definition Rotor.cpp:50
AlphabetIndex transformReverse(AlphabetIndex position) const override
Transforms the given position in reverse using the reverse LUT.
Definition Rotor.cpp:123
void setPosition(int position) override
Sets the rotor to a specific position.
Definition Rotor.cpp:155
AlphabetIndex transform(AlphabetIndex position, bool reverse=false) const override
Transforms the given position based on the transformation lookup table (LUT).
Definition Rotor.cpp:93
int getPosition() const override
Gets the current position of the rotor.
Definition Rotor.cpp:157
int rotate() override
Rotates the rotor by one position. If the rotor reaches the notch position, it returns 1,...
Definition Rotor.cpp:143
bool isNotchPosition(int position) const
Checks if the given position is the notch position.
Definition Rotor.cpp:82
AlphabetIndex transformForward(AlphabetIndex position) const override
Transforms the given position forward using the forward LUT.
Definition Rotor.cpp:103
int initRotorPosition(int offset=0)
Initializes the rotor position. This function sets the initial position of the rotor based on the pro...
Definition Rotor.cpp:77
int rotationCount
Definition Rotor.hpp:20
int notchPosition
Definition Rotor.hpp:19
Base class for transformers (rotors and reflectors). This class provides the interface for transformi...
Configuration structure for an individual Rotor.