halapi hierarchichalalignmentformatapi

- Main Page
- Classes
- Files

- File List

inc/rawH5ExternalArray.h

    00001 /*
    00002  * Copyright (C) 2012 by Glenn Hickey (hickey@soe.ucsc.edu)
    00003  *
    00004  * Released under the MIT license, see LICENSE.txt
    00005  */
    00006
    00007 #ifndef _RAWH5EXTERNALARRAY_H
    00008 #define _RAWH5EXTERNALARRAY_H
    00009
    00010 #include <cassert>
    00011 #include <H5Cpp.h>
    00012 #include "halDefs.h"
    00013
    00014 namespace hal {
    00015
    00024 class RawH5ExternalArray
    00025 {
    00026 public:
    00027
    00029    RawH5ExternalArray();
    00030
    00032    virtual ~RawH5ExternalArray();
    00033
    00041    void create(H5::H5File* file, const H5std_string& path,
    00042                const H5::DataType& dataType, hsize_t numElements,
    00043                const H5::DSetCreatPropList& cparms =
    00044                H5::DSetCreatPropList::DEFAULT);
    00045
    00054    void load(H5::H5File* file, const H5std_string& path,
    00055              hsize_t chunksInBuffer = 1);
    00056
    00058    void write();
    00059
    00063    const void* get(hsize_t i);
    00064
    00068    void* getUpdate(hsize_t i);
    00069
    00070 protected:
    00071
    00073    void page(hsize_t i);
    00074
    00076    H5::H5File* _file;
    00078    H5std_string _path;
    00080    H5::DataType _dataType;
    00082    H5::DataSpace _dataSpace;
    00084    H5::DataSet _dataSet;
    00086    hsize_t _size;
    00088    hsize_t _chunkSize;
    00090    hsize_t _dataSize;
    00092    hsize_t _bufStart;
    00094    hsize_t _bufEnd;
    00096    hsize_t _bufSize;
    00098    char* _buf;
    00100    H5::DataSpace _chunkSpace;
    00103    bool _dirty;
    00104
    00105 private:
    00106
    00107    RawH5ExternalArray(const RawH5ExternalArray&);
    00108    RawH5ExternalArray& operator=(const RawH5ExternalArray&);
    00109 };
    00110
    00111 // INLINE MEMBERS
    00112
    00113 inline const void* RawH5ExternalArray::get(hsize_t i)
    00114 {
    00115   assert(i < _size);
    00116   if (i < _bufStart || i > _bufEnd)
    00117   {
    00118     page(i);
    00119   }
    00120   assert((i - _bufStart) < _bufSize);
    00121   return _buf + (i - _bufStart) * _dataSize;
    00122 }
    00123
    00124 inline void* RawH5ExternalArray::getUpdate(hsize_t i)
    00125 {
    00126   assert(i < _size);
    00127   if (i < _bufStart || i > _bufEnd)
    00128   {
    00129     page(i);
    00130   }
    00131   _dirty = true;
    00132   assert((i - _bufStart) < _bufSize);
    00133   return _buf + (i - _bufStart) * _dataSize;
    00134 }
    00135
    00136 }
    00137 #endif

All Classes Functions Variables