Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

Wastebin.h

Go to the documentation of this file.
00001 
00002 // Name:        Wastebin.h
00003 // Purpose:     
00004 // Author:      Joe Yates
00005 // Modified by:
00006 // Created:     11/10/2004
00007 // RCS-ID:      $Id: Wastebin.h,v 1.1.1.1 2006/01/24 22:13:19 titusd Exp $
00008 // Copyright:   (c) BID Snc
00009 // License:     BSD license (see the file 'LICENSE.txt')
00011 
00012 #ifndef __Wastebin_h__
00013 #define __Wastebin_h__
00014 
00015 #define wxDBI_SQLITE
00016 #include <wx/dbi.h>
00017 
00018 namespace Waste
00019 {
00020 
00021 class File
00022   {
00023   // friends, classes, enums and types
00024   // Constructors/destructors
00025   public:
00026     File
00027       (
00028       const wxString& sPathName,
00029       const wxString& sFileType
00030       );
00031 
00032   protected:
00033     File
00034       (
00035       const wxString& sPathName,
00036       time_t          nAccessTime,
00037       time_t          nModificationTime,
00038       time_t          nCreationTime,
00039 #ifdef __UNIX__
00040       mode_t          nPermissions,
00041 #endif // def __UNIX__
00042       const wxString& sFileType,
00043       bool            bIsFile
00044       );
00045 
00046   // Operators
00047   // Methods
00048   public:
00049     wxString  GetPathName() const;
00050     time_t    GetAccessTime() const;
00051     time_t    GetModificationTime() const;
00052     time_t    GetCreationTime() const;
00053 #ifdef __UNIX__
00054     mode_t    GetPermissions() const;
00055 #endif // def __UNIX__
00056     wxString  GetFileType() const;
00057     bool      GetIsFile() const;
00058     virtual void Dump() const;
00059 
00060   // Members
00061   protected:
00062     wxString  m_sPathName;
00063     wxString  m_sFileType;
00064     bool      m_bIsFile;
00065     time_t    m_nAccessTime;
00066     time_t    m_nModificationTime;
00067     time_t    m_nCreationTime;
00068 #ifdef __UNIX__
00069     mode_t    m_nPermissions;
00070 #endif // def __UNIX__
00071   };
00072 
00077 class WastebinFile : public File
00078   {
00079   // friends, classes, enums and types
00080   friend class Bin; // Only the Bin can create us
00081 
00082   // Constructors/destructors
00083   protected:
00084     WastebinFile
00085       (
00086       int nItemId,
00087       const wxString& sPathName,
00088       time_t nDeletionTime,
00089       time_t nAccessTime,
00090       time_t nModificationTime,
00091       time_t nCreationTime,
00092 #ifdef __UNIX__
00093       mode_t nPermissions,
00094 #endif // def __UNIX__
00095       const wxString& sFileType,
00096       bool bIsFile
00097       );
00098 
00099   // Methods
00100   public:
00101     int     GetItemId() const;
00102     time_t  GetDeletionTime() const;
00103     virtual void Dump() const;
00104 
00105   // Members
00106   private:
00107     int     m_nItemId;
00108     time_t  m_nDeletionTime;
00109   };
00110 
00115 class RestoreFile : public WastebinFile
00116   {
00117   // friends, classes, enums and types
00118   friend class Bin; // Only the Bin can create us
00119 
00120   // Constructors/destructors
00121   protected:
00122     RestoreFile
00123       (
00124       int               nItemId,
00125       const wxString&   sPathName,
00126       time_t            nDeletionTime,
00127       time_t            nAccessTime,
00128       time_t            nModificationTime,
00129       time_t            nCreationTime,
00130 #ifdef __UNIX__
00131       mode_t            nPermissions,
00132 #endif // def __UNIX__
00133       const wxString&   sFileType,
00134       bool bIsFile,
00135       const wxString&   sNameInWastebin
00136       );
00137 
00138   // Methods
00139   public:
00140     bool    Restore();
00141     virtual void Dump() const;
00142 
00143   // Members
00144   private:
00145     wxString            m_sNameInWastebin;
00146   };
00147 
00148 class Bin : private wx::DBI::SQLite
00149   {
00150   // friends, classes, enums and types
00151   public:
00152     typedef bool (* EnumerateWastebinCallbackType)(const WastebinFile&);
00153 
00154   // Constructors/destructors
00155   public:
00156     Bin(const wxString& sWastebinPath);
00157 
00158   // Operators
00159   // Methods
00160   public:
00161     bool  Empty();
00162     int   GetCount();
00163     void  Enumerate(const EnumerateWastebinCallbackType fnCallback);
00164     virtual void Dump();
00165 
00166     int   Throw(File& dli);
00167     void  Delete(int nItemId);
00179     bool  Restore(int nItemId, wxString& sPathName);
00180 
00181   private:
00182     void  OpenDatabase(const wxString& sWastebinDatabasePathName);
00183 
00184   // Members
00185   private:
00186     wxString          m_sWastebinPath;
00187     wxString          m_sWastebinFilesPath;
00188     wx::DBI::StatementCache m_stc;
00189   };
00190 
00191 } // namespace Waste
00192 
00193 #endif // ndef __Wastebin_h__

Generated on Wed Jan 25 08:14:45 2006 for Sherpa by doxygen 1.3.6