2015-02-26 15:02:31 +00:00
|
|
|
#include <sstream>
|
2015-08-04 20:46:44 +00:00
|
|
|
#include <iomanip>
|
2015-02-26 15:02:31 +00:00
|
|
|
|
2015-06-01 15:28:29 +00:00
|
|
|
#include "trick/MonteVarFixed.hh"
|
2015-02-26 15:02:31 +00:00
|
|
|
|
|
|
|
Trick::MonteVarFixed::MonteVarFixed(std::string in_name, double in_value, std::string in_unit) {
|
|
|
|
this->name = in_name;
|
2016-10-03 19:57:11 +00:00
|
|
|
set_value(in_value);
|
|
|
|
this->unit = in_unit;
|
|
|
|
}
|
|
|
|
|
2017-10-10 15:30:28 +00:00
|
|
|
// Composite the various properties of this MonteVarFixed.
|
|
|
|
std::string Trick::MonteVarFixed::describe_variable()
|
|
|
|
{
|
|
|
|
std::stringstream ss;
|
|
|
|
|
|
|
|
ss << "#NAME:\t" << this->name << "\n"
|
|
|
|
<< "#TYPE:\tFIXED\n"
|
|
|
|
<< "#UNIT:\t" << this->unit << "\n";
|
|
|
|
|
|
|
|
return ss.str();
|
|
|
|
}
|
|
|
|
|
2016-10-03 19:57:11 +00:00
|
|
|
void Trick::MonteVarFixed::set_value(double in_value) {
|
2015-02-26 15:02:31 +00:00
|
|
|
std::ostringstream string_stream;
|
2015-08-04 20:46:44 +00:00
|
|
|
string_stream << std::setprecision(15) << in_value ;
|
2015-02-26 15:02:31 +00:00
|
|
|
this->value = string_stream.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string Trick::MonteVarFixed::get_next_value() {
|
|
|
|
std::ostringstream string_stream;
|
|
|
|
if (unit.empty()) {
|
|
|
|
string_stream << name << " = " << value;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
string_stream << name << " = trick.attach_units(\"" << unit << "\", " << value << ")";
|
|
|
|
}
|
|
|
|
return string_stream.str();
|
|
|
|
}
|