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

DirectoryWatch.h

Go to the documentation of this file.
00001 /*  DirectoryWatch.h - encapsulates ReadDirectoryChangesW.
00002 
00003     Copyright (C) 2001-2004 Mark Weaver
00004     Written by Mark Weaver <mark@npsl.co.uk>
00005 
00006     Part of the Open-Win32 library.
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Library General Public
00009     License as published by the Free Software Foundation; either
00010     version 2 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Library General Public License for more details.
00016 
00017     You should have received a copy of the GNU Library General Public
00018     License along with this library; if not, write to the
00019     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00020     Boston, MA  02111-1307, USA.
00021 */
00022 
00028 #ifndef OW32_DirectoryWatch_h
00029 #define OW32_DirectoryWatch_h
00030 
00031 #include <OW32/IoCompletion.h>
00032 #include <OW32/RefCounted.h>
00033 #include <OW32/auto_array_ptr.h>
00034 #include <OW32/SyncObjects.h>
00035 
00036 #include <stl/ci_string.h>
00037 
00038 namespace OW32
00039 {
00040 
00041 class CIoCompletionThreadPool;
00042 class CDirectoryWatchCallback;
00043 
00054 class CDirectoryWatch : 
00055     public CIoCompletion, 
00056     public CRefCounted
00057 {
00058 public:
00059     IMPLEMENT_IO_COMPLETION(CDirectoryWatch);
00060 
00069     CDirectoryWatch(
00070         CDirectoryWatchCallback *callback,
00071         CIoCompletionThreadPool &ioCompletionPool,
00072         const ci_wstring        &directoryName,
00073         DWORD                   changesMask = FILE_NOTIFY_CHANGE_LAST_WRITE|FILE_NOTIFY_CHANGE_FILE_NAME
00074     );
00075 
00079     virtual ~CDirectoryWatch();
00080 
00084     const ci_wstring &getDirectory() const { return m_directory; }
00085 
00089     void cancel();
00090 
00091 private:
00092     // No copy or assignment
00093     CDirectoryWatch(const CDirectoryWatch &other);
00094     CDirectoryWatch &operator= (const CDirectoryWatch &other);
00095 
00099     void OnWatchCompletion(BOOL bRet, DWORD dwBytes, LPOVERLAPPED lpOS);
00100 
00104     void processNotifications();
00105 
00107     CDirectoryWatchCallback *m_callback;
00108 
00110     ci_wstring              m_directory;
00111 
00113     DWORD                   m_changesMask;
00114     
00116     OVERLAPPEDPLUS          m_os;
00117 
00119     auto_array_ptr<BYTE>    m_notifyBuffer;
00120 
00122     DWORD                   m_notifyBufferCount;
00123 
00125     CCriticalSection        m_directoryLock;
00126 
00128     XHANDLE                 m_hDirectory;
00129 };
00130 
00131 #ifdef _MSC_VER
00132 #pragma warning(default: 4251)
00133 #endif
00134 
00136 typedef CAutoRefCountedPtr<CDirectoryWatch> CDirectoryWatchPtr;
00137 
00138 } // namespace OW32
00139 
00140 #endif // OW32_DirectoryWatch_h

Generated on Sun Jun 5 01:29:17 2005 for OW32 by  doxygen 1.3.9.1