base: remove Trace::enabled flag

The DTRACE() macro tests both Trace::enabled and the specific flag. This
change uses the same administrative interface for enabling/disabling
tracing, but masks the SimpleFlags settings directly. This eliminates a
load for every DTRACE() test, e.g. DPRINTF.
This commit is contained in:
Curtis Dunham
2015-09-30 15:21:55 -05:00
parent ccf4f6c3d7
commit 02881a7bf3
13 changed files with 72 additions and 35 deletions

View File

@@ -68,6 +68,8 @@ allFlags()
return flags;
}
bool SimpleFlag::_active = false;
Flag *
findFlag(const std::string &name)
{
@@ -94,18 +96,34 @@ Flag::~Flag()
// should find and remove flag.
}
void
SimpleFlag::enableAll()
{
_active = true;
for (auto& i : allFlags())
i.second->sync();
}
void
SimpleFlag::disableAll()
{
_active = false;
for (auto& i : allFlags())
i.second->sync();
}
void
CompoundFlag::enable()
{
SimpleFlag::enable();
for_each(_kids.begin(), _kids.end(), mem_fun(&Flag::enable));
for (auto& k : _kids)
k->enable();
}
void
CompoundFlag::disable()
{
SimpleFlag::disable();
for_each(_kids.begin(), _kids.end(), mem_fun(&Flag::disable));
for (auto& k : _kids)
k->disable();
}
struct AllFlags : public Flag