https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Classes | Functions
UniqueStorage.h File Reference

Go to the source code of this file.

Classes

class  UniqueStorage< T >
 Storage container that stores a vector of unique pointers of T, but represents most of the public facing accessors (iterators, operator[]) as a vector of T. More...
 
struct  UniqueStorage< T >::DereferenceIterator< BaseIterator >
 Iterator that adds an additional dereference to BaseIterator. More...
 

Functions

template<typename T >
void dataStore (std::ostream &stream, UniqueStorage< T > &, void *)
 UniqueStorage helper routine.
 
template<typename T >
void dataLoad (std::istream &stream, UniqueStorage< T > &, void *)
 UniqueStorage Helper Function.
 

Function Documentation

◆ dataLoad()

template<typename T >
void dataLoad ( std::istream &  stream,
UniqueStorage< T > &  data,
void *  context 
)
inline

UniqueStorage Helper Function.

The unique_ptr<T> loader is called to load the data. That is, you will likely need a specialization of unique_ptr<T> that will appropriately construct and then fill the piece of data.

Definition at line 189 of file DataIO.h.

1183{
1184 std::size_t size;
1185 dataLoad(stream, size, nullptr);
1186 data.resize(size);
1187
1188 for (const auto i : index_range(data))
1189 dataLoad(stream, data.pointerValue(i), context);
1190}
void dataLoad(std::istream &, T &, void *)
Definition DataIO.h:627
void resize(const std::size_t size)
Resizes the underlying vector.
auto index_range(const T &sizable)

◆ dataStore()

template<typename T >
void dataStore ( std::ostream &  stream,
UniqueStorage< T > &  data,
void *  context 
)

UniqueStorage helper routine.

The data within the UniqueStorage object cannot be null. The helper for unique_ptr<T> is called to store the data.

Definition at line 188 of file DataIO.h.

612{
613 std::size_t size = data.size();
614 dataStore(stream, size, nullptr);
615
616 for (const auto i : index_range(data))
617 {
618 mooseAssert(data.hasValue(i), "Data doesn't have a value");
619 dataStore(stream, data.pointerValue(i), context);
620 }
621}
void dataStore(std::ostream &stream, T &v, void *)
Definition DataIO.h:81
std::size_t size() const
bool hasValue(const std::size_t i) const
const std::unique_ptr< T > & pointerValue(const std::size_t i) const
Returns a read-only reference to the underlying unique pointer at index i.