SPAOP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
WonderOscSenderThread.h
Go to the documentation of this file.
1 /*
2  * Copyright 2014 Martin Hansen
3  *
4  * This file is part of SPAOP (Spatial Audio Object Positioner).
5  *
6  * SPAOP 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 3 of the License, or
9  * (at your option) any later version.
10  *
11  * SPAOP 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.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with SPAOP. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef WONDEROSCSENDERTHREAD_H_INCLUDED
21 #define WONDEROSCSENDERTHREAD_H_INCLUDED
22 
23 
24 #include <mutex>
25 #include <condition_variable>
26 #include <deque>
27 #include <chrono>
28 #include <memory>
29 
30 #include "Thread.h"
31 #include "WonderOscSender.h"
32 #include "OscSenderThread.h"
33 #include "ServerThread.h"
34 #include "MessageWithPath.h"
35 
36 #define MSG_WAIT_INTERVAL 1
39 namespace wonderlo {
40 
50 class WonderOscSenderThread : public thread::Thread,
52  public WonderOscSender
53 {
54 public:
55 
66  WonderOscSenderThread(const std::string &host, const std::string &port,
67  int proto = LO_UDP);
68 
70  virtual ~WonderOscSenderThread();
71 
72  void start();
73 
74  void stop();
75 
76  void join();
77 
78 protected:
87  void run();
88 
89 
97  void sendMethod(const MessageWithPath& msg);
98 
103  void enqueMessage(const MessageWithPath* msg);
104 
116  void wonderSend(const MessageWithPath &msg);
117 
118 private:
119  std::mutex qMutex_; // guards the msg-queue
120  std::condition_variable qCondition_;
121  std::deque<const MessageWithPath*> msgQ_; // the message-queue
122 };
123 
124 }
125 
126 
127 
128 #endif // WONDEROSCSENDERTHREAD_H_INCLUDED
A lowrappers::Address implementing the wonder::OscSender interface.
Definition: WonderOscSender.h:33
An interface for a thread implementing the OscSender interface.
Definition: OscSenderThread.h:38
A thread implementing the wonder::OscSenderThread interface.
Definition: WonderOscSenderThread.h:51
A lowrappers::Message object that holds additional information about its destination OSC path...
Definition: MessageWithPath.h:31
A wrapper for the std::thread wrapping it into a Java-style thread object.
Definition: Thread.h:39