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 storeHelper (std::ostream &stream, UniqueStorage< T > &, void *)
 UniqueStorage helper routine.
 
template<typename T >
void loadHelper (std::istream &stream, UniqueStorage< T > &, void *)
 UniqueStorage helper routine.
 

Function Documentation

◆ loadHelper()

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

UniqueStorage helper routine.

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.

1160{
1161 std::size_t size;
1162 dataLoad(stream, size, nullptr);
1163 data.resize(size);
1164
1165 for (const auto i : index_range(data))
1166 loadHelper(stream, data.pointerValue(i), context);
1167}
void dataLoad(std::istream &stream, T &v, void *)
Definition DataIO.h:594
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition DataIO.h:1081
void resize(const std::size_t size)
Resizes the underlying vector.
auto index_range(const T &sizable)

◆ storeHelper()

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

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.

1067{
1068 std::size_t size = data.size();
1069 dataStore(stream, size, nullptr);
1070
1071 for (const auto i : index_range(data))
1072 {
1073 mooseAssert(data.hasValue(i), "Data doesn't have a value");
1074 storeHelper(stream, data.pointerValue(i), context);
1075 }
1076}
void dataStore(std::ostream &stream, T &v, void *)
Definition DataIO.h:197
void storeHelper(std::ostream &stream, P &data, void *context)
Scalar helper routine.
Definition DataIO.h:989
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.