AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
ItemCollection.hpp File Reference

Header file for ItemCollection. More...

#include "axom/config.hpp"
#include "axom/core/Types.hpp"
#include "axom/core/IteratorBase.hpp"
#include "SidreTypes.hpp"

Classes

class  axom::sidre::ItemCollection< T >
 ItemCollection is an abstract base class template for holding a collection of items of template parameter type T. Derived child classes can determine how to specifically store the items. More...
 
class  axom::sidre::ItemCollection< T >::iterator
 An std-compliant forward iterator for an ItemCollection. More...
 
class  axom::sidre::ItemCollection< T >::const_iterator
 An std-compliant forward iterator for a const ItemCollection. More...
 
class  axom::sidre::ItemCollection< T >::iterator_adaptor
 Utility class to wrap an ItemCollection in support of iteration. More...
 
class  axom::sidre::ItemCollection< T >::const_iterator_adaptor
 Utility class to wrap a const ItemCollection in support of iteration. More...
 

Namespaces

 axom
 
 axom::sidre
 

Detailed Description

Header file for ItemCollection.

     This is a templated abstract base class defining an interface for
     classes holding a collection of items of a fixed
     type that can be accessed by string name or sidre::IndexType.

     The primary intent is to decouple the implementation of the
     collections from the Group class which owns collections of
     View and child Group objects. They may have other uses,
     so they are not dependent on the Group class. This class is
     templated on the item type so that derived classes can be used
     to hold either View or Group object pointers without
     having to code a separate class for each.

     Derived implemenations of this class can be used to explore
     alternative collection implementations for performance
     (insertion, lookup, etc.) and memory overhead.

     \attention These classes should be robust against any potential
                user interaction. They don't report errors and leave
                checking of return values to calling code.

     \attention The interface defined by this class is as follows:

     \verbatim
  • - // Return number of items in collection.
  • size_t getNumItems() const;
  • - // Return first valid item index for iteration.
  • // sidre::InvalidIndex returned if no items in collection
  • IndexType getFirstValidIndex() const;
  • - // Return next valid item index for iteration.
  • // sidre::InvalidIndex returned if there are no more items
  • // to be iterated over.
  • IndexType getNextValidIndex(IndexType idx) const;
  • - // Return true if item with given name in collection; else false.
  • bool hasItem(const std::string& name) const;
  • - // Return true if item with given index in collection; else false.
  • bool hasItem(IndexType idx) const;
  • - // Return pointer to item with given name (nullptr if none).
  • T* getItem(const std::string& name);
  • T const* getItem(const std::string& name) const ;
  • - // Return pointer to item with given index (nullptr if none).
  • T* getItem(IndexType idx);
  • T const* getItem(IndexType idx) const;
  • - // Return name of object with given index
  • // (sidre::InvalidName if none).
  • std::string getItemName(IndexType idx) const;
  • - // Return index of object with given name
  • // (sidre::InvalidIndex if none).
  • IndexType getItemIndex(const std::string& name) const;
  • - // Insert item with given name; return index if insertion
  • // succeeded, and InvalidIndex otherwise.
  • IndexType insertItem(T* item, const std::string& name);
  • - // Remove item with given name if it exists and return a
  • // pointer to it. If it doesn't exist, return nullptr.
  • T* removeItem(const std::string& name);
  • - // Remove item with given index if it exists and return a
  • // pointer to it. If it doesn't exist, return nullptr.
  • T* removeItem(IndexType idx);
  • - // Remove all items (items not destroyed).
  • void removeAllItems();
  • - // Clear all items and destroy them.
  • void deleteAllItems();