00001 #ifndef CK_IO_H 00002 #define CK_IO_H 00003 00004 #include <string> 00005 #include <pup.h> 00006 #include <ckcallback.h> 00007 00008 #include "CkIO.decl.h" 00009 00010 namespace Ck { namespace IO { 00013 struct Options { 00014 Options() 00015 : peStripe(0), writeStripe(0), activePEs(-1), basePE(-1), skipPEs(-1) 00016 { } 00017 00019 size_t peStripe; 00021 size_t writeStripe; 00023 int activePEs; 00025 int basePE; 00027 int skipPEs; 00028 00029 void pup(PUP::er &p) { 00030 p|peStripe; 00031 p|writeStripe; 00032 p|activePEs; 00033 p|basePE; 00034 p|skipPEs; 00035 } 00036 }; 00037 00038 class File; 00039 class Session; 00040 00046 void open(std::string name, CkCallback opened, Options opts); 00047 00053 void startSession(File file, size_t bytes, size_t offset, 00054 CkCallback ready, CkCallback complete); 00055 00062 void startSession(File file, size_t bytes, size_t offset, CkCallback ready, 00063 const char *commitData, size_t commitBytes, size_t commitOffset, 00064 CkCallback complete); 00065 00068 void write(Session session, const char *data, size_t bytes, size_t offset); 00069 00072 void close(File file, CkCallback closed); 00073 00074 class File { 00075 int token; 00076 friend void startSession(File file, size_t bytes, size_t offset, 00077 CkCallback ready, CkCallback complete); 00078 friend void startSession(File file, size_t bytes, size_t offset, CkCallback ready, 00079 const char *commitData, size_t commitBytes, size_t commitOffset, 00080 CkCallback complete); 00081 friend void close(File file, CkCallback closed); 00082 friend class FileReadyMsg; 00083 00084 public: 00085 File(int token_) : token(token_) { } 00086 File() : token(-1) { } 00087 void pup(PUP::er &p) { p|token; } 00088 }; 00089 00090 class FileReadyMsg : public CMessage_FileReadyMsg { 00091 public: 00092 File file; 00093 FileReadyMsg(const File &tok) : file(tok) {} 00094 }; 00095 00096 namespace impl { class Manager; } 00097 00098 class Session { 00099 int file; 00100 size_t bytes, offset; 00101 CkArrayID sessionID; 00102 friend class Ck::IO::impl::Manager; 00103 public: 00104 Session(int file_, size_t bytes_, size_t offset_, 00105 CkArrayID sessionID_) 00106 : file(file_), bytes(bytes_), offset(offset_), sessionID(sessionID_) 00107 { } 00108 Session() { } 00109 void pup(PUP::er &p) { 00110 p|file; 00111 p|bytes; 00112 p|offset; 00113 p|sessionID; 00114 } 00115 }; 00116 00117 class SessionReadyMsg : public CMessage_SessionReadyMsg { 00118 public: 00119 Session session; 00120 SessionReadyMsg(Session session_) : session(session_) { } 00121 }; 00122 00123 }} 00124 #endif