00001
00002
00003
00004
00005 #ifndef EQNET_BASE_H
00006 #define EQNET_BASE_H
00007
00008 #include <eq/net/commandFunc.h>
00009
00010 #include <eq/base/base.h>
00011
00012 #include <vector>
00013
00014 namespace eq
00015 {
00016 namespace net
00017 {
00018 class Connection;
00019 class Command;
00020 class CommandQueue;
00021 enum CommandResult;
00022
00029 class EQ_EXPORT Base
00030 {
00031 public:
00032 Base() {}
00033 Base( const Base& from ) {}
00034 virtual ~Base() {}
00035
00037 const Base& operator = ( const Base& ) { return *this; }
00038
00047 virtual bool dispatchCommand( Command& command );
00048
00057 virtual CommandResult invokeCommand( Command& command );
00058
00059 protected:
00071 template< typename T >
00072 void registerCommand( const uint32_t command,
00073 const CommandFunc<T>& func,
00074 CommandQueue* destinationQueue );
00075
00076
00083 CommandResult _cmdUnknown( Command& command );
00084
00085 private:
00086 void _registerCommand( const uint32_t command,
00087 const CommandFunc<Base>& func,
00088 CommandQueue* destinationQueue );
00089
00091 std::vector< CommandFunc<Base> > _vTable;
00092
00094 std::vector< CommandQueue* > _qTable;
00095 };
00096
00097 template< typename T >
00098 void Base::registerCommand( const uint32_t command,
00099 const CommandFunc<T>& func,
00100 CommandQueue* destinationQueue )
00101 {
00102 _registerCommand( command, static_cast< CommandFunc<Base> >( func ),
00103 destinationQueue );
00104 }
00105 }
00106 }
00107
00108 #endif // EQNET_BASE_H