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 4298324 : RestartableDataValue::RestartableDataValue(const std::string & name, void * const context) 13 4298324 : : _name(name), _context(context), _declared(false), _loaded(false), _stored(false) 14 : { 15 4298324 : } 16 : 17 : void 18 2608485 : RestartableDataValue::setDeclared(const SetDeclaredKey) 19 : { 20 : mooseAssert(!_declared, "Already declared"); 21 2608485 : _declared = true; 22 2608485 : } 23 : 24 : void 25 1998065 : RestartableDataValue::store(std::ostream & stream) 26 : { 27 1998065 : storeInternal(stream); 28 1998061 : _stored = true; 29 1998061 : } 30 : 31 : void 32 579697 : RestartableDataValue::load(std::istream & stream) 33 : { 34 579697 : loadInternal(stream); 35 579670 : _loaded = true; 36 579670 : } 37 : 38 : void 39 402 : RestartableDataValue::store(nlohmann::json & json, const StoreJSONParams & params) const 40 : { 41 402 : if (params.value) 42 : { 43 370 : if (hasStoreJSON()) 44 369 : 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 401 : if (params.type) 53 395 : json["type"] = type(); 54 401 : if (params.name) 55 5 : json["name"] = name(); 56 401 : if (params.declared) 57 48 : json["declared"] = declared(); 58 401 : if (params.loaded) 59 47 : json["loaded"] = loaded(); 60 401 : if (params.stored) 61 46 : json["stored"] = stored(); 62 401 : if (params.has_context) 63 45 : json["has_context"] = hasContext(); 64 401 : }