AstraLog-HPC
Loading...
Searching...
No Matches
Validator Class Reference

Validates incoming raw telemetry packets against a known set of sensors. More...

#include <Validator.hpp>

Collaboration diagram for Validator:
Collaboration graph

Public Member Functions

 Validator (const std::string &path)
 Constructs a new Validator and loads the allowed sensors from a configuration file.
 
 ~Validator ()=default
 Default destructor.
 
ValidationResult evaluate (const std::string &json)
 Validates a raw JSON telemetry packet.
 
int get_sensor_count ()
 Gets the total number of valid sensors loaded from the configuration file.
 

Private Member Functions

void load_sensors (const std::string &path)
 Parses the configuration file and populates the internal set of allowed sensors.
 

Private Attributes

simdjson::ondemand::parser parser
 The simdjson parser instance used for fast JSON processing.
 
std::unordered_set< std::string > sensors
 The set of valid sensor IDs loaded from the configuration.
 
int sensor_count = 0
 The total number of valid sensors loaded.
 

Detailed Description

Validates incoming raw telemetry packets against a known set of sensors.

Note
This class uses the simdjson library for high-performance JSON parsing.

Constructor & Destructor Documentation

◆ Validator()

Validator::Validator ( const std::string &  path)
inline

Constructs a new Validator and loads the allowed sensors from a configuration file.

Parameters
pathThe file path to the sensors configuration file (e.g., YAML format).
Here is the call graph for this function:

◆ ~Validator()

Validator::~Validator ( )
default

Default destructor.

Member Function Documentation

◆ evaluate()

ValidationResult Validator::evaluate ( const std::string &  json)

Validates a raw JSON telemetry packet.

Parameters
jsonRaw JSON string received from the MQTT broker.
Returns
A ValidationResult describing the outcome. sensor_id and timestamp are populated once both parse as strings, even if the packet is later rejected.
Here is the caller graph for this function:

◆ get_sensor_count()

int Validator::get_sensor_count ( )

Gets the total number of valid sensors loaded from the configuration file.

Returns
The number of loaded sensors.
Here is the caller graph for this function:

◆ load_sensors()

void Validator::load_sensors ( const std::string &  path)
private

Parses the configuration file and populates the internal set of allowed sensors.

Parameters
pathThe file path to the sensors configuration file.
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ parser

simdjson::ondemand::parser Validator::parser
private

The simdjson parser instance used for fast JSON processing.

◆ sensor_count

int Validator::sensor_count = 0
private

The total number of valid sensors loaded.

◆ sensors

std::unordered_set<std::string> Validator::sensors
private

The set of valid sensor IDs loaded from the configuration.


The documentation for this class was generated from the following files: