AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
|
Group holds a collection of Views and (child) Groups. More...
#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/develop/src/axom/sidre/core/Group.hpp>
Public Types | |
using | ViewCollection = ItemCollection< View > |
using | GroupCollection = ItemCollection< Group > |
Public Member Functions | |
View query methods. | |
bool | hasView (const std::string &path) const |
Return true if Group includes a descendant View with given name or path; else false. More... | |
bool | hasChildView (const std::string &name) const |
Return true if this Group owns a View with given name (not path); else false. More... | |
bool | hasView (IndexType idx) const |
Return true if this Group owns a View with given index; else false. More... | |
IndexType | getViewIndex (const std::string &name) const |
Return index of View with given name owned by this Group object. More... | |
const std::string & | getViewName (IndexType idx) const |
Return name of View with given index owned by Group object. More... | |
View access methods. | |
View * | getView (const std::string &path) |
Return pointer to non-const View with given name or path. More... | |
const View * | getView (const std::string &path) const |
Return pointer to const View with given name or path. More... | |
View * | getView (IndexType idx) |
Return pointer to non-const View with given index. More... | |
const View * | getView (IndexType idx) const |
Return pointer to const View with given index. More... | |
View iteration methods. | |
Using these methods, a code can get the first View index and each succeeding index. This allows View iteration using the same constructs in C++, C, and Fortran. Example: sidre::IndexType idx = grp->getFirstValidViewIndex(); while( sidre::indexIsValid(idx) ) { View* view = grp->getView(idx); /// code here using view idx = grp -> getNextValidViewIndex(idx); } | |
IndexType | getFirstValidViewIndex () const |
Return first valid View index in Group object (i.e., smallest index over all Views). More... | |
IndexType | getNextValidViewIndex (IndexType idx) const |
Return next valid View index in Group object after given index (i.e., smallest index over all View indices larger than given one). More... | |
Methods to create a View that has no associated data. | |
Each of these methods is a no-op if the given View name is an empty string or the Group already has a View with given name or path. Additional conditions under which a method can be a no-op are described for each method. | |
View * | createView (const std::string &path) |
Create an undescribed (i.e., empty) View object with given name or path in this Group. More... | |
View * | createView (const std::string &path, TypeID type, IndexType num_elems) |
Create View object with given name or path in this Group that has a data description with data type and number of elements. More... | |
View * | createViewWithShape (const std::string &path, TypeID type, int ndims, const IndexType *shape) |
Create View object with given name or path in this Group that has a data description with data type and shape. More... | |
View * | createView (const std::string &path, const DataType &dtype) |
Create View object with given name or path in this Group that is described by a Conduit DataType object. More... | |
Methods to create a View with a Buffer attached. | |
Each of these methods is a no-op if Group already has a View or child Group with the given name or path. If this Group was created to hold items in list format, the path can be an empty string. Otherwise an empty string for the path will result in a no-op. Also, calling one of these methods with a null Buffer pointer is similar to creating a View with no data association. Additional conditions under which a method can be a no-op are described for each method. | |
View * | createView (const std::string &path, Buffer *buff) |
Create an undescribed View object with given name or path in this Group and attach given Buffer to it. More... | |
View * | createView (const std::string &path, TypeID type, IndexType num_elems, Buffer *buff) |
Create View object with given name or path in this Group that has a data description with data type and number of elements and attach given Buffer to it. More... | |
View * | createViewWithShape (const std::string &path, TypeID type, int ndims, const IndexType *shape, Buffer *buff) |
Create View object with given name or path in this Group that has a data description with data type and shape and attach given Buffer to it. More... | |
View * | createView (const std::string &path, const DataType &dtype, Buffer *buff) |
Create View object with given name or path in this Group that is described by a Conduit DataType object and attach given Buffer to it. More... | |
Methods to create a View with externally-owned data attached. | |
Each of these methods is a no-op if the given View name is an empty string or the Group already has a View with given name or path. Additional conditions under which a method can be a no-op are described for each method. | |
View * | createView (const std::string &path, void *external_ptr) |
Create View object with given name with given name or path in this Group and attach external data ptr to it. More... | |
View * | createView (const std::string &path, TypeID type, IndexType num_elems, void *external_ptr) |
Create View object with given name or path in this Group that has a data description with data type and number of elements and attach externally-owned data to it. More... | |
View * | createViewWithShape (const std::string &path, TypeID type, int ndims, const IndexType *shape, void *external_ptr) |
Create View object with given name or path in this Group that has a data description with data type and shape and attach externally-owned data to it. More... | |
View * | createView (const std::string &path, const DataType &dtype, void *external_ptr) |
Create View object with given name or path in this Group that is described by a Conduit DataType object and attach externally-owned data to it. More... | |
Methods to create a View and allocate data for it. | |
View * | createViewAndAllocate (const std::string &path, TypeID type, IndexType num_elems, int allocID=INVALID_ALLOCATOR_ID) |
Create View object with given name or path in this Group that has a data description with data type and number of elements and allocate data for it. More... | |
View * | createViewWithShapeAndAllocate (const std::string &path, TypeID type, int ndims, const IndexType *shape, int allocID=INVALID_ALLOCATOR_ID) |
Create View object with given name or path in this Group that has a data description with data type and shape and allocate data for it. More... | |
View * | createViewAndAllocate (const std::string &path, const DataType &dtype, int allocID=INVALID_ALLOCATOR_ID) |
Create View object with given name or path in this Group that is described by a Conduit DataType object and allocate data for it. More... | |
template<typename ScalarType > | |
View * | createViewScalar (const std::string &path, ScalarType value) |
Create View object with given name or path in this Group set its data to given scalar value. More... | |
View * | createViewString (const std::string &path, const std::string &value) |
Create View object with given name or path in this Group set its data to given string. More... | |
View destruction methods. | |
Each of these methods is a no-op if the specified View does not exist. | |
void | destroyView (const std::string &path) |
Destroy View with given name or path owned by this Group, but leave its data intect. More... | |
void | destroyView (IndexType idx) |
Destroy View with given index owned by this Group, but leave its data intect. More... | |
void | destroyViews () |
Destroy all Views owned by this Group, but leave all their data intact. More... | |
void | destroyViewAndData (const std::string &path) |
Destroy View with given name or path owned by this Group and deallocate its data if it's the only View associated with that data. More... | |
void | destroyViewAndData (IndexType idx) |
Destroy View with given index owned by this Group and deallocate its data if it's the only View associated with that data. More... | |
void | destroyViewsAndData () |
Destroy all Views owned by this Group and deallocate data for each View when it's the only View associated with that data. More... | |
View move and copy methods. | |
View * | moveView (View *view) |
Remove given View object from its owning Group and move it to this Group. More... | |
View * | copyView (View *view) |
Create a (shallow) copy of given View object and add it to this Group. More... | |
View * | deepCopyView (View *view, int allocID=INVALID_ALLOCATOR_ID) |
Create a deep copy of given View object and add it to this Group. More... | |
Child Group query methods. | |
bool | hasGroup (const std::string &path) const |
Return true if this Group has a descendant Group with given name or path; else false. More... | |
bool | hasChildGroup (const std::string &name) const |
Return true if this Group has a child Group with given name; else false. More... | |
bool | hasGroup (IndexType idx) const |
Return true if Group has an immediate child Group with given index; else false. More... | |
IndexType | getGroupIndex (const std::string &name) const |
Return the index of immediate child Group with given name. More... | |
const std::string & | getGroupName (IndexType idx) const |
Return the name of immediate child Group with given index. More... | |
Group access and iteration methods. | |
Group * | getGroup (const std::string &path) |
Return pointer to non-const child Group with given name or path. More... | |
Group const * | getGroup (const std::string &path) const |
Return pointer to const child Group with given name or path. More... | |
Group * | getGroup (IndexType idx) |
Return pointer to non-const immediate child Group with given index. More... | |
const Group * | getGroup (IndexType idx) const |
Return pointer to const immediate child Group with given index. More... | |
Group iteration methods. | |
Using these methods, a code can get the first Group index and each succeeding index. This allows Group iteration using the same constructs in C++, C, and Fortran. Example: for (sidre::IndexType idx = grp->getFirstValidGroupIndex(); sidre::indexIsValid(idx); idx = grp->getNextValidGroupIndex(idx)) { Group * group = grp->getGroup(idx); /// code here using group } | |
IndexType | getFirstValidGroupIndex () const |
Return first valid child Group index (i.e., smallest index over all child Groups). More... | |
IndexType | getNextValidGroupIndex (IndexType idx) const |
Return next valid child Group index after given index (i.e., smallest index over all child Group indices larger than given one). More... | |
Child Group creation and destruction methods. | |
Group * | createGroup (const std::string &path, bool is_list=false) |
Create a child Group within this Group with given name or path. More... | |
Group * | createUnnamedGroup (bool is_list=false) |
void | destroyGroup (const std::string &path) |
Destroy child Group in this Group with given name or path. More... | |
void | destroyGroup (IndexType idx) |
Destroy child Group within this Group with given index. More... | |
void | destroyGroupAndData (const std::string &path) |
Destroy child Group at the given path, and destroy data that is not shared elsewhere. More... | |
void | destroyGroupAndData (IndexType idx) |
Destroy child Group with the given index, and destroy data that is not shared elsewhere. More... | |
void | destroyGroupsAndData () |
Destroy all child Groups held by this Group, and destroy data that is not shared elsewhere. More... | |
void | destroyGroupSubtreeAndData () |
Destroy the entire subtree of Groups and Views held by this Group, and destroy data that is not shared elsewhere. More... | |
void | destroyGroups () |
Destroy all child Groups in this Group. More... | |
Group move and copy methods. | |
Group * | moveGroup (Group *group) |
Remove given Group object from its parent Group and make it a child of this Group. More... | |
Group * | copyGroup (Group *group) |
Create a (shallow) copy of Group hierarchy rooted at given Group and make it a child of this Group. More... | |
Group * | deepCopyGroup (Group *srcGroup, int allocID=INVALID_ALLOCATOR_ID) |
Create a deep copy of Group hierarchy rooted at given Group and make the copy a child of this Group. More... | |
Group print methods. | |
void | print () const |
Print JSON description of data Group to stdout. More... | |
void | print (std::ostream &os) const |
Print JSON description of data Group to an ostream. More... | |
void | printTree (const int nlevels, std::ostream &os) const |
Print given number of levels of Group sub-tree starting at this Group object to an output stream. More... | |
void | copyToConduitNode (Node &n) const |
Copy description of Group hierarchy rooted at this Group to given Conduit node. More... | |
bool | createNativeLayout (Node &n, const Attribute *attr=nullptr) const |
Copy Group's native layout to given Conduit node. More... | |
void | createNoDataLayout (Node &n, const Attribute *attr=nullptr) const |
Copy Group's layout to given Conduit node without data. More... | |
bool | createExternalLayout (Node &n, const Attribute *attr=nullptr) const |
Copy data Group external layout to given Conduit node. More... | |
bool | isEquivalentTo (const Group *other, bool checkName=true) const |
Return true if this Group is equivalent to given Group; else false. More... | |
bool | isUsingMap () const |
Return true if this Group holds items in map format. More... | |
bool | isUsingList () const |
Return true if this Group holds items in list format. More... | |
Friends | |
class | DataStore |
class | View |
Basic query and accessor methods. | |
char | getPathDelimiter () const |
Return the path delimiter. More... | |
IndexType | getIndex () const |
Return index of Group object within parent Group. More... | |
const std::string & | getName () const |
Return const reference to name of Group object. More... | |
std::string | getPath () const |
Return path of Group object, not including its name. More... | |
std::string | getPathName () const |
Return full path of Group object, including its name. More... | |
Group * | getParent () |
Return pointer to non-const parent Group of a Group. More... | |
const Group * | getParent () const |
Return pointer to const parent Group of a Group. More... | |
IndexType | getNumGroups () const |
Return number of child Groups in a Group object. More... | |
IndexType | getNumViews () const |
Return number of Views owned by a Group object. More... | |
DataStore * | getDataStore () |
Return pointer to non-const DataStore object that owns this object. More... | |
const DataStore * | getDataStore () const |
Return pointer to const DataStore object that owns this object. More... | |
bool | isRoot () const |
Return true if this Group is the DataStore's root Group. More... | |
int | getDefaultAllocatorID () const |
Return the ID of the default umpire::Allocator associated with this Group. More... | |
Group * | setDefaultAllocator (int allocId) |
Set the default umpire::Allocator associated with this Group. More... | |
void | getDataInfo (Node &n, bool recursive=true) const |
Insert information about data associated with Group subtree with this Group at root of tree (default 'recursive' is true), or for this Group only ('recursive' is false) in fields of given Conduit Node. More... | |
static const std::vector< std::string > & | getValidIOProtocols () |
static method to get valid protocols for Group I/O methods. More... | |
static std::string | getDefaultIOProtocol () |
static method to get the default I/O protocol. More... | |
Accessors for iterating the group and view collections. | |
These methods can be used to iterate over the collection of groups and views Example: for (auto& group : grp->groups()) { /// code here using group } for (auto& view : grp->views()) { /// code here using view } | |
ViewCollection::iterator_adaptor | views () |
Returns an adaptor to support iterating the collection of views. More... | |
ViewCollection::const_iterator_adaptor | views () const |
Returns a const adaptor to support iterating the collection of views. More... | |
GroupCollection::iterator_adaptor | groups () |
Returns an adaptor to support iterating the collection of groups. More... | |
GroupCollection::const_iterator_adaptor | groups () const |
Returns a const adaptor to support iterating the collection of groups. More... | |
Group I/O methods | |
These methods save and load Group trees to and from files. This includes the views and buffers used in by groups in the tree. We provide several "protocol" options: protocols: sidre_hdf5 (default when Axom is configured with hdf5) sidre_conduit_json (default otherwise) sidre_json conduit_hdf5 conduit_bin conduit_json json
There are two overloaded versions for each of save, load, and loadExternalData. The first of each takes a file path and is intended for use in a serial context and can be called directly using any of the supported protocols. The second takes an hdf5 handle that has previously been created by the calling code. These mainly exist to handle parallel I/O calls from the SPIO component. They can only take the sidre_hdf5 or conduit_hdf5 protocols.
| |
bool | save (const std::string &path, const std::string &protocol=Group::getDefaultIOProtocol(), const Attribute *attr=nullptr) const |
Save the Group to a file. More... | |
bool | load (const std::string &path, const std::string &protocol=Group::getDefaultIOProtocol(), bool preserve_contents=false) |
Load a Group hierarchy from a file into this Group. More... | |
bool | load (const std::string &path, const std::string &protocol, bool preserve_contents, std::string &name_from_file) |
Load a Group hierarchy from a file into this Group, reporting the Group name stored in the file. More... | |
Group * | createGroupAndLoad (std::string &group_name, const std::string &path, const std::string &protocol, bool &load_success) |
Create a child Group and load a Group hierarchy from file into the new Group. More... | |
bool | loadExternalData (const std::string &path) |
Load data into the Group's external views from a file. More... | |
bool | rename (const std::string &new_name) |
Change the name of this Group. More... | |
bool | importConduitTree (const conduit::Node &node, bool preserve_contents=false) |
Import data from a conduit Node into a Group. More... | |
bool | importConduitTreeExternal (conduit::Node &node, bool preserve_contents=false) |
Import data from a conduit Node into a Group without copying arrays. More... | |
Group holds a collection of Views and (child) Groups.
The Group class has the following properties:
Note that Views and child Groups within a Group can be accessed by name or index.
Note that certain methods for querying, creating, retrieving, and deleting Groups and Views take a string with path syntax, while others take the name of a direct child of the current Group. Methods that require the name of a direct child are marked with "Child", for example hasChildView() and hasChildGroup(). When a path string is passed to a method that accepts path syntax, the last item in the path indicates the item to be created, accessed, etc. For example,
View* view = group->createView("foo/bar/baz");
is equivalent to
View* view = group->createGroup("foo")->createGroup("bar")->createView("baz");
In particular, intermediate Groups "foo" and "bar" will be created in this case if they don't already exist.
Methods that access Views or Groups by index work with the direct children of the current Group because an index has no meaning outside of the indexed group. None of these methods is marked with "Child".
A Group can optionally be created to hold items in a "list format". In this format, any number of child Group or View items can be created to be held and accessed like a list. When using this format, the child items can be accessed only via iterators that iterate in the order that they were added to the parent Group.
It is recommended but not required that the items held in the list format be created without names. String names may be assigned to these items, but the names will not be useful for accessing them from their parent Group, and none of the methods that access child items by name or path will return a valid pointer. Additionally, strings with path syntax, (such as ("foo/bar/baz") will be considered invalid when creating items to be held in the list format, and the object creation methods will return a null pointer if such a string is provided. Unnamed Groups to be held in the list format should be created using the method createUnnamedGroup, while unnamed Views should be created by passing an empty string as the path argument to any of the createView methods.
|
inline |
Return the path delimiter.
|
inlinestatic |
static method to get valid protocols for Group I/O methods.
Only protocols that work for both input and output are returned.
|
inlinestatic |
static method to get the default I/O protocol.
|
inline |
|
inline |
Return const reference to name of Group object.
std::string axom::sidre::Group::getPath | ( | ) | const |
Return path of Group object, not including its name.
|
inline |
Return full path of Group object, including its name.
If a DataStore contains a Group tree structure a/b/c/d/e, the following results are expected:
Method Call | Result |
---|---|
e->getName() | e |
e->getPath() | a/b/c/d |
e->getPathName() | a/b/c/d/e |
References getName(), getPath(), and getPathDelimiter().
|
inline |
Return pointer to non-const parent Group of a Group.
Note that if this method is called on the root Group in a DataStore, a pointer to itself is returned. This allows root->getParent()->getParent() to always work similar to how the filesystem's cd /; cd ../..
works.
|
inline |
Return pointer to const parent Group of a Group.
Note that if this method is called on the root Group in a DataStore, a pointer to itself is returned. This allows root->getParent()->getParent() to always work similar to how the filesystem's cd /; cd ../..
works.
IndexType axom::sidre::Group::getNumGroups | ( | ) | const |
Return number of child Groups in a Group object.
|
inline |
Return pointer to non-const DataStore object that owns this object.
|
inline |
Return pointer to const DataStore object that owns this object.
|
inline |
|
inline |
Return the ID of the default umpire::Allocator associated with this Group.
References axom::getDefaultAllocatorID().
|
inline |
Set the default umpire::Allocator associated with this Group.
References AXOM_UNUSED_VAR, axom::getDefaultAllocatorID(), and SLIC_ASSERT.
void axom::sidre::Group::getDataInfo | ( | Node & | n, |
bool | recursive = true |
||
) | const |
Insert information about data associated with Group subtree with this Group at root of tree (default 'recursive' is true), or for this Group only ('recursive' is false) 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,
Group* gp = ...;
Node n; gp->getDataInfo(n); axom::IndexType num_views = n["num_views"].value(); // etc...
bool axom::sidre::Group::hasView | ( | const std::string & | path | ) | const |
bool axom::sidre::Group::hasChildView | ( | const std::string & | name | ) | const |
bool axom::sidre::Group::hasView | ( | IndexType | idx | ) | const |
IndexType axom::sidre::Group::getViewIndex | ( | const std::string & | name | ) | const |
const std::string& axom::sidre::Group::getViewName | ( | IndexType | idx | ) | const |
View* axom::sidre::Group::getView | ( | const std::string & | path | ) |
const View* axom::sidre::Group::getView | ( | const std::string & | path | ) | const |
IndexType axom::sidre::Group::getFirstValidViewIndex | ( | ) | const |
Return first valid View index in Group object (i.e., smallest index over all Views).
sidre::InvalidIndex is returned if Group has no Views.
Return next valid View index in Group object after given index (i.e., smallest index over all View indices larger than given one).
sidre::InvalidIndex is returned if there is no valid index greater than given one.
View* axom::sidre::Group::createView | ( | const std::string & | path | ) |
Create an undescribed (i.e., empty) View object with given name or path in this Group.
If path is an empty string, an unnamed view can be created only if this Group was created to hold items in a list format. Otherwise an empty string will result in a nullptr being returned.
Create an undescribed View object with given name or path in this Group and attach given Buffer to it.
This method is equivalent to: group->createView(name)->attachBuffer(buff).
View* axom::sidre::Group::createView | ( | const std::string & | path, |
TypeID | type, | ||
IndexType | num_elems, | ||
Buffer * | buff | ||
) |
Create View object with given name or path in this Group that has a data description with data type and number of elements and attach given Buffer to it.
If given data type is undefined, or given number of elements is < 0, method is a no-op.
This method is equivalent to: group->createView(name, type, num_elems)->attachBuffer(buff), or group->createView(name)->attachBuffer(buff)->apply(type, num_elems).
View* axom::sidre::Group::createViewWithShape | ( | const std::string & | path, |
TypeID | type, | ||
int | ndims, | ||
const IndexType * | shape, | ||
Buffer * | buff | ||
) |
Create View object with given name or path in this Group that has a data description with data type and shape and attach given Buffer to it.
If given data type is undefined, or given number of dimensions is < 0, or given shape ptr is null, method is a no-op.
This method is equivalent to: group->createView(name, type, ndims, shape)->attachBuffer(buff), or group->createView(name)->attachBuffer(buff)->apply(type, ndims, shape).
View* axom::sidre::Group::createView | ( | const std::string & | path, |
const DataType & | dtype, | ||
Buffer * | buff | ||
) |
Create View object with given name or path in this Group that is described by a Conduit DataType object and attach given Buffer to it.
This method is equivalent to: group->createView(name, dtype)->attachBuffer(buff), or group->createView(name)->attachBuffer(buff)->apply(dtype).
View* axom::sidre::Group::createView | ( | const std::string & | path, |
void * | external_ptr | ||
) |
Create View object with given name with given name or path in this Group and attach external data ptr to it.
This method is equivalent to: group->createView(name)->setExternalDataPtr(external_ptr).
View* axom::sidre::Group::createView | ( | const std::string & | path, |
TypeID | type, | ||
IndexType | num_elems, | ||
void * | external_ptr | ||
) |
Create View object with given name or path in this Group that has a data description with data type and number of elements and attach externally-owned data to it.
If given data type is undefined, or given number of elements is < 0, method is a no-op.
This method is equivalent to: group->createView(name, type, num_elems)->setExternalDataPtr(external_ptr), or group->createView(name)->setExternalDataPtr(external_ptr)-> apply(type, num_elems).
View* axom::sidre::Group::createViewWithShape | ( | const std::string & | path, |
TypeID | type, | ||
int | ndims, | ||
const IndexType * | shape, | ||
void * | external_ptr | ||
) |
Create View object with given name or path in this Group that has a data description with data type and shape and attach externally-owned data to it.
If given data type is undefined, or given number of dimensions is < 0, or given shape ptr is null, method is a no-op.
This method is equivalent to: group->createView(name, type, ndims, shape)-> setExternalDataPtr(external_ptr), or group->createView(name)->setExternalDataPtr(external_ptr)-> apply(type, ndims, shape).
View* axom::sidre::Group::createView | ( | const std::string & | path, |
const DataType & | dtype, | ||
void * | external_ptr | ||
) |
Create View object with given name or path in this Group that is described by a Conduit DataType object and attach externally-owned data to it.
This method is equivalent to: group->createView(name, dtype)->setExternalDataPtr(external_ptr), or group->createView(name)->setExternalDataPtr(external_ptr)->apply(dtype).
View* axom::sidre::Group::createViewAndAllocate | ( | const std::string & | path, |
TypeID | type, | ||
IndexType | num_elems, | ||
int | allocID = INVALID_ALLOCATOR_ID |
||
) |
Create View object with given name or path in this Group that has a data description with data type and number of elements and allocate data for it.
If given data type is undefined, or given number of elements is < 0, method is a no-op.
This is equivalent to: createView(name)->allocate(type, num_elems), or createView(name, type, num_elems)->allocate()
View* axom::sidre::Group::createViewWithShapeAndAllocate | ( | const std::string & | path, |
TypeID | type, | ||
int | ndims, | ||
const IndexType * | shape, | ||
int | allocID = INVALID_ALLOCATOR_ID |
||
) |
Create View object with given name or path in this Group that has a data description with data type and shape and allocate data for it.
If given data type is undefined, or given number of dimensions is < 0, or given shape ptr is null, method is a no-op.
This method is equivalent to: group->createView(name)->allocate(type, ndims, shape), or createView(name, type, ndims, shape)->allocate().
View* axom::sidre::Group::createViewAndAllocate | ( | const std::string & | path, |
const DataType & | dtype, | ||
int | allocID = INVALID_ALLOCATOR_ID |
||
) |
Create View object with given name or path in this Group that is described by a Conduit DataType object and allocate data for it.
This method is equivalent to: group->createView(name)->allocate(dtype), or group->createView(name, dtype)->allocate().
If given data type object is empty, data will not be allocated.
|
inline |
Create View object with given name or path in this Group set its data to given scalar value.
This is equivalent to: createView(name)->setScalar(value);
If given data type object is empty, data will not be allocated.
References createView(), and axom::sidre::View::setScalar().
View* axom::sidre::Group::createViewString | ( | const std::string & | path, |
const std::string & | value | ||
) |
Create View object with given name or path in this Group set its data to given string.
This is equivalent to: createView(name)->setString(value);
If given data type object is empty, data will not be allocated.
void axom::sidre::Group::destroyView | ( | const std::string & | path | ) |
void axom::sidre::Group::destroyView | ( | IndexType | idx | ) |
void axom::sidre::Group::destroyViews | ( | ) |
Destroy all Views owned by this Group, but leave all their data intact.
void axom::sidre::Group::destroyViewAndData | ( | const std::string & | path | ) |
void axom::sidre::Group::destroyViewAndData | ( | IndexType | idx | ) |
void axom::sidre::Group::destroyViewsAndData | ( | ) |
Create a (shallow) copy of given View object and add it to this Group.
Note that View copying is a "shallow" copy; the data associated with the View is not copied. The new View object is associated with the same data as the original.
If given View pointer is null or Group already has a View with same name as given View, method is a no-op.
View* axom::sidre::Group::deepCopyView | ( | View * | view, |
int | allocID = INVALID_ALLOCATOR_ID |
||
) |
Create a deep copy of given View object and add it to this Group.
Note that for Views that use sidre Buffers or external data, the deep copy performs a copy of the data described by the View into a new Buffer attached to the destination View. If the source View describes only part of a Buffer or part of an external array, due to strides and or offsets into the data, only the values seen by the description will be copied into the new View. The new View will have a Buffer that is the exact size of the number of values that are copied, with an offset of zero and a stride of one.
If given View pointer is null or Group already has a View with same name as given View, method is a no-op.
bool axom::sidre::Group::hasGroup | ( | const std::string & | path | ) | const |
bool axom::sidre::Group::hasChildGroup | ( | const std::string & | name | ) | const |
bool axom::sidre::Group::hasGroup | ( | IndexType | idx | ) | const |
IndexType axom::sidre::Group::getGroupIndex | ( | const std::string & | name | ) | const |
Return the index of immediate child Group with given name.
If no such child Group exists, return sidre::InvalidIndex;
const std::string& axom::sidre::Group::getGroupName | ( | IndexType | idx | ) | const |
Return the name of immediate child Group with given index.
If no such child Group exists, return sidre::InvalidName.
Group* axom::sidre::Group::getGroup | ( | const std::string & | path | ) |
Group const* axom::sidre::Group::getGroup | ( | const std::string & | path | ) | const |
ViewCollection::iterator_adaptor axom::sidre::Group::views | ( | ) |
Returns an adaptor to support iterating the collection of views.
ViewCollection::const_iterator_adaptor axom::sidre::Group::views | ( | ) | const |
Returns a const adaptor to support iterating the collection of views.
GroupCollection::iterator_adaptor axom::sidre::Group::groups | ( | ) |
Returns an adaptor to support iterating the collection of groups.
GroupCollection::const_iterator_adaptor axom::sidre::Group::groups | ( | ) | const |
Returns a const adaptor to support iterating the collection of groups.
IndexType axom::sidre::Group::getFirstValidGroupIndex | ( | ) | const |
Return first valid child Group index (i.e., smallest index over all child Groups).
sidre::InvalidIndex is returned if Group has no child Groups.
Return next valid child Group index after given index (i.e., smallest index over all child Group indices larger than given one).
sidre::InvalidIndex is returned if there is no valid index greater than given one.
Group* axom::sidre::Group::createGroup | ( | const std::string & | path, |
bool | is_list = false |
||
) |
Group* axom::sidre::Group::createUnnamedGroup | ( | bool | is_list = false | ) |
void axom::sidre::Group::destroyGroup | ( | const std::string & | path | ) |
void axom::sidre::Group::destroyGroup | ( | IndexType | idx | ) |
void axom::sidre::Group::destroyGroupAndData | ( | const std::string & | path | ) |
Destroy child Group at the given path, and destroy data that is not shared elsewhere.
If a View in the subtree under the destroyed Group is the last View attached to a Buffer, the Buffer and its data will also be destroyed. Buffer data will not be destroyed if there are other Views associated with the Buffer.
If no Group exists at the given path, method is a no-op.
void axom::sidre::Group::destroyGroupAndData | ( | IndexType | idx | ) |
Destroy child Group with the given index, and destroy data that is not shared elsewhere.
If a View in the subtree under the destroyed Group is the last View attached to a Buffer, the Buffer and its data will also be destroyed. Buffer data will not be destroyed if there are other Views associated with the Buffer.
If no Group exists with the given index, method is a no-op.
void axom::sidre::Group::destroyGroupsAndData | ( | ) |
Destroy all child Groups held by this Group, and destroy data that is not shared elsewhere.
If a View in a subtree under any of the destroyed Groups is the last View attached to a Buffer, the Buffer and its data will also be destroyed. Buffer data will not be destroyed if there are other Views associated with the Buffer.
void axom::sidre::Group::destroyGroupSubtreeAndData | ( | ) |
Destroy the entire subtree of Groups and Views held by this Group, and destroy data that is not shared elsewhere.
If a View in the subtree being destroyed is the last View attached to a Buffer, the Buffer and its data will also be destroyed. Buffer data will not be destroyed if there are other Views associated with the Buffer.
void axom::sidre::Group::destroyGroups | ( | ) |
Create a (shallow) copy of Group hierarchy rooted at given Group and make it a child of this Group.
Note that all Views in the Group hierarchy are copied as well.
Note that Group copying is a "shallow" copy; the data associated with Views in a Group are not copied. In particular, the new Group hierarchy and all its Views is associated with the same data as the given Group.
If given Group pointer is null or Group already has a child Group with same name as given Group, method is a no-op.
Group* axom::sidre::Group::deepCopyGroup | ( | Group * | srcGroup, |
int | allocID = INVALID_ALLOCATOR_ID |
||
) |
Create a deep copy of Group hierarchy rooted at given Group and make the copy a child of this Group.
Note that all Views in the Group hierarchy are deep copied as well.
The deep copy of the Group creates a duplicate of the entire Group hierarchy and performs a deep copy of the data described by the Views in the hierarchy.
The Views in the new Group hierarchy will each allocate and use new Buffers to hold their copied data. Each Buffer will be sized to receive only the data values seen by the description of the original View and will have zero offset and a strid of one.
If given Group pointer is null or Group already has a child Group with same name as given Group, method is a no-op.
void axom::sidre::Group::print | ( | ) | const |
void axom::sidre::Group::print | ( | std::ostream & | os | ) | const |
void axom::sidre::Group::printTree | ( | const int | nlevels, |
std::ostream & | os | ||
) | const |
void axom::sidre::Group::copyToConduitNode | ( | Node & | n | ) | const |
Copy Group's 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.
Copy Group's layout to given Conduit node without data.
This method copies only a metadata version of the Group's hierarchical layout to a Conduit Node. All of the Groups and Views in the hierarchy will be represented, but the actual data held by the Views will not be present. For every View, the Conduit schema describing its datatype will be copied but not the data. This is intended to provide an object that can be sent to a readable output format where the overall layout of the hierarchy can be seen without sending large arrays or other data to the output.
Copy data Group external layout to given Conduit node.
The external 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.
Only the Views which have external data are added to the node.
bool axom::sidre::Group::isEquivalentTo | ( | const Group * | other, |
bool | checkName = true |
||
) | const |
Return true if this Group is equivalent to given Group; else false.
Two Groups are equivalent if they are the root Groups of identical Group hierarchy structures with the same names for all Views and Groups in the hierarchy, and the Views are also equivalent.
other | The group to compare with |
checkName | If true (default), groups must have the same name to be equivalent. If false, disregard the name. |
|
inline |
Return true if this Group holds items in map format.
|
inline |
Return true if this Group holds items in list format.
bool axom::sidre::Group::save | ( | const std::string & | path, |
const std::string & | protocol = Group::getDefaultIOProtocol() , |
||
const Attribute * | attr = nullptr |
||
) | const |
Save the Group to a file.
Saves the tree starting at this Group and the Buffers used by the Views in this tree. Returns true (success) if no Conduit I/O error occurred since this Group's DataStore was created or had its error flag cleared; false, if an error occurred at some point.
If attr is a null pointer, dump all Views. Otherwise, only dump Views which have the Attribute set.
path | file path |
protocol | I/O protocol |
attr | Save Views that have Attribute set. |
bool axom::sidre::Group::load | ( | const std::string & | path, |
const std::string & | protocol = Group::getDefaultIOProtocol() , |
||
bool | preserve_contents = false |
||
) |
Load a Group hierarchy from a file into this Group.
This method instantiates the Group hierarchy and its Views stored in the file under this Group. The name of this Group is not changed.
If preserve_contents is true, then the names of the children held by the Node cannot be the same as the names of the children already held by this Group. If there is a naming conflict, an error will occur. Returns true (success) if no Conduit I/O error occurred since this Group's DataStore was created or had its error flag cleared; false, if an error occurred at some point.
path | file path |
protocol | I/O protocol |
preserve_contents | If true, any child Groups and Views held by this Group remain in place. If false, all child Groups and Views are destroyed before loading data from the file. |
bool axom::sidre::Group::load | ( | const std::string & | path, |
const std::string & | protocol, | ||
bool | preserve_contents, | ||
std::string & | name_from_file | ||
) |
Load a Group hierarchy from a file into this Group, reporting the Group name stored in the file.
This method instantiates the Group hierarchy and its Views stored in the file under this Group. The name of this Group is not changed. The name of the group stored in the file is returned in the output parameter name_from_file. This can be used to rename the group in a subsequent call.
If preserve_contents is true, then the names of the children held by the Node cannot be the same as the names of the children already held by this Group. If there is a naming conflict, an error will occur. Returns true (success) if no Conduit I/O error occurred since this Group's DataStore was created or had its error flag cleared; false, if an error occurred at some point.
[in] | path | file path to load |
[in] | protocol | I/O protocol to use |
[in] | preserve_contents | If true, any child Groups and Views held by this Group remain in place. If false, all child Groups and Views are destroyed before loading data from the file. |
[out] | name_from_file | Group name stored in the file |
Group* axom::sidre::Group::createGroupAndLoad | ( | std::string & | group_name, |
const std::string & | path, | ||
const std::string & | protocol, | ||
bool & | load_success | ||
) |
Create a child Group and load a Group hierarchy from file into the new Group.
This is a convenience routine for the following sequence:
As with the createGroup() method, if group_name is empty or there already exists a child Group with that name or path, the child Group will not be created and this method will return nullptr.
As with the load() method, after calling createGroupAndLoad() a host code may choose to rename the newly-created Group with the string returned in group_name.
[in,out] | group_name | In: name for the new group. Out: the group name stored in the file. |
[in] | path | file path |
[in] | protocol | I/O protocol |
[out] | load_success | Report success of the load operation |
bool axom::sidre::Group::loadExternalData | ( | const std::string & | path | ) |
Load data into the Group's external views from a file.
No protocol argument is needed, as this only is used with the sidre_hdf5 protocol.
path | file path |
bool axom::sidre::Group::rename | ( | const std::string & | new_name | ) |
Change the name of this Group.
The name of this group is changed to the new name. If this group has a parent group, the name for this group held by the parent is also changed.
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.
It is possible to rename the root Group, but a code cannot subsequently rename root Group back to its original empty string name.
new_name | The new name for this group. |
bool axom::sidre::Group::importConduitTree | ( | const conduit::Node & | node, |
bool | preserve_contents = false |
||
) |
Import data from a conduit Node into a Group.
This imports the hierarchy from the Node into a Sidre Group with the same tree structure.
If preserve_contents is true, then the names of the children held by the Node cannot be the same as the names of the children already held by this Group. If there is a naming conflict, an error will occur.
node | A conduit Node containing hierarchical data. |
preserve_contents | If true, any child Groups and Views held by this Group remain in place. If false, all child Groups and Views are destroyed before importing data from the Node. |
bool axom::sidre::Group::importConduitTreeExternal | ( | conduit::Node & | node, |
bool | preserve_contents = false |
||
) |
Import data from a conduit Node into a Group without copying arrays.
This differs from the importConduitTree in that it does not copy any data held by the Node as an array. Instead it imports the existing pointer to the array as an external pointer.
This imports the hierarchy from the Node into a Sidre Group with the same tree structure.
If preserve_contents is true, then the names of the children held by the Node cannot be the same as the names of the children already held by this Group. If there is a naming conflict, an error will occur.
node | A conduit Node containing hierarchical data. |
preserve_contents | If true, any child Groups and Views held by this Group remain in place. If false, all child Groups and Views are destroyed before importing data from the Node. |
|
friend |
|
friend |