GCC Code Coverage Report


Directory: cvmfs/
File: cvmfs/swissknife.h
Date: 2026-04-26 02:35:59
Exec Total Coverage
Lines: 0 16 0.0%
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 "server_tool.h"
14 #include "util/shared_ptr.h"
15
16 namespace download {
17 class DownloadManager;
18 }
19 namespace manifest {
20 class Manifest;
21 }
22 namespace perf {
23 class Statistics;
24 }
25 namespace signature {
26 class SignatureManager;
27 }
28
29 namespace swissknife {
30
31 class Parameter {
32 public:
33 static Parameter Mandatory(const char key, const std::string &desc) {
34 return Parameter(key, desc, false, false);
35 }
36 static Parameter Optional(const char key, const std::string &desc) {
37 return Parameter(key, desc, true, false);
38 }
39 static Parameter Switch(const char key, const std::string &desc) {
40 return Parameter(key, desc, true, true);
41 }
42
43 char key() const { return key_; }
44 const std::string &description() const { return description_; }
45 bool optional() const { return optional_; }
46 bool mandatory() const { return !optional_; }
47 bool switch_only() const { return switch_only_; }
48
49 protected:
50 Parameter(const char key, const std::string &desc, const bool opt,
51 const bool switch_only)
52 : key_(key)
53 , description_(desc)
54 , optional_(opt)
55 , switch_only_(switch_only) {
56 assert(!switch_only_ || optional_); // switches are optional by definition
57 }
58
59 private:
60 char key_;
61 std::string description_;
62 bool optional_;
63 bool switch_only_;
64 };
65
66 typedef std::vector<Parameter> ParameterList;
67 typedef std::map<char, SharedPtr<std::string> > ArgumentList;
68
69 class Command : public ServerTool {
70 public:
71 // generic command parameters
72 static const char kGenericParam = '+';
73 static const char kGenericParamSeparator = ',';
74
75 Command();
76 virtual ~Command();
77 virtual std::string GetName() const = 0;
78 virtual std::string GetDescription() const = 0;
79 virtual ParameterList GetParams() const = 0;
80 virtual int Main(const ArgumentList &args) = 0;
81 };
82
83 } // namespace swissknife
84
85 #endif // CVMFS_SWISSKNIFE_H_
86