void *FindInTree( Node t, void *key ) { if ( t == (Node)0 ) return NULL; switch( KeyCmp( key, ItemKey(t->item) ) ) { case -1 : return FindInTree( t->left, key ); case 0: return t->item; case +1 : return FindInTree( t->right, key ); } }
void *FindInCollection( collection c, void *key ) { /* Find an item in a collection Pre-condition: (c is a collection created by a call to ConsCollection) && (key != NULL) Post-condition: returns an item identified by key if one exists, otherwise returns NULL */ assert( c != NULL ); assert( key != NULL ); /* Select node at head of list */ return FindInTree( c->root, key ); }
VSPTree::VSPTree( QString appPath, QString argument) : m_applicationPath( appPath ), m_settings( appPath + "/VSPTree.ini", QSettings::IniFormat ) { QDir dir(PATH32); QDir dir2(PATH64); if ( dir.exists() ) { m_profilerpath = PATH32; } else if ( dir2.exists() ) { m_profilerpath = PATH64; } else { QMessageBox::critical(NULL,"Standalone Debugger not installed", "C:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\Team Tools\\Performance Tools\\ does not exist"); } QStringList env = QProcess::systemEnvironment(); env.replaceInStrings(QRegExp("^PATH=(.*)", Qt::CaseInsensitive), QString("PATH=\\1;") + m_profilerpath); m_process.setEnvironment(env); if ( m_settings.contains("m_lastExe") ) { m_lastExe = m_settings.value("m_lastExe").toString(); } if ( m_settings.contains("m_lastVSP") ) { m_lastVSP = m_settings.value("m_lastVSP").toString(); } if ( m_settings.contains("m_lastArguments") ) { m_lastArguments = m_settings.value("m_lastArguments").toString(); } m_editorPath = ""; if ( m_settings.contains("m_editorPath") ) { m_editorPath = m_settings.value("m_editorPath").toString(); } m_editorArguments = "<filename> -n<linenum>"; if ( m_settings.contains("m_editorArguments") ) { m_editorArguments = m_settings.value("m_editorArguments").toString(); } m_log = new QTextEdit(); m_log->setReadOnly(true); connect (&m_process, SIGNAL(readyReadStandardOutput()),this, SLOT(StdOutLog())); connect (&m_process, SIGNAL(readyReadStandardError()),this, SLOT(StdErrorLog())); menubar = this->menuBar(); QMenu* fileMenu = menubar->addMenu("File"); QAction* openAct = fileMenu->addAction("Open VSP"); connect(openAct, SIGNAL(triggered()), this, SLOT(LoadVSPClicked())); QAction* exitAct = fileMenu->addAction("Exit"); connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); QMenu* profilerMenu = menubar->addMenu("Profiler"); QAction* startProfilingAct = profilerMenu->addAction("Start Profiler Service"); connect(startProfilingAct, SIGNAL(triggered()), this, SLOT(StartProfiling())); QAction* ProfileAct = profilerMenu->addAction("Profile Application"); connect(ProfileAct, SIGNAL(triggered()), this, SLOT(Profile())); QAction* stopProfilingAct = profilerMenu->addAction("Stop Profiler Service"); connect(stopProfilingAct, SIGNAL(triggered()), this, SLOT(StopProfiling())); QMenu* OptionsMenu = menubar->addMenu("Options"); QAction* setTextEditor = OptionsMenu->addAction("Set Text Editor"); connect(setTextEditor, SIGNAL(triggered()), this, SLOT(setTextEditor())); m_tabWidget = new QTabWidget(); m_callTreeWidget = new QTreeWidget(); m_flatCallTreeWidget = new QTreeWidget(); m_functionSummaryTreeWidget = new QTreeWidget(); m_tabWidget->addTab(m_callTreeWidget,"CallTree"); m_tabWidget->addTab(m_flatCallTreeWidget,"CallTreeFlat"); m_tabWidget->addTab(m_functionSummaryTreeWidget,"FunctionSummary"); m_tabWidget->addTab(m_log,"Log"); m_callTreeMenu = new QMenu(); QAction* openFileAct = m_callTreeMenu->addAction("Open File"); connect(openFileAct, SIGNAL(triggered()), this, SLOT(openFile())); QAction* expandAllAct = m_callTreeMenu->addAction("Expand All"); connect(expandAllAct, SIGNAL(triggered()), m_callTreeWidget, SLOT(expandAll())); QAction* collapseAllAct = m_callTreeMenu->addAction("Collapse All"); connect(collapseAllAct, SIGNAL(triggered()), m_callTreeWidget, SLOT(collapseAll())); m_flatCallTreeMenu = new QMenu(); m_flatCallTreeMenu->addAction(openFileAct); QAction* FindInTreeAct = m_flatCallTreeMenu->addAction("Find In Tree"); connect(FindInTreeAct, SIGNAL(triggered()), this, SLOT(FindInTree())); //threads connect( &m_thread, SIGNAL( output( QString ) ), this, SLOT( Log( QString ) ) ); connect( &m_thread, SIGNAL( finished() ), this, SLOT( workDone() ) ); this->setCentralWidget(m_tabWidget); this->setWindowTitle(VERSION); this->resize(640,480); this->show(); if ( !argument.isEmpty() ) { LoadVSP(argument); } }