#ifndef TOOLSRECORD_H #define TOOLSRECORD_H // toolsrecord.h Interface file for the ToolsRecord class /******************************************************************************* // MODULE NAME: ToolsRecord // INTERFACE FILE: toolsrecord.h // IMPLEMENTATION FILE: toolsrecord.cpp // // PURPOSE: To provide a ToolsRecord 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 // ToolsRecord Paramterless constructor // ToolsRecord Constructor w/specified Tools 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 string w/abbreviated record contents // 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 "errortype.h" // for error reporting using namespace std; typedef enum{ T_TDEX, // Tool index T_SHOES, // Shoes description T_GLOVE, // Gloves description T_OTHER // Other equipment description } ToolsFieldType; const int T_TDEX_WIDTH=5; // store the field widths as named constants const int T_SHOES_WIDTH=20; // const int T_GLOVE_WIDTH=20; // const int T_OTHER_WIDTH=10; // const int T_TDEX_LIMIT=-1; // store field constraint as named constant const string T_TDEX_LABEL="Tdex: "; // store the field labels as named const string T_SHOES_LABEL="Shoes: "; // constants for later reference const string T_GLOVE_LABEL="Glove: "; // const string T_OTHER_LABEL="Other: "; // const char T_FLD_SEPARATOR=' '; // for formatting tabular output class ToolsRecord { public: // Constructors ToolsRecord(); // parameterless ToolsRecord(int toolIndex); // w/specified Tools Index // Observers bool LessThan(ToolsRecord another); // Is this record < another? bool GreaterThan(ToolsRecord another); // Is this record > another? bool Equals(ToolsRecord another); // Is this record==another? DataErrorType fieldOK(ToolsFieldType fieldToCheck); // Is the field valid? string FieldContains(ToolsFieldType fieldToPrint); // Show what's stored in // a certain field string FieldDefault(ToolsFieldType fieldToCheck); // Find the default value // for a particular field string FieldLimits(ToolsFieldType fieldToCheck); // Show the limits in place // on a particular field string FieldLabel(ToolsFieldType fieldToPrint); // Print label of a field int FieldWidth(ToolsFieldType fieldToCheck); // Find print size of a 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 the value of a particular ToolsFieldType fieldToChange); // field of the record void Reset(ToolsFieldType fieldToChange); // Reset a field to its default void Reset(); // Reset all fields to their defaults void Replace(ToolsRecord newRecord); // Replace the value in all the fields // with those in another record // Iterators string List(); // Produce a string w/the record data formatted for the screen string BriefList(); // Produce an abbreviated listing of the record data string Print(); // Produce a string w/record data formatted for a report private: LimitInt tdex; BALString shoes; BALString glove; BALString other; }; #endif