| 31 | } |
| 32 | |
| 33 | Value GetTargetByName([[maybe_unused]] const String& type, const String& name) const override |
| 34 | { |
| 35 | Namespace::Ptr statsFunctions = ScriptGlobal::Get("StatsFunctions", &Empty); |
| 36 | |
| 37 | if (!statsFunctions) |
| 38 | BOOST_THROW_EXCEPTION(std::invalid_argument("No status functions are available.")); |
| 39 | |
| 40 | Value vfunc; |
| 41 | |
| 42 | if (!statsFunctions->Get(name, &vfunc)) |
| 43 | BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid status function name.")); |
| 44 | |
| 45 | Function::Ptr func = vfunc; |
| 46 | |
| 47 | if (!func) |
| 48 | BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid status function name.")); |
| 49 | |
| 50 | Dictionary::Ptr status = new Dictionary(); |
| 51 | Array::Ptr perfdata = new Array(); |
| 52 | func->Invoke({ status, perfdata }); |
| 53 | |
| 54 | return new Dictionary({ |
| 55 | { "name", name }, |
| 56 | { "status", status }, |
| 57 | { "perfdata", Serialize(perfdata, FAState) } |
| 58 | }); |
| 59 | } |
| 60 | |
| 61 | bool IsValidType(const String& type) const override |
| 62 | { |