diff options
author | Ashish Chaudhari <ashish@ettus.com> | 2016-02-24 17:11:27 -0800 |
---|---|---|
committer | Ashish Chaudhari <ashish@ettus.com> | 2016-02-26 14:23:55 -0800 |
commit | 586944ec2bc991d1b96c8698e5da8b39b3d36f9a (patch) | |
tree | 068f26481fb3ec669de53b0b383e215978d8f6c8 /host | |
parent | 6db9ac785ca5f62e58cf792f0525b37b16a87bdf (diff) | |
download | uhd-586944ec2bc991d1b96c8698e5da8b39b3d36f9a.tar.gz uhd-586944ec2bc991d1b96c8698e5da8b39b3d36f9a.tar.bz2 uhd-586944ec2bc991d1b96c8698e5da8b39b3d36f9a.zip |
experts: Multiple minor fixes/enhancements
- Fixed segfault issue for graph modification errors
- Demangled node type names and added quotes to "dot" labels to allow fully qualified C++ names
- add_prop_node functions initialize the property objects in the tree in addition to data nodes
- Passed in resolve mutex to desired data node correctly
- Added == and != operators to data accessors
Diffstat (limited to 'host')
-rw-r--r-- | host/lib/experts/expert_container.cpp | 10 | ||||
-rw-r--r-- | host/lib/experts/expert_factory.hpp | 6 | ||||
-rw-r--r-- | host/lib/experts/expert_nodes.hpp | 25 |
3 files changed, 31 insertions, 10 deletions
diff --git a/host/lib/experts/expert_container.cpp b/host/lib/experts/expert_container.cpp index 3c4687d66..dc98ee4ed 100644 --- a/host/lib/experts/expert_container.cpp +++ b/host/lib/experts/expert_container.cpp @@ -145,7 +145,7 @@ public: ) { const dag_vertex_t& vertex = _get_vertex(*vi.first); if (vertex.get_class() != CLASS_WORKER) { - dot_str += str(boost::format(" %d [label=\"%s\",shape=%s,xlabel=%s];\n") % + dot_str += str(boost::format(" %d [label=\"%s\",shape=%s,xlabel=\"%s\"];\n") % boost::uint32_t(*vi.first) % vertex.get_name() % DATA_SHAPE % vertex.get_dtype()); } else { @@ -288,12 +288,12 @@ protected: //Sanity check the data node and ensure that it is not already in this graph EX_LOG(0, str(boost::format("add_data_node(%s)") % data_node->get_name())); if (data_node->get_class() == CLASS_WORKER) { - delete data_node; throw uhd::runtime_error("Supplied node " + data_node->get_name() + " is not a data/property node."); + delete data_node; } if (_datanode_map.find(data_node->get_name()) != _datanode_map.end()) { - delete data_node; throw uhd::runtime_error("Data node with name " + data_node->get_name() + " already exists"); + delete data_node; } try { @@ -329,12 +329,12 @@ protected: //Sanity check the data node and ensure that it is not already in this graph EX_LOG(0, str(boost::format("add_worker(%s)") % worker->get_name())); if (worker->get_class() != CLASS_WORKER) { - delete worker; throw uhd::runtime_error("Supplied node " + worker->get_name() + " is not a worker node."); + delete worker; } if (_worker_map.find(worker->get_name()) != _worker_map.end()) { - delete worker; throw uhd::runtime_error("Resolver with name " + worker->get_name() + " already exists."); + delete worker; } try { diff --git a/host/lib/experts/expert_factory.hpp b/host/lib/experts/expert_factory.hpp index 2d378535c..83369117d 100644 --- a/host/lib/experts/expert_factory.hpp +++ b/host/lib/experts/expert_factory.hpp @@ -103,6 +103,7 @@ namespace uhd { namespace experts { property<data_t>& prop = subtree->create<data_t>(path, property_tree::MANUAL_COERCE); data_node_t<data_t>* node_ptr = new data_node_t<data_t>(name, init_val, &container->resolve_mutex()); + prop.set(init_val); prop.add_desired_subscriber(boost::bind(&data_node_t<data_t>::commit, node_ptr, _1)); prop.set_publisher(boost::bind(&data_node_t<data_t>::retrieve, node_ptr)); container->add_data_node(node_ptr, mode); @@ -165,10 +166,11 @@ namespace uhd { namespace experts { property<data_t>& prop = subtree->create<data_t>(path, property_tree::MANUAL_COERCE); data_node_t<data_t>* desired_node_ptr = - new data_node_t<data_t>( - desired_name, init_val, auto_resolve_desired ? &container->resolve_mutex() : NULL); + new data_node_t<data_t>(desired_name, init_val, &container->resolve_mutex()); data_node_t<data_t>* coerced_node_ptr = new data_node_t<data_t>(coerced_name, init_val, &container->resolve_mutex()); + prop.set(init_val); + prop.set_coerced(init_val); prop.add_desired_subscriber(boost::bind(&data_node_t<data_t>::commit, desired_node_ptr, _1)); prop.set_publisher(boost::bind(&data_node_t<data_t>::retrieve, coerced_node_ptr)); diff --git a/host/lib/experts/expert_nodes.hpp b/host/lib/experts/expert_nodes.hpp index 69ecfa661..235ee489f 100644 --- a/host/lib/experts/expert_nodes.hpp +++ b/host/lib/experts/expert_nodes.hpp @@ -25,6 +25,7 @@ #include <boost/foreach.hpp> #include <boost/thread/recursive_mutex.hpp> #include <boost/thread.hpp> +#include <boost/units/detail/utility.hpp> #include <memory> #include <list> @@ -114,7 +115,8 @@ namespace uhd { namespace experts { // Basic info virtual const std::string& get_dtype() const { - static const std::string dtype(typeid(data_t).name()); + static const std::string dtype( + boost::units::detail::demangle(typeid(data_t).name())); return dtype; } @@ -268,7 +270,8 @@ namespace uhd { namespace experts { _datanode = dynamic_cast< data_node_t<data_t>* >(&node()); if (_datanode == NULL) { throw uhd::type_error("Expected data type for node " + n + - " was " + typeid(data_t).name() + " but got " + node().get_dtype()); + " was " + boost::units::detail::demangle(typeid(data_t).name()) + + " but got " + node().get_dtype()); } } @@ -302,6 +305,14 @@ namespace uhd { namespace experts { inline operator const data_t&() const { return get(); } + + inline bool operator==(const data_t& rhs) { + return get() == rhs; + } + + inline bool operator!=(const data_t& rhs) { + return !(get() == rhs); + } }; /*!--------------------------------------------------------- @@ -319,13 +330,21 @@ namespace uhd { namespace experts { retriever, node, ACCESS_WRITER) {} inline const data_t& get() const { - return data_accessor_base<data_t>::_node.get(); + return data_accessor_base<data_t>::_datanode->get(); } inline operator const data_t&() const { return get(); } + inline bool operator==(const data_t& rhs) { + return get() == rhs; + } + + inline bool operator!=(const data_t& rhs) { + return !(get() == rhs); + } + inline void set(const data_t& value) { data_accessor_base<data_t>::_datanode->set(value); } |