Collage
0.6.1
|
00001 00002 /* Copyright (c) 2006-2012, Stefan Eilemann <eile@equalizergraphics.com> 00003 * 00004 * This library is free software; you can redistribute it and/or modify it under 00005 * the terms of the GNU Lesser General Public License version 2.1 as published 00006 * by the Free Software Foundation. 00007 * 00008 * This library is distributed in the hope that it will be useful, but WITHOUT 00009 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00010 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00011 * details. 00012 * 00013 * You should have received a copy of the GNU Lesser General Public License 00014 * along with this library; if not, write to the Free Software Foundation, Inc., 00015 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00016 */ 00017 00018 #ifndef CO_DISPATCHER_H 00019 #define CO_DISPATCHER_H 00020 00021 #include <co/api.h> 00022 #include <co/commandFunc.h> // used inline 00023 #include <co/types.h> 00024 00025 namespace co 00026 { 00027 namespace detail { class Dispatcher; } 00028 00036 class Dispatcher 00037 { 00038 public: 00039 typedef CommandFunc< Dispatcher > Func; 00040 00041 CO_API Dispatcher(); 00042 CO_API Dispatcher( const Dispatcher& from ); 00043 CO_API virtual ~Dispatcher(); 00044 00046 const Dispatcher& operator = ( const Dispatcher& ) { return *this; } 00047 00055 CO_API virtual bool dispatchCommand( Command& command ); 00056 00057 protected: 00070 template< typename T > void 00071 registerCommand( const uint32_t command, const CommandFunc< T >& func, 00072 CommandQueue* destinationQueue ); 00073 00074 00081 CO_API bool _cmdUnknown( Command& command ); 00082 00083 private: 00084 detail::Dispatcher* const _impl; 00085 00086 CO_API void _registerCommand( const uint32_t command, 00087 const Func& func, 00088 CommandQueue* destinationQueue ); 00089 }; 00090 00091 template< typename T > 00092 void Dispatcher::registerCommand( const uint32_t command, 00093 const CommandFunc< T >& func, 00094 CommandQueue* queue ) 00095 { 00096 _registerCommand( command, Dispatcher::Func( func ), queue ); 00097 } 00098 } 00099 #endif // CO_DISPATCHER_H