openPMD-api
Classes | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends | List of all members
openPMD::AttributableInterface Class Reference

Layer to manage storage of attributes associated with file objects. More...

#include <Attributable.hpp>

Inheritance diagram for openPMD::AttributableInterface:
Inheritance graph
[legend]
Collaboration diagram for openPMD::AttributableInterface:
Collaboration graph
[legend]

Classes

struct  MyPath
 String serialization to describe an Attributable. More...
 

Public Member Functions

Attribute getAttribute (std::string const &key) const
 Retrieve value of Attribute stored with provided key. More...
 
bool deleteAttribute (std::string const &key)
 Remove Attribute of provided value both logically and physically. More...
 
std::vector< std::string > attributes () const
 List all currently stored Attributes' keys. More...
 
size_t numAttributes () const
 Count all currently stored Attributes. More...
 
bool containsAttribute (std::string const &key) const
 Check whether am Attribute with a given key exists. More...
 
std::string comment () const
 Retrieve a user-supplied comment associated with the object. More...
 
AttributableInterfacesetComment (std::string const &comment)
 Populate Attribute corresponding to a comment with the user-supplied comment. More...
 
void seriesFlush ()
 Flush the corresponding Series object. More...
 
MyPath myPath () const
 The path to this object within its containing Series. More...
 
template<typename T >
bool setAttribute (std::string const &key, T value)
 Populate Attribute of provided name with provided value. More...
 
bool setAttribute (std::string const &key, char const value[])
 

Protected Types

enum  ReadMode { IgnoreExisting, OverrideExisting, FullyReread }
 

Protected Member Functions

 AttributableInterface (internal::AttributableData *)
 
template<typename T >
 AttributableInterface (T *attri)
 
const internal::SeriesInternalretrieveSeries () const
 
internal::SeriesInternalretrieveSeries ()
 
void seriesFlush (FlushLevel)
 
void flushAttributes ()
 
void readAttributes (ReadMode)
 
template<typename T >
readFloatingpoint (std::string const &key) const
 Retrieve the value of a floating point Attribute of user-defined precision with ensured type-safety. More...
 
template<typename T >
std::vector< T > readVectorFloatingpoint (std::string const &key) const
 Retrieve a vector of values of a floating point Attributes of user-defined precision with ensured type-safety. More...
 
AbstractIOHandlerIOHandler ()
 
const AbstractIOHandlerIOHandler () const
 
Writable *& parent ()
 
const Writableparent () const
 
Writablewritable ()
 
const Writablewritable () const
 
internal::AttributableDataget ()
 
const internal::AttributableDataget () const
 
bool dirty () const
 
bool & dirty ()
 
bool written () const
 
bool & written ()
 
const IterationcontainingIteration () const
 Returns the corresponding Iteration. More...
 
IterationcontainingIteration ()
 

Protected Attributes

internal::AttributableDatam_attri = nullptr
 

Friends

template<typename T_elem >
class BaseRecord
 
template<typename T , typename T_key , typename T_container >
class Container
 
template<typename T >
struct traits::GenerationPolicy
 
class Iteration
 
class Series
 
class SeriesInterface
 
class Writable
 
class WriteIterations
 
WritablegetWritable (AttributableInterface *)
 

Detailed Description

Layer to manage storage of attributes associated with file objects.

Mandatory and user-defined Attributes and their data for every object in the openPMD hierarchy are stored and managed through this class.

Member Enumeration Documentation

◆ ReadMode

Enumerator
IgnoreExisting 

Don't read an attribute from the backend if it has been previously read.

OverrideExisting 

Read all the attributes that the backend has to offer and override if it has been read previously.

FullyReread 

Remove all attributes that have been read previously and read everything that the backend currently has to offer.

Member Function Documentation

◆ attributes()

std::vector< std::string > openPMD::AttributableInterface::attributes ( ) const

List all currently stored Attributes' keys.

Returns
Vector of keys (i.e. names) of all currently stored Attributes.

◆ comment()

std::string openPMD::AttributableInterface::comment ( ) const

Retrieve a user-supplied comment associated with the object.

Exceptions
no_such_attribute_errorIf no comment is currently stored.
Returns
String containing the user-supplied comment.

◆ containingIteration()

Iteration & openPMD::AttributableInterface::containingIteration ( ) const
protected

Returns the corresponding Iteration.

Return the openPMD::iteration that this Attributable is contained in. This walks up the linked parents until it finds the Iteration object. Throws an error otherwise, e.g., for Series objects.

◆ containsAttribute()

bool openPMD::AttributableInterface::containsAttribute ( std::string const &  key) const

Check whether am Attribute with a given key exists.

Parameters
keyKey (i.e. name) of the Attribute to find.
Returns
true if provided key was present, false otherwise.

◆ deleteAttribute()

bool openPMD::AttributableInterface::deleteAttribute ( std::string const &  key)

Remove Attribute of provided value both logically and physically.

Parameters
keyKey (i.e. name) of the Attribute to remove.
Returns
true if provided key was present and removal succeeded, false otherwise.

◆ getAttribute()

Attribute openPMD::AttributableInterface::getAttribute ( std::string const &  key) const

Retrieve value of Attribute stored with provided key.

Exceptions
no_such_attribute_errorIf no Attribute is currently stored with the provided key.
Parameters
keyKey (i.e. name) of the Attribute to retrieve value for.
Returns
Stored Attribute in Variant form.

◆ myPath()

auto openPMD::AttributableInterface::myPath ( ) const

The path to this object within its containing Series.

Returns
A struct informing about the context of this Attributable.

◆ numAttributes()

size_t openPMD::AttributableInterface::numAttributes ( ) const

Count all currently stored Attributes.

Returns
Number of currently stored Attributes.

◆ readFloatingpoint()

template<typename T >
T openPMD::AttributableInterface::readFloatingpoint ( std::string const &  key) const
inlineprotected

Retrieve the value of a floating point Attribute of user-defined precision with ensured type-safety.

Note
Since the precision of certain Attributes is intentionally left unspecified in the openPMD standard, this provides a mechanism to retrieve those values without giving up type-safety.
See also
https://github.com/openPMD/openPMD-standard/blob/latest/STANDARD.md#conventions-throughout-these-documents
Note
If the supplied and stored floating point precision are not the same, the value is cast to the desired precision unconditionally.
Exceptions
no_such_attribute_errorIf no Attribute is currently stored with the provided key.
Template Parameters
TFloating point type of user-defined precision to retrieve the value as.
Parameters
keyKey (i.e. name) of the floating-point Attribute to retrieve value for.
Returns
Value of stored Attribute as supplied floating point type.

◆ readVectorFloatingpoint()

template<typename T >
std::vector< T > openPMD::AttributableInterface::readVectorFloatingpoint ( std::string const &  key) const
inlineprotected

Retrieve a vector of values of a floating point Attributes of user-defined precision with ensured type-safety.

Note
Since the precision of certain Attributes is intentionally left unspecified in the openPMD standard, this provides a mechanism to retrieve those values without giving up type-safety.
See also
https://github.com/openPMD/openPMD-standard/blob/latest/STANDARD.md#conventions-throughout-these-documents
Note
If the supplied and stored floating point precision are not the same, the values are cast to the desired precision unconditionally.
Exceptions
no_such_attribute_errorIf no Attribute is currently stored with the provided key.
Template Parameters
TFloating point type of user-defined precision to retrieve the values as.
Parameters
keyKey (i.e. name) of the floating-point Attribute to retrieve values for.
Returns
Vector of values of stored Attribute as supplied floating point type.

◆ seriesFlush()

void openPMD::AttributableInterface::seriesFlush ( )

Flush the corresponding Series object.

Writable connects all objects of an openPMD series through a linked list of parents. This method will walk up the parent list until it reaches an object that has no parent, which is the Series object, and flush()-es it.

◆ setAttribute()

template<typename T >
bool openPMD::AttributableInterface::setAttribute ( std::string const &  key,
value 
)
inline

Populate Attribute of provided name with provided value.

Note
If the provided Attribute already exists, the value is replaced. If it does not exist, a new Attribute is created.
Template Parameters
TType of the object to be stored. Only types contained in Datatype can be handled.
Parameters
keyKey (i.e. name) to identify and store an Attributes value by.
valueValue of Attribute stored with the provided key.
Returns
true if key was already present, false otherwise

◆ setComment()

AttributableInterface & openPMD::AttributableInterface::setComment ( std::string const &  comment)

Populate Attribute corresponding to a comment with the user-supplied comment.

Parameters
commentString value to be stored as a comment.
Returns
Reference to modified Attributable.

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