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 310 : 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 : * @param ignore_identical_lattice skip adding lattice if an identical lattice exists in lattice 39 : * list 40 : * @return reference to CSGLattice that is passed in 41 : */ 42 : CSGLattice & addLattice(std::unique_ptr<CSGLattice> lattice, 43 : const bool ignore_identical_lattice = false); 44 : 45 : /** 46 : * @brief return whether lattice with given name exists in lattice list 47 : * 48 : * @param name name of the lattice 49 : * @return true if lattice name exists, otherwise false 50 : */ 51 54 : bool hasLattice(const std::string & name) const 52 : { 53 54 : return _lattices.find(name) != _lattices.end(); 54 : } 55 : 56 : /** 57 : * @brief Get map of all names to lattices in lattice list 58 : * 59 : * @return map of all names to CSGLattice pointers 60 : */ 61 170 : std::unordered_map<std::string, std::unique_ptr<CSGLattice>> & getLatticeListMap() 62 : { 63 170 : return _lattices; 64 : } 65 : 66 : /** 67 : * @brief Get const map of all names to lattices in lattice list 68 : * 69 : * @return map of all names to CSGLattice pointers 70 : */ 71 36 : const std::unordered_map<std::string, std::unique_ptr<CSGLattice>> & getLatticeListMap() const 72 : { 73 36 : return _lattices; 74 : } 75 : 76 : /** 77 : * @brief Get all the lattices in CSGBase instance 78 : * 79 : * @return list of references to all CSGLattice objects 80 : */ 81 : std::vector<std::reference_wrapper<const CSGLattice>> getAllLattices() const; 82 : 83 : /** 84 : * @brief Get a Lattice from the list by its name 85 : * 86 : * @param name name of lattice 87 : * @return reference to CSGLattice of the specified name 88 : */ 89 : CSGLattice & getLattice(const std::string & name) const; 90 : 91 : /** 92 : * @brief rename the specified lattice 93 : * 94 : * @param lattice reference to lattice whose name should be renamed 95 : * @param name new name 96 : */ 97 : void renameLattice(const CSGLattice & lattice, const std::string & name); 98 : 99 : /// Operator overload for checking if two CSGLatticeList objects are equal 100 : bool operator==(const CSGLatticeList & other) const; 101 : 102 : /// Operator overload for checking if two CSGLatticeList objects are not equal 103 : bool operator!=(const CSGLatticeList & other) const; 104 : 105 : /// Mapping of lattice names to pointers of stored lattice objects 106 : std::unordered_map<std::string, std::unique_ptr<CSGLattice>> _lattices; 107 : 108 : // Only CSGBase should be calling the methods in CSGLatticeList 109 : friend class CSGBase; 110 : }; 111 : } // namespace CSG