icedb  version 0.5.1
Snow particle scattering database API
Public Member Functions | Private Attributes | Friends | List of all members
icedb::Groups::Group_impl Class Reference

#include <Group_impl.hpp>

Inheritance diagram for icedb::Groups::Group_impl:
Inheritance graph
[legend]
Collaboration diagram for icedb::Groups::Group_impl:
Collaboration graph
[legend]

Public Member Functions

 Group_impl ()
 
 Group_impl (const std::string &name, gsl::not_null< H5::Group *> parent)
 
 Group_impl (const std::string &name, gsl::not_null< H5::H5File *> parent)
 
 Group_impl (const std::string &name, gsl::not_null< const Group *> parent)
 
 Group_impl (Group_HDF_shared_ptr grp)
 
virtual ~Group_impl ()
 
Group_ptr createGroup (const std::string &groupName) override
 Create a group. More...
 
Group_ptr openGroup (const std::string &groupName) const override
 Opens a group. More...
 
bool doesGroupExist (const std::string &groupName) const override
 Does a group with this name exist? More...
 
std::set< std::string > getGroupNames () const override
 
void deleteGroup (const std::string &groupName) override
 Unlink the specified child group. More...
 
Group_HDF_shared_ptr getHDF5Group () const override
 Get the fundamental HDF5 object that the group is built on. More...
 
- Public Member Functions inherited from icedb::Groups::Group
virtual ~Group ()
 
- Public Member Functions inherited from icedb::Attributes::CanHaveAttributes
 ~CanHaveAttributes ()
 
bool doesAttributeExist (const std::string &attributeName) const
 Does the object have an attribute with the given name? More...
 
std::type_index getAttributeTypeId (const std::string &attributeName) const
 Returns the type of an attribute. More...
 
template<class Type >
bool isAttributeOfType (const std::string &attributeName) const
 Is the type of the attribute "Type"? More...
 
std::set< std::string > getAttributeNames () const
 List all attributes attached to this object. More...
 
void deleteAttribute (const std::string &attributeName)
 Delete an attribute, by name, that is attached to this object. More...
 
template<class DataType >
void readAttributeData (const std::string &attributeName, std::vector< size_t > &dimensions, std::vector< DataType > &data) const
 Function to read the data from an attribute using the provided input vectors. More...
 
template<class DataType >
void writeAttributeData (const std::string &attributeName, const std::vector< size_t > &dimensionas, const std::vector< DataType > &data)
 Function to write an attribute to an object, with the provided raw data. More...
 
template<class DataType >
Attribute< DataType > readAttribute (const std::string &attributeName) const
 Convenience function to read an attribute's data and return an Attribute object. More...
 
template<class DataType >
void writeAttribute (const Attribute< DataType > &attribute)
 Convenience function to write an Attribute to an object. More...
 
template<class DataType >
void writeAttribute (const std::string &name, std::initializer_list< size_t > dims, std::initializer_list< DataType > data)
 Convenience function to write a small Attribute to an object, using initializer lists. More...
 
- Public Member Functions inherited from icedb::Tables::CanHaveTables
 ~CanHaveTables ()
 
std::set< std::string > getTableNames () const
 Lists all table names that are children of this object. More...
 
bool doesTableExist (const std::string &tableName) const
 Does a table exist with the given name. More...
 
void unlinkTable (const std::string &tableName)
 Unlink a table. In HDF5, this is not the same as erasing a table, which never actually happens. More...
 
Table::Table_Type openTable (const std::string &tableName)
 
std::vector< size_t > getChunkStrategy (const std::vector< size_t > &dims)
 The default chunking strategy for this table. Used for storage i/o speed, and for compression. More...
 
template<class DataType >
Table::Table_Type createTable (const std::string &tableName, const std::vector< size_t > &dims, const std::vector< size_t > *chunks=nullptr)
 Create a table. More...
 
template<class DataType >
Table::Table_Type createTable (const std::string &tableName, std::initializer_list< size_t > dims, const std::vector< size_t > *chunks=nullptr)
 Create a table. More...
 
template<class DataType >
Table::Table_Type createTable (const std::string &tableName, std::initializer_list< size_t > dims, std::initializer_list< DataType > data, const std::vector< size_t > *chunks=nullptr)
 Create a table and writes initial data. Used with small tables. More...
 
template<class DataType >
Table::Table_Type createTable (const std::string &tableName, std::initializer_list< size_t > dims, const std::vector< DataType > &data, const std::vector< size_t > *chunks=nullptr)
 Create a table and sets the table's initial data. More...
 
template<class DataType >
Table::Table_Type createTable (const std::string &tableName, std::initializer_list< size_t > dims, const gsl::span< DataType > &data, const std::vector< size_t > *chunks=nullptr)
 Create a table and sets the table's initial data. More...
 
template<class DataType >
Table::Table_Type createTable (const std::string &tableName, std::initializer_list< size_t > dims, const gsl::span< const DataType > &data, const std::vector< size_t > *chunks=nullptr)
 Create a table and sets the table's initial data. More...
 
- Public Member Functions inherited from icedb::Attributes::CanHaveAttributes_impl
 CanHaveAttributes_impl (std::shared_ptr< H5::H5Object >)
 
 CanHaveAttributes_impl ()
 
virtual ~CanHaveAttributes_impl ()
 
- Public Member Functions inherited from icedb::Tables::CanHaveTables_impl
virtual ~CanHaveTables_impl ()
 
 CanHaveTables_impl ()
 

Private Attributes

Group_HDF_shared_ptr grp
 

Friends

class Group
 

Additional Inherited Members

- Public Types inherited from icedb::Groups::Group
typedef std::unique_ptr< Groups::GroupGroup_ptr
 
typedef std::shared_ptr< H5::Group > Group_HDF_shared_ptr
 
- Static Public Member Functions inherited from icedb::Groups::Group
static Group_ptr createGroup (const std::string &name, gsl::not_null< H5::Group *> parent)
 Create a group with a specified parent (static function) More...
 
static Group_ptr createGroup (const std::string &name, gsl::not_null< H5::H5File *> parent)
 Create a group with a specified parent (static function) More...
 
static Group_ptr createGroup (const std::string &name, gsl::not_null< const Group *> parent)
 Create a group with a specified parent (static function) More...
 
static Group_ptr openGroup (const std::string &name, gsl::not_null< H5::Group *> parent)
 Open a group under the specified parent (static function) More...
 
static Group_ptr openGroup (const std::string &name, gsl::not_null< H5::H5File *> parent)
 Open a group under the specified parent (static function) More...
 
static Group_ptr openGroup (const std::string &name, gsl::not_null< const Group *> parent)
 Open a group under the specified parent (static function) More...
 
static Group_ptr openGroup (Group_HDF_shared_ptr group)
 Open an icedb group from an HDF5 group object. More...
 
static Group_ptr mount (const std::string &subdirname, gsl::not_null< const Group *> containingParent, gsl::not_null< H5::H5File *> pointsTo)
 Mount an HDF5 file as a child 'group'. More...
 
- Static Public Member Functions inherited from icedb::Attributes::CanHaveAttributes
static bool doesAttributeExist (gsl::not_null< const H5::H5Object *> parent, const std::string &attributeName)
 Does an object (parent) have an attribute with the given name? More...
 
static std::type_index getAttributeTypeId (gsl::not_null< const H5::H5Object *> parent, const std::string &attributeName)
 Returns the type of an attribute. More...
 
template<class DataType >
static void readAttributeData (gsl::not_null< const H5::H5Object *> parent, const std::string &attributeName, std::vector< size_t > &dimensions, std::vector< DataType > &data)
 Function to read the data from an attribute. More...
 
template<class DataType >
static Attribute< DataType > readAttribute (gsl::not_null< const H5::H5Object *> obj, const std::string &attributeName)
 Convenience function to read an attribute's data and return an Attribute object. More...
 
- Public Attributes inherited from icedb::Groups::Group
const std::string name
 The name of the group. More...
 
- Static Public Attributes inherited from icedb::Groups::Group
static const std::string _icedb_obj_type_identifier = { "_icedb_obj_type" }
 The tag used in icedb to identify a group. More...
 
- Protected Member Functions inherited from icedb::Groups::Group
 Group ()
 
 Group (const std::string &name)
 
- Protected Member Functions inherited from icedb::Attributes::CanHaveAttributes
 CanHaveAttributes ()
 
- Protected Member Functions inherited from icedb::Tables::CanHaveTables
 CanHaveTables ()
 Trivial constructor used when CanHaveTables is a virtual base class. More...
 
- Protected Member Functions inherited from icedb::Attributes::CanHaveAttributes_impl
virtual void _setAttributeParent (std::shared_ptr< H5::H5Object > obj) override
 
virtual std::shared_ptr< H5::H5Object > _getAttributeParent () const override
 
- Protected Member Functions inherited from icedb::Tables::CanHaveTables_impl
void _setTablesParent (std::shared_ptr< H5::Group > obj) override
 CanHaveTables needs post-constructor setup. This sets the base HDF5 object that gets manipulated. More...
 
std::shared_ptr< H5::Group > _getTablesParent () const override
 Gets the base HDF5 object that is manipulated. More...
 

Detailed Description

Definition at line 14 of file Group_impl.hpp.

Constructor & Destructor Documentation

◆ Group_impl() [1/5]

icedb::Groups::Group_impl::Group_impl ( )

Definition at line 11 of file Groups.cpp.

References icedb::Groups::Group::_icedb_obj_type_identifier.

11 : Group() {}

◆ Group_impl() [2/5]

icedb::Groups::Group_impl::Group_impl ( const std::string &  name,
gsl::not_null< H5::Group *>  parent 
)

Definition at line 19 of file Groups.cpp.

References icedb::Attributes::CanHaveAttributes_impl::_setAttributeParent(), icedb::Tables::CanHaveTables_impl::_setTablesParent(), grp, icedb::Groups::Group::name, icedb::fs::hdf5::openGroup(), and icedb::Attributes::CanHaveAttributes_impl::parent.

20  : Group{ name }
21  {
22  auto ugrp = fs::hdf5::openGroup(parent.get(), name.c_str());
23  //grp = std::shared_ptr<H5::Group>(ugrp.release());
24  grp = std::shared_ptr<H5::Group>(ugrp.release()); // , mem::icedb_delete<H5::Group>());
25  this->_setAttributeParent(grp);
26  this->_setTablesParent(grp);
27  }
virtual void _setAttributeParent(std::shared_ptr< H5::H5Object > obj) override
Definition: Attributes.cpp:24
void _setTablesParent(std::shared_ptr< H5::Group > obj) override
CanHaveTables needs post-constructor setup. This sets the base HDF5 object that gets manipulated...
Definition: Tables.cpp:343
Group_HDF_shared_ptr grp
Definition: Group_impl.hpp:17
HDFgroup_t openGroup(gsl::not_null< ICEDB_H5_GROUP_OWNER_PTR > base, gsl::not_null< const char *> name)
Definition: export-hdf5.cpp:75
std::shared_ptr< H5::H5Object > parent
const std::string name
The name of the group.
Definition: Group.hpp:34
Here is the call graph for this function:

◆ Group_impl() [3/5]

icedb::Groups::Group_impl::Group_impl ( const std::string &  name,
gsl::not_null< H5::H5File *>  parent 
)

Definition at line 28 of file Groups.cpp.

References icedb::Attributes::CanHaveAttributes_impl::_setAttributeParent(), icedb::Tables::CanHaveTables_impl::_setTablesParent(), grp, icedb::Groups::Group::name, icedb::fs::hdf5::openGroup(), and icedb::Attributes::CanHaveAttributes_impl::parent.

29  : Group{ name }
30  {
31  auto ugrp = fs::hdf5::openGroup(parent.get(), name.c_str());
32  //grp = std::shared_ptr<H5::Group>(ugrp.release());
33  grp = std::shared_ptr<H5::Group>(ugrp.release()); // , mem::icedb_delete<H5::Group>());
34  this->_setAttributeParent(grp);
35  this->_setTablesParent(grp);
36  }
virtual void _setAttributeParent(std::shared_ptr< H5::H5Object > obj) override
Definition: Attributes.cpp:24
void _setTablesParent(std::shared_ptr< H5::Group > obj) override
CanHaveTables needs post-constructor setup. This sets the base HDF5 object that gets manipulated...
Definition: Tables.cpp:343
Group_HDF_shared_ptr grp
Definition: Group_impl.hpp:17
HDFgroup_t openGroup(gsl::not_null< ICEDB_H5_GROUP_OWNER_PTR > base, gsl::not_null< const char *> name)
Definition: export-hdf5.cpp:75
std::shared_ptr< H5::H5Object > parent
const std::string name
The name of the group.
Definition: Group.hpp:34
Here is the call graph for this function:

◆ Group_impl() [4/5]

icedb::Groups::Group_impl::Group_impl ( const std::string &  name,
gsl::not_null< const Group *>  parent 
)

Definition at line 39 of file Groups.cpp.

References icedb::Attributes::CanHaveAttributes_impl::_setAttributeParent(), icedb::Tables::CanHaveTables_impl::_setTablesParent(), grp, icedb::Groups::Group::name, icedb::fs::hdf5::openGroup(), and icedb::Attributes::CanHaveAttributes_impl::parent.

40  : Group{ name }
41  {
42  auto ugrp = fs::hdf5::openGroup(parent->getHDF5Group().get(), name.c_str());
43  //grp = std::shared_ptr<H5::Group>(ugrp.release());
44  grp = std::shared_ptr<H5::Group>(ugrp.release()); // , mem::icedb_delete<H5::Group>());
45  this->_setAttributeParent(grp);
46  this->_setTablesParent(grp);
47  }
virtual void _setAttributeParent(std::shared_ptr< H5::H5Object > obj) override
Definition: Attributes.cpp:24
void _setTablesParent(std::shared_ptr< H5::Group > obj) override
CanHaveTables needs post-constructor setup. This sets the base HDF5 object that gets manipulated...
Definition: Tables.cpp:343
Group_HDF_shared_ptr grp
Definition: Group_impl.hpp:17
HDFgroup_t openGroup(gsl::not_null< ICEDB_H5_GROUP_OWNER_PTR > base, gsl::not_null< const char *> name)
Definition: export-hdf5.cpp:75
std::shared_ptr< H5::H5Object > parent
const std::string name
The name of the group.
Definition: Group.hpp:34
Here is the call graph for this function:

◆ Group_impl() [5/5]

icedb::Groups::Group_impl::Group_impl ( Group_HDF_shared_ptr  grp)

Definition at line 49 of file Groups.cpp.

References icedb::Attributes::CanHaveAttributes_impl::_setAttributeParent(), icedb::Tables::CanHaveTables_impl::_setTablesParent(), and grp.

50  : Group( "UNKNOWN" )
51  {
52  this->grp = grp;
53  this->_setAttributeParent(grp);
54  this->_setTablesParent(grp);
55  }
virtual void _setAttributeParent(std::shared_ptr< H5::H5Object > obj) override
Definition: Attributes.cpp:24
void _setTablesParent(std::shared_ptr< H5::Group > obj) override
CanHaveTables needs post-constructor setup. This sets the base HDF5 object that gets manipulated...
Definition: Tables.cpp:343
Group_HDF_shared_ptr grp
Definition: Group_impl.hpp:17
Here is the call graph for this function:

◆ ~Group_impl()

icedb::Groups::Group_impl::~Group_impl ( )
virtual

Definition at line 17 of file Groups.cpp.

17 {}

Member Function Documentation

◆ createGroup()

Group::Group_ptr icedb::Groups::Group_impl::createGroup ( const std::string &  groupName)
overridevirtual

Create a group.

Parameters
groupNameis the new group's name
Exceptions
ifread-only
ifa group with htis name already exists
Returns
a pointer to the new group

Implements icedb::Groups::Group.

Definition at line 61 of file Groups.cpp.

References icedb::Groups::Group::createGroup(), and grp.

61  {
62  return std::move(Group::createGroup(groupName, this->grp.get()));
63  }
virtual Group_ptr createGroup(const std::string &groupName)=0
Create a group.
Group_HDF_shared_ptr grp
Definition: Group_impl.hpp:17
Here is the call graph for this function:

◆ deleteGroup()

void icedb::Groups::Group_impl::deleteGroup ( const std::string &  groupName)
overridevirtual

Unlink the specified child group.

Parameters
groupNameis the name of the group to be unlinked
Exceptions
ifgroupName is invalid
ifa group with name groupName does not exist

Implements icedb::Groups::Group.

Definition at line 138 of file Groups.cpp.

References grp.

138  {
139  grp->unlink(groupName);
140  }
Group_HDF_shared_ptr grp
Definition: Group_impl.hpp:17

◆ doesGroupExist()

bool icedb::Groups::Group_impl::doesGroupExist ( const std::string &  groupName) const
overridevirtual

Does a group with this name exist?

Returns
true if it exists, false otherwise
Parameters
groupNameis the name of the group
Exceptions
ifgroupName is somehow invalid

Implements icedb::Groups::Group.

Definition at line 142 of file Groups.cpp.

References getGroupNames().

142  {
143  auto gnames = getGroupNames();
144  if (gnames.count(groupName)) return true;
145  return false;
146  }
std::set< std::string > getGroupNames() const override
Definition: Groups.cpp:148
Here is the call graph for this function:

◆ getGroupNames()

std::set< std::string > icedb::Groups::Group_impl::getGroupNames ( ) const
overridevirtual
Note
This shared pointer gets a custom deallocator. TODO: Add deallocator for strings.

Implements icedb::Groups::Group.

Definition at line 148 of file Groups.cpp.

References icedb::fs::hdf5::getGroupMembersTypes(), and grp.

Referenced by doesGroupExist().

148  {
149  auto objs = fs::hdf5::getGroupMembersTypes(*(grp.get()));
150  std::set<std::string> res;
151  for (const auto &o : objs)
152  {
153  if (o.second == H5G_obj_t::H5G_GROUP) res.insert(o.first);
154  }
155  return res;
156  }
Group_HDF_shared_ptr grp
Definition: Group_impl.hpp:17
std::map< std::string, H5G_obj_t > getGroupMembersTypes(const ICEDB_H5_GETNUMOBJS_OWNER &base)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getHDF5Group()

std::shared_ptr< H5::Group > icedb::Groups::Group_impl::getHDF5Group ( ) const
overridevirtual

Get the fundamental HDF5 object that the group is built on.

Implements icedb::Groups::Group.

Definition at line 57 of file Groups.cpp.

References grp.

57  {
58  return grp;
59  }
Group_HDF_shared_ptr grp
Definition: Group_impl.hpp:17

◆ openGroup()

Group::Group_ptr icedb::Groups::Group_impl::openGroup ( const std::string &  groupName) const
overridevirtual

Opens a group.

Parameters
groupNameis the name of the group to be opened
Exceptions
ifthe group does not exist
Returns
a pointer to the newly-opened group

Implements icedb::Groups::Group.

Definition at line 107 of file Groups.cpp.

References grp, icedb::Groups::Group::name, icedb::Groups::Group::openGroup(), and icedb::Attributes::CanHaveAttributes_impl::parent.

Referenced by icedb::Groups::Group::mount().

107  {
108  return std::make_unique<Group_impl>(groupName, grp.get());
109  //return std::move(Group::Group_ptr(new Group_impl(groupName, grp.get())));
110  }
Group_HDF_shared_ptr grp
Definition: Group_impl.hpp:17
Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ Group

friend class Group
friend

Definition at line 19 of file Group_impl.hpp.

Member Data Documentation

◆ grp

Group_HDF_shared_ptr icedb::Groups::Group_impl::grp
private
Note
This shared pointer has a custom deallocator, to ensure that it is freed in the correct module.

Definition at line 17 of file Group_impl.hpp.

Referenced by createGroup(), deleteGroup(), getGroupNames(), getHDF5Group(), Group_impl(), openGroup(), and icedb::Shapes::Shape_impl::Shape_impl().


The documentation for this class was generated from the following files: