/*
 * 2004 Utah High School Programming Contest, University of Utah
 * Take-Home Problem
 *
 * Search.hpp
 *
 * This file contains the definition of the Search class.
 */

#ifndef SEARCH_HPP
#define SEARCH_HPP

#include "Cipher.hpp"
#include "Puzzle.hpp"

// using namespace std;

/**
 * A Search object is responsible for implementing a search strategy to find
 * the best decryption cipher for a Puzzle.  The Search `find_cipher' method
 * creates Cipher objects and passes each one to a Puzzle object, which is
 * responsible for evaluating each cipher individually.  The `find_cipher'
 * method keeps track of the best cipher and returns it.
 *
 * In sum, Search is responsible for deciding what ciphers to test, and in what
 * order.  Other objects are responsible for actually applying a cipher to a
 * cryptogram (this is done by a Cipher) and evaluating the quality of the
 * result (done by a Puzzle).
 */
class Search {
private:
    /**
     * The Puzzle that describes the cryptogram we are trying to solve.
     */
    const Puzzle& puzzle;
    
public:
    /**
     * Construct a Search object to manage the search for the cipher that
     * decrypts a given cryptogram Puzzle.
     *
     * @param the_puzzle    the Puzzle to be solved
     */
    Search(Puzzle& the_puzzle);
    
    /**
     * Destroy a Search object.
     */
    virtual ~Search();
    
    /**
     * Find and return the Cipher object that best decrypts the cryptogram
     * Puzzle.  The returned Cipher must be deleted by the caller.
     *
     * @return    a pointer to the Cipher that best decrypts the puzzle
     */
    virtual Cipher* find_cipher();
};

#endif // SEARCH_HPP

// End of file.

