LCOV - code coverage report
Current view: top level - core - qgsmaplayerdependency.h (source / functions) Hit Total Coverage
Test: coverage.info.cleaned Lines: 6 15 40.0 %
Date: 2021-03-26 12:19:53 Functions: 0 0 -
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : 
       2                 :            : /***************************************************************************
       3                 :            :                           qgsmaplayerdependency.h  -  description
       4                 :            :                              -------------------
       5                 :            :     begin                : September 2016
       6                 :            :     copyright            : (C) 2016 by Hugo Mercier
       7                 :            :     email                : hugo dot mercier at oslandia dot com
       8                 :            :  ***************************************************************************/
       9                 :            : 
      10                 :            : /***************************************************************************
      11                 :            :  *                                                                         *
      12                 :            :  *   This program is free software; you can redistribute it and/or modify  *
      13                 :            :  *   it under the terms of the GNU General Public License as published by  *
      14                 :            :  *   the Free Software Foundation; either version 2 of the License, or     *
      15                 :            :  *   (at your option) any later version.                                   *
      16                 :            :  *                                                                         *
      17                 :            :  ***************************************************************************/
      18                 :            : 
      19                 :            : #ifndef QGSMAPLAYERDEPENDENCY_H
      20                 :            : #define QGSMAPLAYERDEPENDENCY_H
      21                 :            : 
      22                 :            : #include "qgis_core.h"
      23                 :            : #include <QString>
      24                 :            : 
      25                 :            : /**
      26                 :            :  * \ingroup core
      27                 :            :  * \brief This class models dependencies with or between map layers.
      28                 :            :  *
      29                 :            :  * A dependency is defined by a layer ID, a type and an origin.
      30                 :            :  * The two combinations of type/origin that are currently supported are:
      31                 :            :  *
      32                 :            :  * - PresenceDependency && FromProvider: virtual layers for instance which may depend on other layers already loaded to work
      33                 :            :  * - DataDependency && FromUser: dependencies given by the user, mainly to represent database triggers
      34                 :            :  *
      35                 :            :  * \since QGIS 3.0
      36                 :            :  */
      37                 :          1 : class CORE_EXPORT QgsMapLayerDependency
      38                 :            : {
      39                 :            :   public:
      40                 :            :     //! Type of dependency
      41                 :            :     enum Type
      42                 :            :     {
      43                 :            :       PresenceDependency = 1, //< The layer must be already present (in the registry) for this dependency to be resolved
      44                 :            :       DataDependency     = 2  //< The layer may be invalidated by data changes on another layer
      45                 :            :     };
      46                 :            : 
      47                 :            :     //! Origin of the dependency
      48                 :            :     enum Origin
      49                 :            :     {
      50                 :            :       FromProvider = 0,  //< Dependency given by the provider, the user cannot change it
      51                 :            :       FromUser     = 1   //< Dependency given by the user
      52                 :            :     };
      53                 :            : 
      54                 :            :     //! Standard constructor
      55                 :          1 :     QgsMapLayerDependency( const QString &layerId, Type type = DataDependency, Origin origin = FromUser )
      56                 :          1 :       : mType( type )
      57                 :          1 :       , mOrigin( origin )
      58                 :          1 :       , mLayerId( layerId )
      59                 :          1 :     {}
      60                 :            : 
      61                 :            :     //! Returns the dependency type
      62                 :          0 :     Type type() const { return mType; }
      63                 :            : 
      64                 :            :     //! Returns the dependency origin
      65                 :          0 :     Origin origin() const { return mOrigin; }
      66                 :            : 
      67                 :            :     //! Returns the ID of the layer this dependency depends on
      68                 :          0 :     QString layerId() const { return mLayerId; }
      69                 :            : 
      70                 :            :     //! Comparison operator
      71                 :          0 :     bool operator==( const QgsMapLayerDependency &other ) const
      72                 :            :     {
      73                 :          0 :       return layerId() == other.layerId() && origin() == other.origin() && type() == other.type();
      74                 :          0 :     }
      75                 :            : 
      76                 :            : #ifdef SIP_RUN
      77                 :            :     //! hash operator
      78                 :            :     long __hash__() const;
      79                 :            :     % MethodCode
      80                 :            :     sipRes = qHash( *sipCpp );
      81                 :            :     % End
      82                 :            : #endif
      83                 :            :   private:
      84                 :            :     Type mType;
      85                 :            :     Origin mOrigin;
      86                 :            :     QString mLayerId;
      87                 :            : };
      88                 :            : 
      89                 :            : #ifndef SIP_RUN
      90                 :            : 
      91                 :            : /**
      92                 :            :  * global qHash function for QgsMapLayerDependency, so that it can be used in a QSet
      93                 :            :  */
      94                 :          0 : inline uint qHash( const QgsMapLayerDependency &dep )
      95                 :            : {
      96                 :          0 :   return qHash( dep.layerId() ) + dep.origin() + dep.type();
      97                 :          0 : }
      98                 :            : #endif
      99                 :            : 
     100                 :            : #endif

Generated by: LCOV version 1.14