// Cqc.h - CUSTOMER QUERY CACHE DECLARATIONS // // MAINTENANCE HISTORY // DATE PROGRAMMER AND DETAILS // 25-09-10 JS Original // //----------------------------------------------------------------------------- // CUSTOMER DATA STRUCTURE struct Cust_t { long custId; // Customer identifier string custName; // Customer name Cust_t () {} // Default constructor Cust_t (const Cust_t &cust) : custId (cust.custId), custName (cust.custName) {} // Copy constructor Cust_t &operator = (const Cust_t &cust) { custId = cust.custId; custName = cust.custName; } // Assignment operator }; //----------------------------------------------------------------------------- // CUSTOMER QUERY CACHE class Cqc_c { // Customer Data Comparator struct CustCmp_c { inline bool operator () ( const Cust_t &c1, // First customer record const Cust_t &c2) // Second cusomer record { return c1.custId < c2.custId; } }; // Customer Data Set Type Definition typedef set CqcCustSet_t; // Customer set type typedef CqcCustSet_t::iterator CqcCustIter_t; // Customer set iterator // Class Instance Variables CqcCustSet_t cqcCustSet; // Customer set CqcCustIter_t cqcCustIter; // Customer iterator // Public Methods public: void CqcInsert (const Cust_t *cust); // Insert a customer record into the cache void CqcRemove (long custId); // Remove the customer record with customer // identifier 'custId' from the cache void CqcSelect (const char *key); // Select the customers with names that // match 'key'. 'key' may contain wild cards. // For example, "*" selects all customers. const Cust_t *CqcNextCust (); // Return a pointer to the next selected // customer data structure, return zero at // end-of-file. };