Mercurial > public > cpp-enigma
diff enigma/machine.h @ 11:da231533c5c7
To support hill climbing and fewer enigma machine constructor calls, the
enigma machine now uses shared_ptr instead of unique_ptr.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Fri, 29 Jun 2012 23:20:33 -0500 |
parents | b90a41f0cd94 |
children | 424111a36ed7 |
line wrap: on
line diff
--- a/enigma/machine.h Fri Jun 29 21:26:24 2012 -0500 +++ b/enigma/machine.h Fri Jun 29 23:20:33 2012 -0500 @@ -16,7 +16,7 @@ namespace enigma { - typedef std::vector<std::unique_ptr<rotor>> rotor_vector; + typedef std::vector<std::shared_ptr<rotor>> rotor_vector; class enigma_machine_error : public enigma_error { @@ -30,13 +30,13 @@ { public: // construct an Enigma machine from component parts: - enigma_machine(rotor_vector rv, - std::unique_ptr<rotor> reflector, + enigma_machine(const rotor_vector& rv, + std::shared_ptr<rotor> reflector, const plugboard& pb); // construct an Enigma machine with a default plugboard (no cables connected): - enigma_machine(rotor_vector rv, - std::unique_ptr<rotor> reflector); + enigma_machine(const rotor_vector& rv, + std::shared_ptr<rotor> reflector); // key-sheet style constructors: enigma_machine(const std::vector<std::string>& rotor_types, @@ -134,7 +134,7 @@ private: rotor_vector rotors; - std::unique_ptr<rotor> reflector; + std::shared_ptr<rotor> reflector; plugboard pb; rotor* r_rotor; // rightmost rotor rotor* m_rotor; // 2nd to right rotor