From: Christian P. <cp...@us...> - 2005-05-25 08:03:05
|
Update of /cvsroot/pclasses/pclasses2/src/IO In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4874/src/IO Modified Files: Makefile.am Added Files: IOHandler.cpp IOManager.cpp IORequest.cpp Log Message: - Reintroducing Transparent Network I/O architecture --- NEW FILE: IOManager.cpp --- /*************************************************************************** * 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. * ***************************************************************************/ #include "pclasses/Phoenix.h" #include "pclasses/Factory.h" #include "pclasses/IO/IOManager.h" #include "pclasses/IO/IOHandler.h" namespace P { namespace IO { IOManager::IOManager() { } IOManager::~IOManager() { // cleanup requests ... request_map::iterator ri = _requests.begin(); while(ri != _requests.end()) { ri->second->finish(ri->first); request_map::iterator di = ri++; _requests.erase(di); } // cleanup handlers ... handler_map::iterator hi = _handlers.begin(); while(hi != _handlers.end()) { delete hi->second; handler_map::iterator di = hi++; _handlers.erase(di); } } IORequest_Get* IOManager::get(const URL& url) { IOHandler* handler = findHandler(url.protocol()); IORequest_Get* request = 0; if(handler) { request = handler->get(url); if(request) _requests.insert(std::make_pair(request, handler)); } return request; } IORequest_Put* IOManager::put(const URL& url) { IOHandler* handler = findHandler(url.protocol()); IORequest_Put* request = 0; if(handler) { request = handler->put(url); if(request) _requests.insert(std::make_pair(request, handler)); } return request; } IORequest_Unlink* IOManager::unlink(const URL& url) { IOHandler* handler = findHandler(url.protocol()); IORequest_Unlink* request = 0; if(handler) { request = handler->unlink(url); if(request) _requests.insert(std::make_pair(request, handler)); } return request; } IORequest_MakeDir* IOManager::mkdir(const URL& url) { IOHandler* handler = findHandler(url.protocol()); IORequest_MakeDir* request = 0; if(handler) { request = handler->mkdir(url); if(request) _requests.insert(std::make_pair(request, handler)); } return request; } IORequest_RemoveDir* IOManager::rmdir(const URL& url) { IOHandler* handler = findHandler(url.protocol()); IORequest_RemoveDir* request = 0; if(handler) { request = handler->rmdir(url); if(request) _requests.insert(std::make_pair(request, handler)); } return request; } IORequest_ListDir* IOManager::lsdir(const URL& url) { IOHandler* handler = findHandler(url.protocol()); IORequest_ListDir* request = 0; if(handler) { request = handler->lsdir(url); if(request) _requests.insert(std::make_pair(request, handler)); } return request; } void IOManager::finish(IORequest* req) { request_map::iterator i = _requests.find(req); if(i != _requests.end()) { i->second->finish(req); _requests.erase(i); } } IOHandler* IOManager::findHandler(const std::string& proto) { handler_map::const_iterator i = _handlers.find(proto); if(i != _handlers.end()) return i->second; IOHandler* handler = Factory<IOHandler>::instance().create("IOHandler_" + proto); if(handler) _handlers.insert(std::make_pair(proto, handler)); return handler; } struct IOManager_context_t { }; IOManager& IOManager::instance() { typedef Phoenix<IOManager, IOManager_context_t> PHX; return PHX::instance(); } } // !namespace IO } // !namespace P Index: Makefile.am =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/IO/Makefile.am,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- Makefile.am 20 May 2005 14:19:15 -0000 1.10 +++ Makefile.am 25 May 2005 08:02:55 -0000 1.11 @@ -5,7 +5,8 @@ CPPFLAGS = -DPIO_BUILD libpclasses_io_la_SOURCES = IOError.cpp IODevice.cpp IOStream.cpp \ - IOFilter.cpp URL.cpp ZLib.cpp ZLibIOFilter.cpp BZip2.cpp BZip2IOFilter.cpp + IOFilter.cpp URL.cpp ZLib.cpp ZLibIOFilter.cpp BZip2.cpp BZip2IOFilter.cpp \ + IORequest.cpp IOHandler.cpp IOManager.cpp libpclasses_io_la_LDFLAGS = -no-nundefined --- NEW FILE: IOHandler.cpp --- /*************************************************************************** * 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. * ***************************************************************************/ #include "pclasses/IO/IOHandler.h" namespace P { namespace IO { IOHandler::IOHandler() { } IOHandler::~IOHandler() { } IORequest_Get* IOHandler::get(const URL& url) { return 0; } IORequest_Put* IOHandler::put(const URL& url) { return 0; } IORequest_Unlink* IOHandler::unlink(const URL& url) { return 0; } IORequest_MakeDir* IOHandler::mkdir(const URL& url) { return 0; } IORequest_RemoveDir* IOHandler::rmdir(const URL& url) { return 0; } IORequest_ListDir* IOHandler::lsdir(const URL& url) { return 0; } } // !namespace IO } // !namespace P --- NEW FILE: IORequest.cpp --- /*************************************************************************** * 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. * ***************************************************************************/ #include "pclasses/IO/IORequest.h" namespace P { namespace IO { IORequest::IORequest(const URL& url) : _url(url) { } IORequest::~IORequest() { } const URL& IORequest::url() const throw() { return _url; } IORequest_Get::IORequest_Get(const URL& url) : IORequest(url) { } IORequest_Get::~IORequest_Get() { } IORequest_Put::IORequest_Put(const URL& url) : IORequest(url) { } IORequest_Put::~IORequest_Put() { } IORequest_Unlink::IORequest_Unlink(const URL& url) : IORequest(url) { } IORequest_Unlink::~IORequest_Unlink() { } IORequest_MakeDir::IORequest_MakeDir(const URL& url) : IORequest(url) { } IORequest_MakeDir::~IORequest_MakeDir() { } IORequest_RemoveDir::IORequest_RemoveDir(const URL& url) : IORequest(url) { } IORequest_RemoveDir::~IORequest_RemoveDir() { } IORequest_ListDir::IORequest_ListDir(const URL& url) : IORequest(url) { } IORequest_ListDir::~IORequest_ListDir() { } } // !namespace IO } // !namespace P |