7 #include "stg/tariffs.h"
8 #include "stg/user_property.h"
10 #include "asn1/ObjectSyntax.h"
17 virtual bool GetValue(ObjectSyntax_t * objectSyntax) const = 0;
20 typedef std::map<OID, Sensor *> Sensors;
24 virtual bool appendTable(Sensors & sensors);
27 class TotalUsersSensor : public Sensor {
29 TotalUsersSensor(const USERS & u) : users(u) {}
30 virtual ~TotalUsersSensor() {}
32 bool GetValue(ObjectSyntax_t * objectSyntax) const
34 ValueToOS(users.GetUserNum(), objectSyntax);
42 class UsersSensor : public Sensor {
44 UsersSensor(USERS & u) : users(u) {}
45 virtual ~UsersSensor() {};
47 bool GetValue(ObjectSyntax_t * objectSyntax) const;
52 virtual bool UserPredicate(USER_PTR userPtr) const = 0;
55 class ConnectedUsersSensor : public UsersSensor {
57 ConnectedUsersSensor(USERS & u) : UsersSensor(u) {}
58 virtual ~ConnectedUsersSensor() {}
61 bool UserPredicate(USER_PTR userPtr) const
62 { return userPtr->GetConnected(); }
65 class AuthorizedUsersSensor : public UsersSensor {
67 AuthorizedUsersSensor(USERS & u) : UsersSensor(u) {}
68 virtual ~AuthorizedUsersSensor() {}
71 bool UserPredicate(USER_PTR userPtr) const
72 { return userPtr->GetAuthorized(); }
75 class AlwaysOnlineUsersSensor : public UsersSensor {
77 AlwaysOnlineUsersSensor(USERS & u) : UsersSensor(u) {}
78 virtual ~AlwaysOnlineUsersSensor() {}
81 bool UserPredicate(USER_PTR userPtr) const
82 { return userPtr->GetProperty().alwaysOnline; }
85 class NoCashUsersSensor : public UsersSensor {
87 NoCashUsersSensor(USERS & u) : UsersSensor(u) {}
88 virtual ~NoCashUsersSensor() {}
91 bool UserPredicate(USER_PTR userPtr) const
92 { return userPtr->GetProperty().cash < 0; }
95 class DisabledDetailStatsUsersSensor : public UsersSensor {
97 DisabledDetailStatsUsersSensor(USERS & u) : UsersSensor(u) {}
98 virtual ~DisabledDetailStatsUsersSensor() {}
101 bool UserPredicate(USER_PTR userPtr) const
102 { return userPtr->GetProperty().disabledDetailStat; }
105 class DisabledUsersSensor : public UsersSensor {
107 DisabledUsersSensor(USERS & u) : UsersSensor(u) {}
108 virtual ~DisabledUsersSensor() {}
111 bool UserPredicate(USER_PTR userPtr) const
112 { return userPtr->GetProperty().disabled; }
115 class PassiveUsersSensor : public UsersSensor {
117 PassiveUsersSensor(USERS & u) : UsersSensor(u) {}
118 virtual ~PassiveUsersSensor() {}
121 bool UserPredicate(USER_PTR userPtr) const
122 { return userPtr->GetProperty().passive; }
125 class CreditUsersSensor : public UsersSensor {
127 CreditUsersSensor(USERS & u) : UsersSensor(u) {}
128 virtual ~CreditUsersSensor() {}
131 bool UserPredicate(USER_PTR userPtr) const
132 { return userPtr->GetProperty().credit > 0; }
135 class FreeMbUsersSensor : public UsersSensor {
137 FreeMbUsersSensor(USERS & u) : UsersSensor(u) {}
138 virtual ~FreeMbUsersSensor() {}
141 bool UserPredicate(USER_PTR userPtr) const
142 { return userPtr->GetProperty().freeMb > 0; }
145 class TariffChangeUsersSensor : public UsersSensor {
147 TariffChangeUsersSensor(USERS & u) : UsersSensor(u) {}
148 virtual ~TariffChangeUsersSensor() {}
151 bool UserPredicate(USER_PTR userPtr) const
152 { return userPtr->GetProperty().nextTariff.ConstData().empty(); }
155 class TotalTariffsSensor : public Sensor {
157 TotalTariffsSensor(const TARIFFS & t) : tariffs(t) {}
158 virtual ~TotalTariffsSensor() {}
160 bool GetValue(ObjectSyntax_t * objectSyntax) const
162 ValueToOS(tariffs.GetTariffsNum(), objectSyntax);
167 const TARIFFS & tariffs;
170 template <typename T>
171 class ConstSensor : public Sensor {
173 ConstSensor(const T & v) : value(v) {}
174 virtual ~ConstSensor() {}
176 bool GetValue(ObjectSyntax * objectSyntax) const
177 { return ValueToOS(value, objectSyntax); }