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/docs-essman-container_strict/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...
 
GroupgetRoot ()
 Return pointer to the root Group. More...
 
const GroupgetRoot () 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...
 
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...
 
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 a Attribute object with a default scalar value. More...
 
AttributecreateAttributeString (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.
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...
 

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...
 

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.

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.

◆ getNumBuffers()

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

Return number of Buffers in the DataStore.

◆ hasBuffer()

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

◆ 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.

Referenced by hasBuffer().

◆ 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.

Referenced by hasBuffer().

◆ 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.

Referenced by hasBuffer().

◆ 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.

Referenced by hasBuffer().

◆ 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()

Referenced by hasBuffer().

◆ 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()

Referenced by hasBuffer().

◆ getNumAttributes()

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

Return number of Attributes in the DataStore.

Referenced by hasBuffer().

◆ createAttributeScalar()

template<typename ScalarType >
Attribute* axom::sidre::DataStore::createAttributeScalar ( const std::string &  name,
ScalarType  default_value 
)
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().

◆ createAttributeString()

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

◆ hasAttribute() [1/2]

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

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

Referenced by createAttributeString().

◆ 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.

Referenced by createAttributeString().

◆ 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.

Referenced by createAttributeString().

◆ 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.

Referenced by createAttributeString().

◆ 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.

Referenced by createAttributeString().

◆ loadAttributeLayout()

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

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

Referenced by createAttributeString().

◆ 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()

Referenced by createAttributeString().

◆ 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()

Referenced by createAttributeString().

◆ 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.

Referenced by createAttributeString().

◆ 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.

Referenced by createAttributeString().

◆ 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.

Referenced by createAttributeString().

◆ setConduitDefaultMessageHandlers()

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

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

Referenced by createAttributeString().


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