From: Christian P. <cp...@us...> - 2005-05-25 08:03:05
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/IO In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4874/include/pclasses/IO Modified Files: IOManager.h Makefile.am Added Files: IOHandler.h IORequest.h Log Message: - Reintroducing Transparent Network I/O architecture --- NEW FILE: IOHandler.h --- /*************************************************************************** * Copyright (C) 2005 by Christian Prochnow, SecuLogiX GmbH * * 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_IOHandler_h #define P_IO_IOHandler_h #include <pclasses/Export.h> #include <pclasses/IO/URL.h> #include <pclasses/IO/IORequest.h> namespace P { namespace IO { //! IORequest handler class PIO_EXPORT IOHandler { public: IOHandler(); virtual ~IOHandler(); virtual IORequest_Get* get(const URL& url); virtual IORequest_Put* put(const URL& url); virtual IORequest_Unlink* unlink(const URL& url); virtual IORequest_MakeDir* mkdir(const URL& url); virtual IORequest_RemoveDir* rmdir(const URL& url); virtual IORequest_ListDir* lsdir(const URL& url); virtual void finish(IORequest* req) = 0; }; } // !namespace IO } // !namespace P #endif // !P_IO_IOHandler_h --- NEW FILE: IORequest.h --- /*************************************************************************** * Copyright (C) 2005 by Christian Prochnow, SecuLogiX GmbH * * 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_IORequest_h #define P_IO_IORequest_h #include <pclasses/Export.h> #include <pclasses/NonCopyable.h> #include <pclasses/IO/URL.h> namespace P { namespace IO { class PIO_EXPORT IORequest: public NonCopyable { public: IORequest(const URL& url); virtual ~IORequest(); const URL& url() const throw(); virtual void open() = 0; virtual void close() = 0; private: URL _url; }; class PIO_EXPORT IORequest_Get: public IORequest { public: IORequest_Get(const URL& url); ~IORequest_Get(); virtual size_t read(char* buffer, size_t count) = 0; }; class PIO_EXPORT IORequest_Put: public IORequest { public: IORequest_Put(const URL& url); ~IORequest_Put(); virtual size_t write(const char* buffer, size_t count) = 0; }; class PIO_EXPORT IORequest_Unlink: public IORequest { public: IORequest_Unlink(const URL& url); ~IORequest_Unlink(); virtual void doit() = 0; }; class PIO_EXPORT IORequest_MakeDir: public IORequest { public: IORequest_MakeDir(const URL& url); ~IORequest_MakeDir(); virtual void doit() = 0; }; class PIO_EXPORT IORequest_RemoveDir: public IORequest { public: IORequest_RemoveDir(const URL& url); ~IORequest_RemoveDir(); virtual void doit() = 0; }; class PIO_EXPORT IORequest_ListDir: public IORequest { public: IORequest_ListDir(const URL& url); ~IORequest_ListDir(); virtual size_t read(char* buffer, size_t count) = 0; }; } // !namespace IO } // !namespace P #endif // !P_IO_IORequest_h Index: Makefile.am =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/IO/Makefile.am,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- Makefile.am 16 Jan 2005 00:08:01 -0000 1.7 +++ Makefile.am 25 May 2005 08:02:56 -0000 1.8 @@ -2,4 +2,6 @@ INCLUDES = METASOURCES = AUTO -pclasses_io_include_HEADERS = IOError.h IODevice.h IOStream.h IOFilter.h URL.h ZLib.h ZLibIOFilter.h BZip2.h BZip2IOFilter.h +pclasses_io_include_HEADERS = IOError.h IODevice.h IOStream.h IOFilter.h \ + URL.h ZLib.h ZLibIOFilter.h BZip2.h BZip2IOFilter.h IORequest.h \ + IOHandler.h IOManager.h Index: IOManager.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/IO/IOManager.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- IOManager.h 6 Jan 2005 17:02:03 -0000 1.5 +++ IOManager.h 25 May 2005 08:02:56 -0000 1.6 @@ -1,73 +1,72 @@ -#ifndef P_IOMANAGER_HPP_INCLUDED -#define P_IOMANAGER_HPP_INCLUDED 1 +/*************************************************************************** + * Copyright (C) 2005 by Christian Prochnow, SecuLogiX GmbH * + * 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_IOManager_h +#define P_IO_IOManager_h + +#include <pclasses/Export.h> +#include <pclasses/IO/URL.h> +#include <pclasses/IO/IORequest.h> + +#include <map> +#include <string> -#include "pclasses/Factory.h" -#include "pclasses/Plugin/Plugin.h" -#include "pclasses/IO/URL.h" namespace P { + namespace IO { - /** - IOManager is a PluginManager intended specifically for use with - the P::IO layer. - */ - template <typename InterfaceT> - class IOManager : public ::P::Factory<InterfaceT> - { +class IOHandler; + +class PIO_EXPORT IOManager { public: - typdef IOManager<InterfaceT> ThisType; - typedef ::P::PluginManager<InterfaceT> ParentType; - typedef typename ParentType::FactoryFuncType FactoryFuncType; - typedef typename ParentType::ResultType ResultType; - IOManager(){} - virtual ~IOManager(){} + IOManager(); + ~IOManager(); + IORequest_Get* get(const URL& url); + IORequest_Put* put(const URL& url); - /** - Returns a shared instance of this object. + IORequest_Unlink* unlink(const URL& url); - Clients may transparently replace or modify the - default returned object by specializing - P::Hook::FactoryInstanceHook<ThisType>. + IORequest_MakeDir* mkdir(const URL& url); + IORequest_RemoveDir* rmdir(const URL& url); - InterfaceT's which want to be loadable via DLL's - should install a FactoryInstanceHook to plug in the - DLL awareness. - */ - static ThisType & instance() - { - return ::P::Hook::FactoryInstanceHook<ThisType>::instance(); - } + IORequest_ListDir* lsdir(const URL& url); - /** - Returns this->registerFactory(_protocol.protocol()). - */ - void - registerFactory(const URL &_protocol, FactoryFuncType fp) - { - this->registerFactory( _protocol.protocol(), fp ) - } + void finish(IORequest* req); - /** - Returns this->create(_protocol.protocol()). - */ - ResultType create( const URL & _protocol ) - { - return this->create( _protocol.protocol() ); - } + static IOManager& instance(); + private: + IOHandler* findHandler(const std::string& proto); - /** - Returns this->provides(_protocol.protocol()). - */ - bool - provides(const URL &_protocol) const - { - return this->provides( _protocol.protocol() ); - } - }; // class IOManager + typedef std::map<std::string, IOHandler*> handler_map; + typedef std::map<IORequest*, IOHandler*> request_map; -} } // namespace P::IO + handler_map _handlers; + request_map _requests; +}; -#endif // P_IOMANAGER_HPP_INCLUDED +} // !namespace IO + +} // !namespace P + + +#endif // !P_IO_IOManager_h |