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 "CSGLattice.h" 13 : 14 : namespace CSG 15 : { 16 : 17 : /** 18 : * CSGLatticeList creates a container for CSGLattice objects to pass to CSGBase 19 : */ 20 : class CSGLatticeList 21 : { 22 : protected: 23 : /** 24 : * Default constructor 25 : */ 26 : CSGLatticeList(); 27 : 28 : /** 29 : * Destructor 30 : */ 31 280 : virtual ~CSGLatticeList() = default; 32 : 33 : /** 34 : * @brief add an existing lattice to list. Ownership of lattice will be transferred to 35 : * CSGLatticeList object that calls this function 36 : * 37 : * @param lattice pointer to lattice to add 38 : * @return reference to CSGLattice that is passed in 39 : */ 40 : CSGLattice & addLattice(std::unique_ptr<CSGLattice> lattice); 41 : 42 : /** 43 : * @brief return whether lattice with given name exists in lattice list 44 : * 45 : * @param name name of the lattice 46 : * @return true if lattice name exists, otherwise false 47 : */ 48 32 : bool hasLattice(const std::string & name) const 49 : { 50 32 : return _lattices.find(name) != _lattices.end(); 51 : } 52 : 53 : /** 54 : * @brief Get map of all names to lattices in lattice list 55 : * 56 : * @return map of all names to CSGLattice pointers 57 : */ 58 120 : std::unordered_map<std::string, std::unique_ptr<CSGLattice>> & getLatticeListMap() 59 : { 60 120 : return _lattices; 61 : } 62 : 63 : /** 64 : * @brief Get const map of all names to lattices in lattice list 65 : * 66 : * @return map of all names to CSGLattice pointers 67 : */ 68 12 : const std::unordered_map<std::string, std::unique_ptr<CSGLattice>> & getLatticeListMap() const 69 : { 70 12 : return _lattices; 71 : } 72 : 73 : /** 74 : * @brief Get all the lattices in CSGBase instance 75 : * 76 : * @return list of references to all CSGLattice objects 77 : */ 78 : std::vector<std::reference_wrapper<const CSGLattice>> getAllLattices() const; 79 : 80 : /** 81 : * @brief Get a Lattice from the list by its name 82 : * 83 : * @param name name of lattice 84 : * @return reference to CSGLattice of the specified name 85 : */ 86 : CSGLattice & getLattice(const std::string & name) const; 87 : 88 : /** 89 : * @brief rename the specified lattice 90 : * 91 : * @param lattice reference to lattice whose name should be renamed 92 : * @param name new name 93 : */ 94 : void renameLattice(const CSGLattice & lattice, const std::string & name); 95 : 96 : /// Operator overload for checking if two CSGLatticeList objects are equal 97 : bool operator==(const CSGLatticeList & other) const; 98 : 99 : /// Operator overload for checking if two CSGLatticeList objects are not equal 100 : bool operator!=(const CSGLatticeList & other) const; 101 : 102 : /// Mapping of lattice names to pointers of stored lattice objects 103 : std::unordered_map<std::string, std::unique_ptr<CSGLattice>> _lattices; 104 : 105 : // Only CSGBase should be calling the methods in CSGLatticeList 106 : friend class CSGBase; 107 : }; 108 : } // namespace CSG