00001
00002
00003
00004
00005 #ifndef EQNET_COMMAND_H
00006 #define EQNET_COMMAND_H
00007
00008 #include <eq/net/node.h>
00009
00010 #include <eq/base/base.h>
00011 #include <eq/base/refPtr.h>
00012
00013 namespace eq
00014 {
00015 namespace net
00016 {
00017 struct Packet;
00018
00028 class Command
00029 {
00030 public:
00031 Command();
00032 Command( const Command& from );
00033 ~Command();
00034
00035 void swap( Command& rhs );
00036
00037 Packet* getPacket() { return _packet; }
00038 const Packet* getPacket() const { return _packet; }
00039
00040 template< class P > P* getPacket()
00041 { EQASSERT( _packet ); return reinterpret_cast<P*>( _packet ); }
00042 template< class P > const P* getPacket() const
00043 { EQASSERT( _packet ); return reinterpret_cast<P*>( _packet ); }
00044
00045 NodePtr getNode() const { return _node; }
00046 NodePtr getLocalNode() const { return _localNode; }
00047
00048 bool operator ! () const { return ( _packet==0 ); }
00049
00050 Packet* operator->() { EQASSERT(_packet); return _packet; }
00051 const Packet* operator->() const { EQASSERT(_packet); return _packet; }
00052
00053 void allocate( NodePtr node, NodePtr localNode,
00054 const uint64_t packetSize );
00055 void release();
00056 bool isValid() const { return ( _packet!=0 ); }
00057
00058 bool isDispatched() const { return _dispatched; }
00059
00060 private:
00061 Command& operator = ( Command& rhs );
00062
00063 NodePtr _node;
00064 NodePtr _localNode;
00065 Packet* _packet;
00066 uint64_t _packetAllocSize;
00067
00068 bool _dispatched;
00069 friend class CommandQueue;
00070 };
00071
00072 EQ_EXPORT std::ostream& operator << ( std::ostream& os, const Command& );
00073 }
00074 }
00075 #endif // EQNET_COMMAND_H