VBoxDbgStats.h revision ec9a11eb28318df36cc0c39d53454ac2729e932e
/* $Id$ */
/** @file
* VBox Debugger GUI - Statistics.
*/
/*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
#ifndef __VBoxDbgStats_h__
#define __VBoxDbgStats_h__
#include "VBoxDbgBase.h"
#ifdef VBOXDBG_USE_QT4
# include <QTreeWidget>
# include <QTimer>
# include <QComboBox>
# include <QMenu>
typedef QMenu QPopupMenu;
typedef QTreeWidget QListView;
typedef QTreeWidgetItem QListViewItem;
#else
# include <qlistview.h>
# include <qvbox.h>
# include <qtimer.h>
# include <qcombobox.h>
# include <qpopupmenu.h>
#endif
/**
* A statistics item.
*
* This class represent can be both a leaf and a branch item.
*/
{
/**
* Constructor.
*
* @param pszName The name of this item.
* @param pParent The parent view item.
* @param fBranch Set if this is a branch.
*/
/**
* Constructor.
*
* @param pszName The name of this item.
* @param pParent The parent list view.
* @param fBranch Set if this is a branch.
*/
/** Destructor. */
/**
* Gets the STAM name of the item.
* @returns STAM Name.
*/
const char *getName() const
{
return m_pszName;
}
/**
* Branch item?
* @returns true if branch, false if leaf.
*/
bool isBranch() const
{
return m_fBranch;
}
/**
* Leaf item?
* @returns true if leaf, false if branch.
*/
bool isLeaf() const
{
return !m_fBranch;
}
/**
* Gets the parent item.
* @returns Pointer to parent item, NULL if this is the root item.
*/
{
return m_pParent;
}
#ifdef VBOXDBG_USE_QT4
///virtual bool operator<(const QTreeWidgetItem &other) const;
#else
/**
* Get sort key.
*
* @returns The sort key.
* @param iColumn The column to sort.
* @param fAscending The sorting direction.
*/
{
}
#endif
/**
* Logs the tree starting at this item to one of the default logs.
* @param fReleaseLog If set use RTLogRelPrintf instead of RTLogPrintf.
*/
/**
* Converts the tree starting at this item into a string and adds it to
* the specified string object.
* @param String The string to append the stringified tree to.
*/
/**
* Copies the stringified tree onto the clipboard.
*/
void copyTreeToClipboard(void) const;
#ifdef VBOXDBG_USE_QT4
void setVisible(bool fVisible)
{
}
bool isVisible()
{
return !isHidden();
}
#endif
/** The name of this item. */
char *m_pszName;
/** Branch (true) / Leaf (false) indicator */
bool m_fBranch;
/** Parent item.
* This is NULL for the root item. */
};
/**
* A statistics item.
*
* This class represent one statistical item from STAM.
*/
{
/**
* Constructor.
*
* @param pszName The name of this item.
* @param pParent The parent view item.
*/
/** Destructor. */
/**
* Updates the item when current data.
*
* @param enmType The current type of the object.
* @param pvSample Pointer to the sample (may change).
* @param enmUnit The current unit.
* @param enmVisibility The current visibility settings.
* @param pszDesc The current description.
*/
void update(STAMTYPE enmType, void *pvSample, STAMUNIT enmUnit, STAMVISIBILITY enmVisibility, const char *pszDesc);
/**
* Get sort key.
*
* @returns The sort key.
* @param iColumn The column to sort.
* @param fAscending The sorting direction.
*/
/**
* Logs the tree starting at this item to one of the default logs.
* @param fReleaseLog If set use RTLogRelPrintf instead of RTLogPrintf.
*/
/**
* Converts the tree starting at this item into a string and adds it to
* the specified string object.
* @param String The string to append the stringified tree to.
*/
/** Pointer to the next item in the list.
* The list is maintained by the creator of the object, not the object it self. */
/** Pointer to the previous item in the list. */
/** The data type. */
/** The data at last update. */
union
{
/** STAMTYPE_COUNTER. */
/** STAMTYPE_PROFILE. */
/** STAMTYPE_PROFILE_ADV. */
/** STAMTYPE_RATIO_U32. */
/** STAMTYPE_U8 & STAMTYPE_U8_RESET. */
/** STAMTYPE_U16 & STAMTYPE_U16_RESET. */
/** STAMTYPE_U32 & STAMTYPE_U32_RESET. */
/** STAMTYPE_U64 & STAMTYPE_U64_RESET. */
} m_Data;
/** The unit. */
/** The description string. */
};
/**
* The VM statistics tree view.
*
* A tree represenation of the STAM statistics.
*/
{
/**
* Creates a VM statistics list view widget.
*
* @param pVM The VM which STAM data is being viewed.
* @param pParent Parent widget.
*/
/** Destructor. */
/**
* Updates the view with current information from STAM.
* This will indirectly update the m_PatStr.
*
* @param rPatStr Selection pattern. NULL means everything, see STAM for further details.
*/
/**
* Resets the stats items matching the specified pattern.
* This pattern doesn't have to be the one used for update, thus m_PatStr isn't updated.
*
* @param rPatStr Selection pattern. NULL means everything, see STAM for further details.
*/
#ifndef VBOXDBG_USE_QT4
/**
* Expand all items in the view.
*/
void expandAll();
/**
* Collaps all items in the view.
*/
void collapsAll();
#endif /* QT3 */
/**
* Callback function for the STAMR3Enum() made by update().
*
* @returns 0 (i.e. never halt enumeration).
*
* @param pszName The name of the sample.
* @param enmType The type.
* @param pvSample Pointer to the data. enmType indicates the format of this data.
* @param enmUnit The unit.
* @param enmVisibility The visibility.
* @param pszDesc The description.
* @param pvUser Pointer to the VBoxDbgStatsView object.
*/
static DECLCALLBACK(int) updateCallback(const char *pszName, STAMTYPE enmType, void *pvSample, STAMUNIT enmUnit,
/**
* Creates / finds the path to the specified stats item and makes is visible.
*
* @returns Parent node.
* @param pszName Path to a stats item.
*/
/** Context menu. */
/** Leaf context. */
void leafMenuActivated(int iId);
/** Branch context. */
void branchMenuActivated(int iId);
/** View context. */
void viewMenuActivated(int iId);
/** The current selection pattern. */
/** The parent widget. */
/** Head of the items list.
* This list is in the order that STAMR3Enum() uses.
* Access seralization should not be required, and is therefore omitted. */
/** Tail of the items list (see m_pHead). */
/** The current position in the enumeration.
* If NULL we've reached the end of the list and are adding elements. */
/** The root item. */
/** Leaf item menu. */
/** Branch item menu. */
/** View menu. */
/** The pointer to the context menu item which is the focus of a context menu. */
};
/**
* The VM statistics window.
*
* This class displays the statistics of a VM. The UI contains
* a entry field for the selection pattern, a refresh interval
* spinbutton, and the tree view with the statistics.
*/
#ifdef VBOXDBG_USE_QT4
#else
#endif
{
/**
* Creates a VM statistics list view widget.
*
* @param pVM The VM this is hooked up to.
* @param pszPat Initial selection pattern. NULL means everything. (See STAM for details.)
* @param uRefreshRate The refresh rate. 0 means not to refresh and is the default.
* @param pParent Parent widget.
*/
VBoxDbgStats(PVM pVM, const char *pszPat = NULL, unsigned uRefreshRate= 0, QWidget *pParent = NULL);
/** Destructor. */
virtual ~VBoxDbgStats();
/** Apply the activated combobox pattern. */
/** The "All" button was pressed. */
void applyAll();
/** Refresh the data on timer tick and pattern changed. */
void refresh();
/**
* Set the refresh rate.
*
* @param iRefresh The refresh interval in seconds.
*/
void setRefresh(int iRefresh);
/** The current selection pattern. */
/** The pattern combo box. */
/** The refresh rate in seconds.
* 0 means not to refresh. */
unsigned m_uRefreshRate;
/** The refresh timer .*/
/** The tree view widget. */
};
#endif