--------------------- PatchSet 259 Date: 2002/12/05 21:40:40 Author: rbcollins Branch: unify-io Tag: (none) Log: remove knowledge of the file type from fooOpen Members: src/ufscommon.h:1.1.20.4->1.1.20.5 src/fs/diskd/store_diskd.h:1.1.20.15->1.1.20.16 src/fs/diskd/store_io_diskd.cc:1.1.20.16->1.1.20.17 src/fs/ufs/store_io_ufs.cc:1.3.10.10->1.3.10.11 src/fs/ufs/store_ufs.h:1.1.20.8->1.1.20.9 Index: squid3/src/ufscommon.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ufscommon.h,v retrieving revision 1.1.20.4 retrieving revision 1.1.20.5 diff -u -r1.1.20.4 -r1.1.20.5 --- squid3/src/ufscommon.h 5 Dec 2002 12:57:32 -0000 1.1.20.4 +++ squid3/src/ufscommon.h 5 Dec 2002 21:40:40 -0000 1.1.20.5 @@ -1,6 +1,6 @@ /* - * $Id: ufscommon.h,v 1.1.20.4 2002/12/05 12:57:32 rbcollins Exp $ + * $Id: ufscommon.h,v 1.1.20.5 2002/12/05 21:40:40 rbcollins Exp $ * * SQUID Web Proxy Cache http://www.squid-cache.org/ * ---------------------------------------------------------- @@ -96,6 +96,18 @@ virtual bool error() const = 0; }; +#include "IOStrategy.h" +class UFSStrategy : public IOStrategy +{ +public: + virtual bool shedLoad() = 0; + virtual void deleteSelf() const = 0; + virtual void openFailed(){} + virtual int load(){return -1;} + virtual StoreIOState::Pointer createState(SwapDir *, StoreEntry *, STIOCB *, void *)const = 0; + virtual DiskFile::Pointer newFile (char const *path) = 0; +}; + /* Common ufs-store-dir logic */ class UFSStoreState : public storeIOState, public IORequestor { public: Index: squid3/src/fs/diskd/store_diskd.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/diskd/Attic/store_diskd.h,v retrieving revision 1.1.20.15 retrieving revision 1.1.20.16 diff -u -r1.1.20.15 -r1.1.20.16 --- squid3/src/fs/diskd/store_diskd.h 5 Dec 2002 21:12:25 -0000 1.1.20.15 +++ squid3/src/fs/diskd/store_diskd.h 5 Dec 2002 21:40:40 -0000 1.1.20.16 @@ -142,7 +142,7 @@ extern diskd_stats_t diskd_stats; #include "IOStrategy.h" -class DiskdIO : public IOStrategy +class DiskdIO : public UFSStrategy { public: DiskdIO(); @@ -151,6 +151,7 @@ virtual void openFailed(); virtual int load(); virtual StoreIOState::Pointer createState(SwapDir *SD, StoreEntry *e, STIOCB * callback, void *callback_data) const; + virtual DiskFile::Pointer newFile (char const *path); int away; int magic1; int magic2; Index: squid3/src/fs/diskd/store_io_diskd.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/diskd/Attic/store_io_diskd.cc,v retrieving revision 1.1.20.16 retrieving revision 1.1.20.17 diff -u -r1.1.20.16 -r1.1.20.17 --- squid3/src/fs/diskd/store_io_diskd.cc 5 Dec 2002 21:12:25 -0000 1.1.20.16 +++ squid3/src/fs/diskd/store_io_diskd.cc 5 Dec 2002 21:40:41 -0000 1.1.20.17 @@ -1,6 +1,6 @@ /* - * $Id: store_io_diskd.cc,v 1.1.20.16 2002/12/05 21:12:25 rbcollins Exp $ + * $Id: store_io_diskd.cc,v 1.1.20.17 2002/12/05 21:40:41 rbcollins Exp $ * * DEBUG: section 79 Squid-side DISKD I/O functions. * AUTHOR: Duane Wessels @@ -93,6 +93,13 @@ return new diskdstate_t (SD, e, callback, callback_data); } +DiskFile::Pointer +DiskdIO::newFile (char const *path) +{ + return new DiskdFile (path, this); +} + + /* * SHM manipulation routines */ @@ -347,7 +354,8 @@ diskdstate_t *diskdstate = dynamic_cast(sio.getRaw()); char *path = commonUfsDirFullPath(SD, e->swap_filen, NULL); - DiskFile::Pointer myFile = new DiskdFile (path, (DiskdIO *)SD->IO); + UFSStrategy *IO = dynamic_cast(SD->IO); + DiskFile::Pointer myFile = IO->newFile (path); diskdstate->theFile = myFile; diskdstate->opening = true; Index: squid3/src/fs/ufs/store_io_ufs.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/ufs/store_io_ufs.cc,v retrieving revision 1.3.10.10 retrieving revision 1.3.10.11 diff -u -r1.3.10.10 -r1.3.10.11 --- squid3/src/fs/ufs/store_io_ufs.cc 5 Dec 2002 12:57:33 -0000 1.3.10.10 +++ squid3/src/fs/ufs/store_io_ufs.cc 5 Dec 2002 21:40:41 -0000 1.3.10.11 @@ -1,6 +1,6 @@ /* - * $Id: store_io_ufs.cc,v 1.3.10.10 2002/12/05 12:57:33 rbcollins Exp $ + * $Id: store_io_ufs.cc,v 1.3.10.11 2002/12/05 21:40:41 rbcollins Exp $ * * DEBUG: section 79 Storage Manager UFS Interface * AUTHOR: Duane Wessels @@ -64,6 +64,12 @@ return new ufsstate_t (SD, e, callback, callback_data); } +DiskFile::Pointer +UfsIO::newFile (char const *path) +{ + return new UFSFile (path); +} + CBDATA_CLASS_INIT(ufsstate_t); void * @@ -170,7 +176,8 @@ ufsstate_t *ufs = dynamic_cast(sio.getRaw()); char *path = commonUfsDirFullPath(SD, e->swap_filen, NULL); - DiskFile::Pointer myFile = new UFSFile (path); + UFSStrategy *IO = dynamic_cast(SD->IO); + DiskFile::Pointer myFile = IO->newFile (path); ufs->theFile = myFile; ufs->opening = true; Index: squid3/src/fs/ufs/store_ufs.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/ufs/Attic/store_ufs.h,v retrieving revision 1.1.20.8 retrieving revision 1.1.20.9 diff -u -r1.1.20.8 -r1.1.20.9 --- squid3/src/fs/ufs/store_ufs.h 5 Dec 2002 12:57:33 -0000 1.1.20.8 +++ squid3/src/fs/ufs/store_ufs.h 5 Dec 2002 21:40:41 -0000 1.1.20.9 @@ -51,12 +51,13 @@ extern STOBJWRITE storeUfsWrite; extern STOBJUNLINK storeUfsUnlink; #include "IOStrategy.h" -class UfsIO : public IOStrategy +class UfsIO : public UFSStrategy { public: virtual bool shedLoad(); virtual void deleteSelf() const; virtual StoreIOState::Pointer createState(SwapDir *SD, StoreEntry *e, STIOCB * callback, void *callback_data) const; + virtual DiskFile::Pointer newFile (char const *path); static UfsIO Instance; };