UHD  003.003.002
include/uhd/types/sensors.hpp
Go to the documentation of this file.
00001 //
00002 // Copyright 2011 Ettus Research LLC
00003 //
00004 // This program is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 
00018 #ifndef INCLUDED_UHD_TYPES_SENSORS_HPP
00019 #define INCLUDED_UHD_TYPES_SENSORS_HPP
00020 
00021 #include <uhd/config.hpp>
00022 #include <string>
00023 
00024 namespace uhd{
00025 
00038     struct UHD_API sensor_value_t{
00039 
00047         sensor_value_t(
00048             const std::string &name,
00049             bool value,
00050             const std::string &utrue,
00051             const std::string &ufalse
00052         );
00053 
00061         sensor_value_t(
00062             const std::string &name,
00063             signed value,
00064             const std::string &unit,
00065             const std::string &formatter = "%d"
00066         );
00067 
00075         sensor_value_t(
00076             const std::string &name,
00077             double value,
00078             const std::string &unit,
00079             const std::string &formatter = "%f"
00080         );
00081 
00088         sensor_value_t(
00089             const std::string &name,
00090             const std::string &value,
00091             const std::string &unit
00092         );
00093 
00095         bool to_bool(void) const;
00096 
00098         signed to_int(void) const;
00099 
00101         double to_real(void) const;
00102 
00104         const std::string name;
00105 
00111         const std::string value;
00112 
00118         const std::string unit;
00119 
00121         enum data_type_t {
00122             BOOLEAN = 'b',
00123             INTEGER = 'i',
00124             REALNUM = 'r',
00125             STRING  = 's'
00126         };
00127 
00129         const data_type_t type;
00130 
00132         std::string to_pp_string(void) const;
00133     };
00134 
00135 } //namespace uhd
00136 
00137 #endif /* INCLUDED_UHD_TYPES_SENSORS_HPP */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines