![]() |
|
|
00001 /*************************************************************************** 00002 * inspectorJ - java profiler * 00003 * Copyright (C) 2007 by James May 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; if not, write to the * 00017 * Free Software Foundation, Inc., * 00018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00019 ***************************************************************************/ 00020 00026 #ifndef JDWPPACKET_H 00027 #define JDWPPACKET_H 00028 00029 #include "inspectorj/jdwp/jdwpconstants.h" 00030 #include "jdwpTransport.h" 00031 #include <QByteArray> 00032 #include <QDataStream> 00033 00034 namespace inspectorj { 00035 namespace jdwp { 00036 00045 class JDWPPacket 00046 { 00047 public: 00048 JDWPPacket(); 00049 virtual ~JDWPPacket(); 00050 00051 virtual jint getLength(); 00052 virtual jbyte getPacketType() = 0; 00053 virtual jint getId() = 0; 00054 virtual short getErrorCode(); 00055 char* getDataBytes(); 00056 virtual JDWPPacket* copy() = 0; 00057 00058 static void initIDSizes(JDWPPacket&); 00059 00060 00061 /* ==== Write operators ==== */ 00062 00064 JDWPPacket& operator<<(jbyte &byte); 00065 00067 JDWPPacket& operator<<(bool &b); 00068 00070 JDWPPacket& operator<<(jint &i); 00071 00072 #if defined (_WIN32) 00074 JDWPPacket& operator<<(qint32 &i); 00075 #endif 00076 00078 JDWPPacket& operator<<(qint64 &i); 00079 00081 JDWPPacket& operator<<(QString &s); 00082 00084 JDWPPacket& operator<<(FieldID &fid); 00085 00087 JDWPPacket& operator<<(ObjectID &oid); 00088 00090 JDWPPacket& operator<<(MethodID &mid); 00091 00093 JDWPPacket& operator<<(ReferenceTypeID &rid); 00094 00096 JDWPPacket& operator<<(FrameID &fid); 00097 00098 /* ==== Read operators ==== */ 00099 00101 JDWPPacket& operator>>(jbyte &b); 00102 00104 JDWPPacket& operator>>(bool &b); 00105 00107 JDWPPacket& operator>>(qint32 &i); 00108 00110 JDWPPacket& operator>>(qint64 &i); 00111 00113 JDWPPacket& operator>>(QString &s); 00114 00116 JDWPPacket& operator>>(FieldID &fid); 00117 00119 JDWPPacket& operator>>(ObjectID &oid); 00120 00122 JDWPPacket& operator>>(MethodID &mid); 00123 00125 JDWPPacket& operator>>(ReferenceTypeID &rid); 00126 00128 JDWPPacket& operator>>(FrameID &fid); 00129 00130 00131 protected: 00132 00133 /* The following data type sizes are VM specific */ 00134 00136 static int FIELD_ID_SIZE; 00137 00139 static int OBJECT_ID_SIZE; 00140 00142 static int METHOD_ID_SIZE; 00143 00145 static int REFERENCE_TYPE_ID_SIZE; 00146 00148 static int FRAME_ID_SIZE; 00149 00151 QDataStream *data; 00152 00154 QByteArray bytes; 00155 00157 void setReadMode(); 00158 00160 void setWriteMode(); 00161 00162 }; 00163 00164 } // end namespace jdwp 00165 } // end namespace inspectorj 00166 00167 #endif //JDWPPACKET_H