Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://mooseframework.inl.gov 3 : //* 4 : //* All rights reserved, see COPYRIGHT for full restrictions 5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT 6 : //* 7 : //* Licensed under LGPL 2.1, please see LICENSE for details 8 : //* https://www.gnu.org/licenses/lgpl-2.1.html 9 : 10 : #include "RestartableData.h" 11 : 12 3506277 : RestartableDataValue::RestartableDataValue(const std::string & name, void * const context) 13 3506277 : : _name(name), _context(context), _declared(false), _loaded(false), _stored(false) 14 : { 15 3506277 : } 16 : 17 : void 18 2336360 : RestartableDataValue::setDeclared(const SetDeclaredKey) 19 : { 20 : mooseAssert(!_declared, "Already declared"); 21 2336360 : _declared = true; 22 2336360 : } 23 : 24 : void 25 1809707 : RestartableDataValue::store(std::ostream & stream) 26 : { 27 1809707 : storeInternal(stream); 28 1809703 : _stored = true; 29 1809703 : } 30 : 31 : void 32 526644 : RestartableDataValue::load(std::istream & stream) 33 : { 34 526644 : loadInternal(stream); 35 526617 : _loaded = true; 36 526617 : } 37 : 38 : void 39 362 : RestartableDataValue::store(nlohmann::json & json, const StoreJSONParams & params) const 40 : { 41 362 : if (params.value) 42 : { 43 332 : if (hasStoreJSON()) 44 331 : storeJSONValue(json["value"]); 45 : else 46 1 : mooseError("Failed to output restartable data '", 47 1 : name(), 48 : "' as JSON because a to_json method is not implemented for the type '", 49 3 : type(), 50 : "'"); 51 : } 52 361 : if (params.type) 53 355 : json["type"] = type(); 54 361 : if (params.name) 55 5 : json["name"] = name(); 56 361 : if (params.declared) 57 44 : json["declared"] = declared(); 58 361 : if (params.loaded) 59 43 : json["loaded"] = loaded(); 60 361 : if (params.stored) 61 42 : json["stored"] = stored(); 62 361 : if (params.has_context) 63 41 : json["has_context"] = hasContext(); 64 361 : }