trick/trick_source/sim_services/MonteCarlo/MonteVarFixed.cpp

29 lines
761 B
C++
Raw Normal View History

2015-02-26 15:02:31 +00:00
#include <sstream>
#include <iomanip>
2015-02-26 15:02:31 +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;
set_value(in_value);
this->unit = in_unit;
}
void Trick::MonteVarFixed::set_value(double in_value) {
2015-02-26 15:02:31 +00:00
std::ostringstream string_stream;
string_stream << std::setprecision(15) << in_value ;
2015-02-26 15:02:31 +00:00
this->value = string_stream.str();
}
2015-02-26 15:02:31 +00:00
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();
}