From: Christian P. <cp...@us...> - 2005-01-03 13:50:56
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/IO In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19210/include/pclasses/IO Modified Files: IODevice.h Added Files: IOFilter.h Log Message: Added IOFilter support to IODevice. Updated classes that inherit from IODevice. Fixed some minor bugs in ProcessIO class. --- NEW FILE: IOFilter.h --- /*************************************************************************** * Copyright (C) 2004 by Christian Prochnow * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as * * published by the Free Software Foundation; either version 2 of the * * License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef P_IO_IOFilter_h #define P_IO_IOFilter_h #include <pclasses/IO/IOError.h> #include <pclasses/IO/IODevice.h> namespace P { namespace IO { class IOFilter { public: IOFilter(); virtual ~IOFilter(); void setDevice(IODevice* dev); virtual IOFilter* create(); virtual void sync(); virtual bool isSeekable(); virtual size_t read(char* buffer, size_t count) throw(IOError); virtual size_t write(const char* buffer, size_t count) throw(IO::IOError); virtual size_t peek(char* buffer, size_t count) throw(IOError); virtual offset_t seek(offset_t offset, IODevice::SeekMode mode) throw(IOError); virtual offset_t size() const throw(IOError); IODevice* device() const throw(); private: IODevice* _dev; }; } } // !namespace P #endif Index: IODevice.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/IO/IODevice.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- IODevice.h 1 Jan 2005 19:00:08 -0000 1.3 +++ IODevice.h 3 Jan 2005 13:50:44 -0000 1.4 @@ -28,12 +28,14 @@ namespace IO { +class IOFilter; class IOListener; //! I/O Device base class class IODevice { public: friend class IOListener; + friend class IOFilter; enum OpenMode { OpenCreate, @@ -64,24 +66,24 @@ IODevice() throw(); virtual ~IODevice() throw(); - virtual void close() throw(IOError) = 0; + void close() throw(IOError); - virtual size_t read(char* buffer, size_t count) throw(IOError) = 0; + size_t read(char* buffer, size_t count) throw(IOError); - virtual size_t peek(char* buffer, size_t count) throw(IOError); + size_t write(const char* buffer, size_t count) + throw(IOError); - virtual size_t write(const char* buffer, size_t count) - throw(IOError) = 0; + bool isSeekable() const throw(); - virtual bool isSeekable() const throw(); + offset_t seek(offset_t offset, SeekMode mode) throw(IOError); - virtual offset_t seek(offset_t offset, SeekMode mode) throw(IOError); + size_t peek(char* buffer, size_t count) throw(IOError); - virtual offset_t getPos() throw(IOError); + void sync() const throw(IOError); - virtual void sync() const throw(IOError); + offset_t getPos() throw(IOError); - virtual offset_t size() const throw(IOError); + offset_t size() const throw(IOError); bool valid() const throw(); @@ -89,10 +91,30 @@ bool eof() const throw(); + void setFilter(IOFilter* filter) throw(LogicError); + IOFilter* filter() const throw(); + protected: IODevice(const IODevice& dev) throw(); IODevice& operator=(const IODevice& dev) throw(); + virtual void _close() throw(IOError) = 0; + + virtual size_t _read(char* buffer, size_t count) throw(IOError) = 0; + + virtual size_t _write(const char* buffer, size_t count) + throw(IOError) = 0; + + virtual bool _isSeekable() const throw(); + + virtual offset_t _seek(offset_t offset, SeekMode mode) throw(IOError); + + virtual size_t _peek(char* buffer, size_t count) throw(IOError); + + virtual void _sync() const throw(IOError); + + virtual offset_t _size() const throw(IOError); + void setValid(bool v) throw(); void setAccess(AccessMode mode) throw(); void setEof(bool eof) throw(); @@ -102,6 +124,8 @@ virtual void removeListener(IOListener& l); private: + IOFilter* _filter; + bool _filterOwner; bool _valid; AccessMode _access; bool _eof; |