b99c19b122dc2676d4cab729544c13e03379071b
[smartapi.git] / Common / C++ / SmartAPI / smartapi / model / Activity.h
1 #ifndef _ACTIVITY_H_
2 #define _ACTIVITY_H_
3
4 #include "smartapi/common/RESOURCE.h"
5 #include "smartapi/model/Evaluation.h"
6 #include "smartapi/model/Input.h"
7 #include "smartapi/model/Output.h"
8 #include "smartapi/model/Availability.h"
9 #include "smartapi/model/Authorization.h"
10 #include "smartapi/model/InterfaceAddress.h"
11 #include "smartapi/model/Entity.h"
12 #include "smartapi/model/TimeSeries.h"
13 #include "smartapi/model/TemporalContext.h"
14
15 #include "smartapi/rdf/PropertyList.h"
16 #include "smartapi/rdf/Variant.h"
17 #include "smartapi/rdf/Resource.h"
18 #include "smartapi/rdf/Statement.h"
19 #include "smartapi/rdf/Model.h"
20
21 #include <QString>
22 #include <QList>
23
24 class Activity : public Evaluation
25 {
26 public:
27         Activity(QString uri = QString());
28         Activity(Activity* a);
29         ~Activity();
30         
31         Resource* serialize(Model* model);
32         void parse(Statement* statement);
33         virtual void clearReferences(QSet<GraphItem*>* trash);
34         
35         bool hasInput()                                                                                         { return mInputs.length() > 0; }
36         PropertyList<Input*> getInputs()                                                        { return mInputs; }
37         void setInput(Input* input)                                                                     { addInput(input); }
38         void addInput(Input* input)                                                                     { mInputs.append(input); }
39         Input* firstInput();
40         Input* newInput();
41         
42         bool hasOutput()                                                                                        { return mOutputs.length() > 0; }
43         PropertyList<Output*> getOutputs()                                                      { return mOutputs; }
44         void setOutput(Output* output)                                                          { addOutput(output); }
45         void addOutput(Output* output)                                                          { mOutputs.append(output); }
46         Output* firstOutput();
47         Output* newOutput();
48         
49         bool hasTimeSeries()                                                                            { return mTimeSeries.length() > 0; }
50         PropertyList<TimeSeries*> getTimeSeries()                                       { return mTimeSeries; }
51         void setTimeSeries(TimeSeries* ts)                                                      { mTimeSeries.clear(); addTimeSeries(ts); }
52         void addTimeSeries(TimeSeries* ts)                                                      { mTimeSeries.append(ts); }
53
54         bool hasAvailability()                                                                          { return !mAvailabilities.isEmpty(); }
55         PropertyList<Availability*> getAvailabilities()                         { return mAvailabilities; }
56         void addAvailability(Availability* availability)                        { mAvailabilities.append(availability); }
57
58         bool hasDataAvailability()                                                                      { return !mDataAvailabilities.isEmpty(); }
59         PropertyList<Availability*> getDataAvailabilities()                     { return mDataAvailabilities; }
60         void addDataAvailability(Availability* availability)            { mDataAvailabilities.append(availability); }
61
62         bool hasInterface()                                                                                     { return (mInterfaces.length() > 0); }
63         PropertyList<InterfaceAddress*> getInterfaces()                         { return mInterfaces; }
64         InterfaceAddress* getHTTPInterface();
65         void setInterface(InterfaceAddress* interfaceAddress)           { addInterface(interfaceAddress); }
66         void addInterface(InterfaceAddress* interfaceAddress)           { mInterfaces.append(interfaceAddress); }
67
68         bool hasEntity()                                                                                        { return (mEntities.length() > 0); }
69         PropertyList<Entity*> getEntities()                                                     { return mEntities; }
70         void addEntity(Entity* entity)                                                          { mEntities.append(entity); }
71         void setEntities(PropertyList<Entity*> entities)                        { mEntities = entities; add(PROPERTY__ENTITY, &mEntities);  }
72         void unlinkEntities();
73         Entity* firstEntity()                                                                           { if (mEntities.length() > 0) return mEntities.at(0); return NULL; }
74         Entity* newEntity(QString identifier = QString());
75
76         bool hasAuthorization()                                                                         { return (mAuthorization != NULL); }
77         Authorization* getAuthorization()                                                       { return mAuthorization; }
78         void setAuthorization(Authorization* auth)                                      { add(PROPERTY__AUTHORIZATION, auth); mAuthorization = auth; }
79
80         bool hasTemporalContext()                                                                       { return (mTemporalContext != NULL); }
81         TemporalContext* getTemporalContext()                                           { return mTemporalContext; }
82         void setTemporalContext(TemporalContext* temporalContext)       { add(PROPERTY__TEMPORALCONTEXT, temporalContext); mTemporalContext = temporalContext; }
83         void setTemporalContext(QDateTime start)                                        { setTemporalContext(new TemporalContext(start)); }
84         void setTemporalContext(QDateTime start, QDateTime end)         { setTemporalContext(new TemporalContext(start, end)); }
85         void setTemporalContext(QDateTime start, QDateTime end, QString during) { setTemporalContext(new TemporalContext(start, end, during)); }
86
87         bool hasTraverseUntil()                                                                         { return (mTraverseUntil != NULL); }
88         int getTraverseUntil()                                                                          { PROPERTYVAL(mTraverseUntil, asInt, -1); }
89         void setTraverseUntil(Variant* depth)                                           { mTraverseUntil = depth; }
90         void setTraverseUntil(int depth)                                                        { setTraverseUntil(new Variant(depth)); }
91
92         bool hasTraverseTo()                                                                            { return !mTraverseTo.isEmpty(); }
93         PropertyList<Variant*> getTraverseTo()                                          { return mTraverseTo; }
94         void setTraverseTo(PropertyList<Variant*> depths)                       { mTraverseTo = depths; add(PROPERTY__TRAVERSETO, &mTraverseTo); }
95         void setTraverseTo(int depth)                                                           { mTraverseTo.isEmpty(); addTraverseTo(depth); }
96         void addTraverseTo(Variant* depth)                                                      { mTraverseTo.append(depth); }
97         void addTraverseTo(int depth)                                                           { addTraverseTo(new Variant(depth)); }
98
99 private:
100         TemporalContext* mTemporalContext;
101         Authorization* mAuthorization;
102         PropertyList<Input*> mInputs;
103         PropertyList<Output*> mOutputs;
104         PropertyList<Availability*> mAvailabilities;
105         PropertyList<Availability*> mDataAvailabilities;
106         PropertyList<InterfaceAddress*> mInterfaces;
107         PropertyList<Entity*> mEntities;
108         PropertyList<TimeSeries*> mTimeSeries;
109         Variant* mTraverseUntil;
110         PropertyList<Variant*> mTraverseTo;
111         //QSet<int> mTraverseTo;
112 };
113
114 #endif // _ACTIVITY_H_