AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
axom::sidre::DataStore Class Reference

DataStore is the main interface for creating and accessing Buffer objects. More...

#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/develop/src/axom/sidre/core/DataStore.hpp>

Public Types

using AttributeCollection = MapCollection< Attribute >
 
using BufferCollection = IndexedCollection< Buffer >
 

Public Member Functions

 DataStore ()
 Default ctor initializes DataStore object and creates a root Group. More...
 
 ~DataStore ()
 Dtor destroys all contents of the DataStore, including data held in Buffers. More...
 
GroupgetRoot ()
 Return pointer to the root Group. More...
 
const GroupgetRoot () const
 Return pointer to the root Group. More...
 
Methods to query and clear Conduit I/O flags and exception messages.

If an error occurs, the load(), save(), and loadExternalData() methods of any Group owned by this DataStore will return false (for I/O failure) and subsequent calls will continue to return false until the user clears the Conduit errors.

bool getConduitErrorOccurred () const
 Return whether a Conduit error occurred. More...
 
std::string getConduitErrors () const
 Return information on any Conduit errors. More...
 
void clearConduitErrors () const
 Clear any Conduit errors. More...
 
void appendToConduitErrors (const std::string &mesg) const
 Append a string to the accumulated Conduit errors. More...
 
Methods to query, access, create, and destroy Buffers.
IndexType getNumBuffers () const
 Return number of Buffers in the DataStore. More...
 
IndexType getNumReferencedBuffers () const
 Return number of Buffers in the DataStore that are referenced by at least one View. More...
 
IndexType getTotalAllocatedBytesInBuffers () const
 Return total bytes allocated in Buffers in the DataStore. More...
 
bool hasBuffer (IndexType idx) const
 Return true if DataStore owns a Buffer with given index; else false. More...
 
void getBufferInfo (Node &n) const
 Insert information about DataStore Buffers in fields of given Conduit Node. More...
 
BuffergetBuffer (IndexType idx) const
 Return (non-const) pointer to Buffer object with the given index, or nullptr if none exists. More...
 
BuffercreateBuffer ()
 Create an undescribed Buffer object and return a pointer to it. More...
 
BuffercreateBuffer (TypeID type, IndexType num_elems)
 Create a Buffer object with specified type and number of elements and return a pointer to it. More...
 
void destroyBuffer (Buffer *buff)
 Remove Buffer from the DataStore and destroy it and its data. More...
 
void destroyBuffer (IndexType idx)
 Remove Buffer with given index from the DataStore and destroy it and its data. More...
 
void destroyAllBuffers ()
 Remove all Buffers from the DataStore and destroy them and their data. More...
 
Methods for iterating over Buffers in the DataStore.

Using these methods, a code can get the first Buffer index and each succeeding index. This allows Buffer iteration using the same constructs in C++, C, and Fortran. Example:

 for (sidre::IndexType idx = ds->getFirstValidBufferIndex();
      sidre::indexIsValid(idx);
      idx = ds->getNextValidBufferIndex(idx))
 {
     Buffer * buf = ds->getBuffer(idx);

     /// code here using buf
 } 
IndexType getFirstValidBufferIndex () const
 Return first valid Buffer index. More...
 
IndexType getNextValidBufferIndex (IndexType idx) const
 Return next valid Buffer index after given index. More...
 
Accessors for iterating buffer collections.

These methods can be used to iterate over the collection of buffers Example: for (auto& buffer : ds->buffers()) { /// code here using buffers }

BufferCollection::iterator_adaptor buffers ()
 Returns an adaptor to support iterating the collection of buffers. More...
 
BufferCollection::const_iterator_adaptor buffers () const
 Returns a const adaptor to support iterating the collection of buffers. More...
 
Methods to query, access, create, and destroy Attributes.
IndexType getNumAttributes () const
 Return number of Attributes in the DataStore. More...
 
template<typename ScalarType >
AttributecreateAttributeScalar (const std::string &name, ScalarType default_value)
 Create an Attribute object with a default scalar value. More...
 
AttributecreateAttributeString (const std::string &name, const std::string &default_value)
 Create an Attribute object with a default string value. More...
 
bool hasAttribute (const std::string &name) const
 Return true if DataStore has created attribute name, else false. More...
 
bool hasAttribute (IndexType idx) const
 Return true if DataStore has created attribute with index, else false. More...
 
void destroyAttribute (const std::string &name)
 Remove Attribute from the DataStore and destroy it and its data. More...
 
void destroyAttribute (IndexType idx)
 Remove Attribute with given index from the DataStore and destroy it and its data. More...
 
void destroyAttribute (Attribute *attr)
 Remove Attribute from the DataStore and destroy it and its data. More...
 
void destroyAllAttributes ()
 Remove all Attributes from the DataStore and destroy them and their data. More...
 
Attribute access methods.
AttributegetAttribute (IndexType idx)
 Return pointer to non-const Attribute with given index. More...
 
const AttributegetAttribute (IndexType idx) const
 Return pointer to const Attribute with given index. More...
 
AttributegetAttribute (const std::string &name)
 Return pointer to non-const Attribute with given name. More...
 
const AttributegetAttribute (const std::string &name) const
 Return pointer to const Attribute with given name. More...
 
bool saveAttributeLayout (Node &node) const
 Copy Attribute and default value to Conduit node. Return true if attributes were copied. More...
 
void loadAttributeLayout (Node &node)
 Create attributes from name/value pairs in node["attribute"]. More...
 
Methods for iterating over Attributes in the DataStore.

Using these methods, a code can get the first Attribute index and each succeeding index. This allows Attribute iteration using the same constructs in C++, C, and Fortran. Example:

 for (sidre::IndexType idx = ds->getFirstValidAttributeIndex();
      sidre::indexIsValid(idx);
      idx = ds->getNextValidAttributeIndex(idx))
 {
     Attribute * attr = ds->getAttribute(idx);

     /// code here using attr
 } 
IndexType getFirstValidAttributeIndex () const
 Return first valid Attribute index in DataStore object (i.e., smallest index over all Attributes). More...
 
IndexType getNextValidAttributeIndex (IndexType idx) const
 Return next valid Attribute index in DataStore object after given index (i.e., smallest index over all Attribute indices larger than given one). More...
 

Accessors for iterating attribute collections.

These methods can be used to iterate over the collection of attributes Example: for (auto& attr : ds->attributes()) { /// code here using attribute }

AttributeCollection::iterator_adaptor attributes ()
 Returns an adaptor to support iterating the collection of attributes. More...
 
AttributeCollection::const_iterator_adaptor attributes () const
 Returns a const adaptor to support iterating the collection of attributes. More...
 
bool generateBlueprintIndex (const std::string &domain_path, const std::string &mesh_name, const std::string &index_path, int num_domains)
 Generate a Conduit Blueprint index based on a mesh in stored in this DataStore. More...
 
void print () const
 Print JSON description of the DataStore Group hierarchy (starting at root) and Buffer descriptions to std::cout. More...
 
void print (std::ostream &os) const
 Print JSON description of the DataStore Group hierarchy (starting at root) and Buffer descriptions to given output stream. More...
 
static void setConduitSLICMessageHandlers ()
 Wires Conduit info, warning, and error messages to SLIC style handling. More...
 
static void setConduitDefaultMessageHandlers ()
 Wires Conduit info, warning, and error messages to Conduit's default handling. More...
 

Detailed Description

DataStore is the main interface for creating and accessing Buffer objects.

It maintains a collection of Buffer objects and owns the "root" Group. The initial name of the root Group is the empty string: a code uses the getRoot() method to retrieve the root Group. A Group hierarchy (a tree) is created by creating child Groups of Groups.

Member Typedef Documentation

◆ AttributeCollection

◆ BufferCollection

Constructor & Destructor Documentation

◆ DataStore()

axom::sidre::DataStore::DataStore ( )

Default ctor initializes DataStore object and creates a root Group.

The ctor also initializes SLIC logging environment if it is not already initialized.

◆ ~DataStore()

axom::sidre::DataStore::~DataStore ( )

Dtor destroys all contents of the DataStore, including data held in Buffers.

Member Function Documentation

◆ getRoot() [1/2]

Group* axom::sidre::DataStore::getRoot ( )
inline

Return pointer to the root Group.

◆ getRoot() [2/2]

const Group* axom::sidre::DataStore::getRoot ( ) const
inline

Return pointer to the root Group.

◆ getConduitErrorOccurred()

bool axom::sidre::DataStore::getConduitErrorOccurred ( ) const
inline

Return whether a Conduit error occurred.

◆ getConduitErrors()

std::string axom::sidre::DataStore::getConduitErrors ( ) const
inline

Return information on any Conduit errors.

◆ clearConduitErrors()

void axom::sidre::DataStore::clearConduitErrors ( ) const
inline

Clear any Conduit errors.

◆ appendToConduitErrors()

void axom::sidre::DataStore::appendToConduitErrors ( const std::string &  mesg) const
inline

Append a string to the accumulated Conduit errors.

◆ getNumBuffers()

IndexType axom::sidre::DataStore::getNumBuffers ( ) const

Return number of Buffers in the DataStore.

◆ getNumReferencedBuffers()

IndexType axom::sidre::DataStore::getNumReferencedBuffers ( ) const

Return number of Buffers in the DataStore that are referenced by at least one View.

◆ getTotalAllocatedBytesInBuffers()

IndexType axom::sidre::DataStore::getTotalAllocatedBytesInBuffers ( ) const

Return total bytes allocated in Buffers in the DataStore.

◆ hasBuffer()

bool axom::sidre::DataStore::hasBuffer ( IndexType  idx) const

Return true if DataStore owns a Buffer with given index; else false.

◆ getBufferInfo()

void axom::sidre::DataStore::getBufferInfo ( Node n) const

Insert information about DataStore Buffers in fields of given Conduit Node.

Fields in Conduit Node will be named:

  • "num_buffers" : number of Buffer objects owned by DataStore
  • "num_buffers_referenced" : number of Buffers with View attached
  • "num_buffers_detached" : number of Buffers with no View attached
  • "num_bytes_allocated" : total number of allocated bytes over all buffers

Numeric values associated with these fields may be accessed as type axom::IndexType, which is defined at compile-time. For example,

Node n; datastore->getBufferInfo(n); axom::IndexType num_buffers = n["num_buffers"].value(); // etc...

◆ getBuffer()

Buffer* axom::sidre::DataStore::getBuffer ( IndexType  idx) const

Return (non-const) pointer to Buffer object with the given index, or nullptr if none exists.

◆ createBuffer() [1/2]

Buffer* axom::sidre::DataStore::createBuffer ( )

Create an undescribed Buffer object and return a pointer to it.

   The Buffer must be described before it can be allocated.

   The Buffer object is assigned a unique index when created and the
   Buffer object is owned by the DataStore object.

◆ createBuffer() [2/2]

Buffer* axom::sidre::DataStore::createBuffer ( TypeID  type,
IndexType  num_elems 
)

Create a Buffer object with specified type and number of elements and return a pointer to it.

See the Buffer::describe() method for valid data description.

The Buffer object is assigned a unique index when created and the Buffer object is owned by the DataStore object.

◆ destroyBuffer() [1/2]

void axom::sidre::DataStore::destroyBuffer ( Buffer buff)

Remove Buffer from the DataStore and destroy it and its data.

Note that Buffer destruction detaches it from all Views to which it is attached.

◆ destroyBuffer() [2/2]

void axom::sidre::DataStore::destroyBuffer ( IndexType  idx)

Remove Buffer with given index from the DataStore and destroy it and its data.

Note that Buffer destruction detaches it from all Views to which it is attached.

◆ destroyAllBuffers()

void axom::sidre::DataStore::destroyAllBuffers ( )

Remove all Buffers from the DataStore and destroy them and their data.

Note that Buffer destruction detaches it from all Views to which it is attached.

◆ getFirstValidBufferIndex()

IndexType axom::sidre::DataStore::getFirstValidBufferIndex ( ) const

Return first valid Buffer index.

sidre::InvalidIndex is returned if Group has no Buffers.

See also
axom::sidre::indexIsValid()

◆ getNextValidBufferIndex()

IndexType axom::sidre::DataStore::getNextValidBufferIndex ( IndexType  idx) const

Return next valid Buffer index after given index.

sidre::InvalidIndex is returned if there is no valid next index.

See also
axom::sidre::indexIsValid()

◆ buffers() [1/2]

BufferCollection::iterator_adaptor axom::sidre::DataStore::buffers ( )

Returns an adaptor to support iterating the collection of buffers.

◆ buffers() [2/2]

BufferCollection::const_iterator_adaptor axom::sidre::DataStore::buffers ( ) const

Returns a const adaptor to support iterating the collection of buffers.

◆ getNumAttributes()

IndexType axom::sidre::DataStore::getNumAttributes ( ) const

Return number of Attributes in the DataStore.

◆ createAttributeScalar()

template<typename ScalarType >
Attribute* axom::sidre::DataStore::createAttributeScalar ( const std::string &  name,
ScalarType  default_value 
)
inline

Create an Attribute object with a default scalar value.

   The Attribute object is assigned a unique index when created and the
   Attribute object is owned by the DataStore object.

References axom::sidre::Attribute::setDefaultScalar().

◆ createAttributeString()

Attribute* axom::sidre::DataStore::createAttributeString ( const std::string &  name,
const std::string &  default_value 
)
inline

Create an Attribute object with a default string value.

   The Attribute object is assigned a unique index when created and the
   Attribute object is owned by the DataStore object.

References axom::sidre::Attribute::setDefaultString().

◆ hasAttribute() [1/2]

bool axom::sidre::DataStore::hasAttribute ( const std::string &  name) const

Return true if DataStore has created attribute name, else false.

◆ hasAttribute() [2/2]

bool axom::sidre::DataStore::hasAttribute ( IndexType  idx) const

Return true if DataStore has created attribute with index, else false.

◆ destroyAttribute() [1/3]

void axom::sidre::DataStore::destroyAttribute ( const std::string &  name)

Remove Attribute from the DataStore and destroy it and its data.

Note
Destruction of an Attribute detaches it from all Views to which it is attached.

◆ destroyAttribute() [2/3]

void axom::sidre::DataStore::destroyAttribute ( IndexType  idx)

Remove Attribute with given index from the DataStore and destroy it and its data.

Note
Destruction of an Attribute detaches it from all Views to which it is attached.

◆ destroyAttribute() [3/3]

void axom::sidre::DataStore::destroyAttribute ( Attribute attr)

Remove Attribute from the DataStore and destroy it and its data.

Note
Destruction of an Attribute detaches it from all Views to which it is attached.

◆ destroyAllAttributes()

void axom::sidre::DataStore::destroyAllAttributes ( )

Remove all Attributes from the DataStore and destroy them and their data.

Note
Destruction of an Attribute detaches it from all Views to which it is attached.

◆ getAttribute() [1/4]

Attribute* axom::sidre::DataStore::getAttribute ( IndexType  idx)

Return pointer to non-const Attribute with given index.

If no such Attribute exists, nullptr is returned.

◆ getAttribute() [2/4]

const Attribute* axom::sidre::DataStore::getAttribute ( IndexType  idx) const

Return pointer to const Attribute with given index.

If no such Attribute exists, nullptr is returned.

◆ getAttribute() [3/4]

Attribute* axom::sidre::DataStore::getAttribute ( const std::string &  name)

Return pointer to non-const Attribute with given name.

If no such Attribute exists, nullptr is returned.

◆ getAttribute() [4/4]

const Attribute* axom::sidre::DataStore::getAttribute ( const std::string &  name) const

Return pointer to const Attribute with given name.

If no such Attribute exists, nullptr is returned.

◆ saveAttributeLayout()

bool axom::sidre::DataStore::saveAttributeLayout ( Node node) const

Copy Attribute and default value to Conduit node. Return true if attributes were copied.

◆ loadAttributeLayout()

void axom::sidre::DataStore::loadAttributeLayout ( Node node)

Create attributes from name/value pairs in node["attribute"].

◆ getFirstValidAttributeIndex()

IndexType axom::sidre::DataStore::getFirstValidAttributeIndex ( ) const

Return first valid Attribute index in DataStore object (i.e., smallest index over all Attributes).

sidre::InvalidIndex is returned if DataStore has no Attributes.

See also
axom::sidre::indexIsValid()

◆ getNextValidAttributeIndex()

IndexType axom::sidre::DataStore::getNextValidAttributeIndex ( IndexType  idx) const

Return next valid Attribute index in DataStore object after given index (i.e., smallest index over all Attribute indices larger than given one).

sidre::InvalidIndex is returned if there is no valid index greater than given one.

See also
axom::sidre::indexIsValid()

◆ attributes() [1/2]

AttributeCollection::iterator_adaptor axom::sidre::DataStore::attributes ( )

Returns an adaptor to support iterating the collection of attributes.

◆ attributes() [2/2]

AttributeCollection::const_iterator_adaptor axom::sidre::DataStore::attributes ( ) const

Returns a const adaptor to support iterating the collection of attributes.

◆ generateBlueprintIndex()

bool axom::sidre::DataStore::generateBlueprintIndex ( const std::string &  domain_path,
const std::string &  mesh_name,
const std::string &  index_path,
int  num_domains 
)

Generate a Conduit Blueprint index based on a mesh in stored in this DataStore.

If this DataStore contains data for a mesh that adheres to Conduit's Blueprint format, this method generates a Blueprint index and stores it at a specified location within this DataStore. It uses as input a path to a representative domain from that mesh.

The domain must be held in a Group stored in this DataStore. The location of this Group is specified by the domain_path argument. The generated Blueprint index will be stored in a newly-created Group that will be located at the path specified by the index_path argument.

Parameters
domain_pathpath to a domain stored in the Blueprint format
mesh_namename for the mesh to be described
index_pathpath where the Blueprint index will be written within this DataStore
num_domainsnumber of domains in the mesh
Returns
true if the Blueprint index is successfully generated.

◆ print() [1/2]

void axom::sidre::DataStore::print ( ) const

Print JSON description of the DataStore Group hierarchy (starting at root) and Buffer descriptions to std::cout.

◆ print() [2/2]

void axom::sidre::DataStore::print ( std::ostream &  os) const

Print JSON description of the DataStore Group hierarchy (starting at root) and Buffer descriptions to given output stream.

◆ setConduitSLICMessageHandlers()

static void axom::sidre::DataStore::setConduitSLICMessageHandlers ( )
static

Wires Conduit info, warning, and error messages to SLIC style handling.

◆ setConduitDefaultMessageHandlers()

static void axom::sidre::DataStore::setConduitDefaultMessageHandlers ( )
static

Wires Conduit info, warning, and error messages to Conduit's default handling.


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