00001
00002
00003
00004
00005 #ifndef DMLITE_CPP_IO_H
00006 #define DMLITE_CPP_IO_H
00007
00008 #include <fcntl.h>
00009 #include <map>
00010 #include "base.h"
00011 #include "exceptions.h"
00012 #include "utils/extensible.h"
00013
00014 namespace dmlite {
00015
00016
00017 class PluginManager;
00018 class StackInstance;
00019
00020
00021 class IOHandler {
00022 public:
00023 enum Whence { kSet = SEEK_SET,
00024 kCur = SEEK_CUR,
00025 kEnd = SEEK_END
00026 };
00027
00028
00029 virtual ~IOHandler();
00030
00031
00032 virtual void close(void) throw (DmException) = 0;
00033
00034
00035
00036
00037
00038 virtual size_t read(char* buffer, size_t count) throw (DmException) = 0;
00039
00040
00041
00042
00043
00044 virtual size_t write(const char* buffer, size_t count) throw (DmException) = 0;
00045
00046
00047
00048
00049 virtual void seek(off_t offset, Whence whence) throw (DmException) = 0;
00050
00051
00052 virtual off_t tell(void) throw (DmException) = 0;
00053
00054
00055 virtual void flush(void) throw (DmException) = 0;
00056
00057
00058 virtual bool eof(void) throw (DmException) = 0;
00059 };
00060
00061
00062 class IODriver: public virtual BaseInterface {
00063 public:
00064
00065 virtual ~IODriver();
00066
00067
00068
00069
00070
00071 virtual IOHandler* createIOHandler(const std::string& pfn,
00072 int flags,
00073 const Extensible& extras) throw (DmException) = 0;
00074
00075
00076
00077
00078 virtual void doneWriting(const std::string& pfn,
00079 const Extensible& params) throw (DmException) = 0;
00080 };
00081
00082
00083 class IOFactory: public virtual BaseFactory {
00084 public:
00085
00086 virtual ~IOFactory();
00087
00088 protected:
00089 friend class StackInstance;
00090
00091
00092 virtual IODriver* createIODriver(PluginManager* pm) throw (DmException) = 0;
00093 };
00094
00095 };
00096
00097 #endif // DMLITE_CPP_IO_H