https://mooseframework.inl.gov
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...
 
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. More...
 
template<typename T >
void loadHelper (std::istream &stream, UniqueStorage< T > &, void *)
 UniqueStorage helper routine. More...
 

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 1063 of file DataIO.h.

1064 {
1065  std::size_t size;
1066  dataLoad(stream, size, nullptr);
1067  data.resize(size);
1068 
1069  for (const auto i : index_range(data))
1070  loadHelper(stream, data.pointerValue(i), context);
1071 }
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.
void resize(const std::size_t size)
Resizes the underlying vector.
void dataLoad(std::istream &stream, T &v, void *)
Definition: DataIO.h:540
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:985
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 970 of file DataIO.h.

971 {
972  std::size_t size = data.size();
973  dataStore(stream, size, nullptr);
974 
975  for (const auto i : index_range(data))
976  {
977  mooseAssert(data.hasValue(i), "Data doesn't have a value");
978  storeHelper(stream, data.pointerValue(i), context);
979  }
980 }
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.
std::size_t size() const
void storeHelper(std::ostream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:893
void dataStore(std::ostream &stream, T &v, void *)
Definition: DataIO.h:183
bool hasValue(const std::size_t i) const
auto index_range(const T &sizable)