-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPhotoReference.h
executable file
·115 lines (96 loc) · 2.31 KB
/
PhotoReference.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
#pragma once
class PhotoReference
{
public:
PhotoReference(const CString& path);
virtual ~PhotoReference(void);
private:
CString path;
CString title;
CString text;
CString keywords;
bool dirty;
GUID remoteId;
CString uploadResultMessage;
bool finished;
bool locked; //must only be set from gui thread.
CString lockedUpdateTitle;
CString lockedUpdateText;
public:
#ifdef DEBUG
DWORD ownerThread;
#endif
#define PR_ASSERTOWNER ASSERT(ownerThread == ::GetCurrentThreadId())
static const UINT MAX_DIGITS_TITLE = 4;
static const UINT MAX_PHOTO_NAME_LEN = 50;//sync with db
bool LockedStatus() const { return locked; }
void Lock();
void Unlock();
bool Finished() const { return finished; }
void SetFinished() {
PR_ASSERTOWNER;
#ifdef DEBUG
byte z[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
ASSERT(memcmp(z,&remoteId,16) != 0);
#endif
this->dirty = false;
this->finished = true;
}
const CString& GetPath() const {
// PR_ASSERTOWNER;
return path;
}
// the worker thread gets lockedUpdateTitle, which is ok so long as it doesn't try to
// write to it.
const CString& GetTitle() const {
// We don't need to lock here, since the bg-thread don't change these, and
// the assertions is made on GetPath.
// PR_ASSERTOWNER;
if(LockedStatus())
return lockedUpdateTitle;
return title;
}
const CString& GetText() const {
// see GetTitle:
// PR_ASSERTOWNER;
if(LockedStatus())
return lockedUpdateText;
return text;
}
const CString& GetTitleLocked() const {
PR_ASSERTOWNER;
return title;
}
const CString& GetTextLocked() const {
PR_ASSERTOWNER;
return text;
}
const GUID& GetRemoteId() const {
return this->remoteId;
}
void SetTitle(LPCTSTR);
void SetText(LPCTSTR);
bool GetDirty() {
PR_ASSERTOWNER;
return dirty;
}
void ClearDirty() {
PR_ASSERTOWNER;
this->dirty = false;
}
void SetRemoteId(GUID photoId) {
PR_ASSERTOWNER;
#ifdef DEBUG
byte z[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
ASSERT(memcmp(z,&remoteId,16) == 0);
ASSERT(memcmp(z,&photoId,16) != 0);
#endif
memcpy(&this->remoteId, &photoId, 16);
}
void SetUploadResultMessage(const LPCTSTR msg) {
PR_ASSERTOWNER;
this->uploadResultMessage = msg;
}
public:
int imageIndex;
};