-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rating.h
61 lines (44 loc) · 1.86 KB
/
Rating.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
#ifndef _RATING_H_
#define _RATING_H_
#include "dbo/dbo.h"
#include "dbo/kalematieSession.h"
#include <Wt/Dbo/SqlConnectionPool>
#include <vector>
typedef dbo::collection<dbo::ptr<rating> > rPtrCollection;
class Rating {
public:
Rating(Wt::Dbo::SqlConnectionPool& connPool);
~Rating();
// used to manipulate a single rating
// this function tries to fetch the rating
// and assign it to _dbPtr and return true But if the rating
// doesn't exist, it instead initialized the
// newRating_ property and returns false;
bool initASingleRating(int quoteId, int raterId);
bool initWithRaterId(int raterId);
bool initWithQuoteId(int quoteId);
bool initWithRating(double rating);
void setDbPtr(dbo::ptr<rating>& ptr);
void setDbPtrCollection(rPtrCollection& ptrColl);
//int getQuoteId();
//int getRaterId();
double getRating(dbo::ptr<rating>& ptr);
std::vector<double> getRatings();
dbo::ptr<rating>& getDbPtr();
dbo::collection<dbo::ptr<rating> > getDbPtrCollection();
// This function operates on _dbPtr
bool updateRating(int rating);
bool commit();
void initNewRating();
void setQuoteId(int quoteId);
void setRaterId(int raterId);
void setRating(double rating);
void addRating();
private:
dbo::ptr<rating> _dbPtr; // when dealing with a single rating
rPtrCollection _dbPtrCollection; // when dealing with a bunch of ratings
rating *newRating_;
kalematieSession _session;
Wt::Dbo::Transaction _transaction;
};
#endif