GCC Code Coverage Report
Directory: cvmfs/ Exec Total Coverage
File: cvmfs/receiver/../swissknife.h Lines: 0 10 0.0 %
Date: 2019-02-03 02:48:13 Branches: 0 4 0.0 %

Line Branch Exec Source
1
/**
2
 * This file is part of the CernVM File System.
3
 */
4
5
#ifndef CVMFS_SWISSKNIFE_H_
6
#define CVMFS_SWISSKNIFE_H_
7
8
#include <cassert>
9
#include <map>
10
#include <string>
11
#include <vector>
12
13
#include "download.h"
14
#include "manifest_fetch.h"
15
#include "reflog.h"
16
#include "server_tool.h"
17
#include "signature.h"
18
#include "statistics.h"
19
#include "util/shared_ptr.h"
20
21
namespace download {
22
class DownloadManager;
23
}
24
namespace manifest {
25
class Manifest;
26
}
27
namespace perf {
28
class Statistics;
29
}
30
namespace signature {
31
class SignatureManager;
32
}
33
34
namespace swissknife {
35
36
class Parameter {
37
 public:
38
  static Parameter Mandatory(const char key, const std::string &desc) {
39
    return Parameter(key, desc, false, false);
40
  }
41
  static Parameter Optional(const char key, const std::string &desc) {
42
    return Parameter(key, desc, true, false);
43
  }
44
  static Parameter Switch(const char key, const std::string &desc) {
45
    return Parameter(key, desc, true, true);
46
  }
47
48
  char key() const { return key_; }
49
  const std::string &description() const { return description_; }
50
  bool optional() const { return optional_; }
51
  bool mandatory() const { return !optional_; }
52
  bool switch_only() const { return switch_only_; }
53
54
 protected:
55
  Parameter(const char key, const std::string &desc, const bool opt,
56
            const bool switch_only)
57
      : key_(key),
58
        description_(desc),
59
        optional_(opt),
60
        switch_only_(switch_only) {
61
    assert(!switch_only_ || optional_);  // switches are optional by definition
62
  }
63
64
 private:
65
  char key_;
66
  std::string description_;
67
  bool optional_;
68
  bool switch_only_;
69
};
70
71
typedef std::vector<Parameter> ParameterList;
72
typedef std::map<char, SharedPtr<std::string> > ArgumentList;
73
74
class Command : public ServerTool {
75
 public:
76
  // generic command parameters
77
  static const char kGenericParam = '+';
78
  static const char kGenericParamSeparator = ',';
79
80
  Command();
81
  virtual ~Command();
82
  virtual std::string GetName() const = 0;
83
  virtual std::string GetDescription() const = 0;
84
  virtual ParameterList GetParams() const = 0;
85
  virtual int Main(const ArgumentList &args) = 0;
86
};
87
88
}  // namespace swissknife
89
90
#endif  // CVMFS_SWISSKNIFE_H_