forked from iseghiri/LO21_project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Note2.h
369 lines (259 loc) · 11 KB
/
Note2.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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
#ifndef NOTES_H_INCLUDED
#define NOTES_H_INCLUDED
#include<string>
#include "timing.h"
#include <ctime>
using namespace TIME;
using namespace std;
enum state {Waiting,Ongoing,Done};
/*********************************************************************/
/*********************************************************************
*** Execption ***
**********************************************************************/
class NotesException{
public:
NotesException(const string& message):info(message) {}
string getInfo() const {
return info;
}
private:
string info;
};
/*********************************************************************
*** NOTE ABSTRACT ***
**********************************************************************/
class Note {
private:
string id ;
string title ;
Date dateCreation ;
Date dateLastModif ;
bool archive ;
public:
///Constructor
Note(const string i, const string t, Date d_c, Date d_lm, bool a=false): id(i), title(t), dateCreation(d_c), dateLastModif(d_lm), archive(a){}
///Memento
//virtual MementoN* createMemento()=0;
virtual Note& addMemento()=0 ;
///Accessor in Lecture (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) {addMemento(); title=newTitle;}
void SetDateCreation(Date& newDate) {addMemento(); dateCreation=newDate ;}
void setDateLastModif(Date& newDate) {addMemento(); dateLastModif=newDate;}
void SetArchive(bool a) {addMemento(); archive=a ;}
void SetArchive() {addMemento(); archive=!archive ;}
// virtual Note* clone()=0 ;
// virtual ~Note(); // implement to delete in all relation
};
/*********************************************************************
*** Note Abstract Memento ***
**********************************************************************/
class MementoN {
protected :
friend class Note;
// friend class Tache;
// friend class Article;
string id ;
string title ;
Date dateCreation;
Date dateLastModif;
bool archive;
public :
MementoN(const string i, const string t, Date d_c, Date d_lm, bool a) : id(i), title(t), dateCreation(d_c), dateLastModif(d_lm), archive(a) {}
//Note getState()
};
/*********************************************************************
*** Memento Article ***
**********************************************************************/
class MementoA : public MementoN {
private :
friend class Article;
string text;
public:
MementoA(const string i, const string t, Date d_c, Date d_lm, bool a, const string txt): MementoN(i,t,d_c,d_lm,a), text(txt) {}
};
/*********************************************************************
*** Article ***
**********************************************************************/
class Article : public Note {
private:
string text;
MementoA** careTaker;
unsigned int nbMemento;
unsigned int nbMax;
public :
///Constructor
Article(const string i, const string t, Date d_c, Date d_lm, bool a, const string txt): Note(i,t,d_c,d_lm,a), text(txt), careTaker(new MementoA*[5]),nbMemento(0),nbMax(5) {}
//void setMemento(MementoA* mA) {SetTitle(mA->title); SetDateCreation(mA->dateCreation); setDateLastModif(mA->dateLastModif); SetArchive(mA->archive); setText(mA->text);}
///Memento
MementoA* createMemento() {return new MementoA(getId(),getTitle(),getDateCreation(),getLastModif(),GetArchive(),text) ;}
Article& addMemento();
Article& getPreviousMemento();
///clone
//virtual Article* clone() {}
///Accessor
const string& getText() const {return text ;}
///Modify attribute
void setText(const string newTxt) { addMemento(); text=newTxt ; /*SetDateLastModif(dateDuJour);*/}
~Article(){}
};
/*********************************************************************
*** Memento Task ***
**********************************************************************/
class MementoT : public MementoN {
private :
friend class Tache;
string action;
unsigned int priority;
Date deadline;
state status;
public :
MementoT(const string i, const string t, Date d_c, Date d_lm, bool a, const string act, unsigned int p, Date dl, state s): MementoN(i,t,d_c,d_lm,a), action(act), priority(p), deadline(dl) ,status(s) {}
};
/*********************************************************************
*** TACHE ***
**********************************************************************/
class Tache : public Note {
private:
string action;
unsigned int priority;
Date deadline;
state status;
///Memento
MementoT** careTaker;
unsigned int nbMemento;
unsigned int nbMax;
public :
///Constructor (how to put deadline optional)
Tache(const string i, const string t, Date d_c, Date d_lm,bool ar, const string a, unsigned int p/*=0*/, Date dl, state s=Waiting): Note(i,t,d_c,d_lm,ar), action(a), priority(p), deadline(dl), status(s), careTaker(new MementoT*[5]),nbMemento(0),nbMax(5) {}
///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) {addMemento(); action=newAction;}
void setPriority (unsigned int p) {addMemento(); priority = p ;}
void setDeadline (Date newDl) {addMemento(); deadline=newDl ;}
//void setSatus()
///Memento
MementoT* createMemento() {return new MementoT(getId(),getTitle(),getDateCreation(),getLastModif(),GetArchive(),action,priority,deadline,status) ;}
Tache& addMemento();
Tache& getPreviousMemento();
};
/*********************************************************************/
/*********************************************************************
*** Memento Multimedia ***
**********************************************************************/
class MementoM : public MementoN {
private :
friend class Multimedia;
string description;
string image;
public :
MementoM(const string i, const string t, Date d_c, Date d_lm, bool a, const string& d, const string& f) : MementoN(i,t,d_c,d_lm,a), description(d), image(f) {}
};
/*********************************************************************
*** Multimedia ***
**********************************************************************/
class Multimedia : public Note {
private:
string description;
string image;
///Memento
MementoM** careTaker;
unsigned int nbMemento;
unsigned int nbMax;
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), careTaker(new MementoM*[5]),nbMemento(0),nbMax(5) {}
//Accessor
const string& getDescription() const {return description;}
const string& getImage() const {return image;}
//Modif
void setDescription (const string newD) {addMemento() ;description=newD;}
void setImage (const string newI) {addMemento() ;image=newI ;}
//clone virtual pure
virtual Multimedia* clone()=0;
//Memento
MementoM* createMemento() {return new MementoM(getId(),getTitle(),getDateCreation(),getLastModif(),GetArchive(),description,image) ;}
Multimedia& addMemento();
Multimedia& getPreviousMemento();
~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