https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
RestartableDataMap::Data Class Reference

Protected storage for restartable data. More...

#include <RestartableDataMap.h>

Inheritance diagram for RestartableDataMap::Data:
[legend]

Classes

class  WriteKey
 

Public Types

using values_type = typename std::vector< std::unique_ptr< RestartableDataValue > >
 
using iterator = DereferenceIterator< typename values_type::iterator >
 
using const_iterator = DereferenceIterator< typename values_type::const_iterator >
 

Public Member Functions

RestartableDataValueaddPointer (std::unique_ptr< RestartableDataValue > &&ptr, const WriteKey)
 
std::size_t size () const
 
bool empty () const
 
bool hasValue (const std::size_t i) const
 
iterator begin ()
 Begin and end iterators to the underlying data.
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
const RestartableDataValueoperator[] (const std::size_t i) const
 
RestartableDataValueoperator[] (const std::size_t i)
 
const RestartableDataValuequeryValue (const std::size_t i) const
 
RestartableDataValuequeryValue (const std::size_t i)
 

Protected Member Functions

void setPointer (const std::size_t i, std::unique_ptr< RestartableDataValue > &&ptr)
 Sets the underlying unique_ptr at index i to ptr.
 
RestartableDataValueaddPointer (std::unique_ptr< RestartableDataValue > &&ptr)
 Adds the given object in ptr to the storage.
 
void resize (const std::size_t size)
 Resizes the underlying vector.
 
void clear ()
 Clears the underlying vector.
 

Private Member Functions

const std::unique_ptr< RestartableDataValue > & pointerValue (const std::size_t i) const
 Returns a read-only reference to the underlying unique pointer at index i.
 
std::unique_ptr< RestartableDataValue > & pointerValue (const std::size_t i)
 Returns a reference to the underlying unique pointer at index i.
 

Private Attributes

values_type _values
 The underlying data.
 

Detailed Description

Protected storage for restartable data.

Definition at line 33 of file RestartableDataMap.h.

Member Typedef Documentation

◆ const_iterator

using UniqueStorage< RestartableDataValue >::const_iterator = DereferenceIterator<typename values_type::const_iterator>
inherited

Definition at line 72 of file UniqueStorage.h.

◆ iterator

using UniqueStorage< RestartableDataValue >::iterator = DereferenceIterator<typename values_type::iterator>
inherited

Definition at line 71 of file UniqueStorage.h.

◆ values_type

using UniqueStorage< RestartableDataValue >::values_type = typename std::vector<std::unique_ptr<RestartableDataValue > >
inherited

Definition at line 70 of file UniqueStorage.h.

Member Function Documentation

◆ addPointer() [1/2]

RestartableDataValue & UniqueStorage< RestartableDataValue >::addPointer ( std::unique_ptr< RestartableDataValue > &&  ptr)
inlineprotectedinherited

Adds the given object in ptr to the storage.

Definition at line 153 of file UniqueStorage.h.

154 {
155 mooseAssert(ptr, "Null object");
156 return *_values.emplace_back(std::move(ptr));
157 }
values_type _values
The underlying data.

◆ addPointer() [2/2]

RestartableDataValue & RestartableDataMap::Data::addPointer ( std::unique_ptr< RestartableDataValue > &&  ptr,
const WriteKey   
)
inline

Definition at line 43 of file RestartableDataMap.h.

44 {
46 }
T & addPointer(std::unique_ptr< T > &&ptr)
Adds the given object in ptr to the storage.

Referenced by RestartableDataMap::addData().

◆ begin() [1/2]

iterator UniqueStorage< RestartableDataValue >::begin ( )
inlineinherited

Begin and end iterators to the underlying data.

Note that dereferencing these iterators may lead to an assertion or the dereference of a nullptr whether or not the underlying data is initialized.

Definition at line 82 of file UniqueStorage.h.

82{ return iterator(_values.begin()); }
DereferenceIterator< typename values_type::iterator > iterator

◆ begin() [2/2]

const_iterator UniqueStorage< RestartableDataValue >::begin ( ) const
inlineinherited

Definition at line 84 of file UniqueStorage.h.

84{ return const_iterator(_values.begin()); }
DereferenceIterator< typename values_type::const_iterator > const_iterator

◆ clear()

void UniqueStorage< RestartableDataValue >::clear ( )
inlineprotectedinherited

Clears the underlying vector.

Definition at line 167 of file UniqueStorage.h.

167{ _values.clear(); }

◆ empty()

bool UniqueStorage< RestartableDataValue >::empty ( ) const
inlineinherited
Returns
Whether or not the underlying storage is empty.

Definition at line 116 of file UniqueStorage.h.

116{ return _values.empty(); }

◆ end() [1/2]

iterator UniqueStorage< RestartableDataValue >::end ( )
inlineinherited

Definition at line 83 of file UniqueStorage.h.

83{ return iterator(_values.end()); }

◆ end() [2/2]

const_iterator UniqueStorage< RestartableDataValue >::end ( ) const
inlineinherited

Definition at line 85 of file UniqueStorage.h.

85{ return const_iterator(_values.end()); }

◆ hasValue()

bool UniqueStorage< RestartableDataValue >::hasValue ( const std::size_t  i) const
inlineinherited
Returns
whether or not the underlying object at index is initialized

Definition at line 121 of file UniqueStorage.h.

121{ return pointerValue(i) != nullptr; }
const std::unique_ptr< RestartableDataValue > & pointerValue(const std::size_t i) const
Returns a read-only reference to the underlying unique pointer at index i.

◆ operator[]() [1/2]

RestartableDataValue & UniqueStorage< RestartableDataValue >::operator[] ( const std::size_t  i)
inlineinherited

Definition at line 103 of file UniqueStorage.h.

103{ return const_cast<T &>(std::as_const(*this)[i]); }

◆ operator[]() [2/2]

const RestartableDataValue & UniqueStorage< RestartableDataValue >::operator[] ( const std::size_t  i) const
inlineinherited
Returns
A reference to the underlying data at index i.

Note that the underlying data may not necessarily be initialized, in which case this will throw an assertion or dereference a nullptr.

You can check whether or not the underlying data is initialized with hasValue(i).

Definition at line 98 of file UniqueStorage.h.

99 {
100 mooseAssert(hasValue(i), "Null object");
101 return *pointerValue(i);
102 }
bool hasValue(const std::size_t i) const

◆ pointerValue() [1/2]

std::unique_ptr< RestartableDataValue > & UniqueStorage< RestartableDataValue >::pointerValue ( const std::size_t  i)
inlineprivateinherited

Returns a reference to the underlying unique pointer at index i.

Definition at line 183 of file UniqueStorage.h.

184 {
185 return const_cast<std::unique_ptr<T> &>(std::as_const(*this).pointerValue(i));
186 }

◆ pointerValue() [2/2]

const std::unique_ptr< RestartableDataValue > & UniqueStorage< RestartableDataValue >::pointerValue ( const std::size_t  i) const
inlineprivateinherited

Returns a read-only reference to the underlying unique pointer at index i.

Definition at line 174 of file UniqueStorage.h.

175 {
176 mooseAssert(size() > i, "Invalid size");
177 return _values[i];
178 }

◆ queryValue() [1/2]

RestartableDataValue * UniqueStorage< RestartableDataValue >::queryValue ( const std::size_t  i)
inlineinherited

Definition at line 131 of file UniqueStorage.h.

132 {
133 return const_cast<T *>(std::as_const(*this).queryValue(i));
134 }

◆ queryValue() [2/2]

const RestartableDataValue * UniqueStorage< RestartableDataValue >::queryValue ( const std::size_t  i) const
inlineinherited
Returns
A pointer to the underlying data at index i

The pointer will be nullptr if !hasValue(i), that is, if the unique_ptr at index i is not initialized

Definition at line 130 of file UniqueStorage.h.

130{ return pointerValue(i).get(); }

◆ resize()

void UniqueStorage< RestartableDataValue >::resize ( const std::size_t  size)
inlineprotectedinherited

Resizes the underlying vector.

Definition at line 162 of file UniqueStorage.h.

162{ _values.resize(size); }

◆ setPointer()

void UniqueStorage< RestartableDataValue >::setPointer ( const std::size_t  i,
std::unique_ptr< RestartableDataValue > &&  ptr 
)
inlineprotectedinherited

Sets the underlying unique_ptr at index i to ptr.

This can be used to construct objects in the storage, i.e., setPointer(0, std::make_unique<T>(...));

Definition at line 144 of file UniqueStorage.h.

145 {
146 mooseAssert(size() > i, "Invalid size");
147 _values[i] = std::move(ptr);
148 }

◆ size()

std::size_t UniqueStorage< RestartableDataValue >::size ( ) const
inlineinherited
Returns
The size of the underlying storage.

Note that this is not necessarily the size of constructed objects, as underlying objects could be uninitialized

Definition at line 112 of file UniqueStorage.h.

112{ return _values.size(); }

Member Data Documentation

◆ _values

values_type UniqueStorage< RestartableDataValue >::_values
privateinherited

The underlying data.

Definition at line 192 of file UniqueStorage.h.


The documentation for this class was generated from the following file: