X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/2dd96d1468a065ebee3e37b1defcf2c438d72e2f..a3c9db8d7d653af9ef42198452c50c7dc648f0d1:/projects/stargazer/plugins/other/smux/sensors.cpp diff --git a/projects/stargazer/plugins/other/smux/sensors.cpp b/projects/stargazer/plugins/other/smux/sensors.cpp index 48809032..9cfdadd0 100644 --- a/projects/stargazer/plugins/other/smux/sensors.cpp +++ b/projects/stargazer/plugins/other/smux/sensors.cpp @@ -1,4 +1,6 @@ -#include "asn1/INTEGER.h" +#include + +#include "stg/INTEGER.h" #include "stg/user.h" @@ -7,8 +9,7 @@ bool UsersSensor::GetValue(ObjectSyntax_t * objectSyntax) const { int handle = users.OpenSearch(); -if (!handle) - return false; +assert(handle && "USERS::OpenSearch is always correct"); USER_PTR user; size_t count = 0; @@ -23,3 +24,25 @@ users.CloseSearch(handle); ValueToOS(count, objectSyntax); return true; } + +#ifdef DEBUG +std::string UsersSensor::ToString() const +{ +int handle = users.OpenSearch(); +assert(handle && "USERS::OpenSearch is always correct"); + +USER_PTR user; +size_t count = 0; +while (!users.SearchNext(handle, &user)) + { + if (UserPredicate(user)) + ++count; + } + +users.CloseSearch(handle); + +std::string res; +x2str(count, res); +return res; +} +#endif