libpniio
Public Types | Public Member Functions | Private Member Functions | Private Attributes
pni::io::nx::nxattribute< IMPID > Class Template Reference

attribute object More...

#include <nxattribute.hpp>

Collaboration diagram for pni::io::nx::nxattribute< IMPID >:
Collaboration graph
[legend]

Public Types

typedef nximp_map< IMPID >
::attribute_imp 
implementation_type
 implementation type of the attribute More...
 
typedef nximp_map< IMPID >
::type_imp 
type_type
 implementation of the type trait More...
 
typedef nxattribute< IMPID > attribute_type
 define the actual type of this object More...
 

Public Member Functions

 nxattribute () noexcept
 default constructor More...
 
 nxattribute (implementation_type &&i)
 move constructor from implementation More...
 
 nxattribute (const typename nxobject_trait< IMPID >::object_type &o)
 conversion constructor More...
 
attribute_typeoperator= (const typename nxobject_trait< IMPID >::object_type &o)
 conversion assignment More...
 
template<typename STORAGE , typename IMAP , typename IPA >
void write (const pni::core::mdarray< STORAGE, IMAP, IPA > &o) const
 write data from an mdarray instance More...
 
template<typename ATYPE >
void write (const pni::core::array_view< ATYPE > &v) const
 write view data to an attribute More...
 
template<typename T >
void write (size_t n, const T *data) const
 write data from a plain C pointer More...
 
template<typename T >
void write (const std::vector< T > &data) const
 write data from a vector More...
 
template<typename T >
void write (const T &value) const
 write a single scalar value More...
 
void write (const char *value) const
 write a C-string More...
 
void write (const pni::core::array &a) const
 write array type erasure data More...
 
template<typename STORAGE , typename IMAP , typename IPA >
void read (pni::core::mdarray< STORAGE, IMAP, IPA > &o) const
 read data to an array More...
 
template<typename ATYPE >
void read (pni::core::array_view< ATYPE > &v) const
 
template<typename ATYPE >
void read (pni::core::array_view< ATYPE > &&v) const
 
void read (pni::core::array &a) const
 read data to array More...
 
template<typename T >
void read (T &value) const
 read a single scalar value More...
 
template<typename T >
void read (size_t n, T *value) const
 read data to pointer More...
 
template<typename T >
void read (std::vector< T > &data) const
 read data to an STL vector More...
 
template<typename CTYPE >
CTYPE shape () const
 obtain attribute shape More...
 
size_t rank () const
 return attribute rank More...
 
size_t size () const
 obtain attribute size More...
 
pni::core::type_id_t type_id () const
 obtain type id More...
 
void close ()
 close attribute More...
 
bool is_valid () const
 check validity of the attribute More...
 
pni::core::string name () const
 get attribute name More...
 
pni::core::string filename () const
 return filename More...
 
template<typename... ITYPES>
attribute_type operator() (ITYPES...indices) const
 apply selection to an attribute More...
 
attribute_type operator() (const std::vector< pni::core::slice > &indices) const
 
nxobject_trait< IMPID >
::object_type 
parent () const
 return parent object More...
 

Private Member Functions

template<typename ATYPE >
void _write_array (const ATYPE &a) const
 write data from array More...
 
template<typename ATYPE >
void _read_array (ATYPE &a) const
 read data to array More...
 

Private Attributes

implementation_type _imp
 implementation of the attribute object More...
 

Detailed Description

template<nximp_code IMPID>
class pni::io::nx::nxattribute< IMPID >

nxattribute represents an attribute which is attached to one of the Nexus objects. Objects of this type can be used to read and write attribute data from and to an object.

Member Typedef Documentation

template<nximp_code IMPID>
typedef nxattribute<IMPID> pni::io::nx::nxattribute< IMPID >::attribute_type
template<nximp_code IMPID>
typedef nximp_map<IMPID>::attribute_imp pni::io::nx::nxattribute< IMPID >::implementation_type
template<nximp_code IMPID>
typedef nximp_map<IMPID>::type_imp pni::io::nx::nxattribute< IMPID >::type_type

Constructor & Destructor Documentation

template<nximp_code IMPID>
pni::io::nx::nxattribute< IMPID >::nxattribute ( )
inlineexplicitnoexcept
template<nximp_code IMPID>
pni::io::nx::nxattribute< IMPID >::nxattribute ( implementation_type &&  i)
inlineexplicit
Exceptions
invalid_object_errorif the implementation is not valid
type_errorif the implementation type is not an attribute
object_errorin case of any other error
Parameters
irvalue to an implementation instance
template<nximp_code IMPID>
pni::io::nx::nxattribute< IMPID >::nxattribute ( const typename nxobject_trait< IMPID >::object_type &  o)
inline

Constructs an attribute object form an instance of object_type.

Exceptions
type_errorif the object is not an attribute
object_errorin case of any other error
Parameters
oinstance of object_type

Member Function Documentation

template<nximp_code IMPID>
template<typename ATYPE >
void pni::io::nx::nxattribute< IMPID >::_read_array ( ATYPE &  a) const
inlineprivate

Read attribute data from the file and store it to the array.

Exceptions
memory_not_allocated_errorif the arrays buffer is not allocated
shape_mismatch_errorif the shapes of the array and the attribute do not match
io_errorin case of a general IO error
type_errorif the datatype is unkonwn
invalid_object_errorin case the attribute is not valid
object_errorin case of any other error
Template Parameters
ATYPEarray type
Parameters
ainstance of ATYPE
template<nximp_code IMPID>
template<typename ATYPE >
void pni::io::nx::nxattribute< IMPID >::_write_array ( const ATYPE &  a) const
inlineprivate

Read data from an array type and store it in the attribute.

Exceptions
memory_not_allocated_errorif the array buffer is not allocated
shape_mismatch_errorif the shapes of the array and the attribute do not match
io_errorin case of IO errors
invalid_object_errorif attribute is not valid
type_errorif the data type is unknown
object_errorin case of any other error
Template Parameters
ATYPEarray type
Parameters
ainstance of ATYPE
template<nximp_code IMPID>
void pni::io::nx::nxattribute< IMPID >::close ( )
inline
Exceptions
type_errorif object type cannot be determined
object_errorin case of any other error
template<nximp_code IMPID>
pni::core::string pni::io::nx::nxattribute< IMPID >::filename ( ) const
inline

Returns the name of the file the attribute belongs too.

Exceptions
invalid_object_errorif the field is not valid
io_errorif the filename information retrieval fails
type_errorif the internal object type does not support filename retrieval
object_errorin case of any other error
Returns
name of the file
template<nximp_code IMPID>
bool pni::io::nx::nxattribute< IMPID >::is_valid ( ) const
inline
Exceptions
object_errorif the validity check fails
Returns
true if object is valid, false otherwise
template<nximp_code IMPID>
pni::core::string pni::io::nx::nxattribute< IMPID >::name ( ) const
inline

Obtain the name of the attribute. With this name it can be identified at a particular object.

Exceptions
invalid_object_errorif object is not valid
io_errorin case of an IO error
object_errorin case of any other error
type_errorif object type cannot be determined
Returns
string with the attributes name
template<nximp_code IMPID>
template<typename... ITYPES>
attribute_type pni::io::nx::nxattribute< IMPID >::operator() ( ITYPES...  indices) const
inline
template<nximp_code IMPID>
attribute_type pni::io::nx::nxattribute< IMPID >::operator() ( const std::vector< pni::core::slice > &  indices) const
inline
template<nximp_code IMPID>
attribute_type& pni::io::nx::nxattribute< IMPID >::operator= ( const typename nxobject_trait< IMPID >::object_type &  o)
inline

This assignment operator converts an object_type to an attribute.

Exceptions
type_errorif the object is not an attribute
object_errorin case of any other error
Parameters
oinstance of object_type
Returns
reference to attribute
template<nximp_code IMPID>
nxobject_trait<IMPID>::object_type pni::io::nx::nxattribute< IMPID >::parent ( ) const
inline

This method returns the parent object of a

Exceptions
invalid_object_errorif attribute is not valid
type_errorif parent type is unkown
object_errorin case of any other error
Returns
parent object
template<nximp_code IMPID>
size_t pni::io::nx::nxattribute< IMPID >::rank ( ) const
inline

This method returns the rank of the attribute - the number of dimensions.

Exceptions
invalid_object_errorif the attribute is not valid
object_errorin case of any other error
Returns
number of dimensions
template<nximp_code IMPID>
template<typename STORAGE , typename IMAP , typename IPA >
void pni::io::nx::nxattribute< IMPID >::read ( pni::core::mdarray< STORAGE, IMAP, IPA > &  o) const
inline

Read data to an DArray instance.

Exceptions
memory_not_allocated_errorif array buffer is not allocated
size_mismatch_errorif array and attribute shape do not match
invalid_object_errorif field is not valid
type_errorif data type is not supported
io_errorin case of a general IO error
object_errorin case of any other error
Template Parameters
STORAGEstorage type for mdarray
IMAPindex map type for mdarray
IPAin-place arithmetics type for mdarray
Parameters
oinstance of DArray
template<nximp_code IMPID>
template<typename ATYPE >
void pni::io::nx::nxattribute< IMPID >::read ( pni::core::array_view< ATYPE > &  v) const
inline
template<nximp_code IMPID>
template<typename ATYPE >
void pni::io::nx::nxattribute< IMPID >::read ( pni::core::array_view< ATYPE > &&  v) const
inline
template<nximp_code IMPID>
void pni::io::nx::nxattribute< IMPID >::read ( pni::core::array &  a) const
inline
Exceptions
memory_not_allocated_errorif array not allocated
type_errorif data type is not supported
size_mismatch_errorif array shape does not match
invalid_object_errorif field is not valid
io_errorin case of a general IO error
object_errorin case of any other error
Parameters
ainstance of array
template<nximp_code IMPID>
template<typename T >
void pni::io::nx::nxattribute< IMPID >::read ( T &  value) const
inline

Read a single scalar value.

Exceptions
size_mismatch_errorif the attribute is not scalar
invalid_object_errorif the attribute is not valid
io_errorin case of a general IO error
type_errorif data type is not supported
object_errorin case of any other error
Template Parameters
Ttype to read to
Parameters
valuereference to an instance of T
template<nximp_code IMPID>
template<typename T >
void pni::io::nx::nxattribute< IMPID >::read ( size_t  n,
T *  value 
) const
inline

Read data to a memory location referenced by the pointer value. This method is for compatability with old C-code. It is assumed that enough memory is allocated.

Exceptions
size_mismatch_errorif n and attribute size do not match
type_errorif T is not supported
invalid_object_errorif attribute is not valid
io_errorin case of a general IO error
object_errorin case of any other error
Template Parameters
Tdata type to read to
Parameters
nthe size of the memory referred to by the pointer
valuepointer to memory
template<nximp_code IMPID>
template<typename T >
void pni::io::nx::nxattribute< IMPID >::read ( std::vector< T > &  data) const
inline

Read data from an attribute to an STL vector.

Exceptions
size_mismatch_errorif n and attribute size do not match
type_errorif T is not supported
invalid_object_errorif attribute is not valid
io_errorin case of a general IO error
object_errorin case of any other error
Template Parameters
Tdata type to read to
Parameters
datareference to the vector
template<nximp_code IMPID>
template<typename CTYPE >
CTYPE pni::io::nx::nxattribute< IMPID >::shape ( ) const
inline
Exceptions
invalid_object_errorif attribute not valid
object_errorin case of any other error
Template Parameters
CTYPEuser requested container type
Returns
instance of CTYPE with shape information
template<nximp_code IMPID>
size_t pni::io::nx::nxattribute< IMPID >::size ( ) const
inline

Return the number of elements stored in the attribute.

Exceptions
invalid_object_errorif the attribute is not valid
object_errorin case of any other error
Returns
number of elements
template<nximp_code IMPID>
pni::core::type_id_t pni::io::nx::nxattribute< IMPID >::type_id ( ) const
inline

Returns the type ID of the data stored in the attribute.

Exceptions
invalid_object_errorif attribute is not valid
object_errorin case of any other error
type_errorif data type is not supported
Returns
type id of the elements stored in the field
template<nximp_code IMPID>
template<typename STORAGE , typename IMAP , typename IPA >
void pni::io::nx::nxattribute< IMPID >::write ( const pni::core::mdarray< STORAGE, IMAP, IPA > &  o) const
inline

Write data from an mdarray instance to the attribute object

Exceptions
memory_not_allocated_errorif array buffer is not allocated
size_mismatch_errrorif array and attribute shape do not match
io_errorin case of IO errors
invalid_object_errorif the object is not valid
type_errorif the datatype stored in the array is not supported
object_errorin case of any other error
Template Parameters
STORAGEstorage type of the mdarray
IMAPindex map type of the mdarray
IPAinplace arithmetic type of the mdarray
Parameters
oinstance of DArray from which to write data
template<nximp_code IMPID>
template<typename ATYPE >
void pni::io::nx::nxattribute< IMPID >::write ( const pni::core::array_view< ATYPE > &  v) const
inline

Write the data reference by an array view to the attribute.

Exceptions
memory_not_allocated_errorif array buffer is not allocated
size_mismatch_errrorif array and attribute shape do not match
io_errorin case of IO errors
invalid_object_errorif the object is not valid
type_errorif the datatype stored in the array is not supported
object_errorin case of any other error
Template Parameters
ATYPEarray type of the view
Parameters
vrefernence to an array_view instance
template<nximp_code IMPID>
template<typename T >
void pni::io::nx::nxattribute< IMPID >::write ( size_t  n,
const T *  data 
) const
inline

This method is for interoperability with old C-code. It writes data referenced by a plain pointer. It is assumed that the user has allocated enough memory.

Exceptions
size_mismatch_errorif memory and attribute size do not match
io_errorin case of a general IO error
type_errorif data type not supported by the library
invalid_object_errorif attribute not valid
object_errorin case of any other error
Template Parameters
Tdata type of the pointer
Parameters
nthe number of elements to read to memory
datapointer to the data
template<nximp_code IMPID>
template<typename T >
void pni::io::nx::nxattribute< IMPID >::write ( const std::vector< T > &  data) const
inline

Write data stored in an STL vector to an attribute.

Exceptions
size_mismatch_errorif memory and attribute size do not match
io_errorin case of a general IO error
type_errorif data type not supported by the library
invalid_object_errorif attribute not valid
object_errorin case of any other error
Template Parameters
Tvalue type of the vector
Parameters
datareference to the vector
template<nximp_code IMPID>
template<typename T >
void pni::io::nx::nxattribute< IMPID >::write ( const T &  value) const
inline

Write a single scalar value. This throws an exception if the field is not scalar (size=1).

Exceptions
size_mismatch_errorif field is not scalar
io_errorin case of a general IO error
invalid_object_errorin case of an invalid field object
type_errorin case the datatype is not supported
object_errorin case of any other error
Template Parameters
Tdata type of the scalar to write
Parameters
valuereference to the value to write
template<nximp_code IMPID>
void pni::io::nx::nxattribute< IMPID >::write ( const char *  value) const
inline

This is a special implementation of write for classical C-strings.

Exceptions
size_mismatch_errorif field is not scalar
invalid_object_errorif field is not valid
io_errorin case of a general IO error
object_errorin case of any other error
type_errorif the datatype is not supported
Parameters
valuepointer to a C-string
template<nximp_code IMPID>
void pni::io::nx::nxattribute< IMPID >::write ( const pni::core::array &  a) const
inline
Exceptions
memory_not_allocated_errorif array buffer is not allocated
size_mismatch_errrorif array and attribute shape do not match
type_errorif data type not supported
invalid_object_errorif field is not valid
io_errorin case of a general IO error
object_errorin case of any other error
Parameters
ainstance of array

Field Documentation

template<nximp_code IMPID>
implementation_type pni::io::nx::nxattribute< IMPID >::_imp
private

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