3
#include "wb_plugin_be.h"
6
void Wb_plugin::grtm(bec::GRTManager *grtm)
11
grt::GRT *grt= _grtm->get_grt();
12
_options= grt::DictRef(grt);
17
void Wb_plugin::exec_task(bool sync)
21
bec::GRTTask *task= new bec::GRTTask(task_desc(), _grtm->get_dispatcher(), _task_proc_cb);
23
scoped_connect(task->signal_message(),boost::bind(&Wb_plugin::process_task_msg, this, _1));
24
scoped_connect(task->signal_failed(),boost::bind(&Wb_plugin::process_task_fail, this, _1));
25
scoped_connect(task->signal_finished(),boost::bind(&Wb_plugin::process_task_finish, this, _1));
28
_grtm->get_dispatcher()->add_task_and_wait(task);
30
_grtm->get_dispatcher()->add_task(task);
34
void Wb_plugin::process_task_msg(const grt::Message &msg)
42
_task_msg_cb(msg.type, msg.text);
44
case grt::ProgressMsg:
45
if (_task_progress_cb)
46
_task_progress_cb(msg.progress, msg.text);
54
void Wb_plugin::process_task_fail(const std::exception &error)
57
_task_fail_cb(error.what());
61
void Wb_plugin::process_task_finish(grt::ValueRef res)
63
_grtm->get_grt()->send_info(grt::StringRef::cast_from(res));
64
//_grtm->get_grt()->make_output_visible();
65
_grtm->perform_idle_tasks();
71
template<typename T1, typename T2>
72
T2 get_option(const grt::DictRef &options, const std::string &name)
75
if (options.is_valid() && options.has_key(name))
76
value= (T2)T1::cast_from(options.get(name));
81
int Wb_plugin::get_int_option(const std::string &name)
83
return get_option<grt::IntegerRef, int>(_options, name);
87
double Wb_plugin::get_double_option(const std::string &name)
89
return get_option<grt::DoubleRef, double>(_options, name);
93
std::string Wb_plugin::get_string_option(const std::string &name)
95
return get_option<grt::StringRef, std::string>(_options, name);
99
void Wb_plugin::set_option(const std::string &name, int val)
101
_options.set(name, grt::IntegerRef(val));
105
void Wb_plugin::set_option(const std::string &name, const double &val)
107
_options.set(name, grt::DoubleRef(val));
111
void Wb_plugin::set_option(const std::string &name, const std::string &val)
113
_options.set(name, grt::StringRef(val));