-
Notifications
You must be signed in to change notification settings - Fork 0
/
Author.h
59 lines (47 loc) · 2.22 KB
/
Author.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
#ifndef _AUTHOR_H_
#define _AUTHOR_H_
#include "dbo/dbo.h"
#include "dbo/kalematieSession.h"
#include <Wt/Dbo/SqlConnectionPool>
class Author {
public:
Author(Wt::Dbo::SqlConnectionPool& connectionPool);
~Author();
int getAuthorCount();
bool initWithAuthorId(int authorId);
bool initWithNickName(std::string nickName);
bool setDbPtr(dbo::ptr<author>& ptr); // initialize using an existing ptr
int getId();
std::string getNickName();
double getRating();
int getFollowers();
int getFollowing();
// do a manual null check for _dbPtr before calling this method
author::role getRole();
dbo::collection<dbo::ptr<quote> > getQuoteCollection();
dbo::ptr<author>& getDbPtr(); // returns the smart pointer itself
dbo::collection<dbo::ptr<credentials> > getCredentials();
bool updateNickName(std::string nickname);
bool updateRating();
bool updateFollowers();
bool updateFollowing();
bool updateRole(author::role Role);
//bool updateCredentials(dbo::ptr<credentials>& cred);
bool commit(); // persists a new author or the modifications of an existing author
void initNewAuthor();
void setNickName(std::string nickname);
void setRole(author::role Role);
// this method should add the author to the db and if successful
// it should inialize the _dbPtr property with the returned ptr
void addAuthor();
private:
// the smart db pointer incase of working with an existing author
dbo::ptr<author> _dbPtr;
// an author object in case of dealing with a new quote that isn't in the
// database yet
author *newAuthor_;
//Wt::Dbo::SqlConnectionPool& _connectionPool;
kalematieSession _session;
Wt::Dbo::Transaction _transaction;
};
#endif