| 1 |
/* |
| 2 |
This file is part of Icecream. |
| 3 |
|
| 4 |
Copyright (c) 2014 Kevin Funk <[email protected]> |
| 5 |
|
| 6 |
This program is free software; you can redistribute it and/or modify |
| 7 |
it under the terms of the GNU General Public License as published by |
| 8 |
the Free Software Foundation; either version 2 of the License, or |
| 9 |
(at your option) any later version. |
| 10 |
|
| 11 |
This program is distributed in the hope that it will be useful, |
| 12 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
GNU General Public License for more details. |
| 15 |
|
| 16 |
You should have received a copy of the GNU General Public License along |
| 17 |
with this program; if not, write to the Free Software Foundation, Inc., |
| 18 |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 |
*/ |
| 20 |
|
| 21 |
#ifndef ICEMON_MONITOR_H |
| 22 |
#define ICEMON_MONITOR_H |
| 23 |
|
| 24 |
#include "job.h" |
| 25 |
#include "types.h" |
| 26 |
|
| 27 |
#include <QObject> |
| 28 |
|
| 29 |
class StatusView; |
| 30 |
class HostInfoManager; |
| 31 |
class Job; |
| 32 |
|
| 33 |
/** |
| 34 |
* Abstract base class for monitoring a icecream-like scheduler |
| 35 |
*/ |
| 36 |
class Monitor |
| 37 |
: public QObject |
| 38 |
{ |
| 39 |
Q_OBJECT |
| 40 |
Q_PROPERTY(SchedulerState schedulerState READ schedulerState WRITE setSchedulerState NOTIFY schedulerStateChanged) |
| 41 |
Q_ENUMS(SchedulerState) |
| 42 |
|
| 43 |
public |
| 44 |
: enum SchedulerState { |
| 45 |
Offline, |
| 46 |
Online, |
| 47 |
}; |
| 48 |
|
| 49 |
explicit Monitor(HostInfoManager *manager, QObject *parent = nullptr); |
| 50 |
|
| 51 |
QByteArray currentNetname() const; |
| 52 |
void setCurrentNetname(const QByteArray &); |
| 53 |
|
| 54 |
QByteArray currentSchedname() const; |
| 55 |
void setCurrentSchedname(const QByteArray &); |
| 56 |
|
| 57 |
uint currentSchedport() const; |
| 58 |
void setCurrentSchedport(uint port); |
| 59 |
|
| 60 |
SchedulerState schedulerState() const; |
| 61 |
|
| 62 |
virtual QList<Job> jobHistory() const; |
| 63 |
|
| 64 |
HostInfoManager *hostInfoManager() const { return m_hostInfoManager; } |
| 65 |
|
| 66 |
protected: |
| 67 |
void setSchedulerState(SchedulerState online); |
| 68 |
|
| 69 |
Q_SIGNALS: |
| 70 |
void schedulerStateChanged(Monitor::SchedulerState); |
| 71 |
|
| 72 |
void jobUpdated(const Job &job); |
| 73 |
void nodeRemoved(HostId id); |
| 74 |
void nodeUpdated(HostId id); |
| 75 |
|
| 76 |
private: |
| 77 |
HostInfoManager *m_hostInfoManager; |
| 78 |
QByteArray m_currentNetname; |
| 79 |
QByteArray m_currentSchedname; |
| 80 |
uint m_currentSchedport{0}; |
| 81 |
SchedulerState m_schedulerState{Offline}; |
| 82 |
}; |
| 83 |
|
| 84 |
#endif // ICEMON_MONITOR_H |