SPAOP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GenericServerThreadListener.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 
21 #ifndef GENERICSERVERTHREADLISTENER_H_INCLUDED
22 #define GENERICSERVERTHREADLISTENER_H_INCLUDED
23 
24 #include "ServerThread.h"
25 
26 namespace lowrappers {
27 
33 template<class T>
35 {
36 public:
40  typedef int (T::*fpType)(const char *path, const char *types,
41  lo_arg **argv, int argc, lo_message msg);
42 
45  object_(object), fp_(fp)
46  {}
47 
50 
51  virtual int callback(const char *path, const char *types,
52  lo_arg **argv, int argc, lo_message msg)
53  {
54  return (object_.*fp_)(path, types, argv, argc, msg);
55  }
56 
57 private:
58  T& object_;
59  fpType fp_;
60 };
61 
92 template<class T>
93 ServerThread::Listener* ListenerMaker(T& object, int (T::*fp)(const char *path,
94  const char *types,lo_arg **argv, int argc, lo_message msg))
95 {
96  return new GenericServerThreadListener<T>(object, fp);
97 }
98 
99 }
100 
101 #endif // GENERICSERVERTHREADLISTENER_H_INCLUDED
ServerThread::Listener * ListenerMaker(T &object, int(T::*fp)(const char *path, const char *types, lo_arg **argv, int argc, lo_message msg))
A function that conveniently wraps up a GenericServerThreadListener.
Definition: GenericServerThreadListener.h:93
virtual ~GenericServerThreadListener()
Destructor.
Definition: GenericServerThreadListener.h:49
A generic functor class for the ServerThread::Listener interface.
Definition: GenericServerThreadListener.h:34
int(T::* fpType)(const char *path, const char *types, lo_arg **argv, int argc, lo_message msg)
The type of function pointer that can be passed to the constructor.
Definition: GenericServerThreadListener.h:40
GenericServerThreadListener(T &object, fpType fp)
Constructor.
Definition: GenericServerThreadListener.h:44
A listener interface for listeners to be called by the ServerThread when incoming OSC messages are re...
Definition: ServerThread.h:64
virtual int callback(const char *path, const char *types, lo_arg **argv, int argc, lo_message msg)
The callback method that will be called from the ServerThread.
Definition: GenericServerThreadListener.h:51