annotate Common/FileSystemStorage.h @ 78:d7295e8678d7

renames
author Alain Mazy <am@osimis.io>
date Fri, 14 Oct 2022 11:00:18 +0200
parents Common/FileSystemStoragePlugin.h@80792bb9600e
children 407bd022b0cf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
1 /**
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
2 * Cloud storage plugins for Orthanc
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
3 * Copyright (C) 2020-2021 Osimis S.A., Belgium
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
4 *
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
6 * modify it under the terms of the GNU Affero General Public License
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
7 * as published by the Free Software Foundation, either version 3 of
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
8 * the License, or (at your option) any later version.
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
9 *
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful, but
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
13 * Affero General Public License for more details.
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
14 *
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
15 * You should have received a copy of the GNU Affero General Public License
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
17 **/
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
18
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
19
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
20 #pragma once
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
21
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
22 #include "IStorage.h"
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
23 #include <boost/filesystem.hpp>
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
24
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
25 namespace fs = boost::filesystem;
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
26
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
27
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
28 class FileSystemStoragePlugin: public IStorage
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
29 {
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
30 public:
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
31 class FileSystemWriter: public IStorage::IWriter
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
32 {
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
33 const fs::path path_;
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
34 bool fsync_;
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
35 public:
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
36 FileSystemWriter(const fs::path& path, bool fsync)
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
37 : path_(path),
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
38 fsync_(fsync)
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
39 {}
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
40
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
41 virtual ~FileSystemWriter() {}
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
42 virtual void Write(const char* data, size_t size);
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
43 };
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
44
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
45 class FileSystemReader: public IStorage::IReader
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
46 {
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
47 const fs::path path_;
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
48 public:
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
49 FileSystemReader(const fs::path& path)
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
50 : path_(path)
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
51 {}
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
52
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
53 virtual ~FileSystemReader() {}
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
54 virtual size_t GetSize();
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
55 virtual void ReadWhole(char* data, size_t size);
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
56 virtual void ReadRange(char* data, size_t size, size_t fromOffset);
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
57 };
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
58
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
59 std::string fileSystemRootPath_;
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
60 bool fsync_;
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
61 public:
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
62 FileSystemStoragePlugin(const std::string& nameForLogs, const std::string& fileSystemRootPath, bool fsync)
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
63 : IStorage(nameForLogs),
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
64 fileSystemRootPath_(fileSystemRootPath),
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
65 fsync_(fsync)
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
66 {}
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
67
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
68 virtual void SetRootPath(const std::string& rootPath) {}
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
69
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
70 virtual IStorage::IWriter* GetWriterForObject(const char* uuid, OrthancPluginContentType type, bool encryptionEnabled);
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
71 virtual IStorage::IReader* GetReaderForObject(const char* uuid, OrthancPluginContentType type, bool encryptionEnabled);
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
72 virtual void DeleteObject(const char* uuid, OrthancPluginContentType type, bool encryptionEnabled);
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
73 };