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

Function disableFilter

plugins/debug.cpp:881–916  ·  view source on GitHub ↗

Handler for debugfilter disable

Source from the content-addressed store, hash-verified

879
880//! Handler for debugfilter disable
881static command_result disableFilter(color_ostream& out,
882 std::vector<std::string>& parameters)
883{
884 std::set<DebugCategory*> modified;
885 bool mustSave = false;
886 return applyFilterIds(out,parameters,"disable",
887 // Per item
888 [&modified,&mustSave](FilterManager::iterator& iter) -> bool {
889 Filter& filter = iter->second;
890 bool enabled = filter.enabled();
891 if (enabled == false)
892 return true;
893 auto& catMan = DebugManager::getInstance();
894 for (DebugCategory* cat: catMan) {
895 if (filter.remove(*cat))
896 modified.emplace(cat);
897 }
898 filter.enabled(false);
899 mustSave = mustSave || filter.persistent();
900 return false;
901 },
902 // After list
903 [&modified,&mustSave,&out]() {
904 for (DebugCategory* cat: modified) {
905 // Reset filtering back to default
906 cat->allowed(DebugCategory::LWARNING);
907 auto& filMan = FilterManager::getInstance();
908 // Reapply all remaining filters
909 for (auto& filterPair: filMan)
910 filterPair.second.applyAgain(*cat);
911 }
912 if (mustSave)
913 return FilterManager::getInstance().saveConfig(out);
914 return CR_OK;
915 });
916}
917
918//! Handler for debugfilter enable
919static command_result enableFilter(color_ostream& out,

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected