-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservicecategory.h
More file actions
39 lines (34 loc) · 1.31 KB
/
servicecategory.h
File metadata and controls
39 lines (34 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef SERVICECATEGORY_H
#define SERVICECATEGORY_H
#include <QList>
#include "config.h"
#include <QPair>
#include <QHash>
//#include <QDebug>
class ServiceCategory
{
int curIndex;
int waitingCount;
char categoryID;
static QHash<char, ServiceCategory*> id2cat;
ServiceCategory(char catID) : curIndex(1), waitingCount(0), categoryID(catID) { } //qDebug() << "Creating " << catID; }
public:
static ServiceCategory* instance(char catID) {
if(!id2cat.contains(catID)) id2cat[catID] = new ServiceCategory(catID);
return id2cat[catID];
}
char getCategoryID() { return categoryID; }
int getNextWaitingUserID() { return curIndex; }
int getNextTokenID() { return curIndex + waitingCount; }
bool isUserWaiting() { return waitingCount != 0; }
void addWaitingUser() { waitingCount++; }
void removeWaitingUser() { curIndex++; waitingCount--; } //if(waitingCount == 0) curIndex = 1; }
static QList< QPair<QString, char> > getCategoryList() {
QList< QPair<QString, char> > categories;
categories << qMakePair(QString("Withdraw"), STB_CATEGORY_WITHDRAW);
categories << qMakePair(QString("Help"), STB_CATEGORY_HELP);
categories << qMakePair(QString("Deposit"), STB_CATEGORY_DEPOSIT);
return categories;
}
};
#endif // SERVICECATEGORY_H