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/v0.5.0/src/axom/sidre/core/DataStore.hpp>
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... | |
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... | |
Methods to query, access, create, and destroy Buffers. | |
IndexType | getNumBuffers () const |
Return number of Buffers in the DataStore. More... | |
bool | hasBuffer (IndexType idx) const |
Return true if DataStore owns a Buffer with given index; else false. 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... | |
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 a Attribute object with a default scalar value. More... | |
Attribute * | createAttributeString (const std::string &name, const std::string &default_value) |
Create a 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... | |
Static Public Member Functions | |
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 number of Buffers in the DataStore.
|
inline |
Return true if DataStore owns a Buffer with given index; else false.
References createBuffer(), destroyAllBuffers(), destroyBuffer(), getBuffer(), getFirstValidBufferIndex(), getNextValidBufferIndex(), and getNumAttributes().
Return (non-const) pointer to Buffer object with the given index, or nullptr if none exists.
Referenced by hasBuffer().
Buffer* axom::sidre::DataStore::createBuffer | ( | ) |
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 | ) |
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.
Referenced by hasBuffer().
void axom::sidre::DataStore::destroyBuffer | ( | IndexType | idx | ) |
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.
Referenced by hasBuffer().
IndexType axom::sidre::DataStore::getFirstValidBufferIndex | ( | ) | const |
Return first valid Buffer index.
sidre::InvalidIndex is returned if Group has no Buffers.
Referenced by hasBuffer().
Return next valid Buffer index after given index.
sidre::InvalidIndex is returned if there is no valid next index.
Referenced by hasBuffer().
IndexType axom::sidre::DataStore::getNumAttributes | ( | ) | const |
Return number of Attributes in the DataStore.
Referenced by hasBuffer().
|
inline |
Create a 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 a 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 destroyAllAttributes(), destroyAttribute(), generateBlueprintIndex(), getAttribute(), getFirstValidAttributeIndex(), getNextValidAttributeIndex(), hasAttribute(), loadAttributeLayout(), print(), saveAttributeLayout(), setConduitDefaultMessageHandlers(), setConduitSLICMessageHandlers(), and axom::sidre::Attribute::setDefaultString().
bool axom::sidre::DataStore::hasAttribute | ( | const std::string & | name | ) | const |
Return true if DataStore has created attribute name; else false.
Referenced by createAttributeString().
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 | ) |
Remove Attribute from the DataStore and destroy it and its data.
Referenced by createAttributeString().
void axom::sidre::DataStore::destroyAttribute | ( | IndexType | idx | ) |
void axom::sidre::DataStore::destroyAttribute | ( | Attribute * | attr | ) |
void axom::sidre::DataStore::destroyAllAttributes | ( | ) |
Remove all Attributes from the DataStore and destroy them and their data.
Referenced by createAttributeString().
Return pointer to non-const Attribute with given index.
If no such Attribute exists, nullptr is returned.
Referenced by createAttributeString().
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.
Referenced by createAttributeString().
void axom::sidre::DataStore::loadAttributeLayout | ( | Node & | node | ) |
Create attributes from name/value pairs in node["attribute"].
Referenced by createAttributeString().
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.
Referenced by createAttributeString().
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.
Referenced by createAttributeString().
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 |
Referenced by createAttributeString().
void axom::sidre::DataStore::print | ( | ) | const |
Print JSON description of the DataStore Group hierarchy (starting at root) and Buffer descriptions to std::cout.
Referenced by createAttributeString().
void axom::sidre::DataStore::print | ( | std::ostream & | os | ) | const |
|
static |
Wires Conduit info
, warning
, and error
messages to SLIC style handling.
Referenced by createAttributeString().
|
static |
Wires Conduit info
, warning
, and error
messages to Conduit's default handling.
Referenced by createAttributeString().