https://mooseframework.inl.gov
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
RestartableDataValue Class Referenceabstract

Abstract definition of a RestartableData value. More...

#include <RestartableData.h>

Inheritance diagram for RestartableDataValue:
[legend]

Classes

class  SetDeclaredKey
 Helper that protects access to setDeclared() to only MooseApp. More...
 
class  SetNotLoadedKey
 Helper that protects access to setNotLoaded() to only RestartableDataReader. More...
 
class  SetNotStoredKey
 Helper that protects access to setNotStored() to only RestartableDataWriter. More...
 
struct  StoreJSONParams
 Struct that represents parameters for how to store the JSON value via store. More...
 

Public Member Functions

 RestartableDataValue (const std::string &name, void *const context)
 Constructor. More...
 
virtual ~RestartableDataValue ()=default
 Destructor. More...
 
virtual std::string type () const =0
 String identifying the type of parameter stored. More...
 
virtual const std::type_info & typeId () const =0
 The type ID of the underlying data. More...
 
const std::string & name () const
 The full (unique) name of this particular piece of data. More...
 
voidcontext ()
 A context pointer for helping with load / store. More...
 
bool hasContext () const
 
bool declared () const
 Whether or not this data has been declared. More...
 
void setDeclared (const SetDeclaredKey)
 Sets that this restartable value has been declared. More...
 
bool loaded () const
 Whether or not this data has been loaded. More...
 
void setNotLoaded (const SetNotLoadedKey)
 Sets that this restartable value has been loaded. More...
 
bool stored () const
 Whether or not this data has been loaded. More...
 
void setNotStored (const SetNotStoredKey)
 Sets that this restartable value has been loaded. More...
 
void store (std::ostream &stream)
 Stores the value into the stream stream and sets it as stored. More...
 
void load (std::istream &stream)
 Loads the value from the stream stream and sets it as loaded. More...
 
virtual void storeInternal (std::ostream &stream)=0
 Internal method that stores the value into the stream stream in the specialized class. More...
 
virtual void loadInternal (std::istream &stream)=0
 Internal method that loads the value from the stream stream in the specialized class. More...
 
virtual bool hasStoreJSON () const =0
 
void store (nlohmann::json &json, const StoreJSONParams &params=StoreJSONParams{}) const
 Stores this restartable data in the JSON entry json, with the options set by params (optional; defaults to just the type and underlying value) More...
 

Protected Member Functions

virtual void storeJSONValue (nlohmann::json &json) const =0
 Internal method for storing the underlying JSON value. More...
 

Protected Attributes

const std::string _name
 The full (unique) name of this particular piece of data. More...
 
void *const _context
 A context pointer for helping with load and store. More...
 

Private Attributes

bool _declared
 Whether or not this data has been declared (true) or only retreived (false) More...
 
bool _loaded
 Whether or not this has value has been loaded. More...
 
bool _stored
 Whether or not this has value has been stored. More...
 

Detailed Description

Abstract definition of a RestartableData value.

Definition at line 31 of file RestartableData.h.

Constructor & Destructor Documentation

◆ RestartableDataValue()

RestartableDataValue::RestartableDataValue ( const std::string &  name,
void *const  context 
)

Constructor.

Parameters
nameThe full (unique) name for this piece of data.
context'typeless' pointer to user-specific data.

Definition at line 12 of file RestartableData.C.

13  : _name(name), _context(context), _declared(false), _loaded(false), _stored(false)
14 {
15 }
void *const _context
A context pointer for helping with load and store.
bool _loaded
Whether or not this has value has been loaded.
bool _stored
Whether or not this has value has been stored.
void * context()
A context pointer for helping with load / store.
bool _declared
Whether or not this data has been declared (true) or only retreived (false)
const std::string _name
The full (unique) name of this particular piece of data.
const std::string & name() const
The full (unique) name of this particular piece of data.

◆ ~RestartableDataValue()

virtual RestartableDataValue::~RestartableDataValue ( )
virtualdefault

Destructor.

Member Function Documentation

◆ context()

void* RestartableDataValue::context ( )
inline

A context pointer for helping with load / store.

Definition at line 65 of file RestartableData.h.

65 { return _context; }
void *const _context
A context pointer for helping with load and store.

◆ declared()

bool RestartableDataValue::declared ( ) const
inline

Whether or not this data has been declared.

Definition at line 85 of file RestartableData.h.

Referenced by store().

85 { return _declared; }
bool _declared
Whether or not this data has been declared (true) or only retreived (false)

◆ hasContext()

bool RestartableDataValue::hasContext ( ) const
inline
Returns
Whether or not the data has context set.

Definition at line 70 of file RestartableData.h.

Referenced by store().

70 { return _context != nullptr; }
void *const _context
A context pointer for helping with load and store.

◆ hasStoreJSON()

virtual bool RestartableDataValue::hasStoreJSON ( ) const
pure virtual
Returns
Whether or not this value supports storing JSON via store

Implemented in RestartableData< T >, RestartableData< RestartableEquationSystems >, RestartableData< std::list< std::vector< T > > >, and RestartableData< std::list< T > >.

Referenced by store().

◆ load()

void RestartableDataValue::load ( std::istream &  stream)

Loads the value from the stream stream and sets it as loaded.

Definition at line 32 of file RestartableData.C.

33 {
34  loadInternal(stream);
35  _loaded = true;
36 }
bool _loaded
Whether or not this has value has been loaded.
virtual void loadInternal(std::istream &stream)=0
Internal method that loads the value from the stream stream in the specialized class.

◆ loaded()

bool RestartableDataValue::loaded ( ) const
inline

Whether or not this data has been loaded.

This is typically reset on a call to RestartableDataReader::restore()

Definition at line 98 of file RestartableData.h.

Referenced by store().

98 { return _loaded; }
bool _loaded
Whether or not this has value has been loaded.

◆ loadInternal()

virtual void RestartableDataValue::loadInternal ( std::istream &  stream)
pure virtual

◆ name()

const std::string& RestartableDataValue::name ( ) const
inline

The full (unique) name of this particular piece of data.

Definition at line 60 of file RestartableData.h.

Referenced by RestartableDataMap::addData(), RestartableDataMap::findData(), and store().

60 { return _name; }
const std::string _name
The full (unique) name of this particular piece of data.

◆ setDeclared()

void RestartableDataValue::setDeclared ( const SetDeclaredKey  )

Sets that this restartable value has been declared.

Definition at line 18 of file RestartableData.C.

Referenced by MooseApp::registerRestartableData().

19 {
20  mooseAssert(!_declared, "Already declared");
21  _declared = true;
22 }
bool _declared
Whether or not this data has been declared (true) or only retreived (false)

◆ setNotLoaded()

void RestartableDataValue::setNotLoaded ( const SetNotLoadedKey  )
inline

Sets that this restartable value has been loaded.

Definition at line 113 of file RestartableData.h.

113 { _loaded = false; }
bool _loaded
Whether or not this has value has been loaded.

◆ setNotStored()

void RestartableDataValue::setNotStored ( const SetNotStoredKey  )
inline

Sets that this restartable value has been loaded.

Definition at line 136 of file RestartableData.h.

136 { _stored = false; }
bool _stored
Whether or not this has value has been stored.

◆ store() [1/2]

void RestartableDataValue::store ( std::ostream &  stream)

Stores the value into the stream stream and sets it as stored.

Definition at line 25 of file RestartableData.C.

26 {
27  storeInternal(stream);
28  _stored = true;
29 }
virtual void storeInternal(std::ostream &stream)=0
Internal method that stores the value into the stream stream in the specialized class.
bool _stored
Whether or not this has value has been stored.

◆ store() [2/2]

void RestartableDataValue::store ( nlohmann::json &  json,
const StoreJSONParams params = StoreJSONParams{} 
) const

Stores this restartable data in the JSON entry json, with the options set by params (optional; defaults to just the type and underlying value)

If the underlying type is not supported for JSON output (if hasStoreJSON() == false), and the parameters have the value output as enabled, this will error.

Definition at line 39 of file RestartableData.C.

40 {
41  if (params.value)
42  {
43  if (hasStoreJSON())
44  storeJSONValue(json["value"]);
45  else
46  mooseError("Failed to output restartable data '",
47  name(),
48  "' as JSON because a to_json method is not implemented for the type '",
49  type(),
50  "'");
51  }
52  if (params.type)
53  json["type"] = type();
54  if (params.name)
55  json["name"] = name();
56  if (params.declared)
57  json["declared"] = declared();
58  if (params.loaded)
59  json["loaded"] = loaded();
60  if (params.stored)
61  json["stored"] = stored();
62  if (params.has_context)
63  json["has_context"] = hasContext();
64 }
bool stored() const
Whether or not this data has been loaded.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302
virtual bool hasStoreJSON() const =0
bool hasContext() const
virtual void storeJSONValue(nlohmann::json &json) const =0
Internal method for storing the underlying JSON value.
virtual std::string type() const =0
String identifying the type of parameter stored.
bool loaded() const
Whether or not this data has been loaded.
bool declared() const
Whether or not this data has been declared.
const std::string & name() const
The full (unique) name of this particular piece of data.

◆ stored()

bool RestartableDataValue::stored ( ) const
inline

Whether or not this data has been loaded.

This is typically reset on a call to RestartableDataWriter::write()

Definition at line 121 of file RestartableData.h.

Referenced by store().

121 { return _stored; }
bool _stored
Whether or not this has value has been stored.

◆ storeInternal()

virtual void RestartableDataValue::storeInternal ( std::ostream &  stream)
pure virtual

◆ storeJSONValue()

virtual void RestartableDataValue::storeJSONValue ( nlohmann::json &  json) const
protectedpure virtual

◆ type()

virtual std::string RestartableDataValue::type ( ) const
pure virtual

◆ typeId()

virtual const std::type_info& RestartableDataValue::typeId ( ) const
pure virtual

Member Data Documentation

◆ _context

void* const RestartableDataValue::_context
protected

A context pointer for helping with load and store.

Definition at line 197 of file RestartableData.h.

Referenced by context(), and hasContext().

◆ _declared

bool RestartableDataValue::_declared
private

Whether or not this data has been declared (true) or only retreived (false)

Definition at line 201 of file RestartableData.h.

Referenced by declared(), and setDeclared().

◆ _loaded

bool RestartableDataValue::_loaded
private

Whether or not this has value has been loaded.

Definition at line 204 of file RestartableData.h.

Referenced by load(), loaded(), and setNotLoaded().

◆ _name

const std::string RestartableDataValue::_name
protected

The full (unique) name of this particular piece of data.

Definition at line 194 of file RestartableData.h.

Referenced by name().

◆ _stored

bool RestartableDataValue::_stored
private

Whether or not this has value has been stored.

Definition at line 207 of file RestartableData.h.

Referenced by setNotStored(), store(), and stored().


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