Skip to content
Snippets Groups Projects
Forked from asapo / asapo
2150 commits behind the upstream repository.
receiver_config.cpp 971 B
#include "receiver_config.h"
#include "receiver_config_factory.h"
#include "io/io_factory.h"
#include "json_parser/json_parser.h"

namespace hidra2 {

ReceiverConfig config;

ReceiverConfigFactory::ReceiverConfigFactory() : io__{GenerateDefaultIO()} {

}

Error ReceiverConfigFactory::SetConfigFromFile(std::string file_name) {
    JsonFileParser parser(file_name, &io__);
    Error err;
    (err = parser.GetString("MonitorDbAddress", &config.monitor_db_uri)) ||
    (err = parser.GetUInt64("ListenPort", &config.listen_port)) ||
    (err = parser.GetBool("WriteToDisk", &config.write_to_disk)) ||
    (err = parser.GetBool("WriteToDb", &config.write_to_db)) ||
    (err = parser.GetString("BrokerDbAddress", &config.broker_db_uri)) ||
    (err = parser.GetString("BrokerDbName", &config.broker_db_name)) ||

    (err = parser.GetString("MonitorDbName", &config.monitor_db_name));
    return err;
}

const ReceiverConfig*  GetReceiverConfig() {
    return &config;
}


}