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 "SolutionInvalidityRegistry.h" 11 : 12 : #include "DataIO.h" 13 : 14 : namespace moose::internal 15 : { 16 : 17 : SolutionInvalidityRegistry & 18 68047 : getSolutionInvalidityRegistry() 19 : { 20 : // In C++11 this is even thread safe! (Lookup "Static Initializers") 21 68047 : static SolutionInvalidityRegistry solution_invalid_registry_singleton; 22 : 23 68047 : return solution_invalid_registry_singleton; 24 : } 25 : 26 55057 : SolutionInvalidityRegistry::SolutionInvalidityRegistry() 27 : : GeneralRegistry<SolutionInvalidityName, SolutionInvalidityInfo, SoltionInvalidityNameHash>( 28 55057 : "SolutionInvalidityRegistry") 29 : { 30 55057 : } 31 : 32 : InvalidSolutionID 33 337 : SolutionInvalidityRegistry::registerInvalidity(const std::string & object_type, 34 : const std::string & message, 35 : const bool warning) 36 : { 37 337 : const SolutionInvalidityName name(object_type, message); 38 337 : if (keyExists(name)) 39 : mooseAssert(item(id(name)).warning == warning, "Inconsistent registration for a warning"); 40 323 : const auto create_item = [&object_type, &message, &warning](const std::size_t id) 41 323 : { return SolutionInvalidityInfo(object_type, message, id, warning); }; 42 674 : return registerItem(name, create_item); 43 337 : } 44 : 45 : std::ostream & 46 0 : operator<<(std::ostream & os, const SolutionInvalidityName & name) 47 : { 48 0 : os << name.object_type << ": " << name.message; 49 0 : return os; 50 : } 51 : }