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 310 : 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 270 : bool hasUniverse(const std::string & name) const 48 : { 49 270 : 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 172 : std::unordered_map<std::string, std::unique_ptr<CSGUniverse>> & getUniverseListMap() 58 : { 59 172 : 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 36 : const std::unordered_map<std::string, std::unique_ptr<CSGUniverse>> & getUniverseListMap() const 68 : { 69 36 : 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 498 : 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 : * @param ignore_identical_universe skip adding universe if an identical universe exists in 100 : * universe list 101 : * @return reference to universe that is passed in 102 : */ 103 : CSGUniverse & addUniverse(std::unique_ptr<CSGUniverse> universe, 104 : const bool ignore_identical_universe = false); 105 : 106 : /** 107 : * @brief rename the specified universe 108 : * 109 : * @param universe reference to universe whose name should be renamed 110 : * @param name new name 111 : */ 112 : void renameUniverse(const CSGUniverse & universe, const std::string & name); 113 : 114 : /// Operator overload for checking if two CSGUniverseList objects are equal 115 : bool operator==(const CSGUniverseList & other) const; 116 : 117 : /// Operator overload for checking if two CSGUniverseList objects are not equal 118 : bool operator!=(const CSGUniverseList & other) const; 119 : 120 : /// Mapping of universe names to pointers of stored universe objects 121 : std::unordered_map<std::string, std::unique_ptr<CSGUniverse>> _universes; 122 : 123 : /// root universe for the CSGBase instance 124 : const CSGUniverse * _root_universe; 125 : 126 : // Only CSGBase should be calling the methods in CSGUniverseList 127 : friend class CSGBase; 128 : }; 129 : } // namespace CSG