Cupt
manager.hpp
Go to the documentation of this file.
1 /**************************************************************************
2 * Copyright (C) 2010 by Eugene V. Lyubimkin *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License *
6 * (version 3 or above) as 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 General Public License for more details. *
12 * *
13 * You should have received a copy of the GNU GPL *
14 * along with this program; if not, write to the *
15 * Free Software Foundation, Inc., *
16 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA *
17 **************************************************************************/
18 #ifndef CUPT_DOWNLOAD_MANAGER_SEEN
19 #define CUPT_DOWNLOAD_MANAGER_SEEN
20 
22 
23 #include <functional>
24 
25 #include <cupt/common.hpp>
26 #include <cupt/fwd.hpp>
27 #include <cupt/download/uri.hpp>
28 
29 namespace cupt {
30 
31 namespace internal {
32 
33 class ManagerImpl;
34 
35 }
36 
37 namespace download {
38 
40 class CUPT_API Manager
41 {
42  internal::ManagerImpl* __impl;
43  public:
45  struct ExtendedUri
46  {
47  Uri uri;
48  string shortAlias;
49  string longAlias;
50 
52 
57  ExtendedUri(const Uri& uri_, const string& shortAlias_, const string& longAlias_)
58  : uri(uri_), shortAlias(shortAlias_), longAlias(longAlias_)
59  {}
60  };
63  {
64  vector< ExtendedUri > extendedUris;
65  string targetPath;
66  size_t size;
67 
73  std::function< string () > postAction;
74  bool optional;
75 
77  };
78 
80 
84  Manager(const shared_ptr< const Config >& config, const shared_ptr< Progress >& progress);
86  ~Manager();
87 
89 
94  string download(const vector< DownloadEntity >& entities);
95 };
96 
97 }
98 }
99 
100 #endif
101 
cupt::download::Manager::ExtendedUri
uri with aliases
Definition: manager.hpp:45
common.hpp
cupt::download::Manager::DownloadEntity
downloadable element
Definition: manager.hpp:62
cupt::download::Manager::ExtendedUri::uri
Uri uri
uri
Definition: manager.hpp:47
cupt::download::Manager::DownloadEntity::extendedUris
vector< ExtendedUri > extendedUris
list of alternative uris
Definition: manager.hpp:64
cupt::download::Uri
uniform resource indentifier, "download path"
Definition: uri.hpp:37
cupt::download::Manager::DownloadEntity::postAction
std::function< string() > postAction
post-download callback
Definition: manager.hpp:73
cupt::download::Manager::ExtendedUri::shortAlias
string shortAlias
short alias
Definition: manager.hpp:48
cupt::download::Manager::ExtendedUri::longAlias
string longAlias
long alias (full description)
Definition: manager.hpp:49
cupt::download::Manager::DownloadEntity::targetPath
string targetPath
path where to place downloaded file
Definition: manager.hpp:65
cupt::download::Manager::DownloadEntity::optional
bool optional
true if failure to download this is not an error
Definition: manager.hpp:74
uri.hpp
cupt::download::Manager
performs downloads
Definition: manager.hpp:40
cupt::download::Manager::DownloadEntity::size
size_t size
Definition: manager.hpp:66
cupt::download::Manager::ExtendedUri::ExtendedUri
ExtendedUri(const Uri &uri_, const string &shortAlias_, const string &longAlias_)
trivial constructor
Definition: manager.hpp:57