30 ifstream in(inputFile.c_str());
32 throw invalid_argument(
"ProjectParametersParser(const string&): Cannot open input file \""+inputFile+
"\"!");
35 vector<string> fileLines;
36 while (getline(in,line)) {
37 bool onlySpaces =
true;
38 for (
const char& c : line) {
39 if (c !=
' ' && c !=
'\t')
43 if (!onlySpaces && find(line.cbegin(), line.cend(),
'#') == line.cend())
44 fileLines.push_back(line);
49 bool fileParsedCorrectly =
true;
50 for (
const string& line : fileLines) {
54 istringstream istr(line, istringstream::in);
57 if (!(istr>>mParsedParameters.numberOfRobots))
58 cerr<<
"Cannot parse the number of robots!"<<endl;
61 while (istr>>inputPowerOfMode)
62 mParsedParameters.inputPowerOfModes.push_back(inputPowerOfMode);
67 if (mParsedParameters.inputPowerOfModes.empty())
68 cerr<<
"Cannot read the input power of the power save mode!"<<endl;
71 while (istr>>minDelayOfMode)
72 mParsedParameters.minDelayOfModes.push_back(minDelayOfMode);
77 if (mParsedParameters.minDelayOfModes.empty())
78 cerr<<
"Cannot read the minimal delays of the robot's static power save modes!"<<endl;
81 if (!(istr>>mParsedParameters.minDurationOfMovement>>mParsedParameters.prolongationOfMovement))
82 cerr<<
"Cannot read the minimum and maximum time intervals of movements!"<<endl;
86 mParsedParameters.energyFunctionCoefficients.push_back(coeff);
91 if (mParsedParameters.energyFunctionCoefficients.empty())
92 cerr<<
"Coefficients of energy functions were not specified!"<<endl;
95 if (!(istr>>mParsedParameters.degreeOfCoefficients))
96 cerr<<
"Cannot parse the range of powers for coefficients!"<<endl;
99 if (!(istr>>mParsedParameters.minDurationOfOperation>>mParsedParameters.prolongationOfOperation))
100 cerr<<
"Cannot read the minimum and maximum time intervals of staying in the stationary position!"<<endl;
103 if (!(istr>>mParsedParameters.numberOfPoints))
104 cerr<<
"Cannot read the number of points interval!"<<endl;
107 if (!(istr>>mParsedParameters.numberOfSequences))
108 cerr<<
"The average number of sequences for assembling/disassembling operations was not specified!"<<endl;
111 if (!(istr>>mParsedParameters.sequenceLength))
112 cerr<<
"The interval of the length of the assembling/disassembling sequences was not specified!"<<endl;
115 if (!(istr>>mParsedParameters.minimalVertexDegree))
116 cerr<<
"The interval of the minimal degree of the vertex cannot be read!"<<endl;
119 if (!(istr>>mParsedParameters.percentageOfTableHandover))
120 cerr<<
"Cannot read the probability of handovers using tables!"<<endl;
123 if (!(istr>>mParsedParameters.percentageOfRobotsHandover))
124 cerr<<
"Cannot read the probability of the robot handovers!"<<endl;
127 if (!(istr>>mParsedParameters.numberOfCollisions))
128 cerr<<
"Cannot read the interval specifying the number of collisions!"<<endl;
131 if (!(istr>>mParsedParameters.dilatationFactor))
132 cerr<<
"Cannot read the dilatation factor!"<<endl;
135 clog<<
"Ignoring line "<<lineNumber<<
"..."<<endl;
139 fileParsedCorrectly =
false;
145 if (!fileParsedCorrectly || lineNumber <= 15)
146 throw runtime_error(
"ProjectParametersParser(const string&): Error has occured during parsing of the configuration file!");
149 throw runtime_error(
"ProjectParametersParser(const string&): Invalid value(s) in the config file!");
ProjectParametersParser(std::string inputFile=Settings::PROJECT_CONFIGURATION_FILE)
It parses the configuration file and fills ProjectParameters structure. Input configuration file is b...
It declares the class for parsing the desired properties of project instances.
The file declares the structure for storing the properties of generated instances.
bool checkProjectParameters(const ProjectParameters &par)
The function checks that the desired properties of instances are logically correct.
The file declares the Interval class and its iostream operators.