Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages | Examples

piorequest.h

Go to the documentation of this file.
00001 /*
00002  *   P::Classes - Portable C++ Application Framework
00003  *   Copyright (C) 2000-2004  Christian Prochnow <cproch@seculogix.de>
00004  *
00005  *   This library is free software; you can redistribute it and/or
00006  *   modify it under the terms of the GNU Lesser General Public
00007  *   License as published by the Free Software Foundation; either
00008  *   version 2 of the License, or (at your option) any later version.
00009  *
00010  *   This library is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  *   Lesser General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU Lesser General Public
00016  *   License along with this library; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  */
00019 
00020 #ifndef _piorequest_h_
00021 #define _piorequest_h_
00022 
00023 #include <pclasses/pexport.h>
00024 #include <pclasses/ptypes.h>
00025 #include <pclasses/pexception.h>
00026 #include <pclasses/psemaphore.h>
00027 #include <pclasses/purl.h>
00028 #include <string>
00029 #include <map>
00030 
00031 
00032 namespace P {
00033 
00034 class IOHandler;
00035 class IOManager;
00036 
00038 
00045 class PIO_EXPORT IORequest {
00046   public:
00047   
00049     enum state_t {
00050       Initial,     
00051       Open,        
00052       Transfer,    
00053       Finished,    
00054       Failed       
00055     };
00056 
00057     friend class IOManager;
00058     friend class IOHandler;
00059 
00061 
00066     IORequest(IOHandler* handler, const URL& url);
00067     virtual ~IORequest();
00068 
00070     inline IOHandler* handler() const throw()
00071     { return m_handler; }
00072 
00074     inline const URL& url() const throw()
00075     { return m_url; }
00076 
00078     inline state_t state() const throw()
00079     { return m_state; }
00080 
00081   protected:
00082     inline void setState(state_t s) throw()
00083     { m_state = s; }
00084 
00085   private:
00086     IORequest(const IORequest&);
00087     IORequest& operator=(const IORequest&);
00088 
00089     IOHandler*    m_handler;
00090     URL           m_url;
00091     state_t       m_state;
00092 
00093   public:
00094 
00096 
00099     class PIO_EXPORT Error: public RuntimeError {
00100       public:
00101         Error(const char* what, const std::string& text,
00102               const SourceInfo& si) throw();
00103 
00104         ~Error() throw();
00105 
00106         inline BaseError* clone() const
00107         { return new Error(*this); }
00108 
00109         inline const std::string& text() const
00110         { return m_text; }
00111 
00112       private:
00113         std::string m_text;
00114     };
00115 };
00116 
00118 
00121 class PIO_EXPORT IORequest_Get: public IORequest {
00122   public:
00123     IORequest_Get(IOHandler* handler, const URL& url);
00124     virtual ~IORequest_Get();
00125 
00127 
00131     virtual void open() = 0;
00132     
00134 
00138     virtual void close() = 0;
00139 
00141 
00149     virtual size_t receive(char* buff, size_t count) = 0;
00150 };
00151 
00153 
00156 class PIO_EXPORT IORequest_Put: public IORequest {
00157   public:
00158     IORequest_Put(IOHandler* handler, const URL& url);
00159     virtual ~IORequest_Put();
00160 
00162 
00166     virtual void open() = 0;
00167     
00169 
00173     virtual void close() = 0;
00174 
00176 
00184     virtual size_t send(const char* buff, size_t count) = 0;
00185 };
00186 
00188 
00191 class PIO_EXPORT IORequest_Unlink: public IORequest {
00192   public:
00193     IORequest_Unlink(IOHandler* handler, const URL& url);
00194     virtual ~IORequest_Unlink();
00195 
00196     virtual void unlink() = 0;
00197 };
00198 
00200 
00203 class PIO_EXPORT IORequest_MakeDir: public IORequest {
00204   public:
00205     IORequest_MakeDir(IOHandler* handler, const URL& url);
00206     virtual ~IORequest_MakeDir();
00207 
00208     virtual void mkdir() = 0;
00209 };
00210 
00212 
00215 class PIO_EXPORT IORequest_RemoveDir: public IORequest {
00216   public:
00217     IORequest_RemoveDir(IOHandler* handler, const URL& url);
00218     virtual ~IORequest_RemoveDir();
00219 
00220     virtual void rmdir() = 0;
00221 };
00222 
00224 
00227 class PIO_EXPORT IORequest_ListDir: public IORequest {
00228   public:
00229     IORequest_ListDir(IOHandler* handler, const URL& url);
00230     virtual ~IORequest_ListDir();
00231 
00232     virtual void list() = 0;
00233 };
00234 
00235 }
00236 
00237 #endif

Generated on Fri Mar 12 21:08:31 2004 for P::Classes by doxygen 1.3.3