19#include <unordered_set>
20#include <unordered_map>
22#include "nlohmann/json.h"
50 virtual std::string
type()
const = 0;
55 virtual const std::type_info &
typeId()
const = 0;
141 void store(std::ostream & stream);
145 void load(std::istream & stream);
219 static constexpr bool has_store_json = std::is_constructible_v<nlohmann::json, T>;
227 template <
typename... Params>
230 _value(
std::make_unique<T>(
std::forward<Params>(args)...))
252 virtual std::string
type() const override final;
254 virtual const
std::type_info &
typeId() const override final {
return typeid(T); }
282 mooseAssert(_value,
"Not valid");
290 mooseAssert(_value,
"Not valid");
298 mooseAssert(_value,
"Not valid");
306 return MooseUtils::prettyCppType<T>();
328 nlohmann::to_json(json, get());
330 mooseAssert(
false,
"Should not be called");
void storeHelper(std::ostream &stream, P &data, void *context)
Scalar helper routine.
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
std::unordered_set< std::string > DataNames
Base class for MOOSE-based applications.
Reader for restartable data written by the RestartableDataWriter.
Helper that protects access to setDeclared() to only MooseApp.
SetDeclaredKey(const SetDeclaredKey &)
Helper that protects access to setNotLoaded() to only RestartableDataReader.
SetNotLoadedKey(const SetNotLoadedKey &)
Helper that protects access to setNotStored() to only RestartableDataWriter.
SetNotStoredKey(const SetNotStoredKey &)
Abstract definition of a RestartableData value.
void store(std::ostream &stream)
Stores the value into the stream stream and sets it as stored.
virtual void loadInternal(std::istream &stream)=0
Internal method that loads the value from the stream stream in the specialized class.
const std::string _name
The full (unique) name of this particular piece of data.
bool stored() const
Whether or not this data has been loaded.
void setNotLoaded(const SetNotLoadedKey)
Sets that this restartable value has been loaded.
void * context()
A context pointer for helping with load / store.
virtual const std::type_info & typeId() const =0
The type ID of the underlying data.
virtual ~RestartableDataValue()=default
Destructor.
virtual void storeJSONValue(nlohmann::json &json) const =0
Internal method for storing the underlying JSON value.
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.
void setDeclared(const SetDeclaredKey)
Sets that this restartable value has been declared.
void load(std::istream &stream)
Loads the value from the stream stream and sets it as loaded.
virtual std::string type() const =0
String identifying the type of parameter stored.
virtual bool hasStoreJSON() const =0
void *const _context
A context pointer for helping with load and store.
bool _stored
Whether or not this has value has been stored.
bool _declared
Whether or not this data has been declared (true) or only retreived (false)
bool loaded() const
Whether or not this data has been loaded.
virtual void storeInternal(std::ostream &stream)=0
Internal method that stores the value into the stream stream in the specialized class.
void setNotStored(const SetNotStoredKey)
Sets that this restartable value has been loaded.
bool _loaded
Whether or not this has value has been loaded.
Writer for restartable data, to be read by the RestartableDataReader.
Concrete definition of a parameter value for a specified type.
virtual void loadInternal(std::istream &stream) override
Load the RestartableData from a binary stream.
static constexpr bool has_store_json
Whether or not this type has a JSON store method implemented.
std::unique_ptr< T > _value
Stored value.
virtual void storeJSONValue(nlohmann::json &json) const override final
Internal method for storing the underlying JSON value.
virtual bool hasStoreJSON() const override final
virtual void storeInternal(std::ostream &stream) override
Store the RestartableData into a binary stream.
RestartableData(const std::string &name, void *const context, Params &&... args)
Constructor.
void reset()
Resets (destructs) the underlying data.
virtual const std::type_info & typeId() const override final
The type ID of the underlying data.
virtual std::string type() const override final
String identifying the type of parameter stored.
Struct that represents parameters for how to store the JSON value via store.