Mercurial > hg > orthanc
comparison Core/FileStorage.h @ 0:3959d33612cc
initial commit
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 19 Jul 2012 14:32:22 +0200 |
parents | |
children | a15e90e5d6fc |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3959d33612cc |
---|---|
1 /** | |
2 * Palantir - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012 Medical Physics Department, CHU of Liege, | |
4 * Belgium | |
5 * | |
6 * This program is free software: you can redistribute it and/or | |
7 * modify it under the terms of the GNU General Public License as | |
8 * published by the Free Software Foundation, either version 3 of the | |
9 * License, or (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, but | |
12 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 * General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 **/ | |
19 | |
20 | |
21 #pragma once | |
22 | |
23 #include <boost/filesystem.hpp> | |
24 #include <set> | |
25 | |
26 #include "Compression/BufferCompressor.h" | |
27 | |
28 namespace Palantir | |
29 { | |
30 class FileStorage : public boost::noncopyable | |
31 { | |
32 friend class HttpOutput; | |
33 | |
34 private: | |
35 std::auto_ptr<BufferCompressor> compressor_; | |
36 | |
37 boost::filesystem::path root_; | |
38 | |
39 boost::filesystem::path GetPath(const std::string& uuid) const; | |
40 | |
41 std::string CreateFileWithoutCompression(const void* content, size_t size); | |
42 | |
43 public: | |
44 FileStorage(std::string root); | |
45 | |
46 void SetBufferCompressor(BufferCompressor* compressor) // Takes the ownership | |
47 { | |
48 compressor_.reset(compressor); | |
49 } | |
50 | |
51 bool HasBufferCompressor() const | |
52 { | |
53 return compressor_.get() != NULL; | |
54 } | |
55 | |
56 std::string Create(const void* content, size_t size); | |
57 | |
58 std::string Create(const std::vector<uint8_t>& content); | |
59 | |
60 std::string Create(const std::string& content); | |
61 | |
62 void ReadFile(std::string& content, | |
63 const std::string& uuid) const; | |
64 | |
65 void ListAllFiles(std::set<std::string>& result) const; | |
66 | |
67 uintmax_t GetCompressedSize(const std::string& uuid) const; | |
68 | |
69 void Clear(); | |
70 | |
71 void Remove(const std::string& uuid); | |
72 | |
73 uintmax_t GetCapacity() const; | |
74 | |
75 uintmax_t GetAvailableSpace() const; | |
76 | |
77 std::string GetPath() const | |
78 { | |
79 return root_.string(); | |
80 } | |
81 }; | |
82 } |