]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/other/smux/sensors.cpp
Register smux plugin as .stg24, not as a root
[stg.git] / projects / stargazer / plugins / other / smux / sensors.cpp
index 7721d7b7dc3831a4889bb6225992d8e29c9cf18c..9cfdadd074bf053e1d61b82cbb41c6246816cfb1 100644 (file)
@@ -1,3 +1,5 @@
+#include <cassert>
+
 #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