Page MenuHomec4science

path.hpp
No OneTemporary

File Metadata

Created
Sat, Jul 27, 20:19

path.hpp

/* =============================================================================
Copyright (c) 2014 - 2016
F. Georget <fabieng@princeton.edu> Princeton University
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
============================================================================= */
#ifndef SPECMICP_IO_HDF5_PATH_HPP
#define SPECMICP_IO_HDF5_PATH_HPP
#include "id_class.hpp"
#include "specmicp_common/types.hpp"
#include <string>
namespace specmicp {
namespace io {
namespace hdf5 {
class Group;
class Dataset;
//! \brief A basic location, have an id and path
class Path:
public IdClass
{
public:
//! \brief Move constructor
Path(Path&& other) = default;
//! \brief Return the path.
std::string get_path() const {return m_path;}
//! \brief Return a subpath
std::string add_to_path(const std::string& to_add) const;
protected:
Path(hid_t id, const std::string& path):
IdClass(id),
m_path(path)
{}
//! \brief Set the location path3
void set_path(const std::string& path) {m_path = path;}
private:
std::string m_path;
Path(const Path& other) = delete;
Path& operator=(const Path& other) = delete;
};
//! \brief A group
//!
//! similar to H5::CommonFG
class GroupPath:
public Path
{
public:
GroupPath(GroupPath&& other) = default;
//! \brief Open a group
Group open_group(std::string name) const;
//! \brief Create a group
Group create_group(std::string name) const;
//! \brief Open a dataset
Dataset open_dataset(std::string name) const;
//! \brief Create a dataset from an eigen vector
Dataset create_vector_dataset(std::string name, const Vector& data);
//! \brief Read a dataset and transfer its data to an eigen vector
Vector read_vector_dataset(std::string path) const;
//! \brief Check if 'name' exist in this group
bool has_link(std::string name) const;
protected:
GroupPath(hid_t id, const std::string& path):
Path(id, path)
{}
private:
// no copy no assignement
GroupPath(const GroupPath& other) = delete;
GroupPath& operator=(const GroupPath& other) = delete;
};
} // end namespace hdf5
} // end namespace io
} // end namespace specmicp
#endif // SPECMICP_IO_HDF5_PATH_HPP

Event Timeline