2 Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
22 #include "cucumber_bridge.h"
23 #include "lib/nanomsg.h"
24 #include "lib/dcpomatic_assert.h"
25 #include <boost/ref.hpp>
30 using boost::optional;
34 CucumberBridge::CucumberBridge ()
41 CucumberBridge::listener ()
43 Nanomsg nanomsg (false);
44 nanomsg.send (CUCUMBER_BRIDGE_READY "\n", -1);
47 auto message = nanomsg.receive (-1);
52 std::cout << "CB receives " << *message << "\n";
54 if (*message == CUCUMBER_BRIDGE_CLICK_BUTTON) {
55 emit (bind(boost::ref(ClickButton), get_parameter(nanomsg)));
56 } else if (*message == CUCUMBER_BRIDGE_SELECT_MENU) {
57 emit (bind(boost::ref(SelectMenu), get_parameter(nanomsg)));
58 } else if (*message == CUCUMBER_BRIDGE_TYPE) {
59 emit (bind(boost::ref(Type), get_parameter(nanomsg)));
60 } else if (*message == CUCUMBER_BRIDGE_ADD_CONTENT_FILE) {
61 emit (bind(boost::ref(AddContentFile), get_parameter(nanomsg)));
62 } else if (*message == CUCUMBER_BRIDGE_GET_CONTENT_LIST) {
63 nanomsg.send (GetContentList()->c_str(), -1);
70 CucumberBridge::get_parameter (Nanomsg& nanomsg)
72 auto p = nanomsg.receive (100);
79 CucumberBridge::start ()
81 _thread = boost::thread(&CucumberBridge::listener, this);