⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 record.hxx

📁 vovida的软交换
💻 HXX
字号:
/*
 * Record.hxx - 11/03/03
 *
 * Abstract Class used to define generic methods and fields that all Record
 * objects share. Sub-class this class to get a concrete class that can obtain, * modify and store that data that your client is interested in.
 *
 */

#ifndef RECORD_HXX
#define RECORD_HXX

//#include "cpLog.h"
#include "DBConnection.hxx"
#include "RecordTypes.h"

#include <ctime>

class Record
{
public:
    // class constructor
    Record();    
  
    // class destructor
    virtual ~Record();

    /*  
     * populates this object from the database.
     * key is the key used to retrieve information, dbcon is a connection  
     * to the database (provided by the DBManager)
     */
    virtual bool populateRecord(KeyType key, DBConnection* dbcon) = 0; 
 
    /*
     * amends this object in the database, returns true if nothing 
     * goes wrong  
     */
    virtual bool amendRecord(DBConnection* dbconn) = 0;

    /*
     * deletes this object from the database, 
     * returns true if nothing goes wrong
     */
    virtual bool deleteRecord(DBConnection* dbconn) = 0;

    /*
     * inserts this object in the database, 
     * returns true if nothing goes wrong
     */
    virtual bool insertRecord(DBConnection* dbconn) = 0;
    /* 
     * This function queries the database and returns a 
     * list of all the relavent keys that could be used 
     * to retrieve records of this type
     */
    virtual KeyList getAllKeys(DBConnection* dbconn) = 0;

    /*
     * The following methods have default implementations 
     * in this class 
     */

    /* 
     * Displays the record
     */
    virtual void displayRecord() { 
      displayRecord("Record.cxx");
    }
    void displayRecord(string prefix);

    /*
     * The rest of the public methods are not virtual 
     */

    /*
     * The following is a static member function of record 
     * that is used to produce the different types of concrete 
     * Record classes. 
     */
    static Record* createNewRecord(RecordType rec);

    /* 
     * The following function provides an exact duplicate of the record 
     * in the provided memory space. The caching system requires this.
     */
    virtual Record* clone() = 0;
  
    /*
     * Standard get/set methods for the protected members
     */
    KeyType getKey() {return key;};
    time_t getLastAccessed() {return lastAccessed;};
    RecordType getRecordType() {return recordType;};

    static string stringRecordType(RecordType rec);
    static RecordType convertStrRType(string s);

    void setKey(KeyType newKey) {key = newKey;};
    void setLastAccessed(time_t newLastAccessed) {lastAccessed = newLastAccessed;};

protected:
    KeyType key;             // The key that was used to get/set this record 
    time_t lastAccessed;     // Datestamp of last access

    void setRecordType(RecordType newRecordType) { recordType = newRecordType; };
    void copyData(Record* rec);
    
    
private:

  static const string TEST_REC_STR;
  static const string GENERIC_REC_STR;
  static const string UPDATE_REG_INFO_REC_STR;

  RecordType recordType; // Type of record (set in constructor)



};

#endif // RECORD_HXX

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -