00001 00002 /* Copyright (c) 2006-2009, 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 EQNET_DISPATCHER_H 00019 #define EQNET_DISPATCHER_H 00020 00021 #include <eq/net/commandFunc.h> // member 00022 00023 #include <eq/base/base.h> 00024 00025 #include <vector> 00026 00027 namespace eq 00028 { 00029 namespace net 00030 { 00031 class Connection; 00032 class Command; 00033 class CommandQueue; 00034 enum CommandResult; 00035 00043 class Dispatcher 00044 { 00045 public: 00046 EQ_EXPORT Dispatcher(); 00047 EQ_EXPORT Dispatcher( const Dispatcher& from ); 00048 EQ_EXPORT virtual ~Dispatcher(); 00049 00051 const Dispatcher& operator = ( const Dispatcher& ) { return *this; } 00052 00061 EQ_EXPORT virtual bool dispatchCommand( Command& command ); 00062 00071 EQ_EXPORT virtual CommandResult invokeCommand( Command& command ); 00072 00073 protected: 00085 template< typename T > 00086 void registerCommand( const uint32_t command, 00087 const CommandFunc< T >& func, 00088 CommandQueue* destinationQueue ); 00089 00090 00097 CommandResult _cmdUnknown( Command& command ); 00098 00099 private: 00100 EQ_EXPORT void _registerCommand( const uint32_t command, 00101 const CommandFunc< Dispatcher >& func, 00102 CommandQueue* destinationQueue ); 00103 00105 std::vector< CommandFunc< Dispatcher > > _vTable; 00106 00108 std::vector< CommandQueue* > _qTable; 00109 }; 00110 00111 template< typename T > 00112 void Dispatcher::registerCommand( const uint32_t command, 00113 const CommandFunc< T >& func, 00114 CommandQueue* destinationQueue ) 00115 { 00116 _registerCommand( command, CommandFunc< Dispatcher >( func ), 00117 destinationQueue ); 00118 } 00119 } 00120 } 00121 00122 #endif // EQNET_DISPATCHER_H
0.9 by
1.5.8