#ifndef GAMERECORD_H #define GAMERECORD_H // gamerecord.h Interface file for the GameRecord class /******************************************************************************* // MODULE NAME: GameRecord // INTERFACE FILE: gamerecord.h // IMPLEMENTATION FILE: gamerecord.cpp // // PURPOSE: To provide a GameRecord type useful in implementing the BAL program, // which allows the user to create a record, update a field in the record, print // the current value of a field in the record, test the validity of a field in // the record, compare one record to another to determine sorting order, and // produce strings with the record information in them which are formatted for // output either to standard output or to a BAM file. // // FUNCTIONS: Name Purpose // GameRecord Paramterless constructor // GameRecord Constructor w/specified Game Index // GameRecord Constructor w/specifed gdex,adex,edex,tdex,cdex // LessThan Test whether this record should precede another // GreaterThan Test whether this record should follow another // Equals Show whether this record has the same index as // another one // fieldOK Determine if anything is wrong with a field of // the record // FieldContains Print the contents of the field // FieldDefault Print the default contents of a field // FieldLimits Print the limits in effect on the field // FieldLabel Print the correct label for the field // FieldWidth Print the correct width for the field // IndexIs Indicate the index of the record // NewIndex Change the index of a record // Update Change the contents of a field // Reset Reset the value of a field to its default // Reset Reset all fields to their defaults // Replace Change all the fields of a record to the values // of all the fields of another record // List Create a string which holds the record's // contents formatted for on-screen viewing // BriefList Create abbreviated string record listing // Print Create a string which holds the record's // contents formatted for BAM file viewing // // // AUTHOR: Amy Langill *2B DATE: 3/23/1999 *******************************************************************************/ #include // for strings & string operations #include // for stringstreams #include "balint.h" // for LimitInt #include "baltime.h" // for TimeType #include "baldate.h" // for DateType #include "balchar.h" // for setChar #include "balfloat.h" // for LimitFloat #include "errortype.h" // for error reporting using namespace std; typedef enum { G_GDEX, // Game index G_ADEX, // Alley index G_EDEX, // Event index G_TDEX, // Tools index G_CDEX, // Conditions index G_DATE, // Date of game G_START, // Start time G_STOP, // Stop time G_TEMP, // Temperature G_HUMIDITY, // Percent humidity G_SPARE // Spare method } GameFieldType; const int G_GDEX_WIDTH=5; // store the field widths as named constants const int G_ADEX_WIDTH=5; // const int G_EDEX_WIDTH=5; // const int G_TDEX_WIDTH=5; // const int G_CDEX_WIDTH=5; // const int G_TEMP_WIDTH=5; // const int G_HUMIDITY_WIDTH=3; // const int G_GDEX_LIMIT=-1; // store field constraints as named const int G_ADEX_LIMIT=-1; // constants const int G_EDEX_LIMIT=-1; // const int G_TDEX_LIMIT=-1; // const int G_CDEX_LIMIT=-1; // const int G_HUMIDITY_LIMIT=0; // const string G_SPARE_STRING="23CO"; // const string G_GDEX_LABEL="Gdex: "; // store the field labels as named const string G_ADEX_LABEL="Adex: "; // constants for future reference const string G_EDEX_LABEL="Edex: "; // const string G_TDEX_LABEL="Tdex: "; // const string G_CDEX_LABEL="Cdex: "; // const string G_DATE_LABEL="Date: "; // const string G_START_LABEL="Start: "; // const string G_STOP_LABEL="Stop: "; // const string G_TEMP_LABEL="Temp: "; // const string G_HUMIDITY_LABEL="Humidity: "; // const string G_SPARE_LABEL="Spare: "; // const char G_FLD_SEPARATOR=' '; // for formatting record output class GameRecord { public: // Constructors GameRecord(); // parameterless GameRecord(int gameIndex); // w/specified Game Index GameRecord(int gameIndex,int alleyIndex, // w/specifed Game, Alley, Event, int eventIndex,int toolsIndex, // Tools, & Conditions Indices int conditionsIndex); // Observers bool LessThan(GameRecord another); // Is this record < another? bool GreaterThan(GameRecord another); // Is this record > another? bool Equals(GameRecord another); // Is this record==another? DataErrorType fieldOK(GameFieldType fieldToCheck); // Is the field valid? string FieldContains(GameFieldType fieldToPrint); // What's stored in // a particular field string FieldDefault(GameFieldType fieldToCheck); // Find the default of // a particular field string FieldLimits(GameFieldType fieldToCheck); // Describe the limits on // a particular field string FieldLabel(GameFieldType fieldToPrint); // Print the field's label int FieldWidth(GameFieldType fieldToCheck); // Find size of the field int IndexIs(); // What is the index of this record? // Transformers void NewIndex(int newIndexValue); // Change the index of the record void Update(string dataString, // Change a field in the record GameFieldType fieldToChange); // to a different value void Reset(GameFieldType fieldToChange); // Reset a field to its default void Reset(); // Reset all fields to their defaults void Replace(GameRecord newRecord); // Replace the values in all fields // with those in another record // Iterators string List(); // Produce a string w/the record data formated for the screen string Print(); // Produce a string w/record data formatted for a BAM file string BriefList(); // Produce a string w/abbreviated record data private: LimitInt gdex; LimitInt adex; LimitInt edex; LimitInt tdex; LimitInt cdex; DateType date; TimeType start; TimeType stop; LimitFloat temp; LimitInt humidity; setChar spare; }; #endif