Collage  1.7.0
High-performance C++ library for developing object-oriented distributed applications.
dispatcher.h
1 
2 /* Copyright (c) 2006-2016, Stefan Eilemann <eile@equalizergraphics.com>
3  * Daniel Nachbaur <danielnachbaur@gmail.com>
4  *
5  * This file is part of Collage <https://github.com/Eyescale/Collage>
6  *
7  * This library is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU Lesser General Public License version 2.1 as published
9  * by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #ifndef CO_DISPATCHER_H
22 #define CO_DISPATCHER_H
23 
24 #include <co/api.h>
25 #include <co/commandFunc.h> // used inline
26 #include <co/types.h>
27 
28 namespace co
29 {
30 namespace detail
31 {
32 class Dispatcher;
33 }
34 
42 {
43 public:
46 
48  Dispatcher& operator=(const Dispatcher&) { return *this; }
61  template <typename T>
62  void registerCommand(const uint32_t command, const CommandFunc<T>& func,
63  CommandQueue* queue);
64 
73  CO_API virtual bool dispatchCommand(ICommand& command);
74 
75 protected:
76  CO_API Dispatcher();
77  CO_API Dispatcher(const Dispatcher& from);
78  CO_API virtual ~Dispatcher();
79 
86  CO_API bool _cmdUnknown(ICommand& command);
87 
88 private:
89  detail::Dispatcher* const _impl;
90 
91  CO_API void _registerCommand(const uint32_t command, const Func& func,
92  CommandQueue* queue);
93 };
94 
95 template <typename T>
96 void Dispatcher::registerCommand(const uint32_t command,
97  const CommandFunc<T>& func,
98  CommandQueue* queue)
99 {
100  _registerCommand(command, Dispatcher::Func(func), queue);
101 }
102 }
103 #endif // CO_DISPATCHER_H
Defines export visibility macros for library Collage.
CommandFunc< Dispatcher > Func
The signature of the base Dispatcher callback.
Definition: dispatcher.h:45
A thread-safe, blocking queue for ICommand buffers.
Definition: commandQueue.h:36
void registerCommand(const uint32_t command, const CommandFunc< T > &func, CommandQueue *queue)
Register a command member function for a command.
Definition: dispatcher.h:96
Object-oriented network library.
Definition: barrier.h:27
A class managing received commands.
Definition: iCommand.h:45
A wrapper to register a function callback on an object instance.
Definition: commandFunc.h:39
A class providing command dispatch functionality to networked objects.
Definition: dispatcher.h:41