mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-19 00:07:13 +02:00
Exposing vector of strings for loading parameters (#147)
This commit is contained in:
@ -60,29 +60,31 @@ void Detector::loadConfig(const std::string &fname) {
|
||||
}
|
||||
|
||||
void Detector::loadParameters(const std::string &fname) {
|
||||
CmdProxy proxy(this);
|
||||
CmdParser parser;
|
||||
std::ifstream input_file;
|
||||
input_file.open(fname.c_str(), std::ios_base::in);
|
||||
if (!input_file.is_open()) {
|
||||
std::ifstream input_file(fname);
|
||||
if (!input_file) {
|
||||
throw RuntimeError("Could not open configuration file " + fname +
|
||||
" for reading");
|
||||
}
|
||||
std::string current_line;
|
||||
while (input_file.good()) {
|
||||
getline(input_file, current_line);
|
||||
if (current_line.find('#') != std::string::npos) {
|
||||
current_line.erase(current_line.find('#'));
|
||||
std::vector<std::string> parameters;
|
||||
for (std::string line; std::getline(input_file, line);) {
|
||||
if (line.find('#') != std::string::npos) {
|
||||
line.erase(line.find('#'));
|
||||
}
|
||||
LOG(logDEBUG1) << "current_line after removing comments:\n\t"
|
||||
<< current_line;
|
||||
if (current_line.length() > 1) {
|
||||
parser.Parse(current_line);
|
||||
proxy.Call(parser.command(), parser.arguments(),
|
||||
parser.detector_id(), defs::PUT_ACTION);
|
||||
if (line.length() > 1) {
|
||||
parameters.push_back(line);
|
||||
}
|
||||
}
|
||||
input_file.close();
|
||||
loadParameters(parameters);
|
||||
}
|
||||
|
||||
void Detector::loadParameters(const std::vector<std::string> ¶meters) {
|
||||
CmdProxy proxy(this);
|
||||
CmdParser parser;
|
||||
for (const auto ¤t_line : parameters) {
|
||||
parser.Parse(current_line);
|
||||
proxy.Call(parser.command(), parser.arguments(), parser.detector_id(),
|
||||
defs::PUT_ACTION);
|
||||
}
|
||||
}
|
||||
|
||||
Result<std::string> Detector::getHostname(Positions pos) const {
|
||||
|
Reference in New Issue
Block a user