43#ifndef TEUCHOS_STRING_INDEXED_ORDERED_VALUE_OBJECT_CONTAINER_HPP
44#define TEUCHOS_STRING_INDEXED_ORDERED_VALUE_OBJECT_CONTAINER_HPP
105 template<
class ObjType>
117 template <
typename U,
typename = std::enable_if_t<std::is_convertible_v<U, ObjType>>>
118 KeyObjectPair(
const std::string &key_in, U&& obj_in,
bool isActive_in =
true)
144 template<
class ObjType>
183template<
class ObjType>
239 template <
typename U,
typename = std::enable_if_t<std::is_convertible_v<U, ObjType>>>
355template<
class ObjType>
364template<
class ObjType>
373template<
class ObjType>
382template<
class ObjType>
394template<
class ObjType>
404template<
class ObjType>
414template<
class ObjType>
424template<
class ObjType>
442template<
class ObjType>
447template<
class ObjType>
455template<
class ObjType>
466template<
class ObjType>
473 return itr->second.idx;
479template <
typename ObjType>
480template <
typename U,
typename>
485 typename key_to_idx_map_t::iterator obj_idx_itr =
key_to_idx_map_.find(key);
488 const Ordinal obj_idx = obj_idx_itr->second.idx;
500template<
class ObjType>
509template<
class ObjType>
516 const Ordinal idx = itr->second.idx;
525template<
class ObjType>
530 "Error, the ordinal index " << idx <<
" is invalid"
531 <<
" because it falls outside of the range of valid objects"
536template<
class ObjType>
544 "Error, the ordinal index " << idx <<
" is invalid"
545 <<
" because the object has been deleted!");
550template<
class ObjType>
558 "Error, the ordinal index " << idx <<
" is invalid"
559 <<
" because the object has been deleted!");
564template<
class ObjType>
567 const Ordinal idx,
const std::string &key)
const
570 "Error, the key '" << key <<
"' does not exist!");
574template<
class ObjType>
Templated array class derived from the STL std::vector.
TEUCHOS_ORDINAL_TYPE Teuchos_Ordinal
ExceptionBase(const std::string &what_arg)
C++ Standard Library compatable filtered iterator.
Simple wrapper class for raw pointers to single objects where no persisting relationship exists.
Ptr< T > ptrFromRef(T &arg)
Create a pointer to a object from an object reference.
Thrown if an invalid string is passed in.
InvalidKeyError(const std::string &what_arg)
Thrown if an invalid ordinal index is passed in.
InvalidOrdinalIndexError(const std::string &what_arg)
A simple aggregate type to bind a key string and and objects value.
KeyObjectPair(const KeyObjectPair &kop)
Copy-constructor.
const std::string & first
KeyObjectPair & operator=(const KeyObjectPair &kop)
Copy-assignment operator.
KeyObjectPair(KeyObjectPair &&kop)
Move-constructor.
KeyObjectPair(const std::string &key_in, U &&obj_in, bool isActive_in=true)
static KeyObjectPair< ObjType > makeInvalid()
StringIndexedOrderedValueObjectContainerBase::Ordinal Ordinal
OrdinalIndex(const Ordinal idx_in)
Predicate for selecting active object entries in filtered iterator.
bool operator()(const KeyObjectPair< ObjType > &key_and_obj) const
Base types for StringIndexedOrderedValueObjectContainer.
virtual ~StringIndexedOrderedValueObjectContainerBase()
Destructor.
static Ordinal getInvalidOrdinal()
Return the value for invalid ordinal.
Teuchos_Ordinal Ordinal
Ordinal used for the index.
ConstIterator end() const
Ptr< const ObjType > getObjPtr(const std::string &key) const
Get a const semi-persisting association with the stored object indexed by string key.
Ordinal setObj(const std::string &key, U &&obj)
Set (or reset) object by value and return its ordinal index.
Ordinal getObjOrdinalIndex(const std::string &key) const
Get the ordinal index given the string key.
FilteredIterator< typename key_and_obj_array_t::const_iterator, SelectActive< ObjType > > ConstIterator
The const iterator type.
Ordinal assertKeyGetOrdinal(const std::string &key) const
Ordinal numObjects() const
key_and_obj_array_t key_and_obj_array_
FilteredIterator< typename key_and_obj_array_t::iterator, SelectActive< ObjType > > Iterator
The non-const iterator type.
std::deque< key_and_obj_t > key_and_obj_array_t
void removeObj(const Ordinal &idx)
Remove an object given its ordinal index.
key_to_idx_map_t key_to_idx_map_
Ordinal numStorage() const
std::map< std::string, OrdinalIndex > key_to_idx_map_t
Ptr< ObjType > getNonconstObjPtr(const std::string &key)
Get a nonconst semi-persisting association with the stored object indexed by string key.
ConstIterator begin() const
void throwInvalidKeyError(const Ordinal idx, const std::string &key) const
key_and_obj_t & getNonconstKeyAndObject(const Ordinal idx)
Ptr< ObjType > getNonconstObjPtr(const Ordinal &idx)
Get a nonconst semi-persisting association with the stored object indexed by ordinal.
void assertOrdinalIndex(const Ordinal idx) const
KeyObjectPair< ObjType > key_and_obj_t
StringIndexedOrderedValueObjectContainerBase::Ordinal Ordinal
Ordinal used for the index.
Ptr< const ObjType > getObjPtr(const Ordinal &idx) const
Get a const semi-persisting association with the stored object indexed by ordinal.
void removeObj(const std::string &key)
Remove an object given its string key.
const key_and_obj_t & getKeyAndObject(const Ordinal idx) const
StringIndexedOrderedValueObjectContainer()
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.