Allolib  1.0
C++ Components For Interactive Multimedia
al_OSCDomain.hpp
1 #ifndef OSCDOMAIN_H
2 #define OSCDOMAIN_H
3 
4 #include <functional>
5 #include <iostream>
6 
7 #include "al_ComputationDomain.hpp"
8 
9 #include "al/protocol/al_OSC.hpp"
10 #include "al/ui/al_ParameterServer.hpp"
11 
12 namespace al {
13 
18 class OSCDomain : public AsynchronousDomain {
19 public:
20  virtual ~OSCDomain() {}
21  // Domain management functions
22  bool init(ComputationDomain *parent = nullptr) override;
23  bool start() override;
24  bool stop() override;
25  bool cleanup(ComputationDomain *parent = nullptr) override;
26 
27  // Configuration and query
28  bool configure(uint16_t port, std::string address = "");
29 
30  bool running() { return mParameterServer.serverRunning(); }
31 
32  osc::PacketHandler &handler() { return mHandler; }
33 
34  ParameterServer &parameterServer() { return mParameterServer; }
35  ParameterServer const &parameterServer() const { return mParameterServer; }
36 
37  // PacketHandler
38  std::function<void(osc::Message &)> onMessage = [](osc::Message &m) {
39  std::cout << "Received unhandled message." << std::endl;
40  m.print();
41  };
42 
43  std::string interfaceIP = "0.0.0.0";
44  uint16_t port = 9010;
45 
46 private:
47  class Handler : public osc::PacketHandler {
48  public:
49  OSCDomain *mOscDomain;
50  void onMessage(osc::Message &m) { mOscDomain->onMessage(m); }
51  } mHandler;
52  ParameterServer mParameterServer{"0.0.0.0", 9010, false};
53 };
54 
55 } // namespace al
56 
57 #endif // OSCDOMAIN_H
ComputationDomain class.
OSCDomain class.
bool stop() override
stop the asyncrhonous execution of the domain
bool init(ComputationDomain *parent=nullptr) override
initialize
bool cleanup(ComputationDomain *parent=nullptr) override
cleanup
bool start() override
start the asyncrhonous execution of the domain
void print(std::ostream &stream=std::cout)
print prints information about the server to std::out
Definition: al_App.hpp:23