// this is the interface for mediaClass which stores data on multimedia #ifndef MEDIA_CLASS_H #define MEDIA_CLASS_H #include "globals.h" class mediaClass { private: bool flagData; // flags whether item is being used int priceData; // stores price in cents string typeData, // stores type field availData, // stores availability field titleData, // stores title field authorData, // stores author field ownerData; // stores owner field public: // MUTATORS: virtual void flag( const bool FLAG ) { flagData = FLAG; } // sets whether an item is in use // PARAMETERS: // bool FLAG value to set flagData to // PRE-CONDITIONS // none // POST-CONDITIONS // flagData == FLAG // RETURNS // void // CALLS // none // CALLED BY // commandClass:: remove // mediaClass:: readAll // mediaClass bool readAll( istream& ); // reads in item data from a stream // PARAMETERS: // istream& inStream stream with data // PRE-CONDITIONS // none // POST-CONDITIONS // data has been read from inStream and assigned appropriately to fields // RETURNS // bool whether read was successful // CALLS // none // CALLED BY // mediaClass:: mediaClass virtual bool type( istream& ); // sets type field // PARAMETERS: // istream& inStream // PRE-CONDITIONS // none // POST-CONDITIONS // typeData has been set from inStream // RETURNS // bool whether assignment was successful // CALLS // none // CALLED BY // mediaClass:: readAll virtual bool avail( istream& ); // sets availability field // PARAMETERS: // istream& inStream // PRE-CONDITIONS // none // POST-CONDITIONS // availData has been set from inStream // RETURNS // bool whether assignment was successful // CALLS // none // CALLED BY // mediaClass:: readAll virtual bool title( istream& ); // sets title field // PARAMETERS: // istream& inStream // PRE-CONDITIONS // none // POST-CONDITIONS // titleData has been set from inStream // RETURNS // bool whether assignment was successful // CALLS // none // CALLED BY // mediaClass:: readAll virtual bool author( istream& ); // sets author field // PARAMETERS: // istream& inStream // PRE-CONDITIONS // none // POST-CONDITIONS // authoData has been set from inStream // RETURNS // bool whether assignment was successful // CALLS // none // CALLED BY // mediaClass:: readAll virtual bool owner( istream& ); // sets owner field // PARAMETERS: // istream& inStream // PRE-CONDITIONS // none // POST-CONDITIONS // ownerData has been set from inStream // RETURNS // bool whether assignment was successful // CALLS // none // CALLED BY // mediaClass:: readAll virtual bool price( istream& ); // sets price field // PARAMETERS: // istream& inStream // PRE-CONDITIONS // none // POST-CONDITIONS // priceData has been set from inStream // RETURNS // bool whether assignment was successful // CALLS // none // CALLED BY // mediaClass:: readAll // ACCESSORS: bool operator ==( const mediaClass& ITEM ) const; // checks whether two items match // PARAMETERS: // const mediaClass ITEM // PRE-CONDITIONS // none // POST-CONDITIONS // none // RETURNS // bool whether ITEM matches this // CALLS // none // CALLED BY // commandClass:: found bool ownedBy( const string MATCH ) const; // checks for an owner match // PARAMETERS: // const string MATCH // PRE-CONDITIONS // none // POST-CONDITIONS // none // RETURNS // bool whether MATCH == emailData // CALLS // none // CALLED BY // commandClass // main virtual bool flag() const { return flagData; } // signals whether item is being used // PARAMETERS: // none // PRE-CONDITIONS // none // POST-CONDITIONS // none // RETURNS // flagData // CALLS // none // CALLED BY // commandClass string print( const bool ) const; // returns item info // PARAMETERS: // bool flags whether to include the owner field in output // PRE-CONDITIONS // none // POST-CONDITIONS // none // RETURNS // string item info // CALLS // none // CALLED BY // commandClass:: found string emailEcho() const { return ownerData; } // returns owner email address virtual string price() const; // returns correctly formatted price // PARAMETERS: // none // PRE-CONDITIONS // none // POST-CONDITIONS // none // RETURNS // string price in format $x.** with field flag // CALLS // none // CALLED BY // commandClass // the following accessor methods return the various field data formatted with the correct // field flag for output: virtual string type() const { return "Media Type:\n\t" + typeData + '\n'; } virtual string avail() const { return "Availability:\n\t" + availData + '\n'; } virtual string title() const { return "Item:\n\t" + titleData + '\n'; } virtual string author() const { return "by:\n\t" + authorData + '\n'; } virtual string owner() const { return "Owner:\n\t" + ownerData + '\n'; } // CONSTRUCTORS: mediaClass(); // default constructor // PARAMETERS: // none // PRE-CONDITIONS // none // POST-CONDITIONS // this is initialized with blank data // RETURNS // none // CALLS // none // CALLED BY // commandClass mediaClass( istream& ); // constructor that reads a stream into an item // PARAMETERS: // istream& inStream // PRE-CONDITIONS // none // POST-CONDITIONS // this is initialized with data from inStream // RETURNS // none // CALLS // none // CALLED BY // none }; bool operator >>( istream&, mediaClass& ); // reads into a mediaClass from a stream // PARAMETERS: // istream& inStream stream with data // mediaClass& item item to be read into // PRE-CONDITIONS // none // POST-CONDITIONS // data has been read from inStream and assigned appropriately to fields in item // RETURNS // bool whether read was successful // CALLS // mediaClass::readAll // CALLED BY // commandClass bool operator <<( ostream&, const mediaClass& ); // inserts item info into a stream // PARAMETERS: // ostream& outStream // const mediaClass ITEM // PRE-CONDITIONS // none // POST-CONDITIONS // ITEM's info has been inserted into outStream in correct format // RETURNS // bool whether operation was successful // CALLS // mediaClass::print // CALLED BY // commandClass #endif