From: Christian P. <cp...@us...> - 2005-06-06 11:58:16
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/IO In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22523/include/pclasses/IO Modified Files: IOManager.h Log Message: - IOManager is now thread-safe - Added some documentation Index: IOManager.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/IO/IOManager.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- IOManager.h 25 May 2005 08:02:56 -0000 1.6 +++ IOManager.h 6 Jun 2005 11:58:02 -0000 1.7 @@ -22,6 +22,7 @@ #define P_IO_IOManager_h #include <pclasses/Export.h> +#include <pclasses/CoreMutex.h> #include <pclasses/IO/URL.h> #include <pclasses/IO/IORequest.h> @@ -34,32 +35,57 @@ class IOHandler; +//! Transparent Network Filesystem I/O manager +/*! + The IOManager is used to dispatch the various I/O requests to the + specific IOHandler's based on the protocol given in the request-URL's. + The IOHandler's are created by a call to Factory<IOHandler>::create() + and may therefore be registered statically by the Application itself + or dynamically loaded by the PluginManager. + Protocol-IOHandler classes must be named "IOHandler_<protocol>". + + All methods in this class are reentrant. +*/ class PIO_EXPORT IOManager { public: IOManager(); ~IOManager(); + //! Creates a GET request used to download a file IORequest_Get* get(const URL& url); + + //! Creates a PUT request used to upload a file IORequest_Put* put(const URL& url); + //! Creates a UNLINK request used to delete a file IORequest_Unlink* unlink(const URL& url); + //! Creates a MKDIR request used to create a directory IORequest_MakeDir* mkdir(const URL& url); + + //! Creates a RMDIR request used to remove a directory IORequest_RemoveDir* rmdir(const URL& url); + //! Creates a LSDIR request used to list the contents of a directory IORequest_ListDir* lsdir(const URL& url); + //! Cleans up and deletes a no longer needed IORequest void finish(IORequest* req); + //! Returns the global instance of the IOManager static IOManager& instance(); private: IOHandler* findHandler(const std::string& proto); + void addHandlerRequest(IORequest* req, IOHandler* handler); typedef std::map<std::string, IOHandler*> handler_map; typedef std::map<IORequest*, IOHandler*> request_map; + CoreMutex _handlersMtx; handler_map _handlers; + + CoreMutex _requestsMtx; request_map _requests; }; |