summaryrefslogtreecommitdiffstats
path: root/host/include
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-03-15 17:43:10 -0700
committerJosh Blum <josh@joshknows.com>2010-03-15 17:43:10 -0700
commitfc40ff2f1327d01c72c4d7dbc07a14e473251981 (patch)
treead7f1ed847d284c3982157e1c43a13773a6aca9c /host/include
parente4997af8453980922b469e5d3b66a7b26910dad3 (diff)
downloaduhd-fc40ff2f1327d01c72c4d7dbc07a14e473251981.tar.gz
uhd-fc40ff2f1327d01c72c4d7dbc07a14e473251981.tar.bz2
uhd-fc40ff2f1327d01c72c4d7dbc07a14e473251981.zip
Replaced uses of wax:cast with the templated as method (like in boost program options).
Diffstat (limited to 'host/include')
-rw-r--r--host/include/uhd/gain_handler.hpp2
-rw-r--r--host/include/uhd/props.hpp2
-rw-r--r--host/include/uhd/wax.hpp43
3 files changed, 16 insertions, 31 deletions
diff --git a/host/include/uhd/gain_handler.hpp b/host/include/uhd/gain_handler.hpp
index 2d3f8a3f4..a71d63c84 100644
--- a/host/include/uhd/gain_handler.hpp
+++ b/host/include/uhd/gain_handler.hpp
@@ -74,7 +74,7 @@ public:
*/
template <class T> static bool is_equal(const wax::obj &a, const wax::obj &b){
try{
- return wax::cast<T>(a) == wax::cast<T>(b);
+ return a.as<T>() == b.as<T>();
}
catch(const wax::bad_cast &){
return false;
diff --git a/host/include/uhd/props.hpp b/host/include/uhd/props.hpp
index f2ba1769f..0dddba647 100644
--- a/host/include/uhd/props.hpp
+++ b/host/include/uhd/props.hpp
@@ -57,7 +57,7 @@ namespace uhd{
*/
inline named_prop_t extract_named_prop(const wax::obj &key, const std::string &name = ""){
if (key.type() == typeid(named_prop_t)){
- return wax::cast<named_prop_t>(key);
+ return key.as<named_prop_t>();
}
return named_prop_t(key, name);
}
diff --git a/host/include/uhd/wax.hpp b/host/include/uhd/wax.hpp
index 4fd54ba14..0291a06b7 100644
--- a/host/include/uhd/wax.hpp
+++ b/host/include/uhd/wax.hpp
@@ -19,32 +19,35 @@
#define INCLUDED_WAX_HPP
#include <boost/any.hpp>
-#include <iostream>
/*!
* WAX - it's a metaphor!
*
- * The WAX framework allows object to have generic/anyobj properties.
+ * The WAX framework allows an object to have generic/anyobj properties.
* These properties can be addressed through generic/anyobj identifiers.
- * A property of a WAX object may even be another WAX object.
*
- * When a property is a WAX object, the returned value must be an obj pointer.
- * A WAX object provides two objs of pointers: obj::ptr and obj::sptr.
- * The choice of pointer vs smart pointer depends on the owner of the memory.
+ * The WAX object itself is an anytype container much like boost::any.
+ * To retrieve the value of the appropriate type, use my_obj.as<type>().
*
* Proprties may be referenced though the [] overloaded operator.
* The [] operator returns a special proxy that allows for assigment.
* Also, the [] operators may be chained as in the folowing examples:
- * my_obj[prop1][prop2][prop3] = value
- * value = my_obj[prop1][prop2][prop3]
+ * my_obj[prop1][prop2][prop3] = value;
+ * value = my_obj[prop1][prop2][prop3].as<type>();
*
- * Any value returned from an access operation is of wax::obj.
- * To use this value, it must be cast with wax::cast<new_obj>(value).
+ * Property nesting occurs when a WAX object gets another object's link.
+ * This special link is obtained through a call to my_obj.get_link().
*/
namespace wax{
/*!
+ * The wax::bad cast will be thrown when
+ * cast is called with the wrong typeid.
+ */
+ typedef boost::bad_any_cast bad_cast;
+
+ /*!
* WAX object base class:
*
* A wax obj has two major purposes:
@@ -126,7 +129,7 @@ namespace wax{
/*!
* Cast this obj into the desired type.
- * Usage myobj.as<type>()
+ * Usage: myobj.as<type>()
*
* \return an object of the desired type
* \throw wax::bad_cast when the cast fails
@@ -154,24 +157,6 @@ namespace wax{
};
- /*!
- * The wax::bad cast will be thrown when
- * cast is called with the wrong typeid.
- */
- typedef boost::bad_any_cast bad_cast;
-
- /*!
- * Cast a wax::obj into the desired obj.
- * Usage wax::cast<new_obj>(my_value).
- *
- * \param val the obj to cast
- * \return an object of the desired type
- * \throw wax::bad_cast when the cast fails
- */
- template<class T> T cast(const obj &val){
- return val.as<T>();
- }
-
} //namespace wax
#endif /* INCLUDED_WAX_HPP */