Line data Source code
1 :
2 : #include "ErrorHandler/Components/qt_rule_engine.h"
3 :
4 : #include <QtCore/QMetaType>
5 : #include <boost/bind/bind.hpp>
6 :
7 : using namespace novadaq::errorhandler;
8 :
9 0 : qt_rule_engine::qt_rule_engine(fhicl::ParameterSet const& pset, QObject* parent)
10 : : QObject(parent)
11 0 : , engine(pset, boost::bind(&qt_rule_engine::new_alarm, this, boost::placeholders::_1, boost::placeholders::_2), boost::bind(&qt_rule_engine::cond_match, this, boost::placeholders::_1))
12 : {
13 0 : }
14 :
15 0 : qt_rule_engine::~qt_rule_engine()
16 : {
17 0 : }
18 :
19 0 : void qt_rule_engine::new_alarm(std::string const& rule_name, std::string const& msg)
20 : {
21 0 : emit alarm(QString(rule_name.c_str()), QString(msg.c_str()));
22 0 : }
23 :
24 0 : void qt_rule_engine::cond_match(std::string const& cond_name)
25 : {
26 0 : emit match(QString(cond_name.c_str()));
27 0 : }
28 :
29 : QVector<QString>
30 0 : qt_rule_engine::cond_names() const
31 : {
32 0 : QVector<QString> names;
33 0 : std::vector<std::string>::const_iterator it = engine.cond_names().begin();
34 0 : for (; it != engine.cond_names().end(); ++it)
35 0 : names.push_back(QString(it->c_str()));
36 0 : return names;
37 0 : }
38 :
39 : QVector<QString>
40 0 : qt_rule_engine::rule_names() const
41 : {
42 0 : QVector<QString> names;
43 0 : std::vector<std::string>::const_iterator it = engine.rule_names().begin();
44 0 : for (; it != engine.rule_names().end(); ++it)
45 0 : names.push_back(QString(it->c_str()));
46 0 : return names;
47 0 : }
48 :
49 : QVector<QString>
50 0 : qt_rule_engine::rule_cond_names(QString const& name) const
51 : {
52 0 : std::vector<std::string> const& std_names = engine.rule_cond_names(name.toUtf8().constData());
53 :
54 0 : QVector<QString> names;
55 :
56 0 : std::vector<std::string>::const_iterator it = std_names.begin();
57 0 : for (; it != std_names.end(); ++it)
58 0 : names.push_back(QString(it->c_str()));
59 0 : return names;
60 0 : }
|