Quinoa all test code coverage report
Current view: top level - Inciter/AMR - active_element_store.hpp (source / functions) Hit Total Coverage
Commit: -128-NOTFOUND Lines: 2 2 100.0 %
Date: 2024-04-22 13:03:21 Functions: 0 0 -
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 11 14 78.6 %

           Branch data     Line data    Source code
       1                 :            : #ifndef AMR_active_element_store_h
       2                 :            : #define AMR_active_element_store_h
       3                 :            : 
       4                 :            : #include <set>
       5                 :            : #include <cassert>
       6                 :            : 
       7                 :            : namespace AMR {
       8                 :            : 
       9                 :            :     class active_element_store_t {
      10                 :            :         private:
      11                 :            :             std::set<size_t> active_elements;
      12                 :            :         public:
      13                 :            : 
      14                 :            :             //! Non-const-ref access to state
      15                 :      24365 :             std::set<size_t>& data() { return active_elements; }
      16                 :            : 
      17                 :            :             /**
      18                 :            :              * @brief Function to add active elements
      19                 :            :              *
      20                 :            :              * @param id The master_id this should map to
      21                 :            :              */
      22                 :            :             void add(size_t id)
      23                 :            :             {
      24                 :            :                 // Check if that active element already exists
      25                 :            :                 // cppcheck-suppress assertWithSideEffect
      26                 :            :                 assert( !exists(id) );
      27                 :            :                 active_elements.insert(id);
      28                 :            :             }
      29                 :            : 
      30                 :            :             void erase(size_t id)
      31                 :            :             {
      32                 :            :                 active_elements.erase(id);
      33                 :            :             }
      34                 :            : 
      35                 :            :             /**
      36                 :            :              * @brief function to check if an active element exists in the
      37                 :            :              * active_elements store
      38                 :            :              *
      39                 :            :              * @param id The id of the element to check
      40                 :            :              *
      41                 :            :              * @return A bool for if the element was found or no
      42                 :            :              */
      43                 :            :             bool exists(size_t id) const
      44                 :            :             {
      45 [ +  + ][ +  + ]:    5418676 :                 if (active_elements.find(id) != active_elements.end())
         [ +  + ][ +  + ]
         [ +  + ][ -  - ]
                 [ +  - ]
      46                 :            :                 {
      47                 :            :                     return true;
      48                 :            :                 }
      49                 :            :                 return false;
      50                 :            :             }
      51                 :            : 
      52                 :            :             void replace(size_t old_id, size_t new_id)
      53                 :            :             {
      54                 :            :                 erase(old_id);
      55                 :            :                 add(new_id);
      56                 :            :             }
      57                 :            :     };
      58                 :            : }
      59                 :            : 
      60                 :            : #endif // guard

Generated by: LCOV version 1.14