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

Buffer is a container that describes and holds data in memory. More...

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

Public Member Functions

Basic query and accessor methods
IndexType getIndex () const
 Return the unique index of this Buffer object. More...
 
IndexType getNumViews () const
 Return number of Views this Buffer is attached to. More...
 
Methods to query and access Buffer data
void * getVoidPtr ()
 Return void-pointer to data held by Buffer. More...
 
Node::Value getData ()
 Return data held by Buffer (return type is type caller assigns return value to). More...
 
TypeID getTypeID () const
 Return type of data owned by this Buffer object. More...
 
IndexType getNumElements () const
 Return total number of data elements (of its type) owned by this Buffer object. More...
 
IndexType getTotalBytes () const
 Return total number of bytes of data owned by this Buffer object. More...
 
IndexType getBytesPerElement () const
 Return the number of bytes per element owned by this Buffer object. More...
 
bool isAllocated () const
 Return true if Buffer has been (re)allocated with length >= 0, else false. More...
 
bool isDescribed () const
 Return true if data description exists. More...
 

Friends

class DataStore
 
class Group
 
class View
 

Data description and allocation methods

Bufferdescribe (TypeID type, IndexType num_elems)
 Describe a Buffer with data given data type and number of elements. More...
 
Bufferallocate (int allocID=INVALID_ALLOCATOR_ID)
 Allocate data for a Buffer. More...
 
Bufferallocate (TypeID type, IndexType num_elems, int allocID=INVALID_ALLOCATOR_ID)
 Allocate Buffer with data type and number of elements. More...
 
Bufferreallocate (IndexType num_elems)
 Reallocate data to given number of elements. More...
 
Bufferdeallocate ()
 Deallocate data in a Buffer. More...
 
BuffercopyBytesIntoBuffer (void *src, IndexType nbytes)
 Copy given number of bytes of data from src into Buffer. More...
 
void copyToConduitNode (Node &n) const
 Copy Buffer description to a Conduit node. More...
 
void print () const
 Print JSON description of Buffer to std::cout. More...
 
void print (std::ostream &os) const
 Print JSON description of Buffer to given output stream. More...
 
void exportTo (conduit::Node &data_holder)
 Exports Buffer's state to a Conduit node. More...
 
void exportMetadata (conduit::Node &data_holder)
 Exports Buffer's metadata to a Conduit node. More...
 
void importFrom (conduit::Node &data_holder)
 Import Buffer's state from a Conduit node. More...
 

Detailed Description

Buffer is a container that describes and holds data in memory.

The Buffer class has the following properties:

  • Buffer objects can only be created using the DataStore createBuffer() methods. The Buffer ctor is private.
  • A Buffer object has a unique identifier within a DataStore, which is assigned by the DataStore when the Buffer is created.
  • The data owned by a Buffer is unique to that Buffer object; i.e., Buffers do not share their data with other Buffers.
  • Typical usage is to describe the data a Buffer will hold and then allocate it by calling one of the Buffer allocate or reallocate methods.
  • A Buffer object maintains a collection of Views that refer to its data. These references are created when a Buffer object is attached to a View.

Member Function Documentation

◆ getIndex()

IndexType axom::sidre::Buffer::getIndex ( ) const
inline

Return the unique index of this Buffer object.

◆ getNumViews()

IndexType axom::sidre::Buffer::getNumViews ( ) const
inline

Return number of Views this Buffer is attached to.

◆ getVoidPtr()

void* axom::sidre::Buffer::getVoidPtr ( )
inline

Return void-pointer to data held by Buffer.

◆ getData()

Node::Value axom::sidre::Buffer::getData ( )
inline

Return data held by Buffer (return type is type caller assigns return value to).

Note that if Buffer is not allocated, an empty Conduit Node::Value is returned.

References isAllocated(), and SLIC_CHECK_MSG.

◆ getTypeID()

TypeID axom::sidre::Buffer::getTypeID ( ) const
inline

Return type of data owned by this Buffer object.

◆ getNumElements()

IndexType axom::sidre::Buffer::getNumElements ( ) const
inline

Return total number of data elements (of its type) owned by this Buffer object.

◆ getTotalBytes()

IndexType axom::sidre::Buffer::getTotalBytes ( ) const
inline

Return total number of bytes of data owned by this Buffer object.

◆ getBytesPerElement()

IndexType axom::sidre::Buffer::getBytesPerElement ( ) const
inline

Return the number of bytes per element owned by this Buffer object.

◆ isAllocated()

bool axom::sidre::Buffer::isAllocated ( ) const
inline

Return true if Buffer has been (re)allocated with length >= 0, else false.

◆ isDescribed()

bool axom::sidre::Buffer::isDescribed ( ) const
inline

Return true if data description exists.

◆ describe()

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

Describe a Buffer with data given data type and number of elements.

To use the Buffer, the data must be allocated by calling allocate().

If Buffer is already allocated or given number of elements is < 0, method is a no-op.

Returns
pointer to this Buffer object.

◆ allocate() [1/2]

Buffer* axom::sidre::Buffer::allocate ( int  allocID = INVALID_ALLOCATOR_ID)

Allocate data for a Buffer.

If the Buffer is not described or already allocated the method is a no-op.

Returns
pointer to this Buffer object.

◆ allocate() [2/2]

Buffer* axom::sidre::Buffer::allocate ( TypeID  type,
IndexType  num_elems,
int  allocID = INVALID_ALLOCATOR_ID 
)

Allocate Buffer with data type and number of elements.

This is equivalent to: buff->describe(type, num_elems)->allocate().

Method is a no-op under the same conditions as either of those methods.

Returns
pointer to this Buffer object.

◆ reallocate()

Buffer* axom::sidre::Buffer::reallocate ( IndexType  num_elems)

Reallocate data to given number of elements.

This is equivalent to: buff->describe(type, num_elems)->allocate() if the Buffer is not allocated.

If given number of elements < 0, or the Buffer is not already described with type information, this method is a no-op.

Returns
pointer to this Buffer object.

◆ deallocate()

Buffer* axom::sidre::Buffer::deallocate ( )

Deallocate data in a Buffer.

If Buffer is attached to Views, it will remain attached to those Views and the descriptions will remain intact. However, the View descriptions will be 'un-applied' since there is no data to apply them to.

If the Buffer is subsequently redescribed and/or re-allocated, the associated Views may need to be re-described. They will need to be re-applied if the Views will be used to access the Buffer data.

If the Buffer is not allocated, method is a no-op.

Returns
pointer to this Buffer object.

◆ copyBytesIntoBuffer()

Buffer* axom::sidre::Buffer::copyBytesIntoBuffer ( void *  src,
IndexType  nbytes 
)

Copy given number of bytes of data from src into Buffer.

If nbytes < 0 or nbytes > getTotalBytes(), or src is null, method is a no-op.

Returns
pointer to this Buffer object.

◆ copyToConduitNode()

void axom::sidre::Buffer::copyToConduitNode ( Node n) const

Copy Buffer description to a Conduit node.

◆ print() [1/2]

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

Print JSON description of Buffer to std::cout.

◆ print() [2/2]

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

Print JSON description of Buffer to given output stream.

◆ exportTo()

void axom::sidre::Buffer::exportTo ( conduit::Node &  data_holder)

Exports Buffer's state to a Conduit node.

◆ exportMetadata()

void axom::sidre::Buffer::exportMetadata ( conduit::Node &  data_holder)

Exports Buffer's metadata to a Conduit node.

◆ importFrom()

void axom::sidre::Buffer::importFrom ( conduit::Node &  data_holder)

Import Buffer's state from a Conduit node.

Friends And Related Function Documentation

◆ DataStore

friend class DataStore
friend

Friend declarations to constrain usage via controlled access to private members.

◆ Group

friend class Group
friend

◆ View

friend class View
friend

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