X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/0907aa4037b12b6b88ee24495d4577a064d4f8db..32d9767958eece65c3d6feb02419a3f003dc2f0a:/projects/stargazer/plugins/other/smux/sensors.h
diff --git a/projects/stargazer/plugins/other/smux/sensors.h b/projects/stargazer/plugins/other/smux/sensors.h
index 92151807..039aa530 100644
--- a/projects/stargazer/plugins/other/smux/sensors.h
+++ b/projects/stargazer/plugins/other/smux/sensors.h
@@ -1,7 +1,7 @@
-#ifndef __SENSORS_H__
-#define __SENSORS_H__
+#pragma once
-#include <map>
+#include "value2os.h"
+#include "types.h"
#include "stg/users.h"
#include "stg/user.h"
@@ -12,15 +12,17 @@
#include "stg/traffcounter.h"
#include "stg/user_property.h"
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wold-style-cast"
#include "stg/ObjectSyntax.h"
+#pragma GCC diagnostic pop
-#include "value2os.h"
-#include "types.h"
+#include <map>
class Sensor {
public:
virtual ~Sensor() = default;
- virtual bool GetValue(ObjectSyntax_t * objectSyntax) const = 0;
+ virtual void GetValue(ObjectSyntax_t * objectSyntax) const = 0;
#ifdef DEBUG
virtual std::string ToString() const = 0;
#endif
@@ -32,15 +34,14 @@ class TotalUsersSensor : public Sensor {
public:
explicit TotalUsersSensor(const STG::Users & u) : users(u) {}
- bool GetValue(ObjectSyntax_t * objectSyntax) const override
+ void GetValue(ObjectSyntax_t * objectSyntax) const override
{
ValueToOS(users.Count(), objectSyntax);
- return true;
}
#ifdef DEBUG
std::string ToString() const override
- { std::string res; std::to_string(users.Count(), res); return res; }
+ { return std::to_string(users.Count()); }
#endif
private:
@@ -51,7 +52,7 @@ class UsersSensor : public Sensor {
public:
explicit UsersSensor(STG::Users & u) : users(u) {}
- bool GetValue(ObjectSyntax_t * objectSyntax) const override;
+ void GetValue(ObjectSyntax_t * objectSyntax) const override;
#ifdef DEBUG
std::string ToString() const override;
#endif
@@ -164,15 +165,14 @@ class TotalTariffsSensor : public Sensor {
public:
explicit TotalTariffsSensor(const STG::Tariffs & t) : tariffs(t) {}
- bool GetValue(ObjectSyntax_t * objectSyntax) const override
+ void GetValue(ObjectSyntax_t * objectSyntax) const override
{
ValueToOS(tariffs.Count(), objectSyntax);
- return true;
}
#ifdef DEBUG
std::string ToString() const override
- { std::string res; std::to_string(tariffs.Count(), res); return res; }
+ { return std::to_string(tariffs.Count()); }
#endif
private:
@@ -183,15 +183,14 @@ class TotalAdminsSensor : public Sensor {
public:
explicit TotalAdminsSensor(const STG::Admins & a) : admins(a) {}
- bool GetValue(ObjectSyntax_t * objectSyntax) const override
+ void GetValue(ObjectSyntax_t * objectSyntax) const override
{
ValueToOS(admins.count(), objectSyntax);
- return true;
}
#ifdef DEBUG
std::string ToString() const override
- { std::string res; std::to_string(admins.Count(), res); return res; }
+ { return std::to_string(admins.count()); }
#endif
private:
@@ -202,15 +201,14 @@ class TotalServicesSensor : public Sensor {
public:
explicit TotalServicesSensor(const STG::Services & s) : services(s) {}
- bool GetValue(ObjectSyntax_t * objectSyntax) const override
+ void GetValue(ObjectSyntax_t * objectSyntax) const override
{
ValueToOS(services.Count(), objectSyntax);
- return true;
}
#ifdef DEBUG
std::string ToString() const override
- { std::string res; std::to_string(services.Count(), res); return res; }
+ { return std::to_string(services.Count()); }
#endif
private:
@@ -221,15 +219,14 @@ class TotalCorporationsSensor : public Sensor {
public:
explicit TotalCorporationsSensor(const STG::Corporations & c) : corporations(c) {}
- bool GetValue(ObjectSyntax_t * objectSyntax) const override
+ void GetValue(ObjectSyntax_t * objectSyntax) const override
{
ValueToOS(corporations.Count(), objectSyntax);
- return true;
}
#ifdef DEBUG
std::string ToString() const override
- { std::string res; std::to_string(corporations.Count(), res); return res; }
+ { return std::to_string(corporations.Count()); }
#endif
private:
@@ -240,15 +237,14 @@ class TotalRulesSensor : public Sensor {
public:
explicit TotalRulesSensor(const STG::TraffCounter & t) : traffcounter(t) {}
- bool GetValue(ObjectSyntax_t * objectSyntax) const override
+ void GetValue(ObjectSyntax_t * objectSyntax) const override
{
ValueToOS(traffcounter.rulesCount(), objectSyntax);
- return true;
}
#ifdef DEBUG
std::string ToString() const override
- { std::string res; std::to_string(traffcounter.rulesCount(), res); return res; }
+ { return std::to_string(traffcounter.rulesCount()); }
#endif
private:
@@ -260,12 +256,14 @@ class ConstSensor : public Sensor {
public:
explicit ConstSensor(const T & v) : value(v) {}
- bool GetValue(ObjectSyntax * objectSyntax) const override
- { return ValueToOS(value, objectSyntax); }
+ void GetValue(ObjectSyntax * objectSyntax) const override
+ {
+ ValueToOS(value, objectSyntax);
+ }
#ifdef DEBUG
std::string ToString() const override
- { std::string res; std::to_string(value, res); return res; }
+ { return std::to_string(value); }
#endif
private:
@@ -280,5 +278,3 @@ std::string ConstSensor<std::string>::ToString() const
return value;
}
#endif
-
-#endif