/*
 * dbmanager.hpp
 *
 * The RegDB_Manager class provides an interactive interface to a college
 * registrar database stored in a Registrar_DB object.  All of the brains
 * behind the database are in the Registrar_DB class.
 *
 * The interactive interface is fairly stupid.  Commands are read as
 * strings of nonblank characters, using the built-in I/O functions.
 * If a command takes parameters, the user is prompted for them one by
 * one; each parameter is expressed as either a nonblank string or an
 * integer.  Error-checking is minimal.
 *
 * Supported commands:
 *
 *	quit		Terminate the program.
 *	help		Print a simple help message.
 *	student		Add a new student, prompting for name and hair color.
 *	course		Add a new course, prompting for department, course
 *			number, meeting time, and maximum enrollment.
 *	enroll		Enroll a student in a course, prompting for the
 *			student's name, the department, and the course number.
 *	drop		Drop a student from a course, prompting as for
 *			"enroll".
 *	hair		Change a student's hair color, prompting for the name
 *			and the new color.
 *	time		Change a course's meeting time, prompting for the
 *			new information.
 *	show students	Display all students, including the names of the
 *			courses in which they are currently enrolled..
 *	show courses	Display all courses, including the names of students
 *			currently enrolled in each.
 *
 */

#ifndef DBMANAGER_HPP_INCLUDED
#define DBMANAGER_HPP_INCLUDED 1

#include <iostream>
#include <string>
using namespace std;

/*
 * Incomplete class declarations for classes are used but not defined
 * in this file. (For the compiler to understand the interface to the
 * Course class it must know that these classes will exist, but it
 * does not need any additional information about them.)
 */
class Registrar_DB;
class Student;
class Course;


class RegDB_Manager {
public:
                RegDB_Manager(Registrar_DB& db);
                
    /*
     * Interactive interface to a registrar's database.  The user is
     * repeatedly prompted for a command.  The command is then decoded and
     * dispatched to an appropriate routine for execution.
     */
    void	interact();
					// Interactive interface to DB
private:
    /*
     * Disable copy/assignment.
     */
                RegDB_Manager(const RegDB_Manager& orig);
    RegDB_Manager&  operator=(const RegDB_Manager& rhs);

    /*
     * Private functions implementing the user interface.
     */
    static void		printCommandList(ostream& out);
					// Print all legal commands
    static string	promptRead(const string& prompt, ostream& out,
                            istream& in);
                                        // Prompt user and get a string

    void	addStudent();		// Do the add-student command
    void	addCourse();		// Do the add-course command
    void	enroll();		// Do the enroll-in-course command
    void	drop();			// Do the drop-course command
    void	changeHair();		// Do the change-hair-color command
    void	changeTime();		// Do the change-meeting-time command
    void	showStudents();		// Do the show-students command
    void	showCourses();		// Do the show-courses command
    Student*	getStudentByName();	// Find a student by asking for name
    Course*	getCourseByName();	// Find a course by asking for name

    Registrar_DB&	db_;
};

#endif // DBMANAGER_HPP_INCLUDED


/* Junk to make emacs use the right C++ style when editing this code:
 *   Local Variables:
 *   c-file-style: "stroustrup"
 *   End:
 */
