~unity-api-team/storage-framework/vivid

« back to all changes in this revision

Viewing changes to include/unity/storage/qt/client/File.h

  • Committer: Bileto Bot
  • Author(s): James Henstridge
  • Date: 2016-08-04 07:19:51 UTC
  • mfrom: (8.25.12 merge-devel)
  • Revision ID: ci-train-bot@canonical.com-20160804071951-3mfrcheyjvif6o99
Initial release of storage framework.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2016 Canonical Ltd
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify
 
5
 * it under the terms of the GNU Lesser General Public License version 3 as
 
6
 * published by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU Lesser General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU Lesser General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authors: Michi Henning <michi.henning@canonical.com>
 
17
 */
 
18
 
 
19
#pragma once
 
20
 
 
21
#include <unity/storage/qt/client/Item.h>
 
22
 
 
23
namespace unity
 
24
{
 
25
namespace storage
 
26
{
 
27
namespace qt
 
28
{
 
29
namespace client
 
30
{
 
31
 
 
32
class Downloader;
 
33
class Uploader;
 
34
namespace internal
 
35
{
 
36
 
 
37
class FileBase;
 
38
 
 
39
namespace local_client
 
40
{
 
41
 
 
42
class FileImpl;
 
43
 
 
44
}  // namespace local_client
 
45
 
 
46
namespace remote_client
 
47
{
 
48
 
 
49
class FileImpl;
 
50
 
 
51
}  // namespace remotelocal_client
 
52
}  // namespace internal
 
53
 
 
54
/**
 
55
\brief Class that represents a file.
 
56
 
 
57
A file is a sequence of bytes.
 
58
*/
 
59
class UNITY_STORAGE_EXPORT File final : public Item
 
60
{
 
61
public:
 
62
    /// @cond
 
63
    virtual ~File();
 
64
    /// @endcond
 
65
 
 
66
    File(File&&);
 
67
    File& operator=(File&&);
 
68
 
 
69
    /**
 
70
    \brief Convenience type definition.
 
71
    */
 
72
    typedef std::shared_ptr<File> SPtr;
 
73
 
 
74
    /**
 
75
    \brief Returns the size of the file in bytes.
 
76
    \throws DestroyedException if the file has been destroyed.
 
77
    */
 
78
    int64_t size() const;
 
79
 
 
80
    /**
 
81
    \brief Creates an uploader for the file.
 
82
    \param policy The conflict resolution policy. If set to ConflictPolicy::overwrite,
 
83
    the contents of the file will be overwritten even if the file was modified
 
84
    after this File instance was retrieved. Otherwise, if set to ConflictPolicy::error_if_conflict,
 
85
    an attempt to retrieve the File instance from the future returned by Uploader::finish_upload()
 
86
    throws ConflictException if the file was was modified via some other channel.
 
87
    \param size The size of the upload in bytes.
 
88
    \note The provided file size must match the number of bytes that you write for the upload, otherwise
 
89
    an attampt to retrive the File instance from the future returned by Uploader::finish_upload()
 
90
    throws LogicException.
 
91
    */
 
92
    QFuture<std::shared_ptr<Uploader>> create_uploader(ConflictPolicy policy, int64_t size);
 
93
 
 
94
    /**
 
95
    \brief Creates a downloader for the file.
 
96
    */
 
97
    QFuture<std::shared_ptr<Downloader>> create_downloader();
 
98
 
 
99
private:
 
100
    File(internal::FileBase*) UNITY_STORAGE_HIDDEN;
 
101
 
 
102
    friend class internal::local_client::FileImpl;
 
103
    friend class internal::remote_client::FileImpl;
 
104
};
 
105
 
 
106
}  // namespace client
 
107
}  // namespace qt
 
108
}  // namespace storage
 
109
}  // namespace unity