Mercurial > public > cpp-enigma
comparison enigma/machine.h @ 14:919b7a0d1802
Ditched shared_ptr.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Mon, 02 Jul 2012 19:23:49 -0500 |
parents | b9d124a15926 |
children | 9e02d8696e67 |
comparison
equal
deleted
inserted
replaced
13:b9d124a15926 | 14:919b7a0d1802 |
---|---|
14 #include "rotor.h" | 14 #include "rotor.h" |
15 #include "plugboard.h" | 15 #include "plugboard.h" |
16 | 16 |
17 namespace enigma | 17 namespace enigma |
18 { | 18 { |
19 typedef std::vector<std::shared_ptr<rotor>> rotor_vector; | 19 typedef std::vector<rotor*> rotor_vector; |
20 | 20 |
21 class enigma_machine_error : public enigma_error | 21 class enigma_machine_error : public enigma_error |
22 { | 22 { |
23 public: | 23 public: |
24 explicit enigma_machine_error(const std::string& what_arg) | 24 explicit enigma_machine_error(const std::string& what_arg) |
27 }; | 27 }; |
28 | 28 |
29 class enigma_machine | 29 class enigma_machine |
30 { | 30 { |
31 public: | 31 public: |
32 // construct an Enigma machine from component parts: | 32 // Construct an Enigma machine from component parts. |
33 // Note that the enigma_machine makes copies of the rotors and will not | |
34 // delete the rotor pointers: | |
33 enigma_machine(const rotor_vector& rv, | 35 enigma_machine(const rotor_vector& rv, |
34 std::shared_ptr<rotor> reflector, | 36 const rotor& reflector, |
35 const plugboard& pb); | 37 const plugboard& pb); |
36 | 38 |
37 // construct an Enigma machine with a default plugboard (no cables connected): | 39 // construct an Enigma machine with a default plugboard (no cables connected): |
38 enigma_machine(const rotor_vector& rv, | 40 enigma_machine(const rotor_vector& rv, |
39 std::shared_ptr<rotor> reflector); | 41 const rotor& reflector); |
40 | 42 |
41 // key-sheet style constructors: | 43 // key-sheet style constructors: |
42 enigma_machine(const std::vector<std::string>& rotor_types, | 44 enigma_machine(const std::vector<std::string>& rotor_types, |
43 const std::vector<int>& ring_settings, | 45 const std::vector<int>& ring_settings, |
44 const std::string& reflector_name = "B", | 46 const std::string& reflector_name = "B", |