13 #include <type_traits>
25 H5Object
AddChildren(std::shared_ptr<HDF5File> file,
26 std::string
const& groupName);
51 H5Object
OpenFile(std::string
const& filename);
62 std::string
const& path_,
63 bool isDataset_) :
file(file_),
80 assert(
path.length()>0);
83 Eigen::Matrix<ScalarType,Eigen::Dynamic,Eigen::Dynamic> temp(1,1);
96 template<
typename Derived>
99 return (*
this)=val.
eval();
102 template<
typename ScalarType,
int fixedRows,
int fixedCols>
105 assert(
path.length()>0);
109 throw std::runtime_error(
"Error in H5Object::operator=. Unable to save matrix to path \"" +
path +
"\" because it is a group.");
114 template<
typename scalarType,
int rows,
int cols>
115 operator Eigen::Matrix<scalarType,rows,cols>()
117 return eval<scalarType,rows,cols>();
125 template<
typename scalarType=
double,
int rows=Eigen::Dynamic,
int cols=Eigen::Dynamic>
126 Eigen::Matrix<scalarType,rows,cols>
eval()
130 return file->ReadMatrix<scalarType,
rows,
cols>(
path).
template cast<scalarType>();
144 template<
typename ScalarType>
161 BlockDataset block(
unsigned startRow,
unsigned startCol,
unsigned numRows,
unsigned numCols)
const;
183 unsigned rows()
const;
185 unsigned cols()
const;
187 unsigned size()
const;
199 void Print(std::string prefix =
"")
const;
203 std::shared_ptr<HDF5File>
file;
228 #ifndef REGISTER_HDF5OBJECT_ANYTYPE
229 #define REGISTER_HDF5OBJECT_ANYTYPE(REGNAME, NAME) static auto regHDF ##REGNAME \
230 = muq::Utilities::H5Object::GetAnyWriterMap()->insert(std::make_pair(std::type_index(typeid(NAME)), muq::Utilities::AnyWriter<NAME>() ));
H5Object & operator=(ScalarType val)
BlockDataset rightCols(unsigned numCols) const
H5Object & operator=(Eigen::Matrix< ScalarType, fixedRows, fixedCols > const &val)
H5Object(std::shared_ptr< HDF5File > file_, std::string const &path_, bool isDataset_)
H5Object & CreateGroup(std::string const &grpName)
static std::shared_ptr< AnyWriterMapType > GetAnyWriterMap()
BlockDataset bottomLeftCorner(unsigned numRows, unsigned numCols) const
BlockDataset topRows(unsigned numRows) const
std::function< void(boost::any const &, H5Object &)> AnyWriterType
BlockDataset col(unsigned col) const
H5Object & CreatePlaceholder(std::string const &grpName)
H5Object & CreateDataset(std::string const &setName, unsigned int rows, unsigned int cols=0)
std::map< std::string, H5Object > children
void Print(std::string prefix="") const
BlockDataset segment(unsigned startInd, unsigned numInds) const
BlockDataset row(unsigned row) const
std::unordered_map< std::type_index, AnyWriterType > AnyWriterMapType
void ExactCopy(H5Object const &otherObj)
Creates an exact copy.
BlockDataset topLeftCorner(unsigned numRows, unsigned numCols) const
H5Object & operator=(Eigen::DenseBase< Derived > const &val)
BlockDataset topRightCorner(unsigned numRows, unsigned numCols) const
Eigen::Matrix< scalarType, rows, cols > eval()
H5Object & operator[](std::string const &targetPath)
BlockDataset head(unsigned numInds) const
BlockDataset block(unsigned startRow, unsigned startCol, unsigned numRows, unsigned numCols) const
BlockDataset tail(unsigned numInds) const
std::shared_ptr< HDF5File > file
void DeepCopy(H5Object const &otherObj)
BlockDataset bottomRightCorner(unsigned numRows, unsigned numCols) const
double operator()(int i) const
H5Object & operator=(boost::any const &val)
BlockDataset bottomRows(unsigned numRows) const
BlockDataset leftCols(unsigned numCols) const
H5Object OpenFile(std::string const &filename)
Open an HDF5 file and return the root object.
H5Object AddChildren(std::shared_ptr< HDF5File > file, std::string const &groupName)
Recursively add children to create an HDF5 file hierarchy.