File indexing completed on 2024-04-28 04:34:22

0001 /***************************************************************************
0002  *   Copyright 2009 Sandro Andrade <sandroandrade@kde.org>                 *
0003  *                                                                         *
0004  *   This program is free software; you can redistribute it and/or modify  *
0005  *   it under the terms of the GNU Library General Public License as       *
0006  *   published by the Free Software Foundation; either version 2 of the    *
0007  *   License, or (at your option) any later version.                       *
0008  *                                                                         *
0009  *   This program is distributed in the hope that it will be useful,       *
0010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0012  *   GNU General Public License for more details.                          *
0013  *                                                                         *
0014  *   You should have received a copy of the GNU Library General Public     *
0015  *   License along with this program; if not, write to the                 *
0016  *   Free Software Foundation, Inc.,                                       *
0017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
0018  ***************************************************************************/
0019 
0020 #include "duchaincontrolflowinternaljob.h"
0021 
0022 #include "duchaincontrolflow.h"
0023 #include "kdevcontrolflowgraphviewplugin.h"
0024 
0025 DUChainControlFlowInternalJob::DUChainControlFlowInternalJob(DUChainControlFlow *duchainControlFlow, KDevControlFlowGraphViewPlugin *plugin)
0026  : m_duchainControlFlow(duchainControlFlow),
0027    m_plugin(plugin),
0028    m_controlFlowJobType(DUChainControlFlowInternalJob::ControlFlowJobInteractive)
0029 {
0030 }
0031 
0032 DUChainControlFlowInternalJob::~DUChainControlFlowInternalJob()
0033 {
0034 }
0035 
0036 void DUChainControlFlowInternalJob::setControlFlowJobType(DUChainControlFlowInternalJob::ControlFlowJobType controlFlowJobType)
0037 {
0038     m_controlFlowJobType = controlFlowJobType;   
0039 }
0040 
0041 void DUChainControlFlowInternalJob::requestAbort()
0042 {
0043     if (m_plugin)
0044     {
0045         kDebug() << "Requesting abort";
0046         m_plugin->requestAbort();
0047     }
0048 }
0049 
0050 void DUChainControlFlowInternalJob::run()
0051 {
0052     switch(m_controlFlowJobType)
0053     {
0054         case ControlFlowJobInteractive:
0055         {
0056             if (m_duchainControlFlow)
0057                 m_duchainControlFlow->run();
0058             break;
0059         }
0060         case ControlFlowJobBatchForFunction:
0061         {
0062             if (m_plugin)
0063                 m_plugin->generateControlFlowGraph();
0064             break;
0065         }
0066         case ControlFlowJobBatchForClass:
0067         {
0068             if (m_plugin)
0069                 m_plugin->generateClassControlFlowGraph();
0070             break;
0071         }
0072         case ControlFlowJobBatchForProject:
0073         {
0074             if (m_plugin)
0075                 m_plugin->generateProjectControlFlowGraph();
0076             break;
0077         }
0078     };
0079 }