1 /* 2 Copyright (C) 2010-2014 Kristian Duske 3 4 This file is part of TrenchBroom. 5 6 TrenchBroom is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 TrenchBroom is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #include "IssueGeneratorRegistry.h" 21 22 #include "CollectionUtils.h" 23 #include "Model/IssueGenerator.h" 24 25 #include <cassert> 26 27 namespace TrenchBroom { 28 namespace Model { ~IssueGeneratorRegistry()29 IssueGeneratorRegistry::~IssueGeneratorRegistry() { 30 clearGenerators(); 31 } 32 registeredGenerators() const33 const IssueGeneratorList& IssueGeneratorRegistry::registeredGenerators() const { 34 return m_generators; 35 } 36 quickFixes(const IssueType issueTypes) const37 IssueQuickFixList IssueGeneratorRegistry::quickFixes(const IssueType issueTypes) const { 38 IssueQuickFixList result; 39 IssueGeneratorList::const_iterator it, end; 40 for (it = m_generators.begin(), end = m_generators.end(); it != end; ++it) { 41 const IssueGenerator* generator = *it; 42 if ((generator->type() & issueTypes) != 0) 43 VectorUtils::append(result, generator->quickFixes()); 44 } 45 return result; 46 } 47 registerGenerator(IssueGenerator * generator)48 void IssueGeneratorRegistry::registerGenerator(IssueGenerator* generator) { 49 assert(generator != NULL); 50 assert(!VectorUtils::contains(m_generators, generator)); 51 m_generators.push_back(generator); 52 } 53 unregisterAllGenerators()54 void IssueGeneratorRegistry::unregisterAllGenerators() { 55 clearGenerators(); 56 } 57 clearGenerators()58 void IssueGeneratorRegistry::clearGenerators() { 59 VectorUtils::clearAndDelete(m_generators); 60 } 61 } 62 } 63