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

UndoStack.h

Go to the documentation of this file.
00001 
00002 // Name:        UndoStack.h
00003 // Purpose:     
00004 // Author:      Joe Yates
00005 // Modified by:
00006 // Created:     11/10/2004
00007 // RCS-ID:      $Id: UndoStack.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 __UndoStack_h__
00013 #define __UndoStack_h__
00014 
00015 #include <Undo.h>
00016 
00017 #define shFILECHANGE_MOVE       wxT("FileMove")
00018 #define shFILECHANGE_TOWASTEBIN wxT("FileToWastebin")
00019 #define shFILECHANGE_RESTORE    wxT("FileRestore")
00020 #define shFILECHANGE_CREATE     wxT("FileCreate")
00021 
00022 namespace Undo
00023 {
00024 
00029 class FileChange
00030   {
00031   // friends, classes, enums and types
00032 
00033   // Constructors/destructors
00034   public:
00035     FileChange(wxString const& sType, wxString const& sPathName) :
00036       m_sType(sType),
00037       m_sPathName(sPathName)
00038       {}
00039     virtual ~FileChange()
00040       {}
00041 
00042   public:
00043     wxString GetType()
00044       {
00045       return m_sType;
00046       }
00047     wxString GetPathName()
00048       {
00049       return m_sPathName;
00050       }
00051     virtual wxString ToString() = 0;
00052 
00053   protected:
00054     wxString m_sType;
00055     wxString m_sPathName;
00056   };
00057 
00058 class FileMove : public FileChange
00059   {
00060   // Constructors/destructors
00061   public:
00062     FileMove(wxString const& sOldPathName, wxString const& sNewPathName) :
00063       FileChange(shFILECHANGE_MOVE, sOldPathName),
00064       m_sNewPathName(sNewPathName)
00065       {}
00066     virtual ~FileMove()
00067       {}
00068 
00069   public:
00070     wxString GetNewPathName()
00071       {
00072       return m_sNewPathName;
00073       }
00074     virtual wxString ToString()
00075       {
00076       return GetType() << wxT(": ") << GetPathName() << wxT(" -> ") << m_sNewPathName;
00077       }
00078 
00079   public:
00080     wxString m_sNewPathName;
00081   };
00082 
00083 class FileToWastebin : public FileChange
00084   {
00085   // Constructors/destructors
00086   public:
00087     FileToWastebin(wxString const& sPathName, int nWastebinId) :
00088       FileChange(shFILECHANGE_TOWASTEBIN, sPathName),
00089       m_nWastebinId(nWastebinId)
00090       {}
00091     virtual ~FileToWastebin()
00092       {}
00093 
00094   public:
00095     virtual wxString ToString()
00096       {
00097       return GetType() << wxT(": ") << GetPathName() << wxT(" sent to wastebin");
00098       }
00099     int GetWastebinId()
00100       { return m_nWastebinId; }
00101 
00102   public:
00103     void SetPathName(const wxString& sPathName)
00104       { m_sPathName = sPathName; }
00105     void SetWastebinId(int nWastebinId)
00106       { m_nWastebinId = m_nWastebinId; }
00107 
00108   private:
00109     int m_nWastebinId; // Allows us to restore
00110   };
00111 
00112 class FileRestore : public FileChange
00113   {
00114   // Constructors/destructors
00115   public:
00116     FileRestore(wxString const& sPathName) :
00117       FileChange(shFILECHANGE_RESTORE, sPathName)
00118       {}
00119     virtual ~FileRestore()
00120       {}
00121 
00122   public:
00123     virtual wxString ToString()
00124       {
00125       return GetType() << wxT(": ") << GetPathName();
00126       }
00127   };
00128 
00129 class FileCreate : public FileChange
00130   {
00131   // Constructors/destructors
00132   public:
00133     FileCreate(wxString const& sPathName) :
00134       FileChange(shFILECHANGE_CREATE, sPathName)
00135       {}
00136     virtual ~FileCreate()
00137       {}
00138 
00139   public:
00140     virtual wxString ToString()
00141       {
00142       return GetType() << wxT(": ") << GetPathName();
00143       }
00144   };
00145 
00146 class UndoStack : public Undo::DeletingStack<FileChange *>
00147   {
00148   // friends, classes, enums and types
00149   // Constructors/destructors
00150   public:
00151     UndoStack();
00152   // Operators
00153   // Slots
00154   // Methods
00155   public:
00156     wxString Dump();
00157   // Members
00158   };
00159 
00160 } // namespace Undo
00161 
00162 
00163 #endif // ndef __UndoStack_h__

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