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 4540483 : RestartableDataValue::RestartableDataValue(const std::string & name, void * const context) 13 4540483 : : _name(name), _context(context), _declared(false), _loaded(false), _stored(false) 14 : { 15 4540483 : } 16 : 17 : void 18 2825522 : RestartableDataValue::setDeclared(const SetDeclaredKey) 19 : { 20 : mooseAssert(!_declared, "Already declared"); 21 2825522 : _declared = true; 22 2825522 : } 23 : 24 : void 25 2123063 : RestartableDataValue::store(std::ostream & stream) 26 : { 27 2123063 : storeInternal(stream); 28 2123059 : _stored = true; 29 2123059 : } 30 : 31 : void 32 622508 : RestartableDataValue::load(std::istream & stream) 33 : { 34 622508 : loadInternal(stream); 35 622475 : _loaded = true; 36 622475 : } 37 : 38 : void 39 436 : RestartableDataValue::store(nlohmann::json & json, const StoreJSONParams & params) const 40 : { 41 436 : if (params.value) 42 : { 43 396 : if (hasStoreJSON()) 44 394 : storeJSONValue(json["value"]); 45 : else 46 2 : mooseError("Failed to output restartable data '", 47 2 : name(), 48 : "' as JSON because a to_json method is not implemented for the type '", 49 6 : type(), 50 : "'"); 51 : } 52 434 : if (params.type) 53 422 : json["type"] = type(); 54 434 : if (params.name) 55 10 : json["name"] = name(); 56 434 : if (params.declared) 57 52 : json["declared"] = declared(); 58 434 : if (params.loaded) 59 50 : json["loaded"] = loaded(); 60 434 : if (params.stored) 61 48 : json["stored"] = stored(); 62 434 : if (params.has_context) 63 46 : json["has_context"] = hasContext(); 64 434 : }