|
EnigmaMachineCore 0.1.0
A modular Enigma Machine simulation in C++20
|
Class representing a box of rotors in the Enigma machine. More...
#include <RotorBox.hpp>
Public Member Functions | |
| RotorBox (ILogger *logger=nullptr) | |
| Constructor for the RotorBox class. Initializes the rotor box with a default number of rotors (3) and their positions (all set to 0). | |
| RotorBox (const std::vector< AlphabetIndex > &rotorPositions, const std::vector< RotorConfig > &rotors, const ReflectorConfig &reflector, ILogger *logger=nullptr) | |
| Constructor for the RotorBox class. Initializes the rotor box with a specified number of rotors, their positions, and configurations. | |
| RotorBox (std::vector< AlphabetIndex > &&rotorPositions, std::vector< RotorConfig > &&rotors, ReflectorConfig &&reflector, ILogger *logger=nullptr) | |
| Constructor for the RotorBox class (move version). | |
| RotorBox (const RotorBox &)=delete | |
| RotorBox & | operator= (const RotorBox &)=delete |
| RotorBox (RotorBox &&)=default | |
| RotorBox & | operator= (RotorBox &&)=default |
| ~RotorBox ()=default | |
| void | registerObserver (IEnigmaObserver *observer) |
| Registers an observer to receive notifications. | |
| void | removeObserver (IEnigmaObserver *observer) |
| Removes an observer. | |
| void | printTransformers () const |
| Prints the types of transformers in the transformer vector. This function iterates through the transformer vector and prints the type of each transformer. | |
| AlphabetIndex | keyTransform (AlphabetIndex input) |
| Transforms the input key through the rotor box. | |
| void | setLogger (ILogger *logger) |
| Sets the logger for the rotor box. | |
Private Member Functions | |
| void | initTransformers (const std::vector< RotorConfig > &rotors, const ReflectorConfig &reflector) |
| Initializes the transformer vector with rotors and a reflector. | |
| void | updateRotors () |
| Updates the positions of the rotors. | |
Private Attributes | |
| int | rotorCount |
| std::vector< AlphabetIndex > | rotorPositions |
| std::vector< std::unique_ptr< Transformer > > | transformers |
| std::vector< IEnigmaObserver * > | observers |
| ILogger * | logger |
Class representing a box of rotors in the Enigma machine.
This class manages multiple rotors and a reflector, allowing for the transformation of input keys. It handles the initialization of rotors, their positions, and the transformation process.
Definition at line 24 of file RotorBox.hpp.
|
explicit |
Constructor for the RotorBox class. Initializes the rotor box with a default number of rotors (3) and their positions (all set to 0).
| logger | Optional logger for event reporting. |
| std::runtime_error | If initialization of transformers fails. |
Initializes a standard 3-rotor configuration with empty/default wiring. Note: usage of this constructor is discouraged without subsequent initialization.
Definition at line 22 of file RotorBox.cpp.
References initTransformers(), rotorCount, and rotorPositions.
Here is the call graph for this function:| RotorBox::RotorBox | ( | const std::vector< AlphabetIndex > & | rotorPositions, |
| const std::vector< RotorConfig > & | rotors, | ||
| const ReflectorConfig & | reflector, | ||
| ILogger * | logger = nullptr |
||
| ) |
Constructor for the RotorBox class. Initializes the rotor box with a specified number of rotors, their positions, and configurations.
| rotorPositions | A vector containing the initial positions of each rotor. |
| rotors | A vector containing the configuration for each rotor. |
| reflector | Configuration for the reflector. |
| logger | Optional logger for event reporting. |
| std::invalid_argument | If the number of rotors does not match the number of positions. |
| std::runtime_error | If initialization of transformers fails. |
Initializes a custom rotor configuration. Validates that the number of provided positions matches the rotor count before proceeding with transformer initialization and position setting.
Definition at line 35 of file RotorBox.cpp.
References initTransformers(), rotorCount, rotorPositions, and transformers.
Here is the call graph for this function:| RotorBox::RotorBox | ( | std::vector< AlphabetIndex > && | rotorPositions, |
| std::vector< RotorConfig > && | rotors, | ||
| ReflectorConfig && | reflector, | ||
| ILogger * | logger = nullptr |
||
| ) |
Constructor for the RotorBox class (move version).
| rotorPositions | A vector containing the initial positions of each rotor. |
| rotors | A vector containing the configuration for each rotor. |
| reflector | Configuration for the reflector. |
| logger | Optional logger for event reporting. |
Definition at line 52 of file RotorBox.cpp.
References rotorCount, rotorPositions, and transformers.
|
delete |
|
default |
|
default |
|
private |
Initializes the transformer vector with rotors and a reflector.
| rotors | A vector containing the configuration for each rotor. |
| reflector | Configuration for the reflector. |
Populates the internal transformer vector with unique pointers to Rotor and Reflector objects.
Definition at line 85 of file RotorBox.cpp.
References rotorCount, and transformers.
Referenced by RotorBox(), and RotorBox().
Here is the caller graph for this function:| AlphabetIndex RotorBox::keyTransform | ( | AlphabetIndex | input | ) |
Transforms the input key through the rotor box.
| input | The input key to be transformed. |
The signal path inside the RotorBox simulates the actual wiring:
Definition at line 112 of file RotorBox.cpp.
References rotorCount, transformers, and updateRotors().
Here is the call graph for this function:| void RotorBox::printTransformers | ( | ) | const |
Prints the types of transformers in the transformer vector. This function iterates through the transformer vector and prints the type of each transformer.
Definition at line 95 of file RotorBox.cpp.
References logger, and transformers.
| void RotorBox::registerObserver | ( | IEnigmaObserver * | observer | ) |
Registers an observer to receive notifications.
| observer | The observer to register. |
Definition at line 71 of file RotorBox.cpp.
References observers.
| void RotorBox::removeObserver | ( | IEnigmaObserver * | observer | ) |
Removes an observer.
| observer | The observer to remove. |
Definition at line 73 of file RotorBox.cpp.
References observers.
| void RotorBox::setLogger | ( | ILogger * | logger | ) |
Sets the logger for the rotor box.
| logger | The logger to use. |
Definition at line 132 of file RotorBox.cpp.
References logger.
|
private |
Updates the positions of the rotors.
Updates the rotor positions according to Enigma stepping mechanics.
Definition at line 142 of file RotorBox.cpp.
References logger, observers, rotorCount, and transformers.
Referenced by keyTransform().
Here is the caller graph for this function:
|
private |
Definition at line 30 of file RotorBox.hpp.
Referenced by printTransformers(), setLogger(), and updateRotors().
|
private |
Definition at line 29 of file RotorBox.hpp.
Referenced by registerObserver(), removeObserver(), and updateRotors().
|
private |
Definition at line 26 of file RotorBox.hpp.
Referenced by RotorBox(), RotorBox(), RotorBox(), initTransformers(), keyTransform(), and updateRotors().
|
private |
Definition at line 27 of file RotorBox.hpp.
Referenced by RotorBox(), RotorBox(), and RotorBox().
|
private |
Definition at line 28 of file RotorBox.hpp.
Referenced by RotorBox(), RotorBox(), initTransformers(), keyTransform(), printTransformers(), and updateRotors().