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