MCPcopy Create free account
hub / github.com/DFHack/dfhack / unsetFilter

Function unsetFilter

plugins/debug.cpp:959–998  ·  view source on GitHub ↗

Handler for debugfilter unset

Source from the content-addressed store, hash-verified

957
958//! Handler for debugfilter unset
959static command_result unsetFilter(color_ostream& out,
960 std::vector<std::string>& parameters)
961{
962 std::set<DebugCategory*> modified;
963 std::vector<FilterManager::iterator> toErase;
964 return applyFilterIds(out,parameters,"unset",
965 // Per item
966 [&modified, &toErase](FilterManager::iterator& iter) -> bool {
967 Filter& filter = iter->second;
968 if (filter.enabled()) {
969 auto& catMan = DebugManager::getInstance();
970 for (DebugCategory* cat: catMan) {
971 if (filter.remove(*cat))
972 modified.emplace(cat);
973 }
974 }
975 toErase.emplace_back(iter);
976 return false;
977 },
978 // After list
979 [&modified,&toErase,&out]() {
980 auto& filMan = FilterManager::getInstance();
981 bool mustSave = false;
982 for (auto iter: toErase) {
983 mustSave = mustSave || iter->second.persistent();
984 filMan.erase(iter);
985 }
986
987 for (DebugCategory* cat: modified) {
988 // Reset filtering back to default
989 cat->allowed(DebugCategory::LWARNING);
990 // Reapply all remaining filters
991 for (auto& filterPair: filMan)
992 filterPair.second.applyAgain(*cat);
993 }
994 if (mustSave)
995 return FilterManager::getInstance().saveConfig(out);
996 return CR_OK;
997 });
998}
999
1000static const int welement = 16;
1001static const int wsetting = 12;

Callers

nothing calls this directly

Calls 8

applyFilterIdsFunction · 0.85
persistentMethod · 0.80
allowedMethod · 0.80
applyAgainMethod · 0.80
saveConfigMethod · 0.80
enabledMethod · 0.45
removeMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected