ArtMOO
|
00001 #ifndef CONNECTION_H 00002 #define CONNECTION_H 00003 00004 #include <QObject> 00005 #include <QByteArray> 00006 #include "mooglobal.h" 00007 #include "taskentry.h" 00008 #include "inputsink.h" 00009 00010 class Connection : public QObject 00011 { 00012 Q_OBJECT 00013 00014 explicit Connection( ConnectionId pConnectionId, QObject *pParent = 0 ); 00015 00016 inline void setObjectId( const ObjectId pObjectId ) 00017 { 00018 mObjectId = pObjectId; 00019 } 00020 00021 friend class ConnectionManager; 00022 00023 public: 00024 inline ConnectionId id( void ) const 00025 { 00026 return( mConnectionId ); 00027 } 00028 00029 inline QString name( void ) const 00030 { 00031 return( mName ); 00032 } 00033 00034 inline ObjectId player( void ) const 00035 { 00036 return( mPlayerId ); 00037 } 00038 00039 inline ObjectId object( void ) const 00040 { 00041 return( mObjectId ); 00042 } 00043 00044 inline const QString &prefix( void ) const 00045 { 00046 return( mPrefix ); 00047 } 00048 00049 inline const QString &suffix( void ) const 00050 { 00051 return( mSuffix ); 00052 } 00053 00054 void setPrefix( const QString &pPrefix ) 00055 { 00056 mPrefix = pPrefix; 00057 } 00058 00059 void setSuffix( const QString &pSuffix ) 00060 { 00061 mSuffix = pSuffix; 00062 } 00063 00064 inline void setPlayerId( ObjectId pPlayerId ) 00065 { 00066 mPlayerId = pPlayerId; 00067 } 00068 00069 inline void pushInputSink( InputSink *pIS ) 00070 { 00071 mInputSinkList.push_front( pIS ); 00072 } 00073 00074 bool processInput( const QString &pData ); 00075 00076 signals: 00077 void taskOutput( TaskEntry &pTask ); 00078 void textOutput( const QString &pText ); 00079 00080 public slots: 00081 void notify( const QString &pText ); 00082 void dataInput( const QString &pText ); 00083 00084 private: 00085 ConnectionId mConnectionId; 00086 ObjectId mObjectId; 00087 ObjectId mPlayerId; 00088 QString mPrefix; 00089 QString mSuffix; 00090 qint64 mConnectionTime; 00091 qint64 mLastActiveTime; 00092 QString mName; 00093 QList<InputSink *> mInputSinkList; 00094 }; 00095 00096 #endif // CONNECTION_H