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

A View object describes data, which may be owned by the view object (e.g., via an attached Buffer) or owned externally. More...

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

Public Member Functions

template<typename DataType >
DataType getData ()
 Lightweight templated wrapper around getData() that can be used when you are calling getData(), but not assigning the return type. More...
 
void * getVoidPtr () const
 Returns a void pointer to the view's data. More...
 
View query and accessor methods
IndexType getIndex () const
 Return index of View within owning Group. More...
 
const std::string & getName () const
 Return const reference to name of View. More...
 
std::string getPath () const
 Return path of View's owning Group object. More...
 
std::string getPathName () const
 Return full path of View object, including its name. More...
 
GroupgetOwningGroup ()
 Return pointer to non-const Group that owns View object. More...
 
const GroupgetOwningGroup () const
 Return pointer to const Group that owns View object. More...
 
bool hasBuffer () const
 Return true if view has a an associated Buffer object (e.g., view is not opaque, it has been created with a buffer, it has been allocated, etc.); false otherwise. More...
 
BuffergetBuffer ()
 Return pointer to non-const Buffer associated with View. More...
 
const BuffergetBuffer () const
 Return pointer to const Buffer associated with View. More...
 
bool isExternal () const
 Return true if view holds external data; false otherwise. More...
 
bool isAllocated () const
 Return true if view is described and refers to a buffer that has been allocated. More...
 
bool isApplied () const
 Return true if data description (schema) has been applied to data in buffer associated with view; false otherwise. More...
 
bool isDescribed () const
 Return true if data description exists. It may/may not have been applied to the data yet. ( Check isApplied() for that. ) More...
 
bool isEmpty () const
 Return true if view is empty. More...
 
bool isOpaque () const
 Convenience function that returns true if view is opaque (i.e., has access to data but has no knowledge of the data type or structure); false otherwise. More...
 
bool isScalar () const
 Return true if view contains a scalar value. More...
 
bool isString () const
 Return true if view contains a string value. More...
 
TypeID getTypeID () const
 Return type of data for this View object. Return NO_TYPE_ID for an undescribed view. More...
 
IndexType getTotalBytes () const
 Return total number of bytes associated with this View object. More...
 
IndexType getNumElements () const
 Return total number of elements described by this View object. More...
 
IndexType getBytesPerElement () const
 Return number of bytes per element in the described view. More...
 
IndexType getOffset () const
 Return the offset in number of elements for the data described by this View object. More...
 
IndexType getStride () const
 Return the stride in number of elements for the data described by this View object. More...
 
int getNumDimensions () const
 Return dimensionality of this View's data. More...
 
int getShape (int ndims, IndexType *shape) const
 Return number of dimensions in data view and fill in shape information of this data view object. More...
 
const SchemagetSchema () const
 Return const reference to schema describing data. More...
 
NodegetNode ()
 Return non-const reference to Conduit node holding data. More...
 
const NodegetNode () const
 Return const reference to Conduit node holding data. More...
 
bool isEquivalentTo (const View *other) const
 Returns boolean telling whether two Views have equivalent internal description, in terms of name, datatype, and current state of the object. Values of the data are not checked. More...
 
bool isUpdateableFrom (const View *other) const
 Returns true if both Views are either associated with a buffer or external, they span the same number of bytes and have unit stride. More...
 
View allocation methods
Viewallocate (int allocID=INVALID_ALLOCATOR_ID)
 Allocate data for a view, previously described. More...
 
Viewallocate (TypeID type, IndexType num_elems, int allocID=INVALID_ALLOCATOR_ID)
 Allocate data for view given type and number of elements. More...
 
Viewallocate (const DataType &dtype, int allocID=INVALID_ALLOCATOR_ID)
 Allocate data for view described by a Conduit data type object. More...
 
Viewreallocate (IndexType num_elems)
 Reallocate data for view to given number of elements (type stays the same). More...
 
Viewreallocate (const DataType &dtype)
 Reallocate data for view as specified by Conduit data type object. More...
 
Viewdeallocate ()
 Deallocate data for view. More...
 
ViewattachBuffer (Buffer *buff)
 Attach Buffer object to data view. More...
 
ViewattachBuffer (TypeID type, IndexType num_elems, Buffer *buff)
 Describe the data view and attach Buffer object. More...
 
ViewattachBuffer (TypeID type, int ndims, const IndexType *shape, Buffer *buff)
 Describe the data view and attach Buffer object. More...
 
BufferdetachBuffer ()
 Detach this view from its Buffer. More...
 
void clear ()
 Clear data and metadata from a View. More...
 
Methods to apply View description to data.
Viewapply ()
 Apply view description to data. More...
 
Viewapply (IndexType num_elems, IndexType offset=0, IndexType stride=1)
 Apply data description defined by number of elements, and optionally offset and stride to data view (type remains the same). More...
 
Viewapply (TypeID type, IndexType num_elems, IndexType offset=0, IndexType stride=1)
 Apply data description defined by type and number of elements, and optionally offset and stride to data view. More...
 
Viewapply (TypeID type, int ndims, const IndexType *shape)
 Apply data description defined by type and shape information to data view. More...
 
Viewapply (const DataType &dtype)
 Apply data description of given Conduit data type to data view. More...
 
Methods to set data in the view (scalar, string, or external data).
template<typename ScalarType >
ViewsetScalar (ScalarType value)
 Set the view to hold the given scalar. More...
 
ViewsetScalar (Node &value)
 Set the view to hold the given scalar. More...
 
ViewimportArrayNode (const Node &array)
 
ViewsetString (const std::string &value)
 Set the view to hold the given string. More...
 
ViewsetExternalDataPtr (void *external_ptr)
 Set view to hold external data. More...
 
ViewsetExternalDataPtr (TypeID type, IndexType num_elems, void *external_ptr)
 Set view to hold described external data. More...
 
ViewsetExternalDataPtr (TypeID type, int ndims, const IndexType *shape, void *external_ptr)
 Set view to hold described external data. More...
 
ViewupdateFrom (const View *other)
 Update the data in this View with the data in other if isUpdateableFrom( other ). Otherwise nothing is done. More...
 
Methods to retrieve data in a view.
Node::Value getArray ()
 Return a pointer or conduit array object to the view's array data. More...
 
const char * getString () const
 Returns a pointer to the string contained in the view. More...
 
Node::ConstValue getScalar () const
 Returns a copy of the scalar value contained in the view. More...
 
Node::Value getData ()
 Return data held by view and cast it to any compatible type allowed by Conduit (return type depends on type caller assigns it to). More...
 
Node::ConstValue getData () const
 
View print methods.
void print () const
 Print JSON description of data view to stdout. More...
 
void print (std::ostream &os) const
 Print JSON description of data view to an ostream. More...
 
void copyToConduitNode (Node &n) const
 Copy data view description to given Conduit node. More...
 
void createNativeLayout (Node &n) const
 Copy data view native layout to given Conduit node. More...
 
void copyMetadataToNode (Node &n) const
 Copy metadata of the View to the given Conduit node. More...
 
bool rename (const std::string &new_name)
 Change the name of this View. More...
 

Friends

class Group
 
class Buffer
 

Attribute Value query and accessor methods

AttributegetAttribute (IndexType idx)
 Get an Attribute. More...
 
const AttributegetAttribute (IndexType idx) const
 
AttributegetAttribute (const std::string &name)
 
const AttributegetAttribute (const std::string &name) const
 
bool hasAttributeValue (IndexType idx) const
 Return true if the attribute has been explicitly set; else false. More...
 
bool hasAttributeValue (const std::string &name) const
 Return true if the attribute has been explicitly set; else false. More...
 
bool hasAttributeValue (const Attribute *attr) const
 Return true if the attribute has been explicitly set; else false. More...
 
bool setAttributeToDefault (IndexType idx)
 Set Attribute to its default value. More...
 
bool setAttributeToDefault (const std::string &name)
 
bool setAttributeToDefault (const Attribute *attr)
 
template<typename ScalarType >
bool setAttributeScalar (IndexType idx, ScalarType value)
 Set Attribute to a scalar value. More...
 
template<typename ScalarType >
bool setAttributeScalar (const std::string &name, ScalarType value)
 
template<typename ScalarType >
bool setAttributeScalar (const Attribute *attr, ScalarType value)
 
bool setAttributeString (IndexType indx, const std::string &value)
 Set Attribute to a string value. More...
 
bool setAttributeString (const std::string &name, const std::string &value)
 
bool setAttributeString (const Attribute *attr, const std::string &value)
 
Node::ConstValue getAttributeScalar (IndexType idx) const
 Return scalar Attribute value. More...
 
Node::ConstValue getAttributeScalar (const std::string &name) const
 
Node::ConstValue getAttributeScalar (const Attribute *attr) const
 
template<typename DataType >
DataType getAttributeScalar (IndexType idx)
 Lightweight templated wrapper around getAttributeScalar() that can be used when you are calling getAttributeScalar(), but not assigning the return type. More...
 
template<typename DataType >
DataType getAttributeScalar (const std::string &name)
 Lightweight templated wrapper around getAttributeScalar() that can be used when you are calling getAttributeScalar(), but not assigning the return type. More...
 
template<typename DataType >
DataType getAttributeScalar (const Attribute *attr)
 Lightweight templated wrapper around getAttributeScalar() that can be used when you are calling getAttributeScalar(), but not assigning the return type. More...
 
const char * getAttributeString (IndexType idx) const
 Return a string attribute. More...
 
const char * getAttributeString (const std::string &name) const
 
const char * getAttributeString (const Attribute *attr) const
 
const NodegetAttributeNodeRef (IndexType idx) const
 Return reference to an Attribute node. More...
 
const NodegetAttributeNodeRef (const std::string &name) const
 
const NodegetAttributeNodeRef (const Attribute *attr) const
 
IndexType getFirstValidAttrValueIndex () const
 Return first valid Attribute index for a set Attribute in View object (i.e., smallest index over all Attributes). More...
 
IndexType getNextValidAttrValueIndex (IndexType idx) const
 Return next valid Attribute index for a set Attribute in View object after given index (i.e., smallest index over all Attribute indices larger than given one). More...
 

Detailed Description

A View object describes data, which may be owned by the view object (e.g., via an attached Buffer) or owned externally.

The View class has the following properties:

  • View objects can only be created via the Group interface, not constructed directly. A View object is owned by the Group object that creates it. A View object owned by a Group object that is a descendant of some ancestor Group is a descendant View of the ancestor Group.
  • A View object has a unique name (string) within the Group that owns it.
  • A View holds a pointer to the Group that created it and which owns it.
  • A View object can describe and provide access to data in one of four ways:
    • A view can describe (a subset of) data owned by an existing Buffer. In this case, the data can be (re)allocated or deallocated by the view if and only if it is the only view attached to the buffer.
    • A view can describe and allocate data using semantics similar to Buffer data description and allocation. In this case, no other view is allowed to (re)allocate or deallocate the data held by the associated data buffer.
    • A view can describe data associated with a pointer to an "external" data object. In this case, the view cannot (re)allocate or deallocate the data. However, all other view operations are essentially the same as the previous two cases.
    • It can hold a pointer to an undescribed (i.e., "opaque") data object. In this case, the view knows nothing about the type or structure of the data; it is essentially just a handle to the data.
  • For any View object that is "external" or associated with a Buffer, the data description of the view may be specified, or changed, by calling one of the apply() methods.

Member Function Documentation

◆ getIndex()

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

Return index of View within owning Group.

If View is detached, return sidre::InvalidIndex.

◆ getName()

const std::string& axom::sidre::View::getName ( ) const
inline

Return const reference to name of View.

See also
getPath(), getPathName()

◆ getPath()

std::string axom::sidre::View::getPath ( ) const

Return path of View's owning Group object.

See also
getName(), getPathName()

◆ getPathName()

std::string axom::sidre::View::getPathName ( ) const

Return full path of View object, including its name.

If a DataStore contains a Group tree structure a/b/c/d/e, with group d owning a view v, the following results are expected:

Method Call Result
v->getName() v
v->getPath() a/b/c/d
v->getPathName() a/b/c/d/v
See also
getName(), getPath(), Group::getPathName()

◆ getOwningGroup() [1/2]

Group* axom::sidre::View::getOwningGroup ( )
inline

Return pointer to non-const Group that owns View object.

◆ getOwningGroup() [2/2]

const Group* axom::sidre::View::getOwningGroup ( ) const
inline

Return pointer to const Group that owns View object.

◆ hasBuffer()

bool axom::sidre::View::hasBuffer ( ) const
inline

Return true if view has a an associated Buffer object (e.g., view is not opaque, it has been created with a buffer, it has been allocated, etc.); false otherwise.

◆ getBuffer() [1/2]

Buffer* axom::sidre::View::getBuffer ( )
inline

Return pointer to non-const Buffer associated with View.

◆ getBuffer() [2/2]

const Buffer* axom::sidre::View::getBuffer ( ) const
inline

Return pointer to const Buffer associated with View.

◆ isExternal()

bool axom::sidre::View::isExternal ( ) const
inline

Return true if view holds external data; false otherwise.

◆ isAllocated()

bool axom::sidre::View::isAllocated ( ) const

Return true if view is described and refers to a buffer that has been allocated.

◆ isApplied()

bool axom::sidre::View::isApplied ( ) const
inline

Return true if data description (schema) has been applied to data in buffer associated with view; false otherwise.

◆ isDescribed()

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

Return true if data description exists. It may/may not have been applied to the data yet. ( Check isApplied() for that. )

◆ isEmpty()

bool axom::sidre::View::isEmpty ( ) const
inline

Return true if view is empty.

◆ isOpaque()

bool axom::sidre::View::isOpaque ( ) const
inline

Convenience function that returns true if view is opaque (i.e., has access to data but has no knowledge of the data type or structure); false otherwise.

References isApplied().

◆ isScalar()

bool axom::sidre::View::isScalar ( ) const
inline

Return true if view contains a scalar value.

◆ isString()

bool axom::sidre::View::isString ( ) const
inline

Return true if view contains a string value.

◆ getTypeID()

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

Return type of data for this View object. Return NO_TYPE_ID for an undescribed view.

References isDescribed(), and axom::sidre::NO_TYPE_ID.

◆ getTotalBytes()

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

Return total number of bytes associated with this View object.

Attention
This is the total bytes described by the view; they may not yet be allocated.

◆ getNumElements()

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

Return total number of elements described by this View object.

Attention
This is the number of elements described by the view; they may not yet be allocated.

◆ getBytesPerElement()

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

Return number of bytes per element in the described view.

Attention
This is the number of bytes per element described by the view which may not yet be allocated.

◆ getOffset()

IndexType axom::sidre::View::getOffset ( ) const

Return the offset in number of elements for the data described by this View object.

Warning
The code currently assumes that offsets into a view are given in terms of whole elements. It is an assertion error if this is not the case. If you have a different use case, please talk to the Sidre team.
Note
View::getData() and View::getArray() already account for the offset and return a pointer to the first element in the array: View::getVoidPtr() does not account for the offset.
Attention
This function is based on the view description. It does not imply that the data is allocated.
Returns
The offset, in terms of the number of elements, from the described array to the first element.

◆ getStride()

IndexType axom::sidre::View::getStride ( ) const

Return the stride in number of elements for the data described by this View object.

Warning
The code currently assumes that strides into a view are given in terms of whole elements. It is an assertion error if this is not the case. If you have a different use case, please talk to the Sidre team.
Attention
This function is based on the view description. It does not imply that the data is allocated.
Returns
The stride, in terms of the number of elements, between elements in the described array.

◆ getNumDimensions()

int axom::sidre::View::getNumDimensions ( ) const
inline

Return dimensionality of this View's data.

See also
getShape()

◆ getShape()

int axom::sidre::View::getShape ( int  ndims,
IndexType shape 
) const

Return number of dimensions in data view and fill in shape information of this data view object.

ndims - maximum number of dimensions to return. shape - user supplied buffer assumed to be ndims long.

Return the number of dimensions of the view. Return -1 if shape is too short to hold all dimensions.

◆ getSchema()

const Schema& axom::sidre::View::getSchema ( ) const
inline

Return const reference to schema describing data.

◆ getNode() [1/2]

Node& axom::sidre::View::getNode ( )
inline

Return non-const reference to Conduit node holding data.

◆ getNode() [2/2]

const Node& axom::sidre::View::getNode ( ) const
inline

Return const reference to Conduit node holding data.

◆ isEquivalentTo()

bool axom::sidre::View::isEquivalentTo ( const View other) const

Returns boolean telling whether two Views have equivalent internal description, in terms of name, datatype, and current state of the object. Values of the data are not checked.

◆ isUpdateableFrom()

bool axom::sidre::View::isUpdateableFrom ( const View other) const

Returns true if both Views are either associated with a buffer or external, they span the same number of bytes and have unit stride.

◆ allocate() [1/3]

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

Allocate data for a view, previously described.

Note
Allocation from a view is allowed only if it is the only view associated with its buffer (when it has one), or the view is not external, not a string view, or not a scalar view. If none of these condition is true, this method does nothing.
Returns
pointer to this View object.

◆ allocate() [2/3]

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

Allocate data for view given type and number of elements.

Note
The allocate() method (above) describes conditions where View allocation is allowed. If the conditions are not met, type is NO_TYPE_ID, or num_elems < 0, this method does nothing.
Returns
pointer to this View object.

◆ allocate() [3/3]

View* axom::sidre::View::allocate ( const DataType dtype,
int  allocID = INVALID_ALLOCATOR_ID 
)

Allocate data for view described by a Conduit data type object.

Note
The allocate() method describes conditions where view allocation is allowed. If the conditions are not met, this method does nothing.
Returns
pointer to this View object.

◆ reallocate() [1/2]

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

Reallocate data for view to given number of elements (type stays the same).

Note
Reallocation from a view is only allowed under that same conditions for the allocate() method. If the conditions are not met or num_elems < 0 this method does nothing.
Returns
pointer to this View object.

◆ reallocate() [2/2]

View* axom::sidre::View::reallocate ( const DataType dtype)

Reallocate data for view as specified by Conduit data type object.

Note
Reallocation from a view is allowed under the conditions described by the allocate() method. If the conditions are not met or dtype is undefined, this method does nothing.
The given data type object must match the view type, if it is defined. If not, the method does nothing.
Returns
pointer to this View object.

◆ deallocate()

View* axom::sidre::View::deallocate ( )

Deallocate data for view.

Note
Deallocation from a view is only allowed under the conditions described by the allocate() method. If the conditions are not met or a Buffer is not attached this method does nothing.
Returns
pointer to this View object.

◆ attachBuffer() [1/3]

View* axom::sidre::View::attachBuffer ( Buffer buff)

Attach Buffer object to data view.

If the view has no description, then the buffer's description is copied into the view.

Note that, in general, the view cannot be used to access data in buffer until one of the apply() methods is called. However, if the view has a valid data description with a total number of bytes that is <= number of bytes held in the buffer, then apply() will be called internally.

If data view already has a buffer, or it is an external view, a scalar view, or a string view, this method does nothing.

If data view already has a buffer and buff is NULL, the attached buffer will be detached. After the view is detached from the buffer, if the buffer has no views attached to it, then it will be destroyed.

Returns
pointer to this View object.

◆ attachBuffer() [2/3]

View* axom::sidre::View::attachBuffer ( TypeID  type,
IndexType  num_elems,
Buffer buff 
)
inline

Describe the data view and attach Buffer object.

Returns
pointer to this View object.

References attachBuffer().

◆ attachBuffer() [3/3]

View* axom::sidre::View::attachBuffer ( TypeID  type,
int  ndims,
const IndexType shape,
Buffer buff 
)
inline

Describe the data view and attach Buffer object.

Returns
pointer to this View object.

References attachBuffer().

◆ detachBuffer()

Buffer* axom::sidre::View::detachBuffer ( )

Detach this view from its Buffer.

If the view has no buffer, the method does nothing.

Returns
pointer to detached buffer.

◆ clear()

void axom::sidre::View::clear ( )

Clear data and metadata from a View.

The view will be EMPTY. There will be no description or data associated with the View.

◆ apply() [1/5]

View* axom::sidre::View::apply ( )

Apply view description to data.

If view holds a scalar or a string, the method does nothing.

Returns
pointer to this View object.

◆ apply() [2/5]

View* axom::sidre::View::apply ( IndexType  num_elems,
IndexType  offset = 0,
IndexType  stride = 1 
)

Apply data description defined by number of elements, and optionally offset and stride to data view (type remains the same).

Note
The units for offset and stride are in number of elements, which is different than the Conduit DataType usage below where offset and stride are in number of bytes.
Attention
If view has been previously described (or applied), this operation will apply the new data description to the view.

If view holds a scalar or a string, is external and does not have a sufficient data description to get type information, or given number of elements < 0, or offset < 0, the method does nothing.

Returns
pointer to this View object.

◆ apply() [3/5]

View* axom::sidre::View::apply ( TypeID  type,
IndexType  num_elems,
IndexType  offset = 0,
IndexType  stride = 1 
)

Apply data description defined by type and number of elements, and optionally offset and stride to data view.

Note
The units for offset and stride are in number of elements, which is different than the Conduit DataType usage below where offset and stride are in number of bytes.
Attention
If view has been previously described (or applied), this operation will apply the new data description to the view.

If view holds a scalar or a string, or type is NO_TYPE_ID, or given number of elements < 0, or offset < 0, the method does nothing.

Returns
pointer to this View object.

◆ apply() [4/5]

View* axom::sidre::View::apply ( TypeID  type,
int  ndims,
const IndexType shape 
)

Apply data description defined by type and shape information to data view.

Note
The units for the shape are in number of elements.
Attention
If view has been previously described (or applied), this operation will apply the new data description to the view.

If view holds a scalar or a string, or type is NO_TYPE_ID, or given number of dimensions < 0, or pointer to shape is null, the method does nothing.

Returns
pointer to this View object.

◆ apply() [5/5]

View* axom::sidre::View::apply ( const DataType dtype)

Apply data description of given Conduit data type to data view.

If view holds a scalar or a string, the method does nothing.

Returns
pointer to this View object.

◆ setScalar() [1/2]

template<typename ScalarType >
View* axom::sidre::View::setScalar ( ScalarType  value)
inline

Set the view to hold the given scalar.

Returns
pointer to this View object.

References SIDRE_VIEW_LOG_PREPEND, and SLIC_CHECK_MSG.

◆ setScalar() [2/2]

View* axom::sidre::View::setScalar ( Node value)
inline

Set the view to hold the given scalar.

Returns
pointer to this View object.

References SIDRE_VIEW_LOG_PREPEND, and SLIC_CHECK_MSG.

◆ importArrayNode()

View* axom::sidre::View::importArrayNode ( const Node array)

◆ setString()

View* axom::sidre::View::setString ( const std::string &  value)
inline

Set the view to hold the given string.

Returns
pointer to this View object.

References SIDRE_VIEW_LOG_PREPEND, and SLIC_CHECK_MSG.

◆ setExternalDataPtr() [1/3]

View* axom::sidre::View::setExternalDataPtr ( void *  external_ptr)

Set view to hold external data.

Data is undescribed (i.e., view is opaque) until an apply methods is called on the view.

If external_ptr is NULL, the view will be EMPTY. Any existing description is unchanged.

Returns
pointer to this View object.

◆ setExternalDataPtr() [2/3]

View* axom::sidre::View::setExternalDataPtr ( TypeID  type,
IndexType  num_elems,
void *  external_ptr 
)
inline

Set view to hold described external data.

If external_ptr is NULL, the view will be EMPTY.

Returns
pointer to this View object.

References setExternalDataPtr().

◆ setExternalDataPtr() [3/3]

View* axom::sidre::View::setExternalDataPtr ( TypeID  type,
int  ndims,
const IndexType shape,
void *  external_ptr 
)
inline

Set view to hold described external data.

If external_ptr is NULL, the view will be EMPTY.

Returns
pointer to this View object.

References setExternalDataPtr().

◆ updateFrom()

View* axom::sidre::View::updateFrom ( const View other)

Update the data in this View with the data in other if isUpdateableFrom( other ). Otherwise nothing is done.

Returns
pointer to this View object.

◆ getArray()

Node::Value axom::sidre::View::getArray ( )
inline

Return a pointer or conduit array object to the view's array data.

Return value depends on variable type caller assigns it to. For example, if view holds an integer array, the following usage is possible:

 int* a = view->getArray();      // Get array as int pointer
 int_array a = view->getArray(); // Get array as Conduit array struct.
Note
The returned pointer accounts for the View's offset, so getArray()[0] always points to the first element in the array.

References getData().

◆ getString()

const char* axom::sidre::View::getString ( ) const
inline

Returns a pointer to the string contained in the view.

If the view is not a STRING, then nullptr is returned.

◆ getScalar()

Node::ConstValue axom::sidre::View::getScalar ( ) const
inline

Returns a copy of the scalar value contained in the view.

References getData(), SIDRE_VIEW_LOG_PREPEND, and SLIC_CHECK_MSG.

◆ getData() [1/3]

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

Return data held by view and cast it to any compatible type allowed by Conduit (return type depends on type caller assigns it to).

If view does not contain allocated data, an empty Node::Value will be returned.

Note
The return value already accounts for the View's offset (when present), so, if the View is an array, getData()[0] already points to the first element

References isAllocated(), isDescribed(), SIDRE_VIEW_LOG_PREPEND, and SLIC_CHECK_MSG.

◆ getData() [2/3]

Node::ConstValue axom::sidre::View::getData ( ) const
inline

◆ getData() [3/3]

template<typename DataType >
DataType axom::sidre::View::getData ( )
inline

Lightweight templated wrapper around getData() that can be used when you are calling getData(), but not assigning the return type.

See also
getData()

◆ getVoidPtr()

void* axom::sidre::View::getVoidPtr ( ) const

Returns a void pointer to the view's data.

Note
This function returns the base pointer that was used to set up the view. It does not account for any offsets or strides in the View's description.

To access the first data element, you will need to cast to the appropriate type and add the offset. E.g. if the underlying data is an array of integers you can access the first element as follows:

 void* vptr = view->getVoidPtr();
 int*  iptr = static_cast<int*>(vptr) + view->getOffset();
See also
getData(), getArray()

◆ print() [1/2]

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

Print JSON description of data view to stdout.

◆ print() [2/2]

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

Print JSON description of data view to an ostream.

◆ copyToConduitNode()

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

Copy data view description to given Conduit node.

◆ createNativeLayout()

void axom::sidre::View::createNativeLayout ( Node n) const

Copy data view native layout to given Conduit node.

The native layout is a Conduit Node hierarchy that maps the Conduit Node data externally to the Sidre View data so that it can be filled in from the data in the file (independent of file format) and can be accessed as a Conduit tree.

◆ copyMetadataToNode()

void axom::sidre::View::copyMetadataToNode ( Node n) const

Copy metadata of the View to the given Conduit node.

The View's datatype schema and state information will be copied into the node, but not the data held by the View.

◆ rename()

bool axom::sidre::View::rename ( const std::string &  new_name)

Change the name of this View.

The name of this view is changed to the new name. This also changes the name for this view held by the owning group.

Warnings will occur and the name will not be changed under these conditions: If the new name is an empty string, if the new name contains a path delimiter (usually '/'), or if the new name is identical to a name that is already held by the parent for another Group or View object.

Parameters
new_nameThe new name for this view.
Returns
Success or failure of rename.

◆ getAttribute() [1/4]

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

Get an Attribute.

Parameters
[in]idxAttribute identifier.
Returns
the specified Attribute, or nullptr if it doesn't exist.

◆ getAttribute() [2/4]

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

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ getAttribute() [3/4]

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

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ getAttribute() [4/4]

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

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ hasAttributeValue() [1/3]

bool axom::sidre::View::hasAttributeValue ( IndexType  idx) const
inline

Return true if the attribute has been explicitly set; else false.

References getAttribute().

◆ hasAttributeValue() [2/3]

bool axom::sidre::View::hasAttributeValue ( const std::string &  name) const
inline

Return true if the attribute has been explicitly set; else false.

References getAttribute().

◆ hasAttributeValue() [3/3]

bool axom::sidre::View::hasAttributeValue ( const Attribute attr) const
inline

Return true if the attribute has been explicitly set; else false.

References SIDRE_VIEW_LOG_PREPEND, and SLIC_CHECK_MSG.

◆ setAttributeToDefault() [1/3]

bool axom::sidre::View::setAttributeToDefault ( IndexType  idx)
inline

Set Attribute to its default value.

Parameters
[in]idxAttribute identifier

This causes hasAttributeValue to return false for the attribute.

References getAttribute().

◆ setAttributeToDefault() [2/3]

bool axom::sidre::View::setAttributeToDefault ( const std::string &  name)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

References getAttribute().

◆ setAttributeToDefault() [3/3]

bool axom::sidre::View::setAttributeToDefault ( const Attribute attr)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

References SIDRE_VIEW_LOG_PREPEND, and SLIC_CHECK_MSG.

◆ setAttributeScalar() [1/3]

template<typename ScalarType >
bool axom::sidre::View::setAttributeScalar ( IndexType  idx,
ScalarType  value 
)
inline

Set Attribute to a scalar value.

Parameters
[in]idxAttribute identifier
[in]valueValue of Attribute

If no such Attribute exists, this is a no-op.

References getAttribute().

◆ setAttributeScalar() [2/3]

template<typename ScalarType >
bool axom::sidre::View::setAttributeScalar ( const std::string &  name,
ScalarType  value 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

References getAttribute().

◆ setAttributeScalar() [3/3]

template<typename ScalarType >
bool axom::sidre::View::setAttributeScalar ( const Attribute attr,
ScalarType  value 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

References SIDRE_VIEW_LOG_PREPEND, and SLIC_CHECK_MSG.

◆ setAttributeString() [1/3]

bool axom::sidre::View::setAttributeString ( IndexType  indx,
const std::string &  value 
)

Set Attribute to a string value.

Parameters
[in]indxAttribute identifier.
[in]valueValue of attribute.

If no such Attribute exists, this is a no-op.

◆ setAttributeString() [2/3]

bool axom::sidre::View::setAttributeString ( const std::string &  name,
const std::string &  value 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ setAttributeString() [3/3]

bool axom::sidre::View::setAttributeString ( const Attribute attr,
const std::string &  value 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ getAttributeScalar() [1/6]

Node::ConstValue axom::sidre::View::getAttributeScalar ( IndexType  idx) const
inline

Return scalar Attribute value.

Parameters
[in]idxAttribute identifier.

If no such Attribute exists, return empty scalar value.

References getAttribute().

◆ getAttributeScalar() [2/6]

Node::ConstValue axom::sidre::View::getAttributeScalar ( const std::string &  name) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

References getAttribute().

◆ getAttributeScalar() [3/6]

Node::ConstValue axom::sidre::View::getAttributeScalar ( const Attribute attr) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

References SIDRE_VIEW_LOG_PREPEND, and SLIC_CHECK_MSG.

◆ getAttributeScalar() [4/6]

template<typename DataType >
DataType axom::sidre::View::getAttributeScalar ( IndexType  idx)
inline

Lightweight templated wrapper around getAttributeScalar() that can be used when you are calling getAttributeScalar(), but not assigning the return type.

See also
getAttributeScalar()

References getAttribute().

◆ getAttributeScalar() [5/6]

template<typename DataType >
DataType axom::sidre::View::getAttributeScalar ( const std::string &  name)
inline

Lightweight templated wrapper around getAttributeScalar() that can be used when you are calling getAttributeScalar(), but not assigning the return type.

See also
getAttributeScalar()

References getAttribute().

◆ getAttributeScalar() [6/6]

template<typename DataType >
DataType axom::sidre::View::getAttributeScalar ( const Attribute attr)
inline

Lightweight templated wrapper around getAttributeScalar() that can be used when you are calling getAttributeScalar(), but not assigning the return type.

See also
getAttributeScalar()

References SIDRE_VIEW_LOG_PREPEND, and SLIC_CHECK_MSG.

◆ getAttributeString() [1/3]

const char* axom::sidre::View::getAttributeString ( IndexType  idx) const

Return a string attribute.

Parameters
[in]idxAttribute identifer.

If the value has not been explicitly set, return the current default.

Returns
The Attribute name, or nullptr if no such Attribute.

◆ getAttributeString() [2/3]

const char* axom::sidre::View::getAttributeString ( const std::string &  name) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ getAttributeString() [3/3]

const char* axom::sidre::View::getAttributeString ( const Attribute attr) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ getAttributeNodeRef() [1/3]

const Node& axom::sidre::View::getAttributeNodeRef ( IndexType  idx) const
inline

Return reference to an Attribute node.

Parameters
[in]idxAttribute identifier

If the value has not been explicitly set, return the current default.

Returns
The Attribute Node, or an empty Node if no such Attribute.

References getAttribute().

◆ getAttributeNodeRef() [2/3]

const Node& axom::sidre::View::getAttributeNodeRef ( const std::string &  name) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

References getAttribute().

◆ getAttributeNodeRef() [3/3]

const Node& axom::sidre::View::getAttributeNodeRef ( const Attribute attr) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

References SIDRE_VIEW_LOG_PREPEND, and SLIC_CHECK_MSG.

◆ getFirstValidAttrValueIndex()

IndexType axom::sidre::View::getFirstValidAttrValueIndex ( ) const
inline

Return first valid Attribute index for a set Attribute in View object (i.e., smallest index over all Attributes).

sidre::InvalidIndex is returned if View has no Attributes set.

◆ getNextValidAttrValueIndex()

IndexType axom::sidre::View::getNextValidAttrValueIndex ( IndexType  idx) const
inline

Return next valid Attribute index for a set Attribute in View 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. getNextAttrValueIndex(InvalidIndex) returns InvalidIndex.

Friends And Related Function Documentation

◆ Group

friend class Group
friend

◆ Buffer

friend class Buffer
friend

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