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 87 : 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 Get map of all names to universes in universe list 43 : * 44 : * @return map of all names to CSGUniverse pointers 45 : */ 46 6 : std::unordered_map<std::string, std::unique_ptr<CSGUniverse>> & getUniverseListMap() 47 : { 48 6 : return _universes; 49 : } 50 : 51 : /** 52 : * @brief Get all the universes in CSGBase instance 53 : * 54 : * @return list of references to all CSGUniverse objects 55 : */ 56 : std::vector<std::reference_wrapper<const CSGUniverse>> getAllUniverses() const; 57 : 58 : /** 59 : * @brief Get a Universe from the list by its name 60 : * 61 : * @param name name of universe 62 : * @return reference to CSGUniverse of the specified name 63 : */ 64 : CSGUniverse & getUniverse(const std::string & name) const; 65 : 66 : /** 67 : * @brief Get the root universe 68 : * 69 : * @return reference to the root universe 70 : */ 71 140 : const CSGUniverse & getRoot() const { return *_root_universe; }; 72 : 73 : /** 74 : * @brief add an existing universe to list. Ownership of universe will be transferred to universe 75 : * list object that calls this function 76 : * 77 : * @param universe pointer to universe to add 78 : * @return reference to universe that is passed in 79 : */ 80 : CSGUniverse & addUniverse(std::unique_ptr<CSGUniverse> universe); 81 : 82 : /** 83 : * @brief rename the specified universe 84 : * 85 : * @param universe reference to universe whose name should be renamed 86 : * @param name new name 87 : */ 88 : void renameUniverse(const CSGUniverse & universe, const std::string & name); 89 : 90 : /// Mapping of universe names to pointers of stored universe objects 91 : std::unordered_map<std::string, std::unique_ptr<CSGUniverse>> _universes; 92 : 93 : /// root universe for the CSGBase instance 94 : const CSGUniverse * _root_universe; 95 : 96 : // Only CSGBase should be calling the methods in CSGUniverseList 97 : friend class CSGBase; 98 : }; 99 : } // namespace CSG