]> git.stg.codes - stg.git/blob - projects/stargazer/plugins/other/smux/sensors.cpp
String coversion added to the sensors for debugging purpoces
[stg.git] / projects / stargazer / plugins / other / smux / sensors.cpp
1 #include "stg/INTEGER.h"
2
3 #include "stg/user.h"
4
5 #include "sensors.h"
6
7 bool UsersSensor::GetValue(ObjectSyntax_t * objectSyntax) const
8 {
9 int handle = users.OpenSearch();
10 if (!handle)
11     return false;
12
13 USER_PTR user;
14 size_t count = 0;
15 while (!users.SearchNext(handle, &user))
16     {
17     if (UserPredicate(user))
18         ++count;
19     }
20
21 users.CloseSearch(handle);
22
23 ValueToOS(count, objectSyntax);
24 return true;
25 }
26
27 #ifdef DEBUG
28 std::string UsersSensor::ToString() const
29 {
30 int handle = users.OpenSearch();
31 if (!handle)
32     return "";
33
34 USER_PTR user;
35 size_t count = 0;
36 while (!users.SearchNext(handle, &user))
37     {
38     if (UserPredicate(user))
39         ++count;
40     }
41
42 users.CloseSearch(handle);
43
44 std::string res;
45 x2str(count, res);
46 return res;
47 }
48 #endif