Debian Codegraph @

src/fileops/SwiftIO.hpp

raw
1 /*
2 * This File is part of Davix, The IO library for HTTP based protocols
3 * Copyright (C) CERN 2021
4 * Author: Shiting Long <[email protected]> (Forschungszentrum Juelich)
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 */
21
22 #ifndef DAVIX_SWIFTIO_HPP
23 #define DAVIX_SWIFTIO_HPP
24
25 #include <fileops/httpiochain.hpp>
26
27 namespace Davix{
28
29 typedef std::pair <std::string, int> Prop;
30
31 class SwiftIO : public HttpIOChain {
32 public:
33 SwiftIO();
34 ~SwiftIO();
35
36 // write from content provider
37 virtual dav_ssize_t writeFromProvider(IOChainContext & iocontext, ContentProvider &provider);
38
39 private:
40
41 // Write the given chunk. Return object properties (etag + size_bytes),
42 // necessary to commit upload.
43 std::string writeChunk(IOChainContext & iocontext, const char* buff, dav_size_t size, int partNumber);
44
45
46 // Given the properties (etag + size_bytes) of the segments, commit chunks
47 void commitChunks(IOChainContext & iocontext, const std::vector<Prop> &props);
48 // Commit chunks in a inline manner if the number of segments has exceeded the limit defined by max_manifest_segments
49 void commitInlineChunks(IOChainContext & iocontext, const std::vector<Prop> &props, const size_t MaxManifestSegments);
50 };
51
52 }
53
54 #endif //DAVIX_SWIFTIO_HPP