1 |
|
|
/** |
2 |
|
|
* This file is part of the CernVM File System. |
3 |
|
|
*/ |
4 |
|
|
|
5 |
|
|
#ifndef CVMFS_SWISSKNIFE_ASSISTANT_H_ |
6 |
|
|
#define CVMFS_SWISSKNIFE_ASSISTANT_H_ |
7 |
|
|
|
8 |
|
|
#include <string> |
9 |
|
|
|
10 |
|
|
#include "hash.h" |
11 |
|
|
|
12 |
|
|
namespace catalog { |
13 |
|
|
class Catalog; |
14 |
|
|
} |
15 |
|
|
namespace download { |
16 |
|
|
class DownloadManager; |
17 |
|
|
} |
18 |
|
|
namespace history { |
19 |
|
|
class History; |
20 |
|
|
} |
21 |
|
|
namespace manifest { |
22 |
|
|
class Manifest; |
23 |
|
|
} |
24 |
|
|
|
25 |
|
|
namespace swissknife { |
26 |
|
|
|
27 |
|
|
/** |
28 |
|
|
* Common tasks when working with repositories, such as getting the a catalog |
29 |
|
|
* or getting the history database. Objects are automatically removed when the |
30 |
|
|
* Assistant goes out of scope. |
31 |
|
|
*/ |
32 |
|
|
class Assistant { |
33 |
|
|
public: |
34 |
|
|
enum OpenMode { |
35 |
|
|
kOpenReadOnly, |
36 |
|
|
kOpenReadWrite |
37 |
|
|
}; |
38 |
|
|
|
39 |
|
|
Assistant( |
40 |
|
|
download::DownloadManager *d, |
41 |
|
|
manifest::Manifest *m, |
42 |
|
|
const std::string &r, |
43 |
|
|
const std::string &t) |
44 |
|
|
: download_mgr_(d) |
45 |
|
|
, manifest_(m) |
46 |
|
|
, repository_url_(r) |
47 |
|
|
, tmp_dir_(t) |
48 |
|
|
{ } |
49 |
|
|
|
50 |
|
|
history::History *GetHistory(OpenMode open_mode); |
51 |
|
|
catalog::Catalog *GetCatalog(const shash::Any &catalog_hash, |
52 |
|
|
OpenMode open_mode); |
53 |
|
|
|
54 |
|
|
private: |
55 |
|
|
bool FetchObject(const shash::Any &id, const std::string &local_path); |
56 |
|
|
|
57 |
|
|
download::DownloadManager *download_mgr_; |
58 |
|
|
manifest::Manifest *manifest_; |
59 |
|
|
std::string repository_url_; |
60 |
|
|
std::string tmp_dir_; |
61 |
|
|
}; |
62 |
|
|
|
63 |
|
|
} // namespace swissknife |
64 |
|
|
|
65 |
|
|
#endif // CVMFS_SWISSKNIFE_ASSISTANT_H_ |