| Line |
Branch |
Exec |
Source |
| 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 "crypto/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(download::DownloadManager *d, |
| 40 |
|
|
manifest::Manifest *m, |
| 41 |
|
|
const std::string &r, |
| 42 |
|
|
const std::string &t) |
| 43 |
|
✗ |
: download_mgr_(d), manifest_(m), repository_url_(r), tmp_dir_(t) { } |
| 44 |
|
|
|
| 45 |
|
|
history::History *GetHistory(OpenMode open_mode); |
| 46 |
|
|
catalog::Catalog *GetCatalog(const shash::Any &catalog_hash, |
| 47 |
|
|
OpenMode open_mode); |
| 48 |
|
|
|
| 49 |
|
|
private: |
| 50 |
|
|
bool FetchObject(const shash::Any &id, const std::string &local_path); |
| 51 |
|
|
|
| 52 |
|
|
download::DownloadManager *download_mgr_; |
| 53 |
|
|
manifest::Manifest *manifest_; |
| 54 |
|
|
std::string repository_url_; |
| 55 |
|
|
std::string tmp_dir_; |
| 56 |
|
|
}; |
| 57 |
|
|
|
| 58 |
|
|
} // namespace swissknife |
| 59 |
|
|
|
| 60 |
|
|
#endif // CVMFS_SWISSKNIFE_ASSISTANT_H_ |
| 61 |
|
|
|