diff options
Diffstat (limited to 'host')
-rw-r--r-- | host/include/uhd/types/sensors.hpp | 17 | ||||
-rw-r--r-- | host/lib/types/sensors.cpp | 15 |
2 files changed, 28 insertions, 4 deletions
diff --git a/host/include/uhd/types/sensors.hpp b/host/include/uhd/types/sensors.hpp index 529e1e3e3..de1ed014f 100644 --- a/host/include/uhd/types/sensors.hpp +++ b/host/include/uhd/types/sensors.hpp @@ -91,6 +91,12 @@ namespace uhd{ const std::string &unit ); + /*! + * Create a sensor value from another sensor value. + * \param source the source sensor value to copy + */ + sensor_value_t(const sensor_value_t& source); + //! convert the sensor value to a boolean bool to_bool(void) const; @@ -101,21 +107,21 @@ namespace uhd{ double to_real(void) const; //! The name of the sensor value - const std::string name; + std::string name; /*! * The sensor value as a string. * For integer and real number types, this will be the output of the formatter. * For boolean types, the value will be the string literal "true" or "false". */ - const std::string value; + std::string value; /*! * The sensor value's unit type. * For boolean types, this will be the one of the two units * depending upon the value of the boolean true or false. */ - const std::string unit; + std::string unit; //! Enumeration of possible data types in a sensor enum data_type_t { @@ -126,10 +132,13 @@ namespace uhd{ }; //! The data type of the value - const data_type_t type; + data_type_t type; //! Convert this sensor value into a printable string std::string to_pp_string(void) const; + + //! Assignment operator for sensor value + sensor_value_t& operator=(const sensor_value_t& value); }; } //namespace uhd diff --git a/host/lib/types/sensors.cpp b/host/lib/types/sensors.cpp index 52a63d14c..0406e35d4 100644 --- a/host/lib/types/sensors.cpp +++ b/host/lib/types/sensors.cpp @@ -69,6 +69,12 @@ sensor_value_t::sensor_value_t( /* NOP */ } +sensor_value_t::sensor_value_t(const sensor_value_t& source) +{ + *this = source; +} + + std::string sensor_value_t::to_pp_string(void) const{ switch(type){ case BOOLEAN: @@ -92,3 +98,12 @@ signed sensor_value_t::to_int(void) const{ double sensor_value_t::to_real(void) const{ return boost::lexical_cast<double>(value); } + +sensor_value_t& sensor_value_t::operator=(const sensor_value_t& rhs) +{ + this->name = rhs.name; + this->value = rhs.value; + this->unit = rhs.unit; + this->type = rhs.type; + return *this; +} |