ij-16.png   inspectorJ -- JavaTM Profiler
sf project site browse source checkout source
SourceForge.net Logo



src/inspectorj/client/jdwpaction.h

Go to the documentation of this file.
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 
00027 #ifndef JDWP_ACTION_H
00028 #define JDWP_ACTION_H
00029 
00030 #include <QObject>
00031 #include "inspectorj/client/invokerthread.h"
00032         
00033 using inspectorj::jdwp::JDWPPacket;
00034         
00035 namespace inspectorj {
00036 namespace client {   
00037             
00043 class JDWPAction : public QObject
00044 {
00045     Q_OBJECT
00046             
00047     public:
00051         JDWPAction()
00052         {
00053             
00054         };
00055                 
00060         JDWPAction(QObject *parent)
00061         {
00062             setParent(parent);
00063         };
00064         
00068         ~JDWPAction()
00069         {
00070         };
00071         
00076         virtual void trigger(JDWPPacket &packet)
00077         {
00078            emit triggered(packet);
00079            emit finished();
00080         };
00081         
00082     signals:
00086         void triggered(JDWPPacket&);
00087         
00091         void finished();
00092         
00093     private:
00094 
00095 };
00096 
00103 template <typename TClass>
00104 class JDWPThreadAction : public JDWPAction
00105 {
00106     private:
00108         TClass* clsObject;
00109         
00111         void (TClass::*callbackFpt)(JDWPPacket&);
00112 
00113     public:   
00120         JDWPThreadAction(QObject *parent, TClass* cls, void (TClass::*fpt)(JDWPPacket&))
00121             : clsObject(cls), callbackFpt(fpt)
00122         {
00123             setParent(parent);
00124         };
00125         
00129         ~JDWPThreadAction()
00130         {
00131         };
00132         
00138         void trigger(JDWPPacket &packet)
00139         {            
00140             InvokerThread<TClass> *thread = new InvokerThread<TClass>(clsObject, callbackFpt, packet);
00141             connect(thread, SIGNAL(finished()), this, SIGNAL(finished()));
00142             connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));            
00143             thread->start();
00144         };
00145 };
00146     
00147 } // end namespace client
00148 } // end namespace inspectorj
00149 
00150 #endif //JDWP_ACTION_H

Generated on Sun Aug 19 17:07:53 2007 for inspectorJ by  doxygen 1.5.1