use DependencyManager to keep track of BandwidthRecorder

This commit is contained in:
Seth Alves 2015-02-02 08:55:55 -08:00
parent b85456b1e9
commit c0a219678c
8 changed files with 22 additions and 24 deletions

View file

@ -201,6 +201,7 @@ bool setupEssentials(int& argc, char** argv) {
auto lodManager = DependencyManager::set<LODManager>();
auto jsConsole = DependencyManager::set<StandAloneJSConsole>();
auto dialogsManager = DependencyManager::set<DialogsManager>();
auto bandwidthRecorder = DependencyManager::set<BandwidthRecorder>();
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
auto speechRecognizer = DependencyManager::set<SpeechRecognizer>();
#endif
@ -434,10 +435,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
connect(this, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit()));
// hook up bandwidth estimator
QSharedPointer<BandwidthRecorder> bandwidthRecorder = DependencyManager::get<BandwidthRecorder>();
connect(nodeList.data(), SIGNAL(dataSent(const quint8, const int)),
&_bandwidthRecorder, SLOT(updateOutboundData(const quint8, const int)));
&*bandwidthRecorder, SLOT(updateOutboundData(const quint8, const int)));
connect(nodeList.data(), SIGNAL(dataReceived(const quint8, const int)),
&_bandwidthRecorder, SLOT(updateInboundData(const quint8, const int)));
&*bandwidthRecorder, SLOT(updateInboundData(const quint8, const int)));
// check first run...
bool firstRun = SettingHandles::firstRun.get();

View file

@ -202,7 +202,6 @@ public:
bool getLastMouseMoveWasSimulated() const { return _lastMouseMoveWasSimulated; }
FaceTracker* getActiveFaceTracker();
BandwidthRecorder* getBandwidthRecorder() { return &_bandwidthRecorder; }
QSystemTrayIcon* getTrayIcon() { return _trayIcon; }
ApplicationOverlay& getApplicationOverlay() { return _applicationOverlay; }
Overlays& getOverlays() { return _overlays; }
@ -484,9 +483,6 @@ private:
OctreeQuery _octreeQuery; // NodeData derived class for querying octee cells from octree servers
BandwidthRecorder _bandwidthRecorder;
AvatarManager _avatarManager;
MyAvatar* _myAvatar; // TODO: move this and relevant code to AvatarManager (or MyAvatar as the case may be)

View file

@ -904,7 +904,7 @@ void ApplicationOverlay::renderAudioMeter() {
void ApplicationOverlay::renderStatsAndLogs() {
Application* application = Application::getInstance();
BandwidthRecorder* bandwidthRecorder = Application::getInstance()->getBandwidthRecorder();
QSharedPointer<BandwidthRecorder> bandwidthRecorder = DependencyManager::get<BandwidthRecorder>();
auto glCanvas = DependencyManager::get<GLCanvas>();
const OctreePacketProcessor& octreePacketProcessor = application->getOctreePacketProcessor();

View file

@ -52,9 +52,8 @@ void BandwidthChannelDisplay::Paint() {
BandwidthDialog::BandwidthDialog(QWidget* parent, BandwidthRecorder* model) :
QDialog(parent, Qt::Window | Qt::WindowCloseButtonHint | Qt::WindowStaysOnTopHint),
_model(model) {
BandwidthDialog::BandwidthDialog(QWidget* parent) :
QDialog(parent, Qt::Window | Qt::WindowCloseButtonHint | Qt::WindowStaysOnTopHint) {
this->setWindowTitle("Bandwidth Details");
@ -62,12 +61,14 @@ BandwidthDialog::BandwidthDialog(QWidget* parent, BandwidthRecorder* model) :
QFormLayout* form = new QFormLayout();
this->QDialog::setLayout(form);
_allChannelDisplays[0] = _audioChannelDisplay = new BandwidthChannelDisplay(&_model->audioChannel, form);
_allChannelDisplays[1] = _avatarsChannelDisplay = new BandwidthChannelDisplay(&_model->avatarsChannel, form);
_allChannelDisplays[2] = _octreeChannelDisplay = new BandwidthChannelDisplay(&_model->octreeChannel, form);
_allChannelDisplays[3] = _metavoxelsChannelDisplay = new BandwidthChannelDisplay(&_model->metavoxelsChannel, form);
_allChannelDisplays[4] = _otherChannelDisplay = new BandwidthChannelDisplay(&_model->otherChannel, form);
_allChannelDisplays[5] = _totalChannelDisplay = new BandwidthChannelDisplay(&_model->totalChannel, form);
QSharedPointer<BandwidthRecorder> bandwidthRecorder = DependencyManager::get<BandwidthRecorder>();
_allChannelDisplays[0] = _audioChannelDisplay = new BandwidthChannelDisplay(&bandwidthRecorder->audioChannel, form);
_allChannelDisplays[1] = _avatarsChannelDisplay = new BandwidthChannelDisplay(&bandwidthRecorder->avatarsChannel, form);
_allChannelDisplays[2] = _octreeChannelDisplay = new BandwidthChannelDisplay(&bandwidthRecorder->octreeChannel, form);
_allChannelDisplays[3] = _metavoxelsChannelDisplay = new BandwidthChannelDisplay(&bandwidthRecorder->metavoxelsChannel,form);
_allChannelDisplays[4] = _otherChannelDisplay = new BandwidthChannelDisplay(&bandwidthRecorder->otherChannel, form);
_allChannelDisplays[5] = _totalChannelDisplay = new BandwidthChannelDisplay(&bandwidthRecorder->totalChannel, form);
connect(averageUpdateTimer, SIGNAL(timeout()), this, SLOT(updateTimerTimeout()));
averageUpdateTimer->start(1000);

View file

@ -27,10 +27,8 @@ class BandwidthChannelDisplay : public QObject {
void Paint();
private:
BandwidthRecorder::Channel *ch;
QLabel* label;
// std::string strBuf;
QString strBuf;
public slots:
@ -41,8 +39,7 @@ class BandwidthChannelDisplay : public QObject {
class BandwidthDialog : public QDialog {
Q_OBJECT
public:
// Sets up the UI based on the configuration of the BandwidthRecorder
BandwidthDialog(QWidget* parent, BandwidthRecorder* model);
BandwidthDialog(QWidget* parent);
~BandwidthDialog();
void paintEvent(QPaintEvent*);
@ -75,7 +72,6 @@ protected:
void closeEvent(QCloseEvent*);
private:
BandwidthRecorder* _model;
QTimer *averageUpdateTimer = new QTimer(this);
};

View file

@ -102,7 +102,7 @@ void DialogsManager::editAnimations() {
void DialogsManager::bandwidthDetails() {
if (! _bandwidthDialog) {
_bandwidthDialog = new BandwidthDialog(qApp->getWindow(), qApp->getBandwidthRecorder());
_bandwidthDialog = new BandwidthDialog(qApp->getWindow());
connect(_bandwidthDialog, SIGNAL(closed()), _bandwidthDialog, SLOT(deleteLater()));
if (_hmdToolsDialog) {

View file

@ -25,6 +25,7 @@
#include <PerfStat.h>
#include "Stats.h"
#include "BandwidthRecorder.h"
#include "InterfaceConfig.h"
#include "Menu.h"
#include "Util.h"
@ -216,7 +217,7 @@ void Stats::display(
QLocale locale(QLocale::English);
std::stringstream octreeStats;
BandwidthRecorder* bandwidthRecorder = Application::getInstance()->getBandwidthRecorder();
QSharedPointer<BandwidthRecorder> bandwidthRecorder = DependencyManager::get<BandwidthRecorder>();
if (_lastHorizontalOffset != horizontalOffset) {
resetWidth(glCanvas->width(), horizontalOffset);

View file

@ -17,6 +17,7 @@
#include <QObject>
#include <QElapsedTimer>
#include <QTimer>
#include "DependencyManager.h"
#include "Node.h"
#include "SimpleMovingAverage.h"
@ -27,8 +28,9 @@ const unsigned int COLOR1 = 0xffef40c0;
const unsigned int COLOR2 = 0xd0d0d0a0;
class BandwidthRecorder : public QObject {
class BandwidthRecorder : public QObject, public Dependency {
Q_OBJECT
SINGLETON_DEPENDENCY
public:
BandwidthRecorder();