LCOV - code coverage report
Current view: top level - include/csg - CSGUniverseList.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #31782 (615931) with base 7edd10 Lines: 8 8 100.0 %
Date: 2025-11-11 23:21:15 Functions: 5 6 83.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://www.mooseframework.org
       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             : #include "CSGUniverse.h"
      13             : 
      14             : namespace CSG
      15             : {
      16             : 
      17             : /**
      18             :  * CSGUniverseList creates a container for CSGUniverse objects to pass to CSGBase
      19             :  */
      20             : class CSGUniverseList
      21             : {
      22             : protected:
      23             :   /**
      24             :    * Default constructor
      25             :    */
      26             :   CSGUniverseList();
      27             : 
      28             :   /**
      29             :    * Destructor
      30             :    */
      31         118 :   virtual ~CSGUniverseList() = default;
      32             : 
      33             :   /**
      34             :    * @brief create an empty universe
      35             :    *
      36             :    * @param name unique name of universe
      37             :    * @return reference to empty universe that is created
      38             :    */
      39             :   CSGUniverse & addUniverse(const std::string & name);
      40             : 
      41             :   /**
      42             :    * @brief return whether universe with given name exists in universe list
      43             :    *
      44             :    * @param name name of universe
      45             :    * @return true if universe name exists, false otherwise
      46             :    */
      47          37 :   bool hasUniverse(const std::string & name) const
      48             :   {
      49          37 :     return _universes.find(name) != _universes.end();
      50             :   }
      51             : 
      52             :   /**
      53             :    * @brief Get non-const map of all names to universes in universe list
      54             :    *
      55             :    * @return map of all names to CSGUniverse pointers
      56             :    */
      57          24 :   std::unordered_map<std::string, std::unique_ptr<CSGUniverse>> & getUniverseListMap()
      58             :   {
      59          24 :     return _universes;
      60             :   }
      61             : 
      62             :   /**
      63             :    * @brief Get const map of all names to universes in universe list
      64             :    *
      65             :    * @return map of all names to CSGUniverse pointers
      66             :    */
      67          11 :   const std::unordered_map<std::string, std::unique_ptr<CSGUniverse>> & getUniverseListMap() const
      68             :   {
      69          11 :     return _universes;
      70             :   }
      71             : 
      72             :   /**
      73             :    * @brief Get all the universes in CSGBase instance
      74             :    *
      75             :    * @return list of references to all CSGUniverse objects
      76             :    */
      77             :   std::vector<std::reference_wrapper<const CSGUniverse>> getAllUniverses() const;
      78             : 
      79             :   /**
      80             :    * @brief Get a Universe from the list by its name
      81             :    *
      82             :    * @param name name of universe
      83             :    * @return reference to CSGUniverse of the specified name
      84             :    */
      85             :   CSGUniverse & getUniverse(const std::string & name) const;
      86             : 
      87             :   /**
      88             :    * @brief Get the root universe
      89             :    *
      90             :    * @return reference to the root universe
      91             :    */
      92         222 :   const CSGUniverse & getRoot() const { return *_root_universe; };
      93             : 
      94             :   /**
      95             :    * @brief add an existing universe to list. Ownership of universe will be transferred to universe
      96             :    * list object that calls this function
      97             :    *
      98             :    * @param universe pointer to universe to add
      99             :    * @return reference to universe that is passed in
     100             :    */
     101             :   CSGUniverse & addUniverse(std::unique_ptr<CSGUniverse> universe);
     102             : 
     103             :   /**
     104             :    * @brief rename the specified universe
     105             :    *
     106             :    * @param universe reference to universe whose name should be renamed
     107             :    * @param name new name
     108             :    */
     109             :   void renameUniverse(const CSGUniverse & universe, const std::string & name);
     110             : 
     111             :   /// Operator overload for checking if two CSGUniverseList objects are equal
     112             :   bool operator==(const CSGUniverseList & other) const;
     113             : 
     114             :   /// Operator overload for checking if two CSGUniverseList objects are not equal
     115             :   bool operator!=(const CSGUniverseList & other) const;
     116             : 
     117             :   /// Mapping of universe names to pointers of stored universe objects
     118             :   std::unordered_map<std::string, std::unique_ptr<CSGUniverse>> _universes;
     119             : 
     120             :   /// root universe for the CSGBase instance
     121             :   const CSGUniverse * _root_universe;
     122             : 
     123             :   // Only CSGBase should be calling the methods in CSGUniverseList
     124             :   friend class CSGBase;
     125             : };
     126             : } // namespace CSG

Generated by: LCOV version 1.14