| 1 | // -------------------------------------------------------------------------- |
|---|
| 2 | // |
|---|
| 3 | // File |
|---|
| 4 | // Name: BackupStoreAccountDatabase.h |
|---|
| 5 | // Purpose: Database of accounts for the backup store |
|---|
| 6 | // Created: 2003/08/20 |
|---|
| 7 | // |
|---|
| 8 | // -------------------------------------------------------------------------- |
|---|
| 9 | |
|---|
| 10 | #ifndef BACKUPSTOREACCOUNTDATABASE__H |
|---|
| 11 | #define BACKUPSTOREACCOUNTDATABASE__H |
|---|
| 12 | |
|---|
| 13 | #include <memory> |
|---|
| 14 | #include <vector> |
|---|
| 15 | |
|---|
| 16 | #include "BoxTime.h" |
|---|
| 17 | |
|---|
| 18 | class _BackupStoreAccountDatabase; |
|---|
| 19 | |
|---|
| 20 | // -------------------------------------------------------------------------- |
|---|
| 21 | // |
|---|
| 22 | // Class |
|---|
| 23 | // Name: BackupStoreAccountDatabase |
|---|
| 24 | // Purpose: Database of accounts for the backup store |
|---|
| 25 | // Created: 2003/08/20 |
|---|
| 26 | // |
|---|
| 27 | // -------------------------------------------------------------------------- |
|---|
| 28 | class BackupStoreAccountDatabase |
|---|
| 29 | { |
|---|
| 30 | public: |
|---|
| 31 | friend class _BackupStoreAccountDatabase; // to stop compiler warnings |
|---|
| 32 | ~BackupStoreAccountDatabase(); |
|---|
| 33 | private: |
|---|
| 34 | BackupStoreAccountDatabase(const char *Filename); |
|---|
| 35 | BackupStoreAccountDatabase(const BackupStoreAccountDatabase &); |
|---|
| 36 | public: |
|---|
| 37 | |
|---|
| 38 | static std::auto_ptr<BackupStoreAccountDatabase> Read(const char *Filename); |
|---|
| 39 | void Write(); |
|---|
| 40 | |
|---|
| 41 | class Entry |
|---|
| 42 | { |
|---|
| 43 | public: |
|---|
| 44 | Entry(); |
|---|
| 45 | Entry(int32_t ID, int DiscSet); |
|---|
| 46 | Entry(const Entry &rEntry); |
|---|
| 47 | ~Entry(); |
|---|
| 48 | |
|---|
| 49 | int32_t GetID() const {return mID;} |
|---|
| 50 | int GetDiscSet() const {return mDiscSet;} |
|---|
| 51 | |
|---|
| 52 | private: |
|---|
| 53 | int32_t mID; |
|---|
| 54 | int mDiscSet; |
|---|
| 55 | }; |
|---|
| 56 | |
|---|
| 57 | bool EntryExists(int32_t ID) const; |
|---|
| 58 | Entry GetEntry(int32_t ID) const; |
|---|
| 59 | Entry AddEntry(int32_t ID, int DiscSet); |
|---|
| 60 | void DeleteEntry(int32_t ID); |
|---|
| 61 | |
|---|
| 62 | // This interface should change in the future. But for now it'll do. |
|---|
| 63 | void GetAllAccountIDs(std::vector<int32_t> &rIDsOut); |
|---|
| 64 | |
|---|
| 65 | private: |
|---|
| 66 | void ReadFile() const; // const in concept only |
|---|
| 67 | void CheckUpToDate() const; // const in concept only |
|---|
| 68 | box_time_t GetDBFileModificationTime() const; |
|---|
| 69 | |
|---|
| 70 | private: |
|---|
| 71 | mutable _BackupStoreAccountDatabase *pImpl; |
|---|
| 72 | }; |
|---|
| 73 | |
|---|
| 74 | #endif // BACKUPSTOREACCOUNTDATABASE__H |
|---|
| 75 | |
|---|