LCOV - code coverage report
Current view: top level - include/utils - ExecFlagEnum.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 6 6 100.0 %
Date: 2025-07-17 01:28:37 Functions: 5 5 100.0 %
Legend: Lines: hit not hit

          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             : #pragma once
      11             : 
      12             : // MOOSE includes
      13             : #include "MultiMooseEnum.h"
      14             : 
      15             : /**
      16             :  * A MultiMooseEnum object to hold "execute_on" flags.
      17             :  *
      18             :  * This object allows available flags to be added or removed thus each object can control the
      19             :  * flags that are available.
      20             :  */
      21             : class ExecFlagEnum : public MultiMooseEnum
      22             : {
      23             : public:
      24             :   ExecFlagEnum();
      25             :   ExecFlagEnum(const ExecFlagEnum & other);
      26             :   ExecFlagEnum(const MultiMooseEnum & other);
      27    43456677 :   ExecFlagEnum & operator=(const ExecFlagEnum & other) = default;
      28             : 
      29             :   ///@{
      30             :   /**
      31             :    * Add additional execute_on flags to the list of possible flags.
      32             :    *
      33             :    * Use a recursive variadic template function to allow for an arbitrary
      34             :    * number arguments:
      35             :    *     addAvaiableFlags(EXEC_INITIAL);
      36             :    *     addAvaiableFlags(EXEC_INITIAL, EXEC_TIMESTEP_END);
      37             :    */
      38             :   template <typename... Args>
      39             :   void addAvailableFlags(const ExecFlagType & flag, Args... flags);
      40             :   const ExecFlagType & addAvailableFlags(const ExecFlagType & flag);
      41             :   ///@}
      42             : 
      43             :   ///@{
      44             :   /**
      45             :    * Assignment operators for setting the current flags.
      46             :    */
      47             :   using MultiMooseEnum::operator=; // use parent methods
      48             :   ExecFlagEnum & operator=(const std::initializer_list<ExecFlagType> & flags);
      49             :   ExecFlagEnum & operator=(const ExecFlagType & flags);
      50             :   ExecFlagEnum & operator+=(const std::initializer_list<ExecFlagType> & flags);
      51             :   ExecFlagEnum & operator+=(const ExecFlagType & flags);
      52             :   ///@}
      53             : 
      54             :   ///@{
      55             :   /**
      56             :    * Remove flags from being available.
      57             :    */
      58             :   template <typename... Args>
      59             :   void removeAvailableFlags(const ExecFlagType & flag, Args... flags);
      60             :   void removeAvailableFlags(const ExecFlagType & flag);
      61             :   ///@}
      62             : 
      63             :   /**
      64             :    * Generate a documentation string for the "execute_on" parameter.
      65             :    */
      66             :   std::string getDocString() const;
      67             : 
      68             :   /**
      69             :    * Reference the all the available items.
      70             :    */
      71     2315520 :   const std::set<ExecFlagType> & items() const { return _items; }
      72             : 
      73             : protected:
      74             :   /**
      75             :    *  Append the list of current flags.
      76             :    */
      77             :   void appendCurrent(const ExecFlagType & item);
      78             : };
      79             : 
      80             : template <typename... Args>
      81             : void
      82             : ExecFlagEnum::addAvailableFlags(const ExecFlagType & flag, Args... flags)
      83             : {
      84             :   addAvailableFlags(flag);
      85             :   addAvailableFlags(flags...);
      86             : }
      87             : 
      88             : template <typename... Args>
      89             : void
      90       87726 : ExecFlagEnum::removeAvailableFlags(const ExecFlagType & flag, Args... flags)
      91             : {
      92       87726 :   removeAvailableFlags(flag);
      93       87726 :   removeAvailableFlags(flags...);
      94       87726 : }

Generated by: LCOV version 1.14