Equalizer 1.0

dispatcher.h

00001 
00002 /* Copyright (c) 2006-2011, 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> // member
00023 #include <co/types.h>
00024 
00025 #include <vector>
00026 
00027 namespace co
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 >
00071         void registerCommand( const uint32_t command, 
00072                               const CommandFunc< T >& func,
00073                               CommandQueue* destinationQueue );
00074 
00075         
00082         CO_API bool _cmdUnknown( Command& command );
00083 
00084     private:
00085         CO_API void _registerCommand( const uint32_t command, 
00086                                       const Func& func,
00087                                       CommandQueue* destinationQueue );
00088 
00090         std::vector< Func > _fTable;
00091         
00093         std::vector< CommandQueue* > _qTable;
00094     };
00095 
00096     template< typename T >
00097     void Dispatcher::registerCommand( const uint32_t command,
00098                                 const CommandFunc< T >& func,
00099                                 CommandQueue* destinationQueue )
00100     {
00101         _registerCommand( command, Dispatcher::Func( func ),
00102                           destinationQueue );
00103     }
00104 }
00105 
00106 #endif // CO_DISPATCHER_H
Generated on Sun May 8 2011 19:11:05 for Equalizer 1.0 by  doxygen 1.7.3