#ifndef FRAMERECORD_H #define FRAMERECORD_H // framerecord.h Interface file for the FrameRecord class /******************************************************************************* // MODULE NAME: FrameRecord // INTERFACE FILE: framerecord.h // IMPLEMENTATION FILE: framerecord.cpp // // PURPOSE: To provide a FrameRecord 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 // FrameRecord Paramterless constructor // FrameRecord Constructor w/specified Game Index // FrameRecord Constructor w/specified gdex, bdex, rdex // 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 // 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 "ballane.h" // for LaneType #include "balchar.h" // for setChar #include "balfloat.h" // for LimitFloat #include "errortype.h" // for error reporting using namespace std; typedef enum { F_GDEX, // Game index F_LANES, // Lanes F_FRAME, // Frame number F_SHOT, // Shot number F_BDEX, // Ball index F_RDEX, // Release index F_APPROACH, // Feet location F_FEET, // Feet horizontal F_MARK, // Board target F_ACCURACY, // Target hit/miss F_PINHIT, // Ball impact point F_SCORE, // Ball score F_LEAVE // Spare difficulty } FrameFieldType; const int F_GDEX_WIDTH=5; // store the field widths as named constants const int F_FRAME_WIDTH=2; // const int F_SHOT_WIDTH=2; // const int F_BDEX_WIDTH=5; // const int F_RDEX_WIDTH=5; // const int F_APPROACH_WIDTH=4; // const int F_FEET_WIDTH=4; // const int F_MARK_WIDTH=4; // const int F_ACCURACY_WIDTH=4; // const int F_PINHIT_WIDTH=4; // const int F_GDEX_LIMIT=-1; // store field constraints as const int F_BDEX_LIMIT=-1; // named constants const int F_RDEX_LIMIT=-1; // const int F_FRAME_LOWER_LIMIT=0; // const int F_FRAME_UPPER_LIMIT=11; // const int F_SHOT_LOWER_LIMIT=0; // const int F_SHOT_UPPER_LIMIT=22; // const float F_APPROACH_LOWER_LIMIT=0.0f; // const float F_APPROACH_UPPER_LIMIT=16.0f; // const float F_FEET_LOWER_LIMIT=-41.0f; // const float F_FEET_UPPER_LIMIT=41.0f; // const float F_MARK_LOWER_LIMIT=0.0f; // const float F_MARK_UPPER_LIMIT=40.0f; // const float F_ACCURACY_LOWER_LIMIT=-41.0f; // const float F_ACCURACY_UPPER_LIMIT=40.0f; // const float F_PINHIT_LOWER_LIMIT=0.0f; // const float F_PINHIT_UPPER_LIMIT=40.0f; // const string F_SCORE_STRING="0123456789X/-F"; // const string F_LEAVE_STRING="SWD"; // const string F_GDEX_LABEL="Gdex: "; // store the field labels as named const string F_LANES_LABEL="Lanes: "; // constants for future reference const string F_FRAME_LABEL="Frame: "; // const string F_SHOT_LABEL="Shot: "; // const string F_BDEX_LABEL="Bdex: "; // const string F_RDEX_LABEL="Rdex: "; // const string F_APPROACH_LABEL="Approach: "; // const string F_FEET_LABEL="Feet: "; // const string F_MARK_LABEL="Mark: "; // const string F_ACCURACY_LABEL="Accuracy: "; // const string F_PINHIT_LABEL="PinHit: "; // const string F_SCORE_LABEL="Score: "; // const string F_LEAVE_LABEL="Leave: "; // const char F_FLD_SEPARATOR=' '; // for formatting record output const int F_GDEX_MULTIPLIER=100; // for outputting unique index class FrameRecord { public: // Constructors FrameRecord(); // parameterless FrameRecord(int gameIndex); // w/specified game index FrameRecord(int gameIndex,int ballIndex, // w/specified gdex, bdex, rdex int releaseIndex); // Observers bool LessThan(FrameRecord another); // Is this record < another? bool GreaterThan(FrameRecord another); // Is this record > another? bool Equals(FrameRecord another); // Is this record == another? DataErrorType fieldOK(FrameFieldType fieldToCheck); // Is the field valid? string FieldContains(FrameFieldType fieldToPrint); // What is stored in the // field string FieldDefault(FrameFieldType fieldToCheck); // Find the default for a // particular field string FieldLimits(FrameFieldType fieldToCheck); // Find the limits on // a particular field string FieldLabel(FrameFieldType fieldToPrint); // Print field's label int FieldWidth(FrameFieldType fieldToCheck); // What is size of 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 FrameFieldType fieldToChange); // to a different value void Reset(FrameFieldType fieldToChange); // Reset a field to its default void Reset(); // Reset all fields to their defaults void Replace(FrameRecord newRecord); // Replace the values in all fields // w/those in another record // Iterators string List(); // Produce a string w/the record data formatted for the screen string Print(); // Produce a string w/record data formatted for a report private: LimitInt gdex; LaneType lanes; LimitInt frame; LimitInt shot; LimitInt bdex; LimitInt rdex; LimitFloat approach; LimitFloat feet; LimitFloat mark; LimitFloat accuracy; LimitFloat pinHit; setChar score; setChar leave; }; #endif