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

Header file for MapCollection. More...

#include <map>
#include <stack>
#include <string>
#include <vector>
#include "axom/config.hpp"
#include "axom/core/Types.hpp"
#include "axom/core/utilities/StringUtilities.hpp"
#include "ItemCollection.hpp"
#include <unordered_map>

Classes

class  axom::MapCollection< T >
 MapCollection is a container class template for holding a collection of items of template parameter type T. More...
 

Namespaces

 axom
 

Detailed Description

Header file for MapCollection.

     MapCollection is an implemenation of ItemCollection to
     hold a collection of items of a fixed type that can be accessed
     accessed by string name or axom::IndexType.

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

     \attention This class should be robust against any potential
                user interaction. It doesn't report errors and leaves
                checking of return values to calling code.

     \attention Template parameter type must provide a method
                "getName()" that returns a reference to a string object.

     \attention The interface is as follows:

     \verbatim
  • - // Return number of items in collection.
  • size_t getNumItems() const;
  • - // Return first valid item index (i.e., smallest index over
  • // all items).
  • // axom::InvalidIndex returned if no items in collection
  • IndexType getFirstValidIndex() const;
  • - // Return next valid item index after given index (i.e., smallest
  • // index over all indices larger than given one).
  • // axom::InvalidIndex returned
  • 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
  • // (axom::utilities::string::InvalidName if none).
  • const std::string& getItemName(IndexType idx) const;
  • - // Return index of object with given name
  • // (axom::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();