-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.cpp
52 lines (44 loc) · 891 Bytes
/
data.cpp
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
/*
* tokens.h
*
* Created on: Jul 5, 2011
* Author: admin
*/
#include <vector>
#include <string>
class Data {
public:
std::vector<std::string> likes;
std::vector<std::string> hates;
std::vector<std::string> from;
std::vector<std::string> moods;
std::vector<std::string> info;
std::vector<std::string> vals;
static Data* getInstance() {
if (hasInstance_ == false) {
inst_ = new Data();
hasInstance_ = true;
return inst_;
}
return inst_;
}
~Data() {
hasInstance_ = false;
}
void free() {
likes.clear();
moods.clear();
from.clear();
hates.clear();
info.clear();
vals.clear();
}
private:
static Data *inst_;
static bool hasInstance_;
Data() {}; // Private constructor
Data(const Data&); // Prevent copy-construction
Data& operator=(const Data&); // Prevent assignment
};
bool Data::hasInstance_ = false;
Data* Data::inst_ = NULL;