diff enigma/machine.h @ 8:b90a41f0cd94

Created enigma_machine::army_str() & navy_str() functions for logging.
author Brian Neal <bgneal@gmail.com>
date Fri, 29 Jun 2012 20:29:41 -0500
parents db1216d380b3
children da231533c5c7
line wrap: on
line diff
--- a/enigma/machine.h	Fri Jun 29 20:08:10 2012 -0500
+++ b/enigma/machine.h	Fri Jun 29 20:29:41 2012 -0500
@@ -126,6 +126,12 @@
       // for access to the plugboard for hill-climbing, etc
       plugboard& get_plugboard() { return pb; }
 
+      // Returns a string representation of the enigma machine's state. Useful
+      // for logging, etc:
+      //
+      std::string army_str() const { return str(true); }
+      std::string navy_str() const { return str(false); }
+
    private:
       rotor_vector rotors;
       std::unique_ptr<rotor> reflector;
@@ -188,6 +194,8 @@
 
          return pb.signal(pos);
       }
+
+      std::string str(bool army) const;
    };
 }