QGIS API Documentation  3.6.0-Noosa (5873452)
qgsmaplayerdependency.h
Go to the documentation of this file.
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 
35 class CORE_EXPORT QgsMapLayerDependency
36 {
37  public:
39  enum Type
40  {
41  PresenceDependency = 1, //< The layer must be already present (in the registry) for this dependency to be resolved
42  DataDependency = 2 //< The layer may be invalidated by data changes on another layer
43  };
44 
46  enum Origin
47  {
48  FromProvider = 0, //< Dependency given by the provider, the user cannot change it
49  FromUser = 1 //< Dependency given by the user
50  };
51 
53  QgsMapLayerDependency( const QString &layerId, Type type = DataDependency, Origin origin = FromUser )
54  : mType( type )
55  , mOrigin( origin )
56  , mLayerId( layerId )
57  {}
58 
60  Type type() const { return mType; }
61 
63  Origin origin() const { return mOrigin; }
64 
66  QString layerId() const { return mLayerId; }
67 
69  bool operator==( const QgsMapLayerDependency &other ) const
70  {
71  return layerId() == other.layerId() && origin() == other.origin() && type() == other.type();
72  }
73 
74 #ifdef SIP_RUN
75  long __hash__() const;
77  % MethodCode
78  sipRes = qHash( *sipCpp );
79  % End
80 #endif
81  private:
82  Type mType;
83  Origin mOrigin;
84  QString mLayerId;
85 };
86 
87 #ifndef SIP_RUN
88 
92 inline uint qHash( const QgsMapLayerDependency &dep )
93 {
94  return qHash( dep.layerId() ) + dep.origin() + dep.type();
95 }
96 #endif
97 
98 #endif
Origin origin() const
Returns the dependency origin.
bool operator==(const QgsMapLayerDependency &other) const
Comparison operator.
Type type() const
Returns the dependency type.
Type
Type of dependency.
uint qHash(const QgsMapLayerDependency &dep)
global qHash function for QgsMapLayerDependency, so that it can be used in a QSet ...
QString layerId() const
Returns the ID of the layer this dependency depends on.
QgsMapLayerDependency(const QString &layerId, Type type=DataDependency, Origin origin=FromUser)
Standard constructor.
This class models dependencies with or between map layers.
Origin
Origin of the dependency.