UHD  003.001.002
props.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2010-2011 Ettus Research LLC
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 //
17 
18 #ifndef INCLUDED_UHD_UTILS_PROPS_HPP
19 #define INCLUDED_UHD_UTILS_PROPS_HPP
20 
21 #include <uhd/config.hpp>
22 #include <uhd/wax.hpp>
23 #include <uhd/exception.hpp>
24 #include <vector>
25 #include <string>
26 
27 namespace uhd{
28 
30  typedef std::vector<std::string> prop_names_t;
31 
37  const wax::obj key;
38  const std::string name;
39 
41  template<typename T> inline T as(void){
42  return key.as<T>();
43  }
44 
53  static named_prop_t extract(
54  const wax::obj &key, const std::string &name = ""
55  );
56 
62  named_prop_t(const wax::obj &key, const std::string &name);
63  };
64 
69  #define UHD_THROW_PROP_GET_ERROR() \
70  throw uhd::key_error(UHD_THROW_SITE_INFO("cannot get this property"))
71 
76  #define UHD_THROW_PROP_SET_ERROR() \
77  throw uhd::key_error(UHD_THROW_SITE_INFO("cannot set this property"))
78 
79 } //namespace uhd
80 
81 #endif /* INCLUDED_UHD_UTILS_PROPS_HPP */
T as(void) const
Definition: wax.hpp:139
T as(void)
Convert the key to the specified type.
Definition: props.hpp:41
const std::string name
Definition: props.hpp:38
#define UHD_API
Definition: config.hpp:76
Definition: convert.hpp:28
Definition: wax.hpp:64
const wax::obj key
Definition: props.hpp:37
std::vector< std::string > prop_names_t
The type for a vector of property names.
Definition: props.hpp:30
Definition: props.hpp:36