summaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
Diffstat (limited to 'host')
-rw-r--r--host/include/uhd/CMakeLists.txt1
-rw-r--r--host/include/uhd/deprecated.hpp173
-rw-r--r--host/include/uhd/device.hpp3
-rw-r--r--host/include/uhd/wax.hpp171
-rw-r--r--host/lib/CMakeLists.txt2
-rw-r--r--host/lib/deprecated.cpp (renamed from host/lib/wax.cpp)4
-rw-r--r--host/tests/CMakeLists.txt1
-rw-r--r--host/tests/wax_test.cpp104
8 files changed, 182 insertions, 277 deletions
diff --git a/host/include/uhd/CMakeLists.txt b/host/include/uhd/CMakeLists.txt
index 49562a7a0..6ca6d43cc 100644
--- a/host/include/uhd/CMakeLists.txt
+++ b/host/include/uhd/CMakeLists.txt
@@ -24,6 +24,7 @@ ADD_SUBDIRECTORY(utils)
INSTALL(FILES
config.hpp
convert.hpp
+ deprecated.hpp
device.hpp
exception.hpp
property_tree.ipp
diff --git a/host/include/uhd/deprecated.hpp b/host/include/uhd/deprecated.hpp
new file mode 100644
index 000000000..0a49cc423
--- /dev/null
+++ b/host/include/uhd/deprecated.hpp
@@ -0,0 +1,173 @@
+//----------------------------------------------------------------------
+//-- deprecated interfaces below, to be removed when the API is changed
+//----------------------------------------------------------------------
+
+//
+// Copyright 2010-2011 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#ifndef INCLUDED_WAX_HPP
+#define INCLUDED_WAX_HPP
+
+#include <uhd/config.hpp>
+#include <uhd/exception.hpp>
+#include <boost/any.hpp>
+#include <typeinfo>
+#include <string>
+
+/*!
+ * WAX - it's a metaphor!
+ *
+ * The WAX framework allows an object to have generic/anyobj properties.
+ * These properties can be addressed through generic/anyobj identifiers.
+ *
+ * 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].as<type>();
+ *
+ * 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().
+ *
+ * Note: Do not put a class derived from wax::obj into an stl container.
+ * MSVC will compile the code, but the binaries will crash at runtime.
+ * Rather, use pointers or smart pointers to instances of the derived class.
+ */
+
+namespace wax{
+
+ /*!
+ * WAX object base class:
+ *
+ * A wax obj has two major purposes:
+ * 1) to act as a polymorphic container, just like boost any
+ * 2) to provide a nested set/get properties interface
+ *
+ * Internally, the polymorphic container is handled by a boost any.
+ * For properties, a subclass should override the set and get methods.
+ * For property nesting, wax obj subclasses return special links
+ * to other wax obj subclasses, and the api handles the magic.
+ */
+ class UHD_API obj{
+ public:
+
+ /*!
+ * Default constructor:
+ * The contents will be empty.
+ */
+ obj(void);
+
+ /*!
+ * Copy constructor:
+ * The contents will be cloned.
+ * \param o another wax::obj
+ */
+ obj(const obj &o);
+
+ /*!
+ * Templated any type constructor:
+ * The contents can be anything.
+ * Uses the boost::any to handle the magic.
+ * \param o an object of any type
+ */
+ template<class T> obj(const T &o){
+ _contents = o;
+ }
+
+ /*!
+ * Destructor.
+ */
+ virtual ~obj(void);
+
+ /*!
+ * The chaining operator:
+ * This operator allows access objs with properties.
+ * A call to the [] operator will return a new proxy obj.
+ * The proxy object is an obj with special proxy contents.
+ * Assignment and casting can be used on this special object
+ * to access the property referenced by the obj key.
+ * \param key a key to identify a property within this obj
+ * \return a special wax obj that proxies the obj and key
+ */
+ obj operator[](const obj &key);
+
+ /*!
+ * The assignment operator:
+ * This operator allows for assignment of new contents.
+ * In the special case where this obj contains a proxy,
+ * the value will be set to the proxy's property reference.
+ * \param val the new value to assign to the wax obj
+ * \return a reference to this obj (*this)
+ */
+ obj & operator=(const obj &val);
+
+ /*!
+ * Get a link in the chain:
+ * When a wax obj returns another wax obj as part of a get call,
+ * the return value should be set to the result of this method.
+ * Doing so will ensure chain-ability of the returned object.
+ * \return an obj containing a valid link to a wax obj
+ */
+ obj get_link(void) const;
+
+ /*!
+ * Get the type of the contents of this obj.
+ * \return a reference to the type_info
+ */
+ const std::type_info & type(void) const;
+
+ /*!
+ * Cast this obj into the desired type.
+ * Usage: myobj.as<type>()
+ *
+ * \return an object of the desired type
+ * \throw wax::bad_cast when the cast fails
+ */
+ template<class T> T as(void) const{
+ try{
+ return boost::any_cast<T>(resolve());
+ }
+ catch(const boost::bad_any_cast &e){
+ throw uhd::type_error(std::string("") + "Cannot wax cast " + type().name() + " to " + typeid(T).name() + " " + e.what());
+ }
+ }
+
+ private:
+ //private interface (override in subclasses)
+ virtual void get(const obj &, obj &);
+ virtual void set(const obj &, const obj &);
+
+ /*!
+ * Resolve the contents of this obj.
+ * In the case where this obj is a proxy,
+ * the referenced property will be resolved.
+ * Otherwise, just get the private contents.
+ * \return a boost any type with contents
+ */
+ boost::any resolve(void) const;
+
+ //private contents of this obj
+ boost::any _contents;
+
+ };
+
+} //namespace wax
+
+#endif /* INCLUDED_WAX_HPP */
diff --git a/host/include/uhd/device.hpp b/host/include/uhd/device.hpp
index a6571d027..18545427c 100644
--- a/host/include/uhd/device.hpp
+++ b/host/include/uhd/device.hpp
@@ -23,7 +23,6 @@
#include <uhd/types/metadata.hpp>
#include <uhd/types/io_type.hpp>
#include <uhd/types/ref_vector.hpp>
-#include <uhd/wax.hpp>
#include <boost/utility.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
@@ -36,7 +35,7 @@ class property_tree; //forward declaration
* The usrp device interface represents the usrp hardware.
* The api allows for discovery, configuration, and streaming.
*/
-class UHD_API device : boost::noncopyable, public wax::obj{
+class UHD_API device : boost::noncopyable{
public:
typedef boost::shared_ptr<device> sptr;
diff --git a/host/include/uhd/wax.hpp b/host/include/uhd/wax.hpp
index 6fd2b8652..a55e5465d 100644
--- a/host/include/uhd/wax.hpp
+++ b/host/include/uhd/wax.hpp
@@ -1,169 +1,2 @@
-//
-// Copyright 2010-2011 Ettus Research LLC
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-//
-
-#ifndef INCLUDED_WAX_HPP
-#define INCLUDED_WAX_HPP
-
-#include <uhd/config.hpp>
-#include <uhd/exception.hpp>
-#include <boost/any.hpp>
-#include <typeinfo>
-#include <string>
-
-/*!
- * WAX - it's a metaphor!
- *
- * The WAX framework allows an object to have generic/anyobj properties.
- * These properties can be addressed through generic/anyobj identifiers.
- *
- * 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].as<type>();
- *
- * 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().
- *
- * Note: Do not put a class derived from wax::obj into an stl container.
- * MSVC will compile the code, but the binaries will crash at runtime.
- * Rather, use pointers or smart pointers to instances of the derived class.
- */
-
-namespace wax{
-
- /*!
- * WAX object base class:
- *
- * A wax obj has two major purposes:
- * 1) to act as a polymorphic container, just like boost any
- * 2) to provide a nested set/get properties interface
- *
- * Internally, the polymorphic container is handled by a boost any.
- * For properties, a subclass should override the set and get methods.
- * For property nesting, wax obj subclasses return special links
- * to other wax obj subclasses, and the api handles the magic.
- */
- class UHD_API obj{
- public:
-
- /*!
- * Default constructor:
- * The contents will be empty.
- */
- obj(void);
-
- /*!
- * Copy constructor:
- * The contents will be cloned.
- * \param o another wax::obj
- */
- obj(const obj &o);
-
- /*!
- * Templated any type constructor:
- * The contents can be anything.
- * Uses the boost::any to handle the magic.
- * \param o an object of any type
- */
- template<class T> obj(const T &o){
- _contents = o;
- }
-
- /*!
- * Destructor.
- */
- virtual ~obj(void);
-
- /*!
- * The chaining operator:
- * This operator allows access objs with properties.
- * A call to the [] operator will return a new proxy obj.
- * The proxy object is an obj with special proxy contents.
- * Assignment and casting can be used on this special object
- * to access the property referenced by the obj key.
- * \param key a key to identify a property within this obj
- * \return a special wax obj that proxies the obj and key
- */
- obj operator[](const obj &key);
-
- /*!
- * The assignment operator:
- * This operator allows for assignment of new contents.
- * In the special case where this obj contains a proxy,
- * the value will be set to the proxy's property reference.
- * \param val the new value to assign to the wax obj
- * \return a reference to this obj (*this)
- */
- obj & operator=(const obj &val);
-
- /*!
- * Get a link in the chain:
- * When a wax obj returns another wax obj as part of a get call,
- * the return value should be set to the result of this method.
- * Doing so will ensure chain-ability of the returned object.
- * \return an obj containing a valid link to a wax obj
- */
- obj get_link(void) const;
-
- /*!
- * Get the type of the contents of this obj.
- * \return a reference to the type_info
- */
- const std::type_info & type(void) const;
-
- /*!
- * Cast this obj into the desired type.
- * Usage: myobj.as<type>()
- *
- * \return an object of the desired type
- * \throw wax::bad_cast when the cast fails
- */
- template<class T> T as(void) const{
- try{
- return boost::any_cast<T>(resolve());
- }
- catch(const boost::bad_any_cast &e){
- throw uhd::type_error(std::string("") + "Cannot wax cast " + type().name() + " to " + typeid(T).name() + " " + e.what());
- }
- }
-
- private:
- //private interface (override in subclasses)
- virtual void get(const obj &, obj &);
- virtual void set(const obj &, const obj &);
-
- /*!
- * Resolve the contents of this obj.
- * In the case where this obj is a proxy,
- * the referenced property will be resolved.
- * Otherwise, just get the private contents.
- * \return a boost any type with contents
- */
- boost::any resolve(void) const;
-
- //private contents of this obj
- boost::any _contents;
-
- };
-
-} //namespace wax
-
-#endif /* INCLUDED_WAX_HPP */
+//The wax API has been deprecated in favor of the properties interface
+#include <uhd/deprecated.hpp>
diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt
index 2b0210e6e..7a76ebd53 100644
--- a/host/lib/CMakeLists.txt
+++ b/host/lib/CMakeLists.txt
@@ -86,11 +86,11 @@ CONFIGURE_FILE(
# Append to the list of sources for lib uhd
########################################################################
LIBUHD_APPEND_SOURCES(
+ ${CMAKE_CURRENT_SOURCE_DIR}/deprecated.cpp
${CMAKE_CURRENT_SOURCE_DIR}/device.cpp
${CMAKE_CURRENT_SOURCE_DIR}/exception.cpp
${CMAKE_CURRENT_SOURCE_DIR}/property_tree.cpp
${CMAKE_CURRENT_BINARY_DIR}/version.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/wax.cpp
)
########################################################################
diff --git a/host/lib/wax.cpp b/host/lib/deprecated.cpp
index 5f658acd8..eeaba03cb 100644
--- a/host/lib/wax.cpp
+++ b/host/lib/deprecated.cpp
@@ -1,3 +1,7 @@
+//----------------------------------------------------------------------
+//-- deprecated interfaces below, to be removed when the API is changed
+//----------------------------------------------------------------------
+
//
// Copyright 2010-2011 Ettus Research LLC
//
diff --git a/host/tests/CMakeLists.txt b/host/tests/CMakeLists.txt
index c97116233..28cc1c5da 100644
--- a/host/tests/CMakeLists.txt
+++ b/host/tests/CMakeLists.txt
@@ -34,7 +34,6 @@ SET(test_sources
subdev_spec_test.cpp
time_spec_test.cpp
vrt_test.cpp
- wax_test.cpp
)
#turn each test cpp file into an executable with an int main() function
diff --git a/host/tests/wax_test.cpp b/host/tests/wax_test.cpp
deleted file mode 100644
index 18730e0c2..000000000
--- a/host/tests/wax_test.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-//
-// Copyright 2010-2011 Ettus Research LLC
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-//
-
-#include <boost/test/unit_test.hpp>
-#include <boost/shared_ptr.hpp>
-#include <uhd/wax.hpp>
-#include <iostream>
-
-enum opt_a_t{OPTION_A_0, OPTION_A_1};
-enum opt_b_t{OPTION_B_0, OPTION_B_1};
-
-BOOST_AUTO_TEST_CASE(test_enums){
- wax::obj opta = OPTION_A_0;
- BOOST_CHECK_THROW(opta.as<opt_b_t>(), std::exception);
- BOOST_CHECK_EQUAL(opta.as<opt_a_t>(), OPTION_A_0);
-}
-
-/***********************************************************************
- * demo class for wax framework
- **********************************************************************/
-class wax_demo : public wax::obj{
-public:
- typedef boost::shared_ptr<wax_demo> sptr;
-
- wax_demo(size_t sub_demos, size_t len){
- d_nums = std::vector<float>(len);
- if (sub_demos != 0){
- for (size_t i = 0; i < len; i++){
- d_subs.push_back(sptr(new wax_demo(sub_demos-1, len)));
- }
- }
- }
- ~wax_demo(void){
- /* NOP */
- }
-private:
- std::vector<float> d_nums;
- std::vector<sptr> d_subs;
-
- void get(const wax::obj &key, wax::obj &value){
- if (d_subs.size() == 0){
- value = d_nums[key.as<size_t>()];
- }else{
- value = d_subs[key.as<size_t>()]->get_link();
- }
- }
- void set(const wax::obj &key, const wax::obj &value){
- if (d_subs.size() == 0){
- d_nums[key.as<size_t>()] = value.as<float>();
- }else{
- throw std::runtime_error("cant set to a wax demo with sub demos");
- }
- }
-};
-
-BOOST_AUTO_TEST_CASE(test_chaining){
- wax_demo wd(2, 1);
- std::cout << "chain 1" << std::endl;
- wd[size_t(0)];
- std::cout << "chain 2" << std::endl;
- wd[size_t(0)][size_t(0)];
- std::cout << "chain 3" << std::endl;
- wd[size_t(0)][size_t(0)][size_t(0)];
-}
-
-BOOST_AUTO_TEST_CASE(test_set_get){
- wax_demo wd(2, 10);
- std::cout << "set and get all" << std::endl;
- for (size_t i = 0; i < 10; i++){
- for (size_t j = 0; j < 10; j++){
- for (size_t k = 0; k < 10; k++){
- float val = float(i * j * k + i + j + k);
- //std::cout << i << " " << j << " " << k << std::endl;
- wd[i][j][k] = val;
- BOOST_CHECK_EQUAL(val, wd[i][j][k].as<float>());
- }
- }
- }
-}
-
-BOOST_AUTO_TEST_CASE(test_proxy){
- wax_demo wd(2, 1);
- std::cout << "store proxy" << std::endl;
- wax::obj p = wd[size_t(0)][size_t(0)];
- p[size_t(0)] = float(5);
-
- std::cout << "assign proxy" << std::endl;
- wax::obj a = p[size_t(0)];
- BOOST_CHECK_EQUAL(a.as<float>(), float(5));
-}