|
EnigmaMachineCore 0.1.0
A modular Enigma Machine simulation in C++20
|
Class representing the PlugBoard (Steckerbrett) of the Enigma machine. More...
#include <PlugBoard.hpp>
Public Member Functions | |
| PlugBoard () | |
| Constructor for the PlugBoard class. Initializes an empty plugboard with no pairs (identity mapping). | |
| PlugBoard (const std::array< PlugBoardPair, PLUGBOARD_MAX_PAIRS > &pairs) | |
| Constructor for the PlugBoard class. Initializes the plugboard with a given array of pairs. Validates that ports are not already used before connecting. | |
| ~PlugBoard ()=default | |
| AlphabetIndex | swap (AlphabetIndex key) const |
| Swaps the input key based on the plugboard pairs. | |
Private Attributes | |
| std::array< AlphabetIndex, TRANSFORMER_SIZE > | mapping |
Class representing the PlugBoard (Steckerbrett) of the Enigma machine.
The plugboard allows for manual swapping of letter pairs before they enter the rotor assembly and after they exit.
Definition at line 22 of file PlugBoard.hpp.
| PlugBoard::PlugBoard | ( | ) |
Constructor for the PlugBoard class. Initializes an empty plugboard with no pairs (identity mapping).
Definition at line 13 of file PlugBoard.cpp.
References mapping.
|
explicit |
Constructor for the PlugBoard class. Initializes the plugboard with a given array of pairs. Validates that ports are not already used before connecting.
| pairs | An array of pairs to initialize the plugboard with. |
| std::invalid_argument | If a port index is out of range or if there is a mapping conflict. |
Validates the provided pairs before mapping them. A port is 'unused' if it maps to itself. If either port 'a' or 'b' is already mapped to something else, a conflict is reported because a socket cannot have two plugs.
| std::invalid_argument | If a port index is out of range or if there is a mapping conflict. |
Definition at line 23 of file PlugBoard.cpp.
References mapping, and TRANSFORMER_SIZE.
|
default |
| AlphabetIndex PlugBoard::swap | ( | AlphabetIndex | key | ) | const |
Swaps the input key based on the plugboard pairs.
| key | The input key to be swapped. |
Performs a character swap using the pre-calculated mapping table.
Definition at line 55 of file PlugBoard.cpp.
References mapping, and TRANSFORMER_SIZE.
|
private |
Definition at line 24 of file PlugBoard.hpp.
Referenced by PlugBoard(), PlugBoard(), and swap().