QGIS API Documentation  3.4.3-Madeira (2f64a3c)
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 
17 
18 #include "qgsprojectstorage.h"
19 
20 
22 {
23  qDeleteAll( mBackends.values() );
24 }
25 
27 {
28  return mBackends.value( type, nullptr );
29 }
30 
32 {
33  for ( auto it = mBackends.constBegin(); it != mBackends.constEnd(); ++it )
34  {
35  QgsProjectStorage *storage = it.value();
36  QString scheme = storage->type() + ':';
37  if ( uri.startsWith( scheme ) )
38  return storage;
39  }
40  return nullptr;
41 }
42 
43 QList<QgsProjectStorage *> QgsProjectStorageRegistry::projectStorages() const
44 {
45  return mBackends.values();
46 }
47 
49 {
50  mBackends.insert( storage->type(), storage );
51 }
52 
54 {
55  delete mBackends.take( storage->type() );
56 }
void unregisterProjectStorage(QgsProjectStorage *storage)
Unregisters a storage backend and destroys its instance.
virtual QString type()=0
Unique identifier of the project storage type.
QgsProjectStorage * projectStorageFromType(const QString &type)
Returns storage implementation if the storage type matches one. Returns null pointer otherwise (it is...
QList< QgsProjectStorage * > projectStorages() const
Returns a list of registered project storage implementations.
Abstract interface for project storage - to be implemented by various backends and registered in QgsP...
QgsProjectStorage * projectStorageFromUri(const QString &uri)
Returns storage implementation if the URI matches one. Returns null pointer otherwise (it is a normal...
void registerProjectStorage(QgsProjectStorage *storage)
Registers a storage backend and takes ownership of it.