1 /*************************************************************************** 2 qgsvaliditycheckregistry.h 3 -------------------------- 4 begin : November 2018 5 copyright : (C) 2018 by Nyall Dawson 6 email : nyall dot dawson at gmail dot com 7 *************************************************************************** 8 * * 9 * This program is free software; you can redistribute it and/or modify * 10 * it under the terms of the GNU General Public License as published by * 11 * the Free Software Foundation; either version 2 of the License, or * 12 * (at your option) any later version. * 13 * * 14 ***************************************************************************/ 15 #ifndef QGSVALIDITYCHECKREGISTRY_H 16 #define QGSVALIDITYCHECKREGISTRY_H 17 18 #include "qgis_core.h" 19 #include "qgis_sip.h" 20 #include "qgsabstractvaliditycheck.h" 21 #include <QList> 22 #include <memory> 23 #include <vector> 24 25 /** 26 * \class QgsValidityCheckRegistry 27 * \ingroup gui 28 * \brief This class keeps a list of QgsAbstractValidityCheck checks which can be used when 29 * performing validity checks. 30 * 31 * QgsValidityCheckRegistry is not usually directly created, but rather accessed through 32 * QgsApplication::validityCheckRegistry(). 33 * 34 * \since QGIS 3.6 35 */ 36 class CORE_EXPORT QgsValidityCheckRegistry 37 { 38 39 public: 40 41 QgsValidityCheckRegistry(); 42 43 ~QgsValidityCheckRegistry(); 44 45 //! QgsValidityCheckRegistry cannot be copied. 46 QgsValidityCheckRegistry( const QgsValidityCheckRegistry &rh ) = delete; 47 //! QgsValidityCheckRegistry cannot be copied. 48 QgsValidityCheckRegistry &operator=( const QgsValidityCheckRegistry &rh ) = delete; 49 50 /** 51 * Returns the list of available checks. 52 */ 53 QList<const QgsAbstractValidityCheck *> checks() const; 54 55 /** 56 * Returns the list of all available checks of the matching \a type. 57 */ 58 QList<const QgsAbstractValidityCheck *> checks( int type ) const; 59 60 /** 61 * Adds a \a check to the registry. Ownership of the check 62 * is transferred to the registry. 63 */ 64 void addCheck( QgsAbstractValidityCheck *check SIP_TRANSFER ); 65 66 /** 67 * Removes a \a check from the registry. 68 * The check object is automatically deleted. 69 */ 70 void removeCheck( QgsAbstractValidityCheck *check ); 71 72 /** 73 * Runs all checks of the specified \a type and returns a list of results. 74 * 75 * If all checks are "passed" and no warnings or errors are generated, then 76 * an empty list will be returned. 77 * 78 * The \a context argument gives the wider in which the check is being run. 79 * 80 * The \a feedback argument is used to give progress reports and to support 81 * cancellation of long-running checks. 82 * 83 * This is a blocking call, which will run all matching checks in the main 84 * thread and only return when they have all completed. 85 */ 86 QList< QgsValidityCheckResult > runChecks( int type, const QgsValidityCheckContext *context, QgsFeedback *feedback ) const; 87 88 private: 89 90 #ifdef SIP_RUN 91 QgsValidityCheckRegistry( const QgsValidityCheckRegistry &rh ); 92 #endif 93 94 /** 95 * Returns a list containing new copies of all available checks of the matching \a type. 96 */ 97 std::vector<std::unique_ptr< QgsAbstractValidityCheck > > createChecks( int type ) const SIP_FACTORY; 98 99 //! Available checks, owned by this class 100 QList< QgsAbstractValidityCheck * > mChecks; 101 102 }; 103 104 #endif // QGSVALIDITYCHECKREGISTRY_H 105