diff --git a/src/H5ChunkedWriter.cpp b/src/H5ChunkedWriter.cpp index 5602337..d529ca5 100644 --- a/src/H5ChunkedWriter.cpp +++ b/src/H5ChunkedWriter.cpp @@ -10,6 +10,8 @@ extern "C" #include "H5DOpublic.h" } +using namespace std; + hsize_t expand_dataset(const H5::DataSet& dataset, hsize_t frame_index, hsize_t dataset_increase_step) { hsize_t dataset_rank = 3; @@ -19,11 +21,11 @@ hsize_t expand_dataset(const H5::DataSet& dataset, hsize_t frame_index, hsize_t dataset_dimension[0] = frame_index + dataset_increase_step; #ifdef DEBUG - std::cout << "[expand_dataset] Expanding dataspace to size ("; + cout << "[expand_dataset] Expanding dataspace to size ("; for (hsize_t i=0; ifilename = filename; - this->dataset_name = dataset_name; - this->frames_per_file = frames_per_file; - this->initial_dataset_size = initial_dataset_size; + #ifdef DEBUG + cout << "[HDF5ChunkedWriter::HDF5ChunkedWriter] Creating chunked writer"; + cout << " with filename " << filename; + cout << " and dataset_name " << dataset_name; + cout << " and frames_per_file " << frames_per_file; + cout << " and initial_dataset_size " << initial_dataset_size; + cout << endl; + #endif } HDF5ChunkedWriter::~HDF5ChunkedWriter() @@ -67,14 +74,14 @@ void HDF5ChunkedWriter::close_file() { if (file.getId() == -1) { #ifdef DEBUG - std::cout << "[HDF5ChunkedWriter::close_file] Trying to close an already closed file." << std::endl; + cout << "[HDF5ChunkedWriter::close_file] Trying to close an already closed file." << endl; #endif return; } #ifdef DEBUG - std::cout << "[HDF5ChunkedWriter::close_file] Closing file." << std::endl; + cout << "[HDF5ChunkedWriter::close_file] Closing file." << endl; #endif compact_dataset(dataset, max_frame_index); @@ -92,7 +99,7 @@ void HDF5ChunkedWriter::close_file() auto image_nr_high = max_frame_in_dataset + 1; #ifdef DEBUG - std::cout << "[HDF5ChunkedWriter::close_file] Setting dataset attribute image_nr_low=" << image_nr_low << " and image_nr_high=" << image_nr_high << std::endl; + cout << "[HDF5ChunkedWriter::close_file] Setting dataset attribute image_nr_low=" << image_nr_low << " and image_nr_high=" << image_nr_high << endl; #endif // H5::IntType int_type(H5::PredType::NATIVE_UINT32); @@ -123,10 +130,10 @@ void HDF5ChunkedWriter::write_data(size_t frame_index, size_t* frame_shape, size if( H5DOwrite_chunk(dataset.getId(), H5P_DEFAULT, filters, offset, data_bytes_size, data) ) { - std::stringstream error_message; - error_message << "Error while writing chunk to file at offset " << relative_frame_index << "." << std::endl; + stringstream error_message; + error_message << "Error while writing chunk to file at offset " << relative_frame_index << "." << endl; - throw std::invalid_argument( error_message.str() ); + throw invalid_argument( error_message.str() ); } } @@ -141,18 +148,18 @@ void HDF5ChunkedWriter::create_file(size_t* frame_shape, hsize_t frame_chunk) { // In case frames_per_file is > 0, the filename variable is a template for the filename. if (frames_per_file) { #ifdef DEBUG - std::cout << "[HDF5ChunkedWriter::create_file] Frames per file is defined. Format " << filename << " with frame_chunk " << frame_chunk << std::endl; + cout << "[HDF5ChunkedWriter::create_file] Frames per file is defined. Format " << filename << " with frame_chunk " << frame_chunk << endl; #endif // Space for 10 digits should be enough. char buffer[filename.length() + 10]; sprintf(buffer, filename.c_str(), frame_chunk); - target_filename = std::string(buffer); + target_filename = string(buffer); } #ifdef DEBUG - std::cout << "[HDF5ChunkedWriter::create_file] Creating filename " << target_filename << std::endl; + cout << "[HDF5ChunkedWriter::create_file] Creating filename " << target_filename << endl; #endif // TODO: Create folder if it does not exist. @@ -168,11 +175,11 @@ void HDF5ChunkedWriter::create_file(size_t* frame_shape, hsize_t frame_chunk) { H5::DataSpace dataspace(dataset_rank, dataset_dimension, max_dataset_dimension); #ifdef DEBUG - std::cout << "[HDF5ChunkedWriter::create_file] Creating dataspace of size ("; + cout << "[HDF5ChunkedWriter::create_file] Creating dataspace of size ("; for (hsize_t i=0; i