EnigmaMachineCore 0.1.0
A modular Enigma Machine simulation in C++20
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Reflector Class Reference

Class representing a reflector in the Enigma machine. This class inherits from the Transformer class and implements the functionality for transforming positions based on the reflector's transformation lookup table (LUT). Reflectors do not rotate, so the rotate function always returns 0. More...

#include <Reflector.hpp>

+ Inheritance diagram for Reflector:
+ Collaboration diagram for Reflector:

Public Member Functions

 Reflector (const ReflectorConfig &config)
 Constructor for the Reflector class. Initializes the reflector with a configuration. Sets the type of the transformer to Reflector.
 
 Reflector (ReflectorConfig &&config)
 
 ~Reflector () override=default
 
AlphabetIndex transform (AlphabetIndex position, bool reverse=false) const override
 Transforms the given position using the reflector's transformation lookup table (LUT).
 
AlphabetIndex transformForward (AlphabetIndex position) const override
 Transforms the given position forward.
 
AlphabetIndex transformReverse (AlphabetIndex position) const override
 Transforms the given position in reverse.
 
int rotate () override
 Reflector does not rotate.
 
- Public Member Functions inherited from Transformer
 Transformer ()
 Constructor for the Transformer class. Initializes the transformer type to NotDefined.
 
virtual ~Transformer ()=default
 
virtual void setPosition (int)
 
virtual int getPosition () const
 
int sizeOfLookupTable () const
 Calculates the size of the transformation lookup table (LUT).
 
TransformerType getType () const
 Returns the type of the transformer.
 

Additional Inherited Members

- Protected Member Functions inherited from Transformer
void setTransformValue (int row, int col, AlphabetIndex value)
 Sets a value in the transformation lookup table.
 
AlphabetIndex getTransformValue (int row, int col) const
 Gets a value from the transformation lookup table.
 
void fillTransformRow (int row, AlphabetIndex value)
 Fills a row of the transformation lookup table with a specific value.
 
void copyTransformRow (int row, const std::array< AlphabetIndex, TRANSFORMER_SIZE > &values)
 Copies a whole array into a row of the transformation lookup table.
 
const std::array< AlphabetIndex, TRANSFORMER_SIZE > & getTransformRow (int row) const
 Gets a read-only reference to a row in the transformation lookup table. Useful for using standard algorithms like std::find.
 
- Protected Attributes inherited from Transformer
TransformerType type
 

Detailed Description

Class representing a reflector in the Enigma machine. This class inherits from the Transformer class and implements the functionality for transforming positions based on the reflector's transformation lookup table (LUT). Reflectors do not rotate, so the rotate function always returns 0.

Definition at line 17 of file Reflector.hpp.

Constructor & Destructor Documentation

◆ Reflector() [1/2]

Reflector::Reflector ( const ReflectorConfig config)
explicit

Constructor for the Reflector class. Initializes the reflector with a configuration. Sets the type of the transformer to Reflector.

Parameters
configThe ReflectorConfig structure containing the wiring map.

Definition at line 11 of file Reflector.cpp.

References Transformer::copyTransformRow(), Transformer::fillTransformRow(), Reflector, Transformer::type, and ReflectorConfig::wiring.

+ Here is the call graph for this function:

◆ Reflector() [2/2]

Reflector::Reflector ( ReflectorConfig &&  config)
explicit

Definition at line 23 of file Reflector.cpp.

References Transformer::copyTransformRow(), Transformer::fillTransformRow(), Reflector, and Transformer::type.

+ Here is the call graph for this function:

◆ ~Reflector()

Reflector::~Reflector ( )
overridedefault

Member Function Documentation

◆ rotate()

int Reflector::rotate ( )
inlineoverridevirtual

Reflector does not rotate.

Returns
int Always returns 0.

Implements Transformer.

Definition at line 62 of file Reflector.hpp.

◆ transform()

AlphabetIndex Reflector::transform ( AlphabetIndex  position,
bool  reverse = false 
) const
overridevirtual

Transforms the given position using the reflector's transformation lookup table (LUT).

Parameters
positionThe input position to be transformed.
reverseIt should not be set to true.
Returns
AlphabetIndex The transformed position. Returns "-1" if the position is not found in the LUT when reverse is true.

This method is const-qualified, ensuring that the signal transformation does not modify the internal state of the reflector.

Performs the signal reflection.

Implements Transformer.

Definition at line 36 of file Reflector.cpp.

References transformForward(), and transformReverse().

+ Here is the call graph for this function:

◆ transformForward()

AlphabetIndex Reflector::transformForward ( AlphabetIndex  position) const
overridevirtual

Transforms the given position forward.

Parameters
positionThe current position (0 to TRANSFORMER_SIZE - 1).
Returns
AlphabetIndex The transformed position (0 to TRANSFORMER_SIZE - 1).

Implements the signal reflection at the end of the rotor sequence.

Reflects the input signal back towards the rotors.

Implements Transformer.

Definition at line 44 of file Reflector.cpp.

References Transformer::getTransformValue().

Referenced by transform().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ transformReverse()

AlphabetIndex Reflector::transformReverse ( AlphabetIndex  position) const
overridevirtual

Transforms the given position in reverse.

Parameters
positionThe current position (0 to TRANSFORMER_SIZE - 1).
Returns
AlphabetIndex Returns -1 since reflectors are symmetric and do not have separate reverse paths.

Returns -1 for Reflector reverse transformations.

Implements Transformer.

Definition at line 50 of file Reflector.cpp.

References Transformer::getTransformValue().

Referenced by transform().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: