16 #include <boost/core/demangle.hpp> 25 namespace uhd {
namespace experts {
56 virtual const std::string&
get_dtype()
const = 0;
58 virtual std::string
to_string()
const = 0;
79 const std::string _name;
86 template <
typename data_t>
87 static std::string
print(
const data_t& val)
89 std::ostringstream os;
94 static std::string
print(
const uint8_t& val)
96 std::ostringstream os;
103 std::ostringstream os;
127 template <
typename data_t>
136 data_node_t(
const std::string& name, std::recursive_mutex* mutex = NULL)
138 , _callback_mutex(mutex)
145 const std::string& name,
const data_t& value, std::recursive_mutex* mutex = NULL)
147 , _callback_mutex(mutex)
156 static const std::string dtype(boost::core::demangle(
typeid(data_t).name()));
173 return _data.is_dirty();
192 void set(
const data_t& value)
198 const data_t&
get()
const 206 if (_callback_mutex == NULL)
208 "node " +
get_name() +
" is missing the callback mutex");
209 std::lock_guard<std::recursive_mutex> lock(*_callback_mutex);
220 if (_callback_mutex == NULL)
222 "node " +
get_name() +
" is missing the callback mutex");
223 std::lock_guard<std::recursive_mutex> lock(*_callback_mutex);
225 _rd_callback(std::string(
get_name()));
239 return bool(_wr_callback);
244 _wr_callback =
nullptr;
254 return bool(_rd_callback);
259 _rd_callback =
nullptr;
262 std::recursive_mutex* _callback_mutex;
281 virtual const dag_vertex_t& lookup(
const std::string& name)
const = 0;
285 virtual dag_vertex_t& retrieve(
const std::string& name)
const = 0;
300 virtual bool is_reader()
const = 0;
301 virtual bool is_writer()
const = 0;
306 : _vertex(r.retrieve(n))
312 template <
typename data_t>
330 return _datanode->is_dirty();
335 return _datanode->get_class();
340 return _datanode->get_author();
349 if (_datanode == NULL) {
351 + boost::core::demangle(
typeid(data_t).name())
373 template <
typename data_t>
382 inline const data_t&
get()
const 387 inline operator const data_t&()
const 399 return !(
get() == rhs);
416 template <
typename data_t>
425 inline const data_t&
get()
const 430 inline operator const data_t&()
const 442 return !(
get() == rhs);
445 inline void set(
const data_t& value)
481 std::list<std::string> retval;
483 retval.push_back(acc->node().get_name());
490 std::list<std::string> retval;
492 retval.push_back(acc->node().get_name());
505 _inputs.push_back(&accessor);
507 _outputs.push_back(&accessor);
517 bool inputs_dirty =
false;
519 inputs_dirty |= acc->node().is_dirty();
527 acc->node().mark_clean();
534 acc->node().force_dirty();
541 const std::string&
get_dtype()
const override 543 static const std::string dtype =
"<worker>";
566 std::list<data_accessor_t*> _inputs;
567 std::list<data_accessor_t*> _outputs;
virtual ~node_retriever_t()
Definition: expert_nodes.hpp:280
bool is_dirty() const override
Definition: expert_nodes.hpp:171
Definition: expert_nodes.hpp:29
Definition: expert_nodes.hpp:374
dag_vertex_t(const node_class_t c, const std::string &n)
Definition: expert_nodes.hpp:75
const data_t retrieve() const
Definition: expert_nodes.hpp:218
data_node_t(const std::string &name, const data_t &value, std::recursive_mutex *mutex=NULL)
Definition: expert_nodes.hpp:144
virtual bool is_writer() const =0
virtual void clear_read_callback()=0
virtual void mark_clean()=0
const std::string & get_dtype() const override
Definition: expert_nodes.hpp:154
node_class_t get_class() const
Definition: expert_nodes.hpp:46
bool operator!=(const data_t &rhs)
Definition: expert_nodes.hpp:397
boost::noncopyable noncopyable
Definition: noncopyable.hpp:45
Definition: expert_nodes.hpp:473
std::string to_string() const override
Definition: expert_nodes.hpp:160
void commit(const data_t &value)
Definition: expert_nodes.hpp:204
Definition: time_spec.hpp:28
data_reader_t(const node_retriever_t &retriever, const std::string &node)
Definition: expert_nodes.hpp:377
~data_accessor_base() override
Definition: expert_nodes.hpp:316
virtual void clear_write_callback()=0
virtual const std::string & get_dtype() const =0
virtual void force_dirty()=0
node_class_t
Definition: expert_nodes.hpp:27
bool operator!=(const data_t &rhs)
Definition: expert_nodes.hpp:440
static std::string print(const time_spec_t time)
Definition: expert_nodes.hpp:101
data_writer_t(const node_retriever_t &retriever, const std::string &node)
Definition: expert_nodes.hpp:420
virtual void set_write_callback(const callback_func_t &func)=0
Definition: expert_nodes.hpp:28
double get_real_secs(void) const
node_author_t
Definition: expert_nodes.hpp:29
node_author_t get_author() const
Definition: expert_nodes.hpp:338
Definition: expert_nodes.hpp:38
Definition: expert_nodes.hpp:313
bool operator==(const data_t &rhs)
Definition: expert_nodes.hpp:435
virtual ~data_accessor_t()
Definition: expert_nodes.hpp:298
Definition: expert_nodes.hpp:295
Definition: expert_nodes.hpp:28
data_node_t< data_t > * _datanode
Definition: expert_nodes.hpp:356
std::list< std::string > get_inputs() const
Definition: expert_nodes.hpp:479
Definition: build_info.hpp:12
Definition: dirty_tracked.hpp:24
Definition: expert_nodes.hpp:27
virtual bool is_dirty() const =0
virtual bool is_reader() const =0
void bind_accessor(data_accessor_t &accessor)
Definition: expert_nodes.hpp:502
void force_dirty() override
Definition: expert_nodes.hpp:181
bool is_writer() const override
Definition: expert_nodes.hpp:323
const node_access_t _access
Definition: expert_nodes.hpp:357
Definition: expert_nodes.hpp:128
Definition: expert_nodes.hpp:27
node_class_t get_class() const
Definition: expert_nodes.hpp:333
bool operator==(const data_t &rhs)
Definition: expert_nodes.hpp:392
node_author_t get_author() const
Definition: expert_nodes.hpp:165
virtual void set_read_callback(const callback_func_t &func)=0
void mark_clean() override
Definition: expert_nodes.hpp:176
data_accessor_t(const node_retriever_t &r, const std::string &n)
Definition: expert_nodes.hpp:305
Definition: expert_nodes.hpp:417
Definition: exception.hpp:47
bool is_dirty() const
Definition: expert_nodes.hpp:328
worker_node_t(const std::string &name)
Definition: expert_nodes.hpp:476
const data_t & get() const
Definition: expert_nodes.hpp:382
virtual ~dag_vertex_t()
Definition: expert_nodes.hpp:43
friend std::ostream & operator<<(std::ostream &os, const data_reader_t &reader)
Definition: expert_nodes.hpp:402
void resolve() override
Definition: expert_nodes.hpp:186
Definition: expert_nodes.hpp:27
Definition: expert_nodes.hpp:29
bool is_reader() const override
Definition: expert_nodes.hpp:318
virtual bool has_read_callback() const =0
data_writer_t< data_t > & operator=(const data_writer_t< data_t > &value)
Definition: expert_nodes.hpp:456
Definition: exception.hpp:95
static std::string print(const uint8_t &val)
Definition: expert_nodes.hpp:94
Definition: expert_nodes.hpp:29
node_access_t
Definition: expert_nodes.hpp:28
Definition: expert_nodes.hpp:82
std::list< std::string > get_outputs() const
Definition: expert_nodes.hpp:488
const data_t & get() const
Definition: expert_nodes.hpp:425
dag_vertex_t & _vertex
Definition: expert_nodes.hpp:309
virtual std::string to_string() const =0
data_node_t(const std::string &name, std::recursive_mutex *mutex=NULL)
Definition: expert_nodes.hpp:136
virtual bool has_write_callback() const =0
Definition: expert_nodes.hpp:277
const std::string & get_name() const
Definition: expert_nodes.hpp:51
static std::string print(const data_t &val)
Definition: expert_nodes.hpp:87
data_accessor_base(const node_retriever_t &r, const std::string &n, const node_access_t a)
Definition: expert_nodes.hpp:344
std::function< void(std::string)> callback_func_t
Definition: expert_nodes.hpp:41
data_writer_t< data_t > & operator=(const data_t &value)
Definition: expert_nodes.hpp:450