#ifndef EVENTRECORD_H #define EVENTRECORD_H // eventrecord.h Interface file for the EventRecordType class /******************************************************************************* // MODULE NAME: EventRecord // INTERFACE FILE: eventrecord.h // IMPLEMENTATION FILE: eventrecord.cpp // // PURPOSE: To provide an EventRecord 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 // EventRecord Paramterless constructor // EventRecord Constructor w/specified Ball Index // 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 an 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 "balstring.h" // for BALString #include "balchar.h" // for setChar #include "errortype.h" // for error reporting using namespace std; typedef enum{ E_EDEX, // Event index E_EVENT, // Type of event E_TITLE // Event name } EventFieldType; const int E_EDEX_WIDTH=5; // store the field widths as named constants const int E_TITLE_WIDTH=20; // const int E_EDEX_LIMIT=-1; // store the field constraints as const string E_EVENT_STRING="54TSPO"; // named constants const string E_EDEX_LABEL="Edex: "; // store the field labels as const string E_EVENT_LABEL="Event: "; // named constants const string E_TITLE_LABEL="Title: "; // const char E_FLD_SEPARATOR=' '; // for formatting tabular output class EventRecord { public: // Constructors EventRecord(); // parameterless EventRecord(int eventIndex); // w/specified Event Index // Observers bool LessThan(EventRecord another); // Is this record < another? bool GreaterThan(EventRecord another); // Is this record > another? bool Equals(EventRecord another); // Is this record==another? DataErrorType fieldOK(EventFieldType fieldToCheck); // Is the field valid? string FieldContains(EventFieldType fieldToPrint); // What's stored in the // field string FieldDefault(EventFieldType fieldToCheck); // Find the default of // a particular field string FieldLimits(EventFieldType fieldToCheck); // What are the limits on // a particular field? string FieldLabel(EventFieldType fieldToPrint); // Print the field's label int FieldWidth(EventFieldType fieldToCheck); // What is the field's size? 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 EventFieldType fieldToChange); // to a different value void Reset(EventFieldType fieldToChange); // Reset a field to its default void Reset(); // Reset all fields to their defaults void Replace(EventRecord newRecord); // Replace all fields with 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 string BriefList(); // Produce shorter screen listing private: LimitInt edex; setChar event; BALString title; }; #endif