49 : MetaLog::Entity(header_) {
57 int32_t now = (int32_t)time(0);
58 for (
auto &spec : specs) {
60 String msg =
format(
"System state %s=%s set administratively.",
62 spec.value ?
"true" :
"false");
83 int32_t now = (int32_t)time(0);
85 String msg =
format(
"System state %s=%s set administratively.",
87 value ?
"true" :
"false");
109 value ?
"true" :
"false", reason.c_str());
110 int32_t now = (int32_t)time(0);
130 uint64_t *generation) {
144 specs.push_back(spec);
153 return !notifications.empty();
158 uint64_t *generation) {
170 specs.push_back(spec);
189 uint16_t definition_version) {
190 if (definition_version < 4) {
194 Entity::decode(bufp, remainp);
206 length += spec.encoded_length() + 4;
209 length += spec.encoded_length() + 4;
233 for (
int i=0; i<count; i++) {
234 spec.
decode(bufp, remainp);
248 for (
int i=0; i<count; i++) {
249 spec.
decode(bufp, remainp);
270 for (
int i=0; i<count; i++) {
286 for (
int i=0; i<count; i++) {
void display(std::ostream &os) override
Return textual representation of entity state.
void get(std::vector< SystemVariable::Spec > &specs, uint64_t *generation)
Get system variables and generation number.
std::vector< int32_t > m_auto_last_notification
Last notification times for auto set variables.
void decode(const uint8_t **bufp, size_t *remainp, uint16_t definition_version) override
Decodes system state.
Holds a notification message to be deliverd to the administrator.
PropertiesPtr properties
This singleton map stores all options.
std::string String
A String is simply a typedef to std::string.
String format(const char *fmt,...)
Returns a String using printf like format facilities Vanilla snprintf is about 1.5x faster than this...
void decode_internal(uint8_t version, const uint8_t **bufp, size_t *remainp) override
Reads serialized representation of object from a buffer.
bool admin_set(const std::vector< SystemVariable::Spec > &specs)
Set a vector of variables by administrator.
int32_t code
Variable code.
bool default_value(int var_code)
Returns default value for given variable.
std::string specs_to_string(const std::vector< Spec > &specs)
Returns a textual representation of variable specifications.
std::vector< NotificationMessage > m_notifications
Pending notification messages.
uint32_t decode_i32(const uint8_t **bufp, size_t *remainp)
Decode a 32-bit integer in little-endian order.
uint64_t decode_i64(const uint8_t **bufp, size_t *remainp)
Decode a 64-bit integer in little-endian order.
Declarations for SystemState.
uint64_t m_generation
Generation number incremented with each state change.
void get_non_default(std::vector< SystemVariable::Spec > &specs, uint64_t *generation=0)
Get system state variables that are not set to their default value.
size_t encoded_length_internal() const override
Returns internal serialized length.
bool decode_bool(const uint8_t **bufp, size_t *remainp)
Decodes a boolean value from the given buffer.
void encode_i32(uint8_t **bufp, uint32_t val)
Encode a 32-bit integer in little-endian order.
Compatibility Macros for C/C++.
void encode_i64(uint8_t **bufp, uint64_t val)
Encode a 64-bit integer in little-endian order.
Functions to serialize/deserialize primitives to/from a memory buffer.
Holds a variable code and boolean value.
std::vector< int32_t > m_admin_last_notification
Last notification times for admin set variables.
virtual void decode(const uint8_t **bufp, size_t *remainp)
Reads serialized representation of object from a buffer.
void decode_old(const uint8_t **bufp, size_t *remainp)
std::vector< SystemVariable::Spec > m_auto_specified
Automatically set state variables.
bool auto_set(int code, bool value, const String &reason)
Set a variable by automated condition.
SystemState()
Constructor.
void encode_internal(uint8_t **bufp) const override
Writes serialized representation of object to a buffer.
int32_t m_notification_interval
Notification interval in seconds.
bool value
Variable value.
std::vector< SystemVariable::Spec > m_admin_specified
Administratively set state variables.
uint8_t encoding_version() const override
Returns encoding version.
bool get_notifications(std::vector< NotificationMessage > ¬ifications)
Get pending notifications.
const char * code_to_string(int var_code)
Converts variable code to variable string.