QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
qgsexternalstorageregistry.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsexternalstorageregistry.cpp
3 --------------------------------------
4 Date : March 2021
5 Copyright : (C) 2021 by Julien Cabieces
6 Email : julien dot cabieces at oslandia 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 "qgsexternalstorage.h"
21
23{
24 registerExternalStorage( new QgsSimpleCopyExternalStorage() );
25 registerExternalStorage( new QgsWebDavExternalStorage() );
26 registerExternalStorage( new QgsAwsS3ExternalStorage() );
27}
28
30{
31 qDeleteAll( mBackends );
32}
33
35{
36 auto it = std::find_if( mBackends.begin(), mBackends.end(), [ = ]( QgsExternalStorage * storage )
37 {
38 return storage->type() == type;
39 } );
40
41 return it != mBackends.end() ? *it : nullptr;
42}
43
44QList<QgsExternalStorage *> QgsExternalStorageRegistry::externalStorages() const
45{
46 return mBackends;
47}
48
50{
51 if ( !mBackends.contains( storage ) )
52 mBackends.append( storage );
53}
54
56{
57 const int index = mBackends.indexOf( storage );
58 if ( index >= 0 )
59 {
60 delete mBackends.takeAt( index );
61 }
62}
QgsExternalStorage * externalStorageFromType(const QString &type) const
Returns external storage implementation if the storage type matches one.
void registerExternalStorage(QgsExternalStorage *storage)
Registers a storage backend and takes ownership of it.
QList< QgsExternalStorage * > externalStorages() const
Returns a list of registered project storage implementations.
QgsExternalStorageRegistry()
Constructor - creates a registry of external storage backends.
void unregisterExternalStorage(QgsExternalStorage *storage)
Unregisters a storage backend and destroys its instance.
Abstract interface for external storage - to be implemented by various backends and registered in Qgs...