56455fa71aa203610560e2bb2942cb2baaf0cec2
[smartapi.git] / Common / C++ / SmartAPI / smartapi / model / TemporalContext.h
1 #ifndef _TEMPORALCONTEXT_H_
2 #define _TEMPORALCONTEXT_H_
3
4 #include <QString>
5 #include <QDateTime>
6
7 #include "smartapi/common/PROPERTY.h"
8 #include "smartapi/model/Obj.h"
9 #include "smartapi/rdf/Variant.h"
10
11 class Model;
12 class Resource;
13 class Statement;
14
15 class TemporalContext : public Obj
16 {
17 public:
18         TemporalContext();
19         TemporalContext(QString uri);
20         TemporalContext(QDateTime mStart, QDateTime mEnd);
21         TemporalContext(QDateTime mStart, QDateTime mEnd, QString mDuring);
22         TemporalContext(QDateTime mStart);
23         TemporalContext(QTime mStart, QTime mEnd);
24         TemporalContext(QTime mStart, QTime mEnd, QString mDuring);
25         TemporalContext(QTime mStart);
26         TemporalContext(TemporalContext* t);
27         ~TemporalContext();
28
29         Resource* serialize(Model* model);
30         void parse(Statement* statement);
31         void clearReferences(QSet<GraphItem*>* trash);
32         
33         bool hasStart()                                         { return (mStart != NULL); }
34         QDateTime getStart()                            { PROPERTYVAL(mStart, asDateTime, QDateTime()); }
35         QTime getStartTime()                            { PROPERTYVAL(mStart, asTime, QTime()); }
36         void setStart(Variant* s)                       { add(PROPERTY__START, s); mStart = s; }
37         void setStart(QDateTime _start)         { setStart(new Variant(_start)); }
38         void setStart(QTime _start)                     { setStart(new Variant(_start)); }
39
40         bool hasEnd()                                           { return (mEnd != NULL); }
41         QDateTime getEnd()                                      { PROPERTYVAL(mEnd, asDateTime, QDateTime()); }
42         QTime getEndTime()                                      { PROPERTYVAL(mEnd, asTime, QTime()); }
43         void setEnd(Variant* e)                         { add(PROPERTY__END, e); mEnd = e; }
44         void setEnd(QDateTime _end)                     { setEnd(new Variant(_end)); }
45         void setEnd(QTime _end)                         { setEnd(new Variant(_end)); }
46
47         bool hasCount()                                         { return mCount != NULL; }
48         int getCount()                                          { PROPERTYVAL(mCount, asInt, -1); }
49         void setCount(Variant* c)                       { add(PROPERTY__COUNT, c); mCount = c; }
50         void setCount(int _count)                       { setCount(new Variant(_count)); }
51
52         bool hasDuration()                                      { return mDuration != NULL; }
53         QString getDuration()                           { PROPERTYVAL(mDuration, asString, QString()); }
54         void setDuration(Variant* d)            { add(PROPERTY__DURATION, d); mDuration = d; }
55         void setDuration(QString _duration)     { setDuration(new Variant(_duration)); }
56
57         bool hasDuring()                                        { return mDuring != NULL; }
58         QString getDuring()                                     { PROPERTYVAL(mDuring, asString, QString()); }
59         void setDuring(Variant* d)                      { add(PROPERTY__DURING, d); mDuring = d; }
60         void setDuring(QString _during)         { setDuring(new Variant(_during)); }
61
62 private:
63         Variant* mStart;
64         Variant* mEnd;
65         Variant* mCount;
66         Variant* mDuration;
67         Variant* mDuring;
68 };
69
70 #endif // _TEMPORALCONTEXT_H_