KVIrc 5.2.6
Developer APIs
KviLagMeter.h
Go to the documentation of this file.
1#ifndef _KVI_LAGMETER_H_
2#define _KVI_LAGMETER_H_
3//=============================================================================
4//
5// File : KviLagMeter.h
6// Creation date : Fri Oct 18 13:30:26 CEST 1999 by Juanjo Álvarez
7//
8// This file is part of the KVIrc IRC client distribution
9// Copyright (C) 1999 Juanjo Álvarez
10// Copyright (C) 2002-2010 Szymon Stefanek (pragma at kvirc dot net)
11//
12// This program is FREE software. You can redistribute it and/or
13// modify it under the terms of the GNU General Public License
14// as published by the Free Software Foundation; either version 2
15// of the License, or (at your option) any later version.
16//
17// This program is distributed in the HOPE that it will be USEFUL,
18// but WITHOUT ANY WARRANTY; without even the implied warranty of
19// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20// See the GNU General Public License for more details.
21//
22// You should have received a copy of the GNU General Public License
23// along with this program. If not, write to the Free Software Foundation,
24// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25//
26//=============================================================================
27
28#include "kvi_settings.h"
29#include "KviCString.h"
30
31#include <QObject>
32#include <QList>
33
35
37{
39 long lSecs; // since epoch
40 long lUSecs;
41 unsigned int uReliability; // [0-100]
42};
43
44class KVIRC_API KviLagMeter : public QObject
45{
46 friend class KviIrcConnection;
47 Q_OBJECT
48
49protected:
52
53protected:
55 unsigned int m_uLag = 0; // last computed lag
56 unsigned int m_uLastEmittedLag = 0; // last emitted lag
57 long m_tLastCompleted = 0; // time when the last lag was completed (gettimeofday!)
58 unsigned int m_uLastReliability = 0; // how much reliable was the last completed check ?
59 QList<KviLagCheck *> m_lCheckList;
60 long m_tFirstOwnCheck = 0; // time when the first ping after a completed check was sent
61 long m_tLastOwnCheck = 0; // time when the last ping was sent
62 bool m_bOnAlarm = false;
63 bool * m_pDeletionSignal = nullptr; // we use this to signal our own delete
64public:
65 // lag checks should be done only against the user's server
66 // please make SURE that the key is unique!
67 void lagCheckRegister(const char * key, unsigned int uReliability = 50);
68 bool lagCheckComplete(const char * key);
69 void lagCheckAbort(const char * key);
70 unsigned int lag() const { return m_uLag; }
71 unsigned int secondsSinceLastCompleted();
72
73protected:
74 void timerEvent(QTimerEvent * e) override;
75};
76
77#endif // _KVI_LAGMETER_H_
Definition KviCString.h:102
An abstraction of a connection to an IRC server.
Definition KviIrcConnection.h:97
QList< KviLagCheck * > m_lCheckList
Definition KviLagMeter.h:59
bool * m_pDeletionSignal
Definition KviLagMeter.h:63
friend class KviIrcConnection
Definition KviLagMeter.h:46
void lagCheckAbort(const char *key)
Definition KviLagMeter.cpp:263
long m_tLastCompleted
Definition KviLagMeter.h:57
unsigned int m_uLastReliability
Definition KviLagMeter.h:58
KviLagMeter(KviIrcConnection *c)
Definition KviLagMeter.cpp:41
bool m_bOnAlarm
Definition KviLagMeter.h:62
long m_tFirstOwnCheck
Definition KviLagMeter.h:60
bool lagCheckComplete(const char *key)
Definition KviLagMeter.cpp:207
long m_tLastOwnCheck
Definition KviLagMeter.h:61
unsigned int m_uLastEmittedLag
Definition KviLagMeter.h:56
unsigned int m_uLag
Definition KviLagMeter.h:55
KviIrcConnection * m_pConnection
Definition KviLagMeter.h:54
unsigned int lag() const
Definition KviLagMeter.h:70
void lagCheckRegister(const char *key, unsigned int uReliability=50)
Definition KviLagMeter.cpp:181
#define e
Definition detector.cpp:70
This file contains compile time settings.
#define KVIRC_API
Definition kvi_settings.h:127
Definition KviLagMeter.h:37
unsigned int uReliability
Definition KviLagMeter.h:41
long lSecs
Definition KviLagMeter.h:39
KviCString szKey
Definition KviLagMeter.h:38
long lUSecs
Definition KviLagMeter.h:40