forked from SimonKagstrom/kcov
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcapabilities.cc
49 lines (39 loc) · 895 Bytes
/
capabilities.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <capabilities.hh>
#include <utils.hh>
#include <unordered_map>
using namespace kcov;
class Capabilities : public ICapabilities
{
public:
Capabilities()
{
m_capabilities["handle-solibs"] = false;
}
void addCapability(const std::string &name)
{
validateCapability(name);
m_capabilities[name] = true;
}
void removeCapability(const std::string &name)
{
validateCapability(name);
m_capabilities[name] = false;
}
bool hasCapability(const std::string &name)
{
validateCapability(name);
return m_capabilities[name];
}
private:
void validateCapability(const std::string &name)
{
panic_if(m_capabilities.find(name) == m_capabilities.end(),
"Capability %s not present", name.c_str());
}
std::unordered_map<std::string, bool> m_capabilities;
};
static Capabilities g_capabilities;
ICapabilities &ICapabilities::getInstance()
{
return g_capabilities;
}