comparison Google/GoogleStoragePlugin.h @ 1:fc26a8fc54d5

initial release
author Alain Mazy <alain@mazy.be>
date Fri, 03 Jul 2020 10:08:44 +0200
parents
children 2a02b21f0a19
comparison
equal deleted inserted replaced
0:d7198e8f0d47 1:fc26a8fc54d5
1 /**
2 * Cloud storage plugins for Orthanc
3 * Copyright (C) 2017-2020 Osimis S.A., Belgium
4 *
5 * This program is free software: you can redistribute it and/or
6 * modify it under the terms of the GNU Affero General Public License
7 * as published by the Free Software Foundation, either version 3 of
8 * the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 **/
18
19 #pragma once
20
21 #include "../Common/IStoragePlugin.h"
22
23 #include "google/cloud/storage/client.h"
24
25 class GoogleStoragePluginFactory
26 {
27 public:
28 static const char* GetStoragePluginName();
29 static IStoragePlugin* CreateStoragePlugin(const OrthancPlugins::OrthancConfiguration& orthancConfig);
30 };
31
32
33 class GoogleStoragePlugin : public IStoragePlugin
34 {
35 public:
36
37 std::string bucketName_;
38 google::cloud::storage::Client mainClient_; // the client that is created at startup. Each thread should copy it when it needs it. (from the doc: Instances of this class created via copy-construction or copy-assignment share the underlying pool of connections. Access to these copies via multiple threads is guaranteed to work. Two threads operating on the same instance of this class is not guaranteed to work.)
39
40 public:
41
42 GoogleStoragePlugin(const std::string& bucketName,
43 google::cloud::storage::Client& mainClient
44 );
45
46 virtual IWriter* GetWriterForObject(const char* uuid, OrthancPluginContentType type, bool encryptionEnabled);
47 virtual IReader* GetReaderForObject(const char* uuid, OrthancPluginContentType type, bool encryptionEnabled);
48 virtual void DeleteObject(const char* uuid, OrthancPluginContentType type, bool encryptionEnabled);
49 private:
50 virtual std::string GetPath(const char* uuid, OrthancPluginContentType type, bool encryptionEnabled);
51 };