forked from iseghiri/LO21_project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Note.h
323 lines (210 loc) · 8.73 KB
/
Note.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
#ifndef NOTES_H_INCLUDED
#define NOTES_H_INCLUDED
#include<string>
#include "timing.h"
#include <ctime>
using namespace TIME;
using namespace std;
/*********************************************************************/
/*********************************************************************
*** Execption ***
**********************************************************************/
class NotesException{
public:
NotesException(const string& message):info(message) {}
string getInfo() const {
return info;
}
private:
string info;
};
/*********************************************************************/
/*********************************************************************
*** Note Abstract Class ***
**********************************************************************/
class Note {
private:
string id ;
string title ;
Date dateCreation;
Date dateLastModif;
bool archive;
//attributs statiques réunissant l'ensemble des ids de toutes les notes
static string* ids;
static unsigned int nbId, nbMaxId;
public:
///Constructor
Note(const string i, const string t, Date d_c, Date d_lm): id(i), title(t), dateCreation(d_c), dateLastModif(d_lm), archive(false){addID(i);}
///Memento
//Memento createMemento();
//setMemento(Memento m);
///Accessor in Reading (return by const ref)
const string& getId() const {return id;}
const string& getTitle() const {return title;}
const Date& getDateCreation() const {return dateCreation ;}
const Date& getLastModif() const {return dateLastModif ;}
const bool GetArchive() const {return archive ;}
///Modify attribute
void SetTitle(const string& newTitle) {title=newTitle ;}
void SetDateCreation(Date& newDate) {dateCreation=newDate ;}
void setDateLastCreation(Date& newDate) {dateLastModif=newDate;}
void SetArchive() {archive=!archive ;}
Note& setId(const string& i) {id = i; addID(i); return *this;}
void addID(const string & id);
//Get Ascendant/Descendant in all differents Relations
void getRelAsc(const string& /*titre de la note à obtenir*/);
void getRelDesc(const string&);
virtual Note* clone()=0 ;
virtual ~Note() {} // implement to delete in all relation
/// Class Iterator
class Iterator{
friend class Note;
string* currentI;
int nbRemain;
Iterator(string*a, int nb): currentA(a), nbRemain(nb){}
public:
bool isDone()const {return nbRemain == 0;}
Article& current() const{ return *currentI;}
void next(){
if(isDone())
throw NotesException("ERROR : fin de la collection");
currentI++;
nbRemain--;
}
};
//Méthode static car on itère sur l'attribut static ids (ensemble des IDs de toutes les notes)
static Iterator getIterator() const;
/*********************************************************************/
/*********************************************************************
*** Article **
*********************************************************************/
class Article : public Note {
private:
string text;
public :
///Constructor
Article(const string i, const string t, Date d_c, Date d_lm, const string txt): Note(i,t,d_c,d_lm), text(txt) {}
///clone
virtual Article* clone();
///Accessor
const string& getText() const {return text ;}
///Modify attribute
void setText(string& newTxt) {text=newTxt ;}
~Article() {}
};
/********************************************************************/
/********************************************************************
*** Task ***
*********************************************************************/
enum state {Waiting,Ongoing,Done};
class Tache : public Note {
private:
string action;
unsigned int priority;
Date deadline;
state status;
public :
///Constructor (how to put deadline optional)
Tache(const string i, const string t, Date d_c, Date d_lm, const string a, unsigned int p=0, Date dl=Date(1,1,1), state s=Waiting):
Note(i,t,d_c,d_lm), action(a), priority(p), deadline(dl), status(s) {}
///clone
virtual Tache* clone();
///Accessor
const string& getAction() const {return action ;}
const unsigned int& getPriority() const {return priority ;}
const Date& getDeadline() const {return deadline ;}
const state& getStatus() const {return status ;}
///Modify attribute
void setAction(string& newAction) {action=newAction;}
void setPriority (unsigned int p) {priority = p ;}
void setDeadline (Date newDl) {deadline=newDl ;}
//void setSatus()
~Tache() {}
};
/*********************************************************************/
/*********************************************************************
*** Multimedia ***
**********************************************************************/
class Multimedia : public Note {
private:
string description;
string image;
public:
//Constructor
Multimedia (const string i, const string t, Date d_c, Date d_lm, const string& d, const string& f) : Note(i,t,d_c,d_lm), description(d), image(f) {}
//Accessor
const string& getDescription() const {return description;}
const string& getImage() {return image;}
//clone virtual pure
virtual Multimedia* clone()=0;
~Multimedia(){}
};
/*********************************************************************/
/*********************************************************************
*** Image ***
**********************************************************************/
class Image : public Multimedia{
public:
Image(const string i, const string t, Date d_c, Date d_lm, const string& d, const string& f):
Multimedia(i,t,d_c,d_lm,d,f) {}
virtual Image * clone ();
~Image() {}
};
/*********************************************************************/
/*********************************************************************
*** Enregistrement Audio ***
**********************************************************************/
class Audio : public Multimedia{
public:
Audio(const string i, const string t, Date d_c, Date d_lm, const string& d, const string& f):
Multimedia(i,t,d_c,d_lm,d,f) {}
virtual Audio* clone ();
~Audio() {}
};
/*********************************************************************/
/*********************************************************************
*** video ***
**********************************************************************/
class Video : public Multimedia{
public:
Video(const string i, const string t, Date d_c, Date d_lm, const string& d, const string& f):
Multimedia(i,t,d_c,d_lm,d,f) {}
virtual Video * clone ();
~Video() {}
};
/*********************************************************************/
/********************************************************************
*** Couple ***
********************************************************************/
class Couple {
private:
string label;
Note* note1;
Note* note2;
public:
Couple(const string& l,Note* n1, Note* n2) :label(l), note1(n1), note2(n2) {}
Note* getNote1() const {return note1;}
Note* getNote2() const {return note2;}
const string& getLabel() const {return label;}
void setLabel(const string & l) {label =l;}
};
/*********************************************************************/
/*******************************************************************
*** Relation ***
*******************************************************************/
class Relation{
private:
string title, description;
Couple** couples;
unsigned int nbCouple, nbMaxCouple;
bool oriented;
public:
Relation(const string & t, const string& d) : title(t), description(d), couples(nullptr), nbCouple(0), nbMaxCouple(0), oriented(false) {}
const string& getTitle() const {return title;}
const string& getDescription() const {return description;}
void addCouple(Note* n1, Note* n2); //add a couple without label
void removeCouple(const string&,Note* n1, Note* n2); //looks for a couple with this label & notes
void setOriented(){oriented= !oriented;};
~Relation() {for (unsigned int i=0; i<nbCouple;i++) delete couples[i]; delete [] couples;}
};
#endif // NOTES_H_INCLUDED