QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
project
qgsprojectstorageregistry.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsprojectstorageregistry.cpp
3
--------------------------------------
4
Date : March 2018
5
Copyright : (C) 2018 by Martin Dobias
6
Email : wonder dot sk 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
16
#include "
qgsprojectstorageregistry.h
"
17
18
#include "
qgsprojectstorage.h
"
19
20
QgsProjectStorageRegistry::~QgsProjectStorageRegistry
()
21
{
22
qDeleteAll( mBackends );
23
}
24
25
QgsProjectStorage
*
QgsProjectStorageRegistry::projectStorageFromType
(
const
QString &type )
26
{
27
return
mBackends.value( type,
nullptr
);
28
}
29
30
QgsProjectStorage
*
QgsProjectStorageRegistry::projectStorageFromUri
(
const
QString &uri )
31
{
32
for
(
auto
it = mBackends.constBegin(); it != mBackends.constEnd(); ++it )
33
{
34
QgsProjectStorage
*storage = it.value();
35
if
( uri.startsWith( storage->
type
() +
':'
) || uri.startsWith( storage->
type
() +
"%3A"
) )
36
return
storage;
37
}
38
39
// second chance -- use isSupportedUri to determine if a uri is supported by a backend
40
for
(
auto
it = mBackends.constBegin(); it != mBackends.constEnd(); ++it )
41
{
42
QgsProjectStorage
*storage = it.value();
43
if
( storage->
isSupportedUri
( uri ) )
44
return
storage;
45
}
46
return
nullptr
;
47
}
48
49
QList<QgsProjectStorage *>
QgsProjectStorageRegistry::projectStorages
()
const
50
{
51
return
mBackends.values();
52
}
53
54
void
QgsProjectStorageRegistry::registerProjectStorage
(
QgsProjectStorage
*storage )
55
{
56
mBackends.insert( storage->
type
(), storage );
57
}
58
59
void
QgsProjectStorageRegistry::unregisterProjectStorage
(
QgsProjectStorage
*storage )
60
{
61
delete
mBackends.take( storage->
type
() );
62
}
QgsProjectStorageRegistry::projectStorageFromUri
QgsProjectStorage * projectStorageFromUri(const QString &uri)
Returns storage implementation if the URI matches one. Returns nullptr otherwise (it is a normal file...
Definition
qgsprojectstorageregistry.cpp:30
QgsProjectStorageRegistry::unregisterProjectStorage
void unregisterProjectStorage(QgsProjectStorage *storage)
Unregisters a storage backend and destroys its instance.
Definition
qgsprojectstorageregistry.cpp:59
QgsProjectStorageRegistry::registerProjectStorage
void registerProjectStorage(QgsProjectStorage *storage)
Registers a storage backend and takes ownership of it.
Definition
qgsprojectstorageregistry.cpp:54
QgsProjectStorageRegistry::~QgsProjectStorageRegistry
~QgsProjectStorageRegistry()
Definition
qgsprojectstorageregistry.cpp:20
QgsProjectStorageRegistry::projectStorageFromType
QgsProjectStorage * projectStorageFromType(const QString &type)
Returns storage implementation if the storage type matches one. Returns nullptr otherwise (it is a no...
Definition
qgsprojectstorageregistry.cpp:25
QgsProjectStorageRegistry::projectStorages
QList< QgsProjectStorage * > projectStorages() const
Returns a list of registered project storage implementations.
Definition
qgsprojectstorageregistry.cpp:49
QgsProjectStorage
Abstract interface for project storage - to be implemented by various backends and registered in QgsP...
Definition
qgsprojectstorage.h:37
QgsProjectStorage::isSupportedUri
virtual bool isSupportedUri(const QString &uri) const
Returns true if the specified uri is supported by the storage provider.
Definition
qgsprojectstorage.cpp:18
QgsProjectStorage::type
virtual QString type()=0
Unique identifier of the project storage type.
qgsprojectstorage.h
qgsprojectstorageregistry.h
Generated on
for QGIS API Documentation by
1.17.0