QGIS API Documentation 4.1.0-Master (659fe69c07c)
Loading...
Searching...
No Matches
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
24#include <QString>
25
37class CORE_EXPORT QgsMapLayerDependency
38{
39 public:
46
48 enum Origin
49 {
52 };
53
56 : mType( type )
57 , mOrigin( origin )
58 , mLayerId( layerId )
59 {}
60
62 Type type() const { return mType; }
63
65 Origin origin() const { return mOrigin; }
66
68 QString layerId() const { return mLayerId; }
69
70 // TODO c++20 - replace with = default
71
72 bool operator==( const QgsMapLayerDependency &other ) const { return layerId() == other.layerId() && origin() == other.origin() && type() == other.type(); }
73
74#ifdef SIP_RUN
75 // clang-format off
77 long __hash__() const;
78 % MethodCode
79 sipRes = qHash( *sipCpp );
80 % End
81// clang-format on
82#endif
83 // clang-format off
84 private:
85 // clang-format on
86 Type mType;
87 Origin mOrigin;
88 QString mLayerId;
89};
90
91#ifndef SIP_RUN
92
96inline size_t qHash( const QgsMapLayerDependency &dep )
97{
98 return qHash( dep.layerId() ) + dep.origin() + dep.type();
99}
100#endif
101
102#endif
Models dependencies with or between map layers.
QgsMapLayerDependency(const QString &layerId, Type type=DataDependency, Origin origin=FromUser)
Standard constructor.
@ DataDependency
The layer may be invalidated by data changes on another layer.
@ PresenceDependency
The layer must be already present (in the registry) for this dependency to be resolved.
Origin
Origin of the dependency.
@ FromProvider
Dependency given by the provider, the user cannot change it.
@ FromUser
Dependency given by the user.
bool operator==(const QgsMapLayerDependency &other) const
QString layerId() const
Returns the ID of the layer this dependency depends on.
Origin origin() const
Returns the dependency origin.
Type type() const
Returns the dependency type.
size_t qHash(const QVariant &variant)
Hash for QVariant.
Definition qgis.cpp:611
size_t qHash(const QgsMapLayerDependency &dep)
global qHash function for QgsMapLayerDependency, so that it can be used in a QSet