1515#include " MooseError.h"
1616#include " MooseObjectName.h"
1717#include " MooseObjectParameterName.h"
18+ #include " MooseVerbosityHelper.h"
1819
1920class MooseApp ;
2021
@@ -46,7 +47,7 @@ class Node;
4647 * - MooseObject for an object created within a system
4748 * - Action for a class performing a setup task, like creating objects
4849 */
49- class MooseBase : public ConsoleStreamInterface
50+ class MooseBase : public ConsoleStreamInterface , public MooseVerbosityHelper
5051{
5152public:
5253 // / The name of the parameter that contains the object type
@@ -130,11 +131,6 @@ class MooseBase : public ConsoleStreamInterface
130131 */
131132 const InputParameters & parameters () const { return _pars; }
132133
133- /* *
134- * @returns The block-level hit node for this object, if any
135- */
136- const hit::Node * getHitNode () const { return getHitNode (_pars); }
137-
138134 /* *
139135 * @returns Whether or not this object has a registered base (set via
140136 * InputParameters::registerBase())
@@ -220,138 +216,6 @@ class MooseBase : public ConsoleStreamInterface
220216 const std::string & object_name,
221217 const std::string & object_parameter) const ;
222218
223- /* *
224- * Emits an error prefixed with the file and line number of the given param (from the input
225- * file) along with the full parameter path+name followed by the given args as the message.
226- * If this object's parameters were not created directly by the Parser, then this function falls
227- * back to the normal behavior of mooseError - only printing a message using the given args.
228- */
229- template <typename ... Args>
230- [[noreturn]] void paramError (const std::string & param, Args... args) const ;
231-
232- /* *
233- * Emits a warning prefixed with the file and line number of the given param (from the input
234- * file) along with the full parameter path+name followed by the given args as the message.
235- * If this object's parameters were not created directly by the Parser, then this function falls
236- * back to the normal behavior of mooseWarning - only printing a message using the given args.
237- */
238- template <typename ... Args>
239- void paramWarning (const std::string & param, Args... args) const ;
240-
241- /* *
242- * Emits an informational message prefixed with the file and line number of the given param
243- * (from the input file) along with the full parameter path+name followed by the given args as
244- * the message. If this object's parameters were not created directly by the Parser, then this
245- * function falls back to the normal behavior of mooseInfo - only printing a message using
246- * the given args.
247- */
248- template <typename ... Args>
249- void paramInfo (const std::string & param, Args... args) const ;
250-
251- /* *
252- * @returns A prefix to be used in messages that contain the input
253- * file location associated with this object (if any) and the
254- * name and type of the object.
255- */
256- std::string messagePrefix (const bool hit_prefix = true ) const
257- {
258- return messagePrefix (_pars, hit_prefix);
259- }
260-
261- /* *
262- * Deprecated message prefix; the error type is no longer used
263- */
264- std::string errorPrefix (const std::string &) const { return messagePrefix (); }
265-
266- /* *
267- * Emits an error prefixed with object name and type and optionally a file path
268- * to the top-level block parameter if available.
269- */
270- template <typename ... Args>
271- [[noreturn]] void mooseError (Args &&... args) const
272- {
273- callMooseError (argumentsToString (std::forward<Args>(args)...), /* with_prefix = */ true );
274- }
275-
276- template <typename ... Args>
277- [[noreturn]] void mooseDocumentedError (const std::string & repo_name,
278- const unsigned int issue_num,
279- Args &&... args) const
280- {
281- callMooseError (moose::internal::formatMooseDocumentedError (
282- repo_name, issue_num, argumentsToString (std::forward<Args>(args)...)),
283- /* with_prefix = */ true );
284- }
285-
286- /* *
287- * Emits an error without the prefixing included in mooseError().
288- */
289- template <typename ... Args>
290- [[noreturn]] void mooseErrorNonPrefixed (Args &&... args) const
291- {
292- callMooseError (argumentsToString (std::forward<Args>(args)...), /* with_prefix = */ false );
293- }
294-
295- /* *
296- * Emits a warning prefixed with object name and type.
297- */
298- template <typename ... Args>
299- void mooseWarning (Args &&... args) const
300- {
301- moose::internal::mooseWarningStream (_console, messagePrefix (true ), std::forward<Args>(args)...);
302- }
303-
304- /* *
305- * Emits a warning without the prefixing included in mooseWarning().
306- */
307- template <typename ... Args>
308- void mooseWarningNonPrefixed (Args &&... args) const
309- {
310- moose::internal::mooseWarningStream (_console, std::forward<Args>(args)...);
311- }
312-
313- template <typename ... Args>
314- void mooseDeprecated (Args &&... args) const
315- {
316- moose::internal::mooseDeprecatedStream (
317- _console, false , true , messagePrefix (true ), std::forward<Args>(args)...);
318- }
319-
320- template <typename ... Args>
321- void mooseInfo (Args &&... args) const
322- {
323- moose::internal::mooseInfoStream (_console, messagePrefix (true ), std::forward<Args>(args)...);
324- }
325-
326- /* *
327- * External method for calling moose error with added object context.
328- * @param msg The message
329- * @param with_prefix If true, add the prefix from messagePrefix(), which is the object
330- * information (type, name, etc)
331- * @param node Optional hit node to add file path context as a prefix
332- */
333- [[noreturn]] void
334- callMooseError (std::string msg, const bool with_prefix, const hit::Node * node = nullptr ) const ;
335-
336- /* *
337- * External method for calling moose error with added object context.
338- *
339- * Needed so that objects without the MooseBase context (InputParameters)
340- * can call errors with context
341- *
342- * @param app The app pointer (if available); adds multiapp context and clears the console
343- * @param params The parameters, needed to obtain object information
344- * @param msg The message
345- * @param with_prefix If true, add the prefix from messagePrefix(), which is the object
346- * information (type, name, etc)
347- * @param node Optional hit node to add file path context as a prefix
348- */
349- [[noreturn]] static void callMooseError (MooseApp * const app,
350- const InputParameters & params,
351- std::string msg,
352- const bool with_prefix,
353- const hit::Node * node);
354-
355219protected:
356220 // / The MOOSE application this is associated with
357221 MooseApp & _app;
@@ -364,23 +228,6 @@ class MooseBase : public ConsoleStreamInterface
364228
365229 // / The object's parameters
366230 const InputParameters & _pars;
367-
368- private:
369- /* *
370- * Internal method for getting the message prefix for an object (object type, name, etc).
371- *
372- * Needs to be static so that we can call it externally from InputParameters for
373- * errors that do not have context of the MooseBase
374- */
375- static std::string messagePrefix (const InputParameters & params, const bool hit_prefix);
376-
377- /* *
378- * Internal method for getting a hit node (if available) given a set of parameters
379- *
380- * Needs to be static so that we can call it externally from InputParameters for
381- * errors that do not have context of the MooseBase
382- */
383- static const hit::Node * getHitNode (const InputParameters & params);
384231};
385232
386233template <typename T>
@@ -434,23 +281,89 @@ MooseBase::getCheckedPointerParam(const std::string & name, const std::string &
434281 return _pars.getCheckedPointerParam <T>(name, error_string);
435282}
436283
284+ // These templates for routines in MooseVerbosityHelper need to be defined here because they require
285+ // the declaration of a MooseBase to be known at compile time.
286+ template <typename ... Args>
287+ void
288+ MooseVerbosityHelper::untrackedMooseWarning (Args &&... args) const
289+ {
290+ moose::internal::mooseWarningStream (
291+ _moose_base._console , messagePrefix (true ), std::forward<Args>(args)...);
292+ }
293+
294+ template <typename ... Args>
295+ void
296+ MooseVerbosityHelper::untrackedMooseWarningNonPrefixed (Args &&... args) const
297+ {
298+ moose::internal::mooseWarningStream (_moose_base._console , std::forward<Args>(args)...);
299+ }
300+
437301template <typename ... Args>
438302[[noreturn]] void
439- MooseBase::paramError (const std::string & param, Args... args) const
303+ MooseVerbosityHelper::paramError (const std::string & param, Args... args) const
304+ {
305+ _moose_base.parameters ().paramError (param, std::forward<Args>(args)...);
306+ }
307+
308+ template <typename ... Args>
309+ void
310+ MooseVerbosityHelper::untrackedParamWarning (const std::string & param, Args... args) const
311+ {
312+ mooseWarning (_moose_base.parameters ().paramMessage (param, std::forward<Args>(args)...));
313+ }
314+
315+ template <typename ... Args>
316+ void
317+ MooseVerbosityHelper::paramInfo (const std::string & param, Args... args) const
318+ {
319+ mooseInfo (_moose_base.parameters ().paramMessage (param, std::forward<Args>(args)...));
320+ }
321+
322+ template <typename ... Args>
323+ void
324+ MooseVerbosityHelper::untrackedMooseDeprecated (Args &&... args) const
325+ {
326+ moose::internal::mooseDeprecatedStream (
327+ _moose_base._console , false , true , messagePrefix (true ), std::forward<Args>(args)...);
328+ }
329+
330+ template <typename ... Args>
331+ void
332+ MooseVerbosityHelper::mooseWarning (Args &&... args) const
333+ {
334+ untrackedMooseWarning (std::forward<Args>(args)...);
335+ flagSolutionWarningMultipleRegistration (_moose_base.name () + " : warning" );
336+ }
337+
338+ template <typename ... Args>
339+ void
340+ MooseVerbosityHelper::mooseWarningNonPrefixed (Args &&... args) const
341+ {
342+ untrackedMooseWarningNonPrefixed (std::forward<Args>(args)...);
343+ flagSolutionWarningMultipleRegistration (_moose_base.name () + " : warning" );
344+ }
345+
346+ template <typename ... Args>
347+ void
348+ MooseVerbosityHelper::mooseDeprecated (Args &&... args) const
440349{
441- _pars.paramError (param, std::forward<Args>(args)...);
350+ untrackedMooseDeprecated (std::forward<Args>(args)...);
351+ flagSolutionWarningMultipleRegistration (_moose_base.name () + " : deprecation" );
442352}
443353
444354template <typename ... Args>
445355void
446- MooseBase::paramWarning ( const std::string & param, Args ... args) const
356+ MooseVerbosityHelper::mooseInfo (Args && ... args) const
447357{
448- mooseWarning (_pars.paramMessage (param, std::forward<Args>(args)...));
358+ moose::internal::mooseInfoStream (
359+ _moose_base._console , messagePrefix (true ), std::forward<Args>(args)...);
449360}
450361
451362template <typename ... Args>
452363void
453- MooseBase::paramInfo (const std::string & param, Args... args) const
364+ MooseVerbosityHelper::paramWarning (const std::string & param, Args... args) const
454365{
455- mooseInfo (_pars.paramMessage (param, std::forward<Args>(args)...));
366+ untrackedParamWarning (param, std::forward<Args>(args)...);
367+ flagSolutionWarningMultipleRegistration (_moose_base.name () + " : warning for parameter '" + param +
368+ " '" );
456369}
0 commit comments