-
Notifications
You must be signed in to change notification settings - Fork 3
/
Client.h
127 lines (94 loc) · 2.84 KB
/
Client.h
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#ifndef CLIENT_H
#define CLIENT_H
#include <QObject>
#include <QIcon>
#include <QString>
#include <QHash>
#include "DbRec.h"
class Client;
class Client_Table : public QObject, public DbTable
/*********************************************
* class for table that stores client records.
*/
{
Q_OBJECT
public:
Client_Table(QSqlDatabase &db);
~Client_Table();
/* Eliminate default copy constructor and assignment operator */
Client_Table(const Client_Table&)= delete;
Client_Table& operator=(const Client_Table&)= delete;
Client* operator[](int64_t id);
/* Fetch a group of records */
int fetchAll(QVector<int64_t> &idVec, const QString & sql_tail = QString());
int fetchAfter(QVector<int64_t> &idVec, const QDateTime &when);
/* Create new instance of Client, return it cast to DbRec */
virtual DbRec* factory() const;
signals:
void sig_insert(int64_t client_id);
void sig_update(int64_t client_id);
void sig_remove(int64_t client_id);
private:
virtual void emit_cast_sig_insert(DbRec*);
virtual void emit_cast_sig_update(DbRec*);
virtual void emit_cast_sig_remove(DbRec*);
QHash<int64_t,Client*> _hash;
};
class Client : public DbRec
/*********************************************
* Class for record of client_tbl
*/
{
public:
Client();
~Client();
/* Eliminate default copy constructor and assignment operator */
Client(const Client&)= delete;
Client& operator=(const Client&)= delete;
void set_id(int64_t id);
void set_acronym(const QString & acronym);
void set_name(const QString & name);
void set_default_rate(int64_t default_rate);
void set_default_charge_quantum(int32_t default_charge_quantum);
/* Returns true if field is null */
bool id(int64_t *rtn) const;
bool acronym(QString *rtn) const;
bool name(QString *rtn) const;
bool default_rate(int64_t *rtn) const;
bool default_charge_quantum(int32_t *rtn) const;
/* Asserted access */
int64_t id() const;
QString acronym() const;
QString name() const;
int64_t default_rate() const;
int64_t default_charge_quantum() const;
/* Overloaded DbRec functions */
int insert();
int update();
int remove();
/* Used to set tab icon */
QIcon currentStateIcon();
private:
friend class Client_Table;
#if 0
// Smoke out any heap usage
void * operator new (size_t);
void * operator new[] (size_t);
void operator delete (void *);
void operator delete[] (void*);
#endif
enum {
/* Make sure the field enums start at 0, and increase sequentially */
ID_FIELD = 0,
ACRONYM_FIELD,
NAME_FIELD,
DEFAULT_RATE_FIELD,
DEFAULT_CHARGE_QUANTUM_FIELD,
UNKNOWN_FIELD
};
int64_t _id, _default_rate;
int32_t _default_charge_quantum;
QString _acronym, _name;
const static DbField S_DbField_arr[];
};
#endif // CLIENT_H