VBoxDbgStatsQt4.h revision a1ede5a1624d0f50c5bfc81237cf0e824f5cebac
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl/* $Id$ */
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl/** @file
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * VBox Debugger GUI - Statistics.
b340aad1efbfbba5e837fac89da17767384f24e7noodl */
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl/*
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * Copyright (C) 2006-2007 Sun Microsystems, Inc.
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl *
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * This file is part of VirtualBox Open Source Edition (OSE), as
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * available from http://www.virtualbox.org. This file is free software;
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * you can redistribute it and/or modify it under the terms of the GNU
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * General Public License (GPL) as published by the Free Software
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * Foundation, in version 2 as it comes in the "COPYING" file of the
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl *
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * Clara, CA 95054 USA or visit http://www.sun.com if you need
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * additional information or have any questions.
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl */
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl#ifndef ___Debugger_VBoxDbgStats_h
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl#define ___Debugger_VBoxDbgStats_h
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim#include "VBoxDbgBase.h"
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim#include <QTreeView>
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl#include <QTimer>
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl#include <QComboBox>
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl#include <QMenu>
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jimclass VBoxDbgStats;
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodlclass VBoxDbgStatsModel;
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl
c3ea2f06571c877091cd2f1016e47b1d5660df9drjung/** Pointer to a statistics sample. */
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodltypedef struct DBGGUISTATSNODE *PDBGGUISTATSNODE;
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim/** Pointer to a const statistics sample. */
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodltypedef struct DBGGUISTATSNODE const *PCDBGGUISTATSNODE;
c3ea2f06571c877091cd2f1016e47b1d5660df9drjung
c3ea2f06571c877091cd2f1016e47b1d5660df9drjung
c3ea2f06571c877091cd2f1016e47b1d5660df9drjung/**
c3ea2f06571c877091cd2f1016e47b1d5660df9drjung * The VM statistics tree view.
c3ea2f06571c877091cd2f1016e47b1d5660df9drjung *
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim * A tree represenation of the STAM statistics.
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl */
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodlclass VBoxDbgStatsView : public QTreeView, public VBoxDbgBase
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl{
62a2a9c404bec6aee7dc0ba15465c9ee899be4a2noodl Q_OBJECT;
2f83bdeb8f4a4f370e26edf99666e7965c58de22poirier
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodlpublic:
c3ea2f06571c877091cd2f1016e47b1d5660df9drjung /**
c3ea2f06571c877091cd2f1016e47b1d5660df9drjung * Creates a VM statistics list view widget.
c3ea2f06571c877091cd2f1016e47b1d5660df9drjung *
c3ea2f06571c877091cd2f1016e47b1d5660df9drjung * @param a_pVM The VM which STAM data is being viewed.
c3ea2f06571c877091cd2f1016e47b1d5660df9drjung * @param a_pModel The model. Will take ownership of this and delete it together
c3ea2f06571c877091cd2f1016e47b1d5660df9drjung * with the view later
c3ea2f06571c877091cd2f1016e47b1d5660df9drjung * @param a_pParent Parent widget.
c3ea2f06571c877091cd2f1016e47b1d5660df9drjung */
c3ea2f06571c877091cd2f1016e47b1d5660df9drjung VBoxDbgStatsView(PVM a_pVM, VBoxDbgStatsModel *a_pModel, VBoxDbgStats *a_pParent = NULL);
c3ea2f06571c877091cd2f1016e47b1d5660df9drjung
c3ea2f06571c877091cd2f1016e47b1d5660df9drjung /** Destructor. */
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl virtual ~VBoxDbgStatsView();
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl /**
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim * Updates the view with current information from STAM.
c3ea2f06571c877091cd2f1016e47b1d5660df9drjung * This will indirectly update the m_PatStr.
c3ea2f06571c877091cd2f1016e47b1d5660df9drjung *
c3ea2f06571c877091cd2f1016e47b1d5660df9drjung * @param rPatStr Selection pattern. NULL means everything, see STAM for further details.
c3ea2f06571c877091cd2f1016e47b1d5660df9drjung */
c3ea2f06571c877091cd2f1016e47b1d5660df9drjung void update(const QString &rPatStr);
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl /**
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * Resets the stats items matching the specified pattern.
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * This pattern doesn't have to be the one used for update, thus m_PatStr isn't updated.
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim *
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * @param rPatStr Selection pattern. NULL means everything, see STAM for further details.
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl */
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl void reset(const QString &rPatStr);
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jimprivate:
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl /**
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * Callback function for the STAMR3Enum() made by update().
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl *
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * @returns 0 (i.e. never halt enumeration).
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim *
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * @param pszName The name of the sample.
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim * @param enmType The type.
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * @param pvSample Pointer to the data. enmType indicates the format of this data.
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * @param enmUnit The unit.
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * @param enmVisibility The visibility.
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim * @param pszDesc The description.
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * @param pvUser Pointer to the VBoxDbgStatsView object.
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim */
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl//later: static DECLCALLBACK(int) updateCallback(const char *pszName, STAMTYPE enmType, void *pvSample, STAMUNIT enmUnit,
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl//later: STAMVISIBILITY enmVisibility, const char *pszDesc, void *pvUser);
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodlprotected:
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl /**
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * Creates / finds the path to the specified stats item and makes is visible.
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl *
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * @returns Parent node.
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * @param pszName Path to a stats item.
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl */
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim// VBoxDbgStatsItem *createPath(const char *pszName);
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodlprotected slots:
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl//later: /** Context menu. */
1f5c891e2da26b6b787e429aa71d9c899cc26dfcnoodl//later: void contextMenuReq(QListViewItem *pItem, const QPoint &rPoint, int iColumn);
1f5c891e2da26b6b787e429aa71d9c899cc26dfcnoodl//later: /** Leaf context. */
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl//later: void leafMenuActivated(int iId);
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim//later: /** Branch context. */
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl//later: void branchMenuActivated(int iId);
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl//later: /** View context. */
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl//later: void viewMenuActivated(int iId);
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodlprotected:
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim typedef enum { eRefresh = 1, eReset, eExpand, eCollaps, eCopy, eLog, eLogRel } MenuId;
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodlprotected:
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl /** Pointer to the data model. */
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim VBoxDbgStatsModel *m_pModel;
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl /** The current selection pattern. */
62a2a9c404bec6aee7dc0ba15465c9ee899be4a2noodl QString m_PatStr;
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl /** The parent widget. */
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl VBoxDbgStats *m_pParent;
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim /** Leaf item menu. */
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl QMenu *m_pLeafMenu;
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl /** Branch item menu. */
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl QMenu *m_pBranchMenu;
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl /** View menu. */
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl QMenu *m_pViewMenu;
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim /** The pointer to the node which is the current focus of a context menu. */
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl PDBGGUISTATSNODE m_pContextNode;
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl};
1f5c891e2da26b6b787e429aa71d9c899cc26dfcnoodl
1f5c891e2da26b6b787e429aa71d9c899cc26dfcnoodl
1f5c891e2da26b6b787e429aa71d9c899cc26dfcnoodl
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim/**
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * The VM statistics window.
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl *
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim * This class displays the statistics of a VM. The UI contains
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * a entry field for the selection pattern, a refresh interval
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * spinbutton, and the tree view with the statistics.
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl */
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jimclass VBoxDbgStats :
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl#ifdef VBOXDBG_USE_QT4
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl public QWidget,
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl#else
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim public QVBox,
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl#endif
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl public VBoxDbgBase
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl{
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim Q_OBJECT;
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodlpublic:
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl /**
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * Creates a VM statistics list view widget.
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl *
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim * @param pVM The VM this is hooked up to.
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * @param pszPat Initial selection pattern. NULL means everything. (See STAM for details.)
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * @param uRefreshRate The refresh rate. 0 means not to refresh and is the default.
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * @param pParent Parent widget.
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim */
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl VBoxDbgStats(PVM pVM, const char *pszPat = NULL, unsigned uRefreshRate= 0, QWidget *pParent = NULL);
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl /** Destructor. */
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl virtual ~VBoxDbgStats();
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodlprotected slots:
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim /** Apply the activated combobox pattern. */
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl void apply(const QString &Str);
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim /** The "All" button was pressed. */
a92ed1dc978b8a21f85d67024c3de804c78ce801noodl void applyAll();
1f5c891e2da26b6b787e429aa71d9c899cc26dfcnoodl /** Refresh the data on timer tick and pattern changed. */
1f5c891e2da26b6b787e429aa71d9c899cc26dfcnoodl void refresh();
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl /**
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * Set the refresh rate.
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl *
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * @param iRefresh The refresh interval in seconds.
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim */
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl void setRefresh(int iRefresh);
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim
1f5c891e2da26b6b787e429aa71d9c899cc26dfcnoodlprotected:
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl /** The current selection pattern. */
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim QString m_PatStr;
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl /** The pattern combo box. */
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl QComboBox *m_pPatCB;
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim /** The refresh rate in seconds.
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl * 0 means not to refresh. */
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl unsigned m_uRefreshRate;
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl /** The refresh timer .*/
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim QTimer *m_pTimer;
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl /** The tree view widget. */
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl VBoxDbgStatsView *m_pView;
09b7818702ba693db2f407a7dc9fd3b47075e4fetdonovan};
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl
7b552a9601e65e956b13ad02add4c625d32e30a6dpejesh
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl#endif
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl
e6ecf842cd6b826f0f0c3ce4415c054ed61581efnoodl