aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorAshish Chaudhari <ashish@ettus.com>2015-08-25 13:44:46 -0700
committerAshish Chaudhari <ashish@ettus.com>2016-02-11 14:36:20 -0800
commit0d74d16093c9350205eb704b1aa6a4bcefa5667d (patch)
treedf9a27fb73a00da8ad5724bf2be41c14fc3af3be /host
parente9bd85c60b5de5f2979d8bf2886d3931aa03f1c8 (diff)
downloaduhd-0d74d16093c9350205eb704b1aa6a4bcefa5667d.tar.gz
uhd-0d74d16093c9350205eb704b1aa6a4bcefa5667d.tar.bz2
uhd-0d74d16093c9350205eb704b1aa6a4bcefa5667d.zip
lib: Made sensor_value_t copyable
- Added copy ctor and assignment operator - Possibly ABI breaking
Diffstat (limited to 'host')
-rw-r--r--host/include/uhd/types/sensors.hpp17
-rw-r--r--host/lib/types/sensors.cpp15
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;
+}