icedb
version 0.5.1
Snow particle scattering database API
|
A high-level class to manipulate particle shapes. More...
#include <shape.hpp>
Public Types | |
typedef std::unique_ptr< Shape > | Shape_Type |
The preferred C++ type for referencing a shape. More... | |
![]() | |
typedef std::unique_ptr< Groups::Group > | Group_ptr |
typedef std::shared_ptr< H5::Group > | Group_HDF_shared_ptr |
Public Member Functions | |
virtual | ~Shape () |
bool | isShape () const |
Is this object actually a shape? More... | |
bool | isValid (std::ostream *out=nullptr) const |
Is this object a valid shape, according to the spec? More... | |
![]() | |
virtual | ~Group () |
virtual Group_ptr | createGroup (const std::string &groupName)=0 |
Create a group. More... | |
virtual Group_ptr | openGroup (const std::string &groupName) const =0 |
Opens a group. More... | |
virtual bool | doesGroupExist (const std::string &groupName) const =0 |
Does a group with this name exist? More... | |
virtual std::set< std::string > | getGroupNames () const =0 |
Get the names of all sub-groups within the current group. More... | |
virtual void | deleteGroup (const std::string &groupName)=0 |
Unlink the specified child group. More... | |
virtual Group_HDF_shared_ptr | getHDF5Group () const =0 |
Get the fundamental HDF5 object that the group is built on. More... | |
![]() | |
~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... | |
![]() | |
~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... | |
Static Public Member Functions | |
static bool | isShape (Groups::Group &owner, const std::string &name) |
Is this object a shape? More... | |
static bool | isShape (gsl::not_null< H5::Group *> group) |
Is this object a group? More... | |
static bool | isValid (gsl::not_null< H5::Group *> group, std::ostream *out=nullptr) |
Is "group" a valid shape, according to the spec.? More... | |
static Shape_Type | openShape (Groups::Group &grpshp) |
static Shape_Type | openShape (Groups::Group &owner, const std::string &name) |
Open a group's subgroup as a shape. More... | |
static Shape_Type | openShape (Groups::Group::Group_HDF_shared_ptr shape) |
Re-open an open HDF5 group as a shape. More... | |
static Shape_Type | createShape (Groups::Group &grpshp, const std::string &uid, gsl::not_null< const NewShapeRequiredProperties *> required, const NewShapeCommonOptionalProperties *optional=nullptr) |
Create a new shape. More... | |
static Shape_Type | createShape (Groups::Group &owner, const std::string &name, const std::string &uid, gsl::not_null< const NewShapeRequiredProperties *> required, const NewShapeCommonOptionalProperties *optional=nullptr) |
Create a new shape. More... | |
static Shape_Type | createShape (Groups::Group::Group_HDF_shared_ptr newShapeLocation, const std::string &uid, gsl::not_null< const NewShapeRequiredProperties *> required, const NewShapeCommonOptionalProperties *optional=nullptr) |
Create a new shape. More... | |
![]() | |
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 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 | |
const std::string | particle_unique_id |
This is the unique identifier for this shape. More... | |
![]() | |
const std::string | name |
The name of the group. More... | |
Static Public Attributes | |
static const std::string | _icedb_obj_type_shape_identifier = "shape" |
Each shape 'group' has an attribute with this identifier. Used for shape collection and searching. More... | |
![]() | |
static const std::string | _icedb_obj_type_identifier = { "_icedb_obj_type" } |
The tag used in icedb to identify a group. More... | |
Protected Member Functions | |
Shape (const std::string &uid) | |
![]() | |
Group () | |
Group (const std::string &name) | |
![]() | |
CanHaveAttributes () | |
virtual void | _setAttributeParent (std::shared_ptr< H5::H5Object > obj)=0 |
virtual std::shared_ptr< H5::H5Object > | _getAttributeParent () const =0 |
![]() | |
CanHaveTables () | |
Trivial constructor used when CanHaveTables is a virtual base class. More... | |
virtual void | _setTablesParent (std::shared_ptr< H5::Group > obj)=0 |
CanHaveTables needs post-constructor setup. This sets the base HDF5 object that gets manipulated. More... | |
virtual std::shared_ptr< H5::Group > | _getTablesParent () const =0 |
Gets the base HDF5 object that is manipulated. More... | |
A high-level class to manipulate particle shapes.
Shapes are implemented as a set of tables and attributes, contained within a discrete Group. This class provides a higl-level interface to accessing and manipulating shapes. It acts as an "overlay" to an alreagy-existing group. It adds additional functions and "value".
typedef std::unique_ptr<Shape> icedb::Shapes::Shape::Shape_Type |
|
protected |
Definition at line 160 of file Shapes.cpp.
References _icedb_obj_type_shape_identifier.
|
virtual |
Definition at line 159 of file Shapes.cpp.
|
static |
Create a new shape.
uid | is a unique name for the shape |
grpshp | is the opened group that is converted into a shape |
if | the group has any already-existing tables or attributes that conflict with the new shape object |
required | is a pointer to the NewShapeRequiredProperties structure, that provides the "required" shape data. |
optional | is a pointer to the Common Optional Properties structure, that provides optional, supplementary data. |
on | failure |
Definition at line 231 of file Shapes.cpp.
References icedb::Groups::Group::getHDF5Group().
Referenced by createShape(), main(), and icedb::Examples::Shapes::ShapeDataBasic::toShape().
|
static |
Create a new shape.
owner | is the "parent" of the shape - a shape is constructed as a child of the owner |
name | is the name of the new group that gets created |
uid | is a unique name for the shape |
if | the group has any already-existing tables or attributes that conflict with the new shape object |
required | is a pointer to the NewShapeRequiredProperties structure, that provides the "required" shape data. |
optional | is a pointer to the Common Optional Properties structure, that provides optional, supplementary data. |
on | failure |
Definition at line 239 of file Shapes.cpp.
References icedb::Groups::Group::createGroup(), createShape(), icedb::Groups::Group::doesGroupExist(), and icedb::Groups::Group::openGroup().
|
static |
Create a new shape.
newShapeLocation | is the "parent" of the shape - a shape is constructed as a child of the owner |
uid | is a unique name for the shape |
if | the group has any already-existing tables or attributes that conflict with the new shape object |
required | is a pointer to the NewShapeRequiredProperties structure, that provides the "required" shape data. |
optional | is a pointer to the Common Optional Properties structure, that provides optional, supplementary data. |
on | failure |
Definition at line 254 of file Shapes.cpp.
References icedb::Shapes::NewShapeCommonOptionalProperties::hint_max_scattering_element_dimension, icedb::Shapes::NewShapeCommonOptionalProperties::isValid(), icedb::Shapes::NewShapeCommonOptionalProperties::particle_constituent_number, icedb::Shapes::NewShapeCommonOptionalProperties::particle_constituent_single_name, icedb::Shapes::NewShapeCommonOptionalProperties::particle_scattering_element_composition_fractional, icedb::Shapes::NewShapeCommonOptionalProperties::particle_scattering_element_composition_whole, icedb::Shapes::NewShapeCommonOptionalProperties::particle_scattering_element_number, icedb::Shapes::NewShapeCommonOptionalProperties::particle_scattering_element_radius, icedb::Shapes::NewShapeCommonOptionalProperties::particle_scattering_element_spacing, icedb::Tables::Table::setDimensionScale(), and icedb::Tables::Table::writeAll().
|
static |
Is this object a shape?
owner | is the parent group |
name | is the sub-group that is being tested |
if | the group "name" does not exist |
Definition at line 163 of file Shapes.cpp.
References icedb::Groups::Group::doesGroupExist(), isShape(), and icedb::Groups::Group::openGroup().
|
static |
Is this object a group?
group | is the HDF5 group |
if | the object pointed to by group is not a valid HDF5 group. |
Definition at line 168 of file Shapes.cpp.
References icedb::Attributes::Attribute< DataType >::data, icedb::Attributes::CanHaveAttributes::doesAttributeExist(), and icedb::Attributes::CanHaveAttributes::getAttributeTypeId().
bool icedb::Shapes::Shape::isShape | ( | ) | const |
Is this object actually a shape?
Definition at line 178 of file Shapes.cpp.
References icedb::Groups::Group::getHDF5Group().
Referenced by isShape(), isValid(), and openShape().
|
static |
Is "group" a valid shape, according to the spec.?
group | is the HDF5 group |
if | the object pointed to by group is not a valid HDF5 group. |
out | is an output stream to which diagnostic messages can be written. Diagnostics include why an object is not a shape (e.g. missing an essential parameter). |
if | the output stream is somehow invalid |
Check for the existence of the standard tables, dimensions and attributes, and that they have the appropriate sizes.
Definition at line 183 of file Shapes.cpp.
References icedb::Groups::Group::_icedb_obj_type_identifier, icedb::Attributes::CanHaveAttributes::doesAttributeExist(), icedb::Attributes::CanHaveAttributes::getAttributeTypeId(), and isShape().
Referenced by isValid().
bool icedb::Shapes::Shape::isValid | ( | std::ostream * | out = nullptr | ) | const |
Is this object a valid shape, according to the spec?
out | is an output stream to which diagnostic messages can be written. Diagnostics include why an object is not a shape (e.g. missing an essential parameter). |
if | the output stream is somehow invalid |
Definition at line 182 of file Shapes.cpp.
References icedb::Groups::Group::getHDF5Group(), and isValid().
|
static |
Re-open a group as a shape
if | the group is not a valid shape |
Definition at line 227 of file Shapes.cpp.
References icedb::Groups::Group::getHDF5Group().
Referenced by openShape().
|
static |
Open a group's subgroup as a shape.
Definition at line 222 of file Shapes.cpp.
References icedb::Groups::Group::doesGroupExist(), icedb::Groups::Group::openGroup(), and openShape().
|
static |
Re-open an open HDF5 group as a shape.
Definition at line 432 of file Shapes.cpp.
References isShape().
|
static |
const std::string icedb::Shapes::Shape::particle_unique_id |