OSSIA
Open Scenario System for Interactive Application
Loading...
Searching...
No Matches
phidgets_protocol.hpp
1#pragma once
2#include <ossia/detail/config.hpp>
3
4#include <ossia/detail/hash_map.hpp>
5#include <ossia/detail/optional.hpp>
6#include <ossia/network/base/protocol.hpp>
7#include <ossia/network/phidgets/phidgets_parameter_data.hpp>
8
9#include <readerwriterqueue.h>
10
11namespace ossia
12{
13namespace net
14{
15class device_base;
16}
17class phidget_node;
18class OSSIA_EXPORT phidget_protocol : public ossia::net::protocol_base
19{
20 net::device_base* m_dev{};
21 std::function<void()> m_commandCb;
22 moodycamel::ReaderWriterQueue<std::function<void()>> m_functionQueue;
23
24 ossia::hash_map<PhidgetHandle, ossia::phidget_node*> m_phidgetMap;
25
26public:
27 phidget_protocol();
28 ~phidget_protocol() override;
29
30 bool pull(net::parameter_base&) override;
31 std::future<void> pull_async(net::parameter_base&) override;
32 void request(net::parameter_base&) override;
33 bool push(const net::parameter_base&, const ossia::value& v) override;
34 bool observe(net::parameter_base&, bool) override;
35 bool observe_quietly(net::parameter_base&, bool) override;
36 bool update(net::node_base& node_base) override;
37
38 void set_device(net::device_base& dev) override;
39
40 void set_command_callback(std::function<void()>);
41 void run_commands();
42 void run_command();
43 bool push_raw(const ossia::net::full_parameter_data&) override;
44
45private:
46 ossia::net::node_base* get_parent(ossia::phidget_handle_t hdl);
47 PhidgetManagerHandle m_hdl{};
48
49 void on_deviceCreated(PhidgetHandle phid);
50 void on_deviceRemoved(phidget_id sn);
51 void remove_parent_rec(ossia::net::node_base* par);
52 void remove_node(ossia::net::node_base* par);
53 void deleting_node(const ossia::net::node_base& par);
54};
55}
The node_base class.
Definition node.hpp:48
The protocol_base class.
Definition protocol.hpp:40
The value class.
Definition value.hpp:173
Definition git_info.h:7
Full information about a parameter.
Definition parameter_data.hpp:61