AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
|
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 = axom::MapCollection< Attribute > |
using | BufferCollection = axom::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... | |
Group * | getRoot () |
Return pointer to the root Group. More... | |
const Group * | getRoot () const |
Return pointer to the root Group. More... | |
Methods to query and clear Conduit I/O flags and exception messages. | |
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... | |
Buffer * | getBuffer (IndexType idx) const |
Return (non-const) pointer to Buffer object with the given index, or nullptr if none exists. More... | |
Buffer * | createBuffer () |
Create an undescribed Buffer object and return a pointer to it. More... | |
Buffer * | createBuffer (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 > | |
Attribute * | createAttributeScalar (const std::string &name, ScalarType default_value) |
Create an Attribute object with a default scalar value. More... | |
Attribute * | createAttributeString (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. | |
Attribute * | getAttribute (IndexType idx) |
Return pointer to non-const Attribute with given index. More... | |
const Attribute * | getAttribute (IndexType idx) const |
Return pointer to const Attribute with given index. More... | |
Attribute * | getAttribute (const std::string &name) |
Return pointer to non-const Attribute with given name. More... | |
const Attribute * | getAttribute (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... | |
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.
axom::sidre::DataStore::DataStore | ( | ) |
axom::sidre::DataStore::~DataStore | ( | ) |
Dtor destroys all contents of the DataStore, including data held in Buffers.
|
inline |
Return whether a Conduit error occurred.
|
inline |
Return information on any Conduit errors.
|
inline |
Clear any Conduit errors.
|
inline |
Append a string to the accumulated Conduit errors.
IndexType axom::sidre::DataStore::getNumBuffers | ( | ) | const |
Return number of Buffers in the DataStore.
IndexType axom::sidre::DataStore::getNumReferencedBuffers | ( | ) | const |
IndexType axom::sidre::DataStore::getTotalAllocatedBytesInBuffers | ( | ) | const |
Return total bytes allocated in Buffers in the DataStore.
bool axom::sidre::DataStore::hasBuffer | ( | IndexType | idx | ) | const |
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:
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...
Return (non-const) pointer to Buffer object with the given index, or nullptr if none exists.
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.
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.
void axom::sidre::DataStore::destroyBuffer | ( | Buffer * | buff | ) |
void axom::sidre::DataStore::destroyBuffer | ( | IndexType | idx | ) |
void axom::sidre::DataStore::destroyAllBuffers | ( | ) |
IndexType axom::sidre::DataStore::getFirstValidBufferIndex | ( | ) | const |
Return first valid Buffer index.
sidre::InvalidIndex is returned if Group has no Buffers.
Return next valid Buffer index after given index.
sidre::InvalidIndex is returned if there is no valid next index.
BufferCollection::iterator_adaptor axom::sidre::DataStore::buffers | ( | ) |
Returns an adaptor to support iterating the collection of buffers.
BufferCollection::const_iterator_adaptor axom::sidre::DataStore::buffers | ( | ) | const |
Returns a const adaptor to support iterating the collection of buffers.
IndexType axom::sidre::DataStore::getNumAttributes | ( | ) | const |
Return number of Attributes in the DataStore.
|
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().
|
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().
bool axom::sidre::DataStore::hasAttribute | ( | const std::string & | name | ) | const |
Return true if DataStore has created attribute name, else false.
bool axom::sidre::DataStore::hasAttribute | ( | IndexType | idx | ) | const |
Return true if DataStore has created attribute with index, else false.
void axom::sidre::DataStore::destroyAttribute | ( | const std::string & | name | ) |
void axom::sidre::DataStore::destroyAttribute | ( | IndexType | idx | ) |
void axom::sidre::DataStore::destroyAttribute | ( | Attribute * | attr | ) |
void axom::sidre::DataStore::destroyAllAttributes | ( | ) |
Attribute* axom::sidre::DataStore::getAttribute | ( | const std::string & | name | ) |
const Attribute* axom::sidre::DataStore::getAttribute | ( | const std::string & | name | ) | const |
bool axom::sidre::DataStore::saveAttributeLayout | ( | Node & | node | ) | const |
Copy Attribute and default value to Conduit node. Return true if attributes were copied.
void axom::sidre::DataStore::loadAttributeLayout | ( | Node & | node | ) |
Create attributes from name/value pairs in node["attribute"].
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.
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.
AttributeCollection::iterator_adaptor axom::sidre::DataStore::attributes | ( | ) |
Returns an adaptor to support iterating the collection of attributes.
AttributeCollection::const_iterator_adaptor axom::sidre::DataStore::attributes | ( | ) | const |
Returns a const adaptor to support iterating the collection of attributes.
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.
domain_path | path to a domain stored in the Blueprint format |
mesh_name | name for the mesh to be described |
index_path | path where the Blueprint index will be written within this DataStore |
num_domains | number of domains in the mesh |
void axom::sidre::DataStore::print | ( | ) | const |
void axom::sidre::DataStore::print | ( | std::ostream & | os | ) | const |
|
static |
Wires Conduit info
, warning
, and error
messages to SLIC style handling.
|
static |
Wires Conduit info
, warning
, and error
messages to Conduit's default handling.