Skip to content

Commit 51e1fff

Browse files
committed
Rename Host -> SSH
Create base Input class Rename BackgroundReader -> BackgroundUpdater
1 parent 6636f06 commit 51e1fff

File tree

14 files changed

+321
-91
lines changed

14 files changed

+321
-91
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#############################################################################
22
# Makefile for building: gltrail
3-
# Generated by qmake (2.01a) (Qt 4.3.2) on: Wed Mar 5 21:49:48 2008
3+
# Generated by qmake (2.01a) (Qt 4.3.2) on: Sat Mar 15 17:33:31 2008
44
# Project: gltrail.pro
55
# Template: subdirs
66
# Command: /usr/bin/qmake -unix -o Makefile gltrail.pro

src/Makefile

Lines changed: 48 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#############################################################################
22
# Makefile for building: ../bin/gltrail
3-
# Generated by qmake (2.01a) (Qt 4.3.2) on: Wed Mar 5 21:50:02 2008
3+
# Generated by qmake (2.01a) (Qt 4.3.2) on: Sat Mar 15 17:33:31 2008
44
# Project: src.pro
55
# Template: app
66
# Command: /usr/bin/qmake -unix -o Makefile src.pro
@@ -47,22 +47,24 @@ SOURCES = main.cpp \
4747
element.cpp \
4848
window.cpp \
4949
glwidget.cpp \
50-
background_reader.cpp \
51-
host.cpp moc_window.cpp \
50+
background_updater.cpp \
51+
inputs/ssh.cpp moc_input.cpp \
52+
moc_window.cpp \
5253
moc_glwidget.cpp \
53-
moc_background_reader.cpp \
54-
moc_host.cpp
54+
moc_background_updater.cpp \
55+
moc_ssh.cpp
5556
OBJECTS = main.o \
5657
activity.o \
5758
element.o \
5859
window.o \
5960
glwidget.o \
60-
background_reader.o \
61-
host.o \
61+
background_updater.o \
62+
ssh.o \
63+
moc_input.o \
6264
moc_window.o \
6365
moc_glwidget.o \
64-
moc_background_reader.o \
65-
moc_host.o
66+
moc_background_updater.o \
67+
moc_ssh.o
6668
DIST = /usr/share/qt4/mkspecs/common/g++.conf \
6769
/usr/share/qt4/mkspecs/common/unix.conf \
6870
/usr/share/qt4/mkspecs/common/linux.conf \
@@ -159,7 +161,7 @@ qmake: FORCE
159161

160162
dist:
161163
@$(CHK_DIR_EXISTS) .tmp/gltrail1.0.0 || $(MKDIR) .tmp/gltrail1.0.0
162-
$(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/gltrail1.0.0/ && $(COPY_FILE) --parents element.h activity.h relation.h window.h glwidget.h background_reader.h host.h .tmp/gltrail1.0.0/ && $(COPY_FILE) --parents main.cpp activity.cpp element.cpp window.cpp glwidget.cpp background_reader.cpp host.cpp .tmp/gltrail1.0.0/ && (cd `dirname .tmp/gltrail1.0.0` && $(TAR) gltrail1.0.0.tar gltrail1.0.0 && $(COMPRESS) gltrail1.0.0.tar) && $(MOVE) `dirname .tmp/gltrail1.0.0`/gltrail1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/gltrail1.0.0
164+
$(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/gltrail1.0.0/ && $(COPY_FILE) --parents input.h element.h activity.h relation.h window.h glwidget.h background_updater.h inputs/ssh.h .tmp/gltrail1.0.0/ && $(COPY_FILE) --parents main.cpp activity.cpp element.cpp window.cpp glwidget.cpp background_updater.cpp inputs/ssh.cpp .tmp/gltrail1.0.0/ && (cd `dirname .tmp/gltrail1.0.0` && $(TAR) gltrail1.0.0.tar gltrail1.0.0 && $(COMPRESS) gltrail1.0.0.tar) && $(MOVE) `dirname .tmp/gltrail1.0.0`/gltrail1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/gltrail1.0.0
163165

164166

165167
clean:compiler_clean
@@ -178,26 +180,32 @@ mocclean: compiler_moc_header_clean compiler_moc_source_clean
178180

179181
mocables: compiler_moc_header_make_all compiler_moc_source_make_all
180182

181-
compiler_moc_header_make_all: moc_window.cpp moc_glwidget.cpp moc_background_reader.cpp moc_host.cpp
183+
compiler_moc_header_make_all: moc_input.cpp moc_window.cpp moc_glwidget.cpp moc_background_updater.cpp moc_ssh.cpp
182184
compiler_moc_header_clean:
183-
-$(DEL_FILE) moc_window.cpp moc_glwidget.cpp moc_background_reader.cpp moc_host.cpp
185+
-$(DEL_FILE) moc_input.cpp moc_window.cpp moc_glwidget.cpp moc_background_updater.cpp moc_ssh.cpp
186+
moc_input.cpp: input.h
187+
/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) input.h -o moc_input.cpp
188+
184189
moc_window.cpp: glwidget.h \
190+
input.h \
185191
window.h
186192
/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) window.h -o moc_window.cpp
187193

188-
moc_glwidget.cpp: glwidget.h
194+
moc_glwidget.cpp: input.h \
195+
glwidget.h
189196
/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) glwidget.h -o moc_glwidget.cpp
190197

191-
moc_background_reader.cpp: element.h \
192-
host.h \
198+
moc_background_updater.cpp: element.h \
199+
input.h \
193200
glwidget.h \
194201
activity.h \
195202
relation.h \
196-
background_reader.h
197-
/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) background_reader.h -o moc_background_reader.cpp
203+
background_updater.h
204+
/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) background_updater.h -o moc_background_updater.cpp
198205

199-
moc_host.cpp: host.h
200-
/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) host.h -o moc_host.cpp
206+
moc_ssh.cpp: input.h \
207+
inputs/ssh.h
208+
/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) inputs/ssh.h -o moc_ssh.cpp
201209

202210
compiler_rcc_make_all:
203211
compiler_rcc_clean:
@@ -219,59 +227,65 @@ compiler_clean: compiler_moc_header_clean
219227
####### Compile
220228

221229
main.o: main.cpp window.h \
222-
glwidget.h
230+
glwidget.h \
231+
input.h
223232
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp
224233

225234
activity.o: activity.cpp activity.h \
226235
glwidget.h \
236+
input.h \
227237
element.h \
228-
host.h \
229238
relation.h
230239
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o activity.o activity.cpp
231240

232241
element.o: element.cpp element.h \
233-
host.h \
242+
input.h \
234243
glwidget.h \
235244
activity.h \
236245
relation.h
237246
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o element.o element.cpp
238247

239248
window.o: window.cpp window.h \
240249
glwidget.h \
241-
host.h
250+
input.h \
251+
inputs/ssh.h
242252
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o window.o window.cpp
243253

244254
glwidget.o: glwidget.cpp glwidget.h \
255+
input.h \
245256
element.h \
246-
host.h \
247257
activity.h \
248258
relation.h \
249-
background_reader.h
259+
background_updater.h
250260
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o glwidget.o glwidget.cpp
251261

252-
background_reader.o: background_reader.cpp background_reader.h \
262+
background_updater.o: background_updater.cpp background_updater.h \
253263
element.h \
254-
host.h \
264+
input.h \
255265
glwidget.h \
256266
activity.h \
257267
relation.h
258-
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o background_reader.o background_reader.cpp
268+
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o background_updater.o background_updater.cpp
259269

260-
host.o: host.cpp host.h \
270+
ssh.o: inputs/ssh.cpp inputs/ssh.h \
271+
input.h \
261272
glwidget.h
262-
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o host.o host.cpp
273+
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o ssh.o inputs/ssh.cpp
274+
275+
moc_input.o: moc_input.cpp
276+
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_input.o moc_input.cpp
263277

264278
moc_window.o: moc_window.cpp
265279
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_window.o moc_window.cpp
266280

267281
moc_glwidget.o: moc_glwidget.cpp
268282
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_glwidget.o moc_glwidget.cpp
269283

270-
moc_background_reader.o: moc_background_reader.cpp
271-
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_background_reader.o moc_background_reader.cpp
284+
moc_background_updater.o: moc_background_updater.cpp
285+
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_background_updater.o moc_background_updater.cpp
272286

273-
moc_host.o: moc_host.cpp
274-
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_host.o moc_host.cpp
287+
moc_ssh.o: moc_ssh.cpp
288+
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_ssh.o moc_ssh.cpp
275289

276290
####### Install
277291

src/background_updater.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include "background_updater.h"
2+
#include <iostream>
3+
4+
BackgroundUpdater::BackgroundUpdater(Inputs *h, Elements *e) {
5+
hosts = h;
6+
elements = e;
7+
}
8+
9+
void BackgroundUpdater::run(void ) {
10+
forever {
11+
12+
if( hosts && hosts->size() > 0 ) {
13+
hosts->first()->getGLWidget()->decayMax();
14+
}
15+
16+
int num = 0;
17+
for(Elements::const_iterator iter = elements->constBegin(); iter != elements->constEnd(); ++iter) {
18+
(*iter)->update_stats();
19+
num ++;
20+
}
21+
22+
std::cout << "Elements: " << num << std::endl;
23+
24+
sleep(1);
25+
}
26+
}
27+

src/background_updater.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#ifndef BACKGROUND_READER_H
2+
#define BACKGROUND_READER_H
3+
4+
#include <QThread>
5+
#include "element.h"
6+
#include "input.h"
7+
8+
/**
9+
@author Erlend Simonsen <[email protected]>
10+
*/
11+
12+
class BackgroundUpdater : public QThread
13+
{
14+
Q_OBJECT
15+
16+
public:
17+
18+
BackgroundUpdater(Inputs *h, Elements *e);
19+
~BackgroundUpdater() {};
20+
21+
protected:
22+
void run();
23+
24+
25+
26+
private:
27+
Inputs *hosts;
28+
Elements *elements;
29+
30+
};
31+
32+
#endif
33+
34+

src/element.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
using namespace std;
2626

27-
Element::Element(Host *h, QString name, QColor col, bool referrer)
27+
Element::Element(Input *h, QString name, QColor col, bool referrer)
2828
{
2929
x = 1.0 - rand() % 1000 / 500.0;
3030
y = 1.0 - rand() % 1000 / 500.0;

src/element.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <list>
2424
#include <QWidget>
2525
#include <QtOpenGL>
26-
#include "host.h"
26+
#include "input.h"
2727
#include "glwidget.h"
2828
#include "activity.h"
2929
#include "relation.h"
@@ -40,7 +40,7 @@ class Element{
4040

4141
public:
4242
Element() {};
43-
Element(Host *h, QString name, QColor col, bool referrer = false);
43+
Element(Input *h, QString name, QColor col, bool referrer = false);
4444

4545
virtual ~Element();
4646

@@ -88,7 +88,7 @@ class Element{
8888
int totalMessages;
8989
float rate;
9090

91-
Host *host;
91+
Input *host;
9292
QString m_name;
9393
QColor color;
9494

src/glwidget.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ using namespace std;
2626
#include <iostream>
2727
#include <stdlib.h>
2828
#include <list>
29-
#include "background_reader.h"
30-
#include "host.h"
29+
#include "background_updater.h"
30+
#include "input.h"
3131
#include <sys/time.h>
3232
#include <math.h>
3333

@@ -38,15 +38,15 @@ Nodes nodes;
3838
int frames = 0;
3939
int last_time = 0;
4040

41-
GLWidget::GLWidget(QWidget *parent, Hosts *h)
41+
GLWidget::GLWidget(QWidget *parent, Inputs *h)
4242
: QGLWidget(QGLFormat(QGL::DoubleBuffer | QGL::Rgba | QGL::DirectRendering | QGL::AlphaChannel), parent)
4343
{
4444
// startTimer(1);
4545
startTimer(16);
4646
setFocusPolicy(Qt::StrongFocus);
4747
setMouseTracking(true);
4848

49-
BackgroundReader *bg = new BackgroundReader(h, &elements);
49+
BackgroundUpdater *bg = new BackgroundUpdater(h, &elements);
5050
bg->start();
5151

5252
linesMode = 2;
@@ -74,7 +74,7 @@ GLWidget::GLWidget(QWidget *parent, Hosts *h)
7474
GLWidget::~GLWidget()
7575
{
7676
if( hosts != NULL ) {
77-
for(Hosts::iterator it = hosts->begin(); it != hosts->end(); ++it)
77+
for(Inputs::iterator it = hosts->begin(); it != hosts->end(); ++it)
7878
(*it)->end();
7979
}
8080
}
@@ -341,7 +341,7 @@ void GLWidget::resizeGL(int width, int height) {
341341

342342
void GLWidget::keyPressEvent(QKeyEvent *event) {
343343
if( event->key() == Qt::Key_Escape ) {
344-
for(Hosts::iterator it = hosts->begin(); it != hosts->end(); ++it)
344+
for(Inputs::iterator it = hosts->begin(); it != hosts->end(); ++it)
345345
(*it)->end();
346346
hosts = NULL;
347347
QApplication::exit(1);
@@ -410,7 +410,7 @@ void GLWidget::mouseMoveEvent(QMouseEvent *event)
410410
// cout << "x: " << x << ", y: " << y << endl;
411411
}
412412

413-
void GLWidget::addRelation(Host *h, QString &url, QString &ref, bool external) {
413+
void GLWidget::addRelation(Input *h, QString &url, QString &ref, bool external) {
414414

415415
if( elements.contains(h->getDomain() + url) == false ) {
416416
QColor color = h->getColor();

src/glwidget.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#include <QGLWidget>
2424
#include <QtOpenGL>
2525

26+
#include "input.h"
27+
2628
class Host;
2729
class Element;
2830

@@ -62,13 +64,13 @@ class GLWidget : public QGLWidget
6264
Q_OBJECT
6365

6466
public:
65-
GLWidget(QWidget *parent, QList<Host *> *h);
67+
GLWidget(QWidget *parent, QList<Input *> *h);
6668
~GLWidget();
6769

6870
QSize minimumSizeHint() const;
6971
QSize sizeHint() const;
7072

71-
void addRelation(Host *h, QString &url, QString &ref, bool external = false);
73+
void addRelation(Input *h, QString &url, QString &ref, bool external = false);
7274

7375
int showLines() { return linesMode; };
7476
bool showForces() const { return forces; };
@@ -139,7 +141,7 @@ class GLWidget : public QGLWidget
139141

140142
double lastTick;
141143

142-
QList<Host *> *hosts;
144+
QList<Input *> *hosts;
143145

144146

145147
};

0 commit comments

Comments
 (0)