/*
---------------------------------buildPatrons--------------------------------
buildPatrons - creates patrons from the data file and hands them to the
               library to appropriately manage.

PreConditions: File must be in the valid format, defined for Assignment #3.
PostConditions: Every line is read, processed, and each patron generated from
                the process is handed to the library to insert into the 
                data structures.
*/
void Manager::buildPatrons() {
    int inputID = -1;
    std::string inputName;

    //While we have stuff to process from the data file...
    while(!patronsStream.eof()) {
        inputID = -1;
        patronsStream >> inputID;

        //Is the Patron ID valid?
        if(inputID >= 0 && inputID < MAX_PATRON_SIZE) {
            
            //Yes!  Let's process the input data and add them to the patron
            //data structure.
            patronsStream.get();
            getline(patronsStream, inputName);
            Patron* inputPatron = new Patron();
            inputPatron->setName(inputName);
            inputPatron->setID(inputID);
            bool inserted = MyLibrary.insert(inputPatron);
            
            //delete inputPatron if we are unable to insert them
            if(inserted == false) {
                delete inputPatron;
            }

            inputPatron = NULL;
            inputID = -1;
        //Patron ID is invalid, so we throw away the rest of the line.
        } else {
            getline(patronsStream, inputName);
        }
    }
    patronsStream.close();
}