libpniio
|
NXgroup object. More...
#include <nxgroup.hpp>
Public Types | |
using | imp_type = typename nximp_map< IMPID >::group_imp |
group implementation type More... | |
using | type_type = typename nximp_map< IMPID >::type_imp |
type implementation More... | |
using | group_type = nxgroup< IMPID > |
the group type More... | |
using | value_type = typename nxobject_trait< IMPID >::object_type |
nxobject as container value_type More... | |
using | iterator = pni::core::container_iterator< const group_type > |
iterator type More... | |
using | field_type = typename nxobject_trait< IMPID >::field_type |
field type More... | |
using | attribute_type = typename nxobject_trait< IMPID >::attribute_type |
attribute type More... | |
using | link_type = typename nxobject_trait< IMPID >::link_type |
link type More... | |
Public Member Functions | |
nxgroup () | |
default constructor More... | |
nxgroup (const group_type &o) | |
copy constructor More... | |
nxgroup (group_type &&o) | |
move constructor More... | |
nxgroup (imp_type &&imp) | |
move construct from implementation object More... | |
nxgroup (const typename nxobject_trait< IMPID >::object_type &o) | |
conversion constructor More... | |
group_type & | operator= (const group_type &g) |
copy assignment More... | |
group_type & | operator= (group_type &&g) |
move assignment More... | |
group_type & | operator= (const typename nxobject_trait< IMPID >::object_type &o) |
conversion assignment More... | |
group_type | create_group (const pni::core::string &n, const pni::core::string &type=pni::core::string()) const |
create a group as nexus class More... | |
template<typename T , typename CTYPE = pni::core::shape_t> | |
field_type | create_field (const pni::core::string &n, const CTYPE &shape={1}) const |
create a field More... | |
template<typename T , typename CTYPE = pni::core::shape_t> | |
field_type | create_field (const pni::core::string &n, const CTYPE &shape, const CTYPE &chunk) const |
create a field More... | |
template<typename T , typename CTYPES , typename FIMP > | |
field_type | create_field (const pni::core::string &n, const CTYPES &shape, const nxfilter< FIMP > &filter) const |
Creates a multidimensional field with a filter. More... | |
template<typename T , typename CTYPES , typename CTYPEC , typename FIMP > | |
field_type | create_field (const pni::core::string &n, const CTYPES &s, const CTYPEC &cs, const nxfilter< FIMP > &filter) const |
create a multidimensional field (explicit chunk) with filter More... | |
nxobject_trait< IMPID > ::object_type | at (const pni::core::string &n) const |
open an arbitrary object More... | |
nxobject_trait< IMPID > ::object_type | operator[] (const pni::core::string &n) const |
open an object More... | |
size_t | size () const |
return number of children More... | |
nxobject_trait< IMPID > ::object_type | parent () const |
return parent object More... | |
nxobject_trait< IMPID > ::object_type | at (size_t i) const |
open object by index More... | |
nxobject_trait< IMPID > ::object_type | operator[] (size_t i) const |
open object by index More... | |
bool | has_child (const pni::core::string &n) const |
check if a particular object exists More... | |
void | remove (const pni::core::string &n) const |
remove an object from the file More... | |
iterator | begin () const noexcept |
iterator on first child More... | |
iterator | end () const |
iterator on last child More... | |
pni::core::string | name () const |
name of the group More... | |
pni::core::string | filename () const |
return filename More... | |
void | close () |
close the group More... | |
bool | is_valid () const |
check group validity More... | |
const imp_type & | imp () const noexcept |
get constant reference to the implementation More... | |
Data Fields | |
nxattribute_manager< group_type > | attributes |
attribute manager More... | |
Private Types | |
using | field_imp_type = typename nximp_map< IMPID >::field_imp |
field implementation type More... | |
using | object_imp_type = typename nximp_map< IMPID >::object_imp |
object implementation type More... | |
Private Member Functions | |
template<typename CTYPE , typename STYPE > | |
CTYPE | _create_auto_chunk (const STYPE &shape) const |
automatic chunk creation More... | |
template<typename T , typename CTYPE > | |
field_type | _create_field (const pni::core::string &n, const CTYPE &shape, const CTYPE &chunk) const |
field creation function More... | |
template<typename T , typename CTYPE , typename FIMP > | |
field_type | _create_field (const pni::core::string &n, const CTYPE &shape, const CTYPE &chunk, const nxfilter< FIMP > &filter) const |
field creation function More... | |
Private Attributes | |
imp_type | _imp |
the implementation instance of nxgroup More... | |
nxgroup is the basic container in Nexus. It can hold other grous, fields and of course attributes. The attributes can be accessed via the public nxattribute_manager attribute. The field and group children of a group can be accessed via the container interface. nxgroup exposes an STL compliant interface and thus can be used like many other STL containers. The value_type of nxgroup is nxobject which is a generic object that can be converted into an attribute, field, or group (provided it represents such an object). As an example we use here nxgroup in a for each loop separating the group and field children into vectors
nxgroup g = ....; std::vector<nxfield> field_vector; std::vector<nxgroup> group_vector;
for(auto child: g) { if(is_field(child)) field_vector.push_back(as_field(child)); else if(is_group(child)) group_vector.push_back(as_group(child)); else throw type_error(...); }In addition we can use lambda functions along with STL lambda functions. Consider the case where we would like to determine the number of fields and groups in a group. This could be easily done with
nxgroup g = ....; size_t number_of_fields = std::count_if(g.begin(),g.end(), [](const nxobject &child) {return is_field(child);}); size_t number_of_groups = std::count_if(g.begin(),g.end(), [](const nxobject &child) {return is_group(child);});For a more detailed explanation about groups and field see the user reference manual.
IMPID | implementation ID for the group |
using pni::io::nx::nxgroup< IMPID >::attribute_type = typename nxobject_trait<IMPID>::attribute_type |
|
private |
using pni::io::nx::nxgroup< IMPID >::field_type = typename nxobject_trait<IMPID>::field_type |
using pni::io::nx::nxgroup< IMPID >::group_type = nxgroup<IMPID> |
using pni::io::nx::nxgroup< IMPID >::imp_type = typename nximp_map<IMPID>::group_imp |
using pni::io::nx::nxgroup< IMPID >::iterator = pni::core::container_iterator<const group_type> |
using pni::io::nx::nxgroup< IMPID >::link_type = typename nxobject_trait<IMPID>::link_type |
|
private |
using pni::io::nx::nxgroup< IMPID >::type_type = typename nximp_map<IMPID>::type_imp |
using pni::io::nx::nxgroup< IMPID >::value_type = typename nxobject_trait<IMPID>::object_type |
|
inlineexplicit |
|
inline |
The copy constructor is doing exactly the same as the assignment operator. Thus it can be used to assign an object directly at its construction.
o | original group object |
|
inline |
|
inlineexplicit |
Construction from an implementation instance has to be done via an rvalue reference. This ensures that ownership of the implementation object is passed over to the new nxgroup instance.
imp | rvalue reference to the implementation instance |
|
inline |
|
inlineprivate |
This utility function creates auomatically a chunk shape for a given field shape. Basically, what it does is to copy the shape and than replace the first element with a 1.
CTYPE | container type for the chunk |
STYPE | container type for the shape |
shape | reference to STYPE with shape data |
|
inlineprivate |
This member function template is doing the real work on creating a field. The frontend functions provided by the public interface take only care about the shape and chunk shape configuration. This function creates a field without a filter.
size_mismatch_error | if chunk and shape have different size |
type_error | if data type is not supported |
invalid_object_error | if the group is not valid |
object_error | in case of any other error |
T | data type of the field to create |
CTYPE | container type for shape and chunk shape |
n | name of the field |
shape | container with shape information |
chunk | container with chunk shape data |
|
inlineprivate |
This member function template is doing the real work on creating a field. The frontend functions provided by the public interface take only care about the shape and chunk shape configuration. This function creates a field with filter.
size_mismatch_error | if chunk and shape have different size |
type_error | if data type is not supported |
invalid_object_error | if the group is not valid |
object_error | in case of any other error |
T | data type of the field to create |
CTYPE | container type for shape and chunk shape |
FIMP | filter implementation type |
n | name of the field |
shape | container with shape information |
chunk | container with chunk shape data |
filter | reference to a filter instance |
|
inline |
Returns an object by name. The name can be either an absolute or relative path.
invalid_object_error | if group is not valid |
key_error | if child does not exist |
type_error | if child type is not supported |
value_error | if name contains a '/' character |
object_error | in case of any other error |
n | path or name of the object to open |
|
inline |
Unlike open(const string &n) here the object is addressed by its index. Thus only objects directly linked below this group can be accessed.
index_error | if the index exceeds number of childs |
invalid_object_error | if the group is not valid |
type_error | if the child type is not supported |
object_error | in case of any other error |
i | index of the object |
|
inlinenoexcept |
Return an iterator on the first child stored in below the group.
|
inline |
type_error | if the internal type could not be determined |
object_error | in case of other errors |
|
inline |
Create a field. The shape of the field can be specified by the optional shape argument. By default this is set to {1} which means that an expandable scalar field will be created. The chunk size for the field is automatically derived by the method by replacing the first element of the shape with 1. As an example consider the following shape for the field {100,1024,3}. This would yield a chunk size of {1,1024,3}.
If the user passes a container with shape information the container must not be empty. Otherwise an exception will be thrown.
size_mismatch_error | if chunk and shape have different size |
type_error | if data type is not supported |
invalid_object_error | if the group is not valid |
object_error | in case of any other error |
T | data type of the field |
CTYPE | container type for the shape |
n | name of the field |
shape | optional shape argument |
|
inline |
Create a new data field without a filter for compression.
The chunk shape here is optional. If not given a default value will be generated from the original shape where the first dimension is set to one.
size_mismatch_error | if chunk and shape have different size |
type_error | if data type is not supported |
invalid_object_error | if the group is not valid |
object_error | in case of any other error |
T | data type of the field |
CTYPE | container type for the shape and chunk |
n | name (path) of the field |
shape | shape of the field |
chunk | chunk shape of the field |
|
inline |
Create a multidimensional field with a filter for data compression. With this method the chunk shape for the field is determined automatically.
size_mismatch_error | if chunk and shape have different size |
type_error | if data type is not supported |
invalid_object_error | if the group is not valid |
object_error | in case of any other error |
T | data type for the filed |
CTYPES | container type for the field shape |
n | name of the field |
shape | shape of the field |
filter | implementation |
|
inline |
Create a field with filter and adjustable chunk shape.
size_mismatch_error | if chunk and shape have different size |
type_error | if data type is not supported |
invalid_object_error | if the group is not valid |
object_error | in case of any other error |
T | data type of the field |
CTYPES | container type for the shape |
CTYPEC | container type for the chunk shape |
n | name or path of the field |
s | shape of the field |
cs | chunk shape of the field |
filter | filter instance to use |
|
inline |
Create a new group. The optional argument type determines the Nexus object type the group represents. By default type is an empty string in which case the NX_class attribute will not be written.
invalid_object_error | if parent is not valid |
object_error | in case of any other error |
n | group name |
type | nexus class type |
|
inline |
Returns an iterator on the last+1 obejct stored in the group.
invalid_object_error | if group is not valid |
object_error | in case of any other error |
|
inline |
Returns the name of the file the group belongs too.
invalid_object_error | if the field is not valid |
io_error | if the filename information retrieval fails |
type_error | if the internal object type does not support filename retrieval |
object_error | in case of any other error |
|
inline |
Check if a link with name n to an object can be found below this group.
invalid_object_error | if group is not valid |
object_error | in case of any other error |
n | name of the link (object) to look for |
|
inlinenoexcept |
|
inline |
Returns true if the group is valid, false otherwise.
object_error | if validity check fails |
|
inline |
Returns the name of the group
invalid_object_error | if group is not valid |
type_error | if the internals object type cannot be determined |
io_error | in case of errors during reading data |
object_error | in case of any other error |
|
inline |
|
inline |
|
inline |
|
inline |
Opens an object using the [] operator. w
invalid_object_error | if group is not valid |
key_error | if child does not exist |
type_error | if child type is not supported |
value_error | if name contains a '/' value error |
object_error | in case of any other error |
n | name or path of the object |
|
inline |
Opens an object by index using the [] operator.
index_error | if the index exceeds number of childs |
invalid_object_error | if the group is not valid |
type_error | if the child type is not supported |
object_error | in case of any other error |
i | index of the object |
|
inline |
Return the parent object of the gruop.
invalid_object_error | if group is not valid |
type_error | if the parents object type is unkown |
object_error | in case of any other error |
|
inline |
Remove the link with name n to an object. As objects are not really delted this will only remove a particular link to an object. If this was the only link the object is no longer accessible. However, the object still exists. You have to use h5repack in order to physically delete the object from the file.
key_error | if the child does not exist |
invalid_object_error | if group is not valid |
object_error | in case of any other error |
n | name of the link to delete |
|
inline |
Returns the number of children attached to this group.
invalid_object_error | if group is not valid |
object_error | in case of any other error |
|
private |
nxattribute_manager<group_type> pni::io::nx::nxgroup< IMPID >::attributes |
This public attribute provides access to the groups attribute manager.