00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _HDF5SERIE_FILE_H_
00023 #define _HDF5SERIE_FILE_H_
00024
00025 #include <hdf5serie/group.h>
00026 #include <boost/filesystem.hpp>
00027 #include <boost/date_time/posix_time/posix_time_types.hpp>
00028 #include <boost/shared_ptr.hpp>
00029
00030 namespace boost {
00031 namespace interprocess {
00032 class shared_memory_object;
00033 class mapped_region;
00034 class interprocess_mutex;
00035 class interprocess_condition;
00036 }
00037 }
00038
00039 namespace H5 {
00040
00041 class Dataset;
00042
00043 class File : public GroupBase {
00044 friend class Dataset;
00045 friend class GroupBase;
00046 public:
00047 enum FileAccess {
00048 read,
00049 write
00050 };
00051 File(const boost::filesystem::path &filename, FileAccess type_);
00052 ~File();
00053 void reopenAsSWMR();
00054 static void reopenAllFilesAsSWMR();
00055 static int getDefaultCompression() { return defaultCompression; }
00056 static void setDefaultCompression(int comp) { defaultCompression=comp; }
00057 static int getDefaultChunkSize() { return defaultChunkSize; }
00058 static void setDefaultChunkSize(int chunk) { defaultChunkSize=chunk; }
00059 void refresh();
00060 void flush();
00061
00062 void requestWriterFlush();
00063 bool waitForWriterFlush();
00064
00065 void flushIfRequested();
00066 static void flushAllFiles();
00067 static void flushAllFilesIfRequested();
00068 void refreshAfterWriterFlush();
00069 static void refreshAllFiles();
00070 static void refreshFilesAfterWriterFlush(const std::set<H5::File*> &files);
00071 static void refreshAllFilesAfterWriterFlush();
00072
00073 struct IPC {
00074 boost::filesystem::path filename;
00075 std::string interprocessName;
00076 boost::shared_ptr<boost::interprocess::shared_memory_object> shm;
00077 boost::shared_ptr<boost::interprocess::mapped_region> shmmap;
00078 bool *flushVar;
00079 boost::interprocess::interprocess_mutex *mutex;
00080 boost::interprocess::interprocess_condition *cond;
00081 boost::posix_time::ptime flushRequestTime;
00082 };
00083 protected:
00084 FileAccess type;
00085 bool isSWMR;
00086 void close();
00087 void open();
00088 static int defaultCompression;
00089 static int defaultChunkSize;
00090
00091 static std::set<File*> writerFiles;
00092 static std::set<File*> readerFiles;
00093 std::string interprocessName;
00094 IPC ipc;
00095 void addFileToNotifyOnRefresh(const boost::filesystem::path &filename);
00096 std::vector<IPC> ipcAdd;
00097 };
00098 }
00099
00100 #endif