C++: Fix some of the parsers to fit the correct inheritance
authorjani <jani@asema.com>
Tue, 8 Jan 2019 02:13:40 +0000 (04:13 +0200)
committerjani <jani@asema.com>
Tue, 8 Jan 2019 02:13:40 +0000 (04:13 +0200)
15 files changed:
Common/C++/SmartAPI/smartapi.pro
Common/C++/SmartAPI/smartapi/model/Activity.cpp
Common/C++/SmartAPI/smartapi/model/Activity.h
Common/C++/SmartAPI/smartapi/model/CalculationMethod.cpp
Common/C++/SmartAPI/smartapi/model/Capacity.cpp
Common/C++/SmartAPI/smartapi/model/Evaluation.h
Common/C++/SmartAPI/smartapi/model/Input.cpp
Common/C++/SmartAPI/smartapi/model/Input.h
Common/C++/SmartAPI/smartapi/model/License.cpp
Common/C++/SmartAPI/smartapi/model/Message.h
Common/C++/SmartAPI/smartapi/model/Person.cpp
Common/C++/SmartAPI/smartapi/model/Provenance.cpp
Common/C++/SmartAPI/smartapi/model/Restriction.cpp
Common/C++/SmartAPI/smartapi/model/SystemOfInterest.cpp
Common/C++/SmartAPI/smartapi/model/TemporalContext.cpp

index 79df68cf6d2970a421991b781c7bca679ad18ad6..27168692f67292d0bc8b1b4b5945d9662472c456 100644 (file)
@@ -140,7 +140,6 @@ SOURCES += smartapi/agents/Agent.cpp \
         smartapi/model/Velocity.cpp \
         smartapi/model/Waypoint.cpp \
         smartapi/model/Waypoints.cpp \
-        smartapi/model/WeatherServiceProvider.cpp \
         smartapi/model/Zone.cpp \
         smartapi/rdf/GraphItem.cpp \
         smartapi/rdf/PropertyList.cpp \
@@ -278,7 +277,6 @@ HEADERS += smartapi/agents/Agent.h \
         smartapi/model/Velocity.h \
         smartapi/model/Waypoint.h \
         smartapi/model/Waypoints.h \
-        smartapi/model/WeatherServiceProvider.h \
         smartapi/model/Zone.h \
         smartapi/rdf/PropertyListItem.h \
         smartapi/rdf/PropertyList.h \
index 26c20de0a0368a2e3d2c982e1c55e10fd550be02..9ac055d25463240462de8f286db6cd18f4503847 100755 (executable)
@@ -62,7 +62,7 @@ void Activity::parse(Statement* statement)
        PARSE_PROPERTY(PROPERTY__AUTHORIZATION, setAuthorization, Authorization)
        PARSE_PROPERTY(PROPERTY__TRAVERSEUNTIL, setTraverseUntil, Variant)
        PARSE_PROPERTY(PROPERTY__TRAVERSETO, addTraverseTo, Variant)
-       FINISH_PARSE(Obj)
+       FINISH_PARSE(Evaluation)
 }
 
 Input* Activity::firstInput()
index 8d9fbaef21b14652b167d933dd574edabc3a0e8d..1a38bda0069a2f9668a46ffc6d3d13d0f00903d9 100644 (file)
@@ -86,12 +86,12 @@ public:
 
 private:
        Authorization* mAuthorization;
+       PropertyList<Entity*> mEntities;
        PropertyList<Input*> mInputs;
        PropertyList<Output*> mOutputs;
        PropertyList<Availability*> mAvailabilities;
        PropertyList<Availability*> mDataAvailabilities;
        PropertyList<InterfaceAddress*> mInterfaces;
-       PropertyList<Entity*> mEntities;
        Variant* mTraverseUntil;
        PropertyList<Variant*> mTraverseTo;
        //QSet<int> mTraverseTo;
index f340e89ac1aaf5d4178395153c51b76f9a873961..dba37f0430e0bde07b5a9543777199fcc54c1785 100644 (file)
@@ -5,7 +5,7 @@ CalculationMethod::CalculationMethod(QString identifierUri) : Calculable(identif
 }
 
 CalculationMethod::CalculationMethod(CalculationMethod* o) :
-    Calculable(o)
+       Calculable(o)
 {
 }
 
index ac3f572aad438ca51b99d5660edf11eb7c67fd22..7b4095600e3c576b29beaa0e25c132d5e721c063 100755 (executable)
@@ -199,18 +199,18 @@ void Capacity::clearReferences(QSet<GraphItem*>* trash)
 Resource* Capacity::serialize(Model* model)
 {
        INIT_SERIALIZE(ValueObject,model)
-    if (mAutomaticPercentageCalculation ) {
-        calculatePercentage();
-    }
-    FINISH_SERIALIZE(ValueObject)
+       if (mAutomaticPercentageCalculation ) {
+               calculatePercentage();
+       }
+       FINISH_SERIALIZE(ValueObject)
 }
 
 void Capacity::parse(Statement* statement)
 {
-    INIT_PARSE(statement)
-    PARSE_PROPERTY(PROPERTY__PERCENTAGE, setPercentage, Variant)
-    PARSE_PROPERTY(PROPERTY__SYSTEMOFINTEREST, setSystemOfInterest, SystemOfInterest)
-    FINISH_PARSE(Obj)
+       INIT_PARSE(statement)
+       PARSE_PROPERTY(PROPERTY__PERCENTAGE, setPercentage, Variant)
+       PARSE_PROPERTY(PROPERTY__SYSTEMOFINTEREST, setSystemOfInterest, SystemOfInterest)
+       FINISH_PARSE(ValueObject)
 }
 
 
index 1155a4137df9b0fa826c66ad4cfae1a5dc64d99c..21f3a74077e708d4980eadb6f4a36eb86f5bef80 100644 (file)
@@ -57,6 +57,7 @@ public:
        bool hasTimeSeries()                                                                            { return hasTimeSerie(); }
        void setTimeSerie(TimeSeries* timeSerie)                                        { mTimeSeries.clear(); addTimeSerie(timeSerie); }
        void addTimeSerie(TimeSeries* timeSerie)                                        { mTimeSeries.append(timeSerie); }
+       void addTimeSeries(TimeSeries* timeSerie)                                       { addTimeSerie(timeSerie); } // syntax compatibility only
 
        bool hasSystemOfInterest()                                                                      { return (mSystemOfInterest != NULL); }
        SystemOfInterest* getSystemOfInterest()                                         { return mSystemOfInterest; }
index de24c3a6a8cef0eea76fe73a347d6e2d5155d270..a29f145f224fe2cf523b2a6e1eba71456c146a10 100755 (executable)
@@ -9,6 +9,7 @@ Input::Input(QString uri, InputType inputType)
 {
        setType(RESOURCE__INPUT);
        INIT_PROPERTYLIST(mOutputValues,PROPERTY__OUTPUTVALUES);
+       INIT_PROPERTYLIST(mActivities,PROPERTY__ACTIVITY);
 }
 
 Input::Input(Input* i) : Evaluation(i)
@@ -17,6 +18,7 @@ Input::Input(Input* i) : Evaluation(i)
                mInputType = (InputType)i->getInputType();
        }
        SET_PROPERTYLIST_REFERENCE(PROPERTY__OUTPUTVALUES, mOutputValues, ValueObject)
+       SET_PROPERTYLIST_REFERENCE(PROPERTY__ACTIVITY, mActivities, Activity)
        setType(RESOURCE__INPUT);
 }
 
@@ -39,5 +41,13 @@ void Input::parse(Statement* statement)
 {
        INIT_PARSE(statement)
        PARSE_PROPERTY(PROPERTY__OUTPUTVALUES, addOutputValue, ValueObject)
+       PARSE_PROPERTY(PROPERTY__ACTIVITY, addActivity, Activity)
        FINISH_PARSE(Evaluation)
 }
+
+Activity* Input::firstActivity()
+{
+       if (mActivities.length() > 0) return mActivities.at(0);
+       return NULL;
+}
+
index 9fbd8fdc4d8b83ff44e5deb9d3cacf3c89da0f0d..a96bc10308006dc25caf834a851fd65639a64f0c 100644 (file)
@@ -37,10 +37,17 @@ public:
        PropertyList<ValueObject*> getOutputValues()    { return mOutputValues; }
        void setOutputValue(ValueObject* v)                             { mOutputValues.clear(); addOutputValue(v); }
        void addOutputValue(ValueObject* v)                             { mOutputValues.append(v); }
-               
+
+       bool hasActivity()                                                      { return mActivities.length() > 0; }
+       PropertyList<Activity*> getActivities()         { return mActivities; }
+       void setActivity(Activity* activity)            { mActivities.clear(); addActivity(activity); }
+       void addActivity(Activity* activity)            { mActivities.append(activity); }
+       Activity* firstActivity();
+
 private:
        InputType mInputType;
        PropertyList<ValueObject*> mOutputValues;
+       PropertyList<Activity*> mActivities;
 };
 
 #endif // _INPUT_H_
index b88c91753830a8a5c9e7d8bacafd6c79fbc92b9c..4ee0b1d308d50962916400a978e1ce8de9c77959 100644 (file)
@@ -23,13 +23,13 @@ License::~License()
 void License::clearReferences(QSet<GraphItem*>* trash)
 {
        INIT_CLEAR(Obj,trash);
-       FINISH_CLEAR(Obj,trash);
+       FINISH_CLEAR(Contract,trash);
 }
 
 Resource* License::serialize(Model* model)
 {
        INIT_SERIALIZE(Obj,model)
-       FINISH_SERIALIZE(Obj)
+       FINISH_SERIALIZE(Contract)
 }
 
 void License::parse(Statement* statement)
@@ -38,5 +38,5 @@ void License::parse(Statement* statement)
        PARSE_PROPERTY(PROPERTY__LICENSEKEY, setLicenseKey, Variant)
        PARSE_PROPERTY(PROPERTY__ACCOUNT, setAccount, Account)
        PARSE_PROPERTY(PROPERTY__HASPRICESPECIFICATION, addPriceSpecification, PriceSpecification)
-       FINISH_PARSE(Obj)
+       FINISH_PARSE(Contract)
 }
index d91fcbffd7dac6cf8867d3dd4880d26a48fe9c9e..4452fe385476c3899968beefc20a95d7a246fb31 100644 (file)
@@ -25,20 +25,20 @@ public:
        void parse(Statement* statement);
        virtual void clearReferences(QSet<GraphItem*>* trash);
        
-       bool hasMessageId()             { return (mMessageId != NULL); }
-       int getMessageId()              { PROPERTYVAL(mMessageId, asInt, -1); }
-       void setMessageId(Variant* id)  { add(PROPERTY__ID, id); mMessageId = id; }
-       void setMessageId(int id)       { setMessageId(new Variant(id)); }
+       bool hasMessageId()                                                     { return (mMessageId != NULL); }
+       int getMessageId()                                                      { PROPERTYVAL(mMessageId, asInt, -1); }
+       void setMessageId(Variant* id)                          { add(PROPERTY__ID, id); mMessageId = id; }
+       void setMessageId(int id)                                       { setMessageId(new Variant(id)); }
 
-       bool hasProcessId()             { return (mProcessId != NULL); }
-       int getProcessId()              { PROPERTYVAL(mProcessId, asInt, -1); }
-       void setProcessId(Variant* id)  { add(PROPERTY__PROCESSID, id); mProcessId = id; }
-       void setProcessId(int id)       { setProcessId(new Variant(id)); }
+       bool hasProcessId()                                                     { return (mProcessId != NULL); }
+       int getProcessId()                                                      { PROPERTYVAL(mProcessId, asInt, -1); }
+       void setProcessId(Variant* id)                          { add(PROPERTY__PROCESSID, id); mProcessId = id; }
+       void setProcessId(int id)                                       { setProcessId(new Variant(id)); }
 
-       bool hasActivity()                                                                                      { return mActivities.length() > 0; }
-       PropertyList<Activity*> getActivities()                                         { return mActivities; }
-       void setActivity(Activity* activity)                                            { mActivities.clear(); addActivity(activity); }
-       void addActivity(Activity* activity)                                            { mActivities.append(activity); }
+       bool hasActivity()                                                      { return mActivities.length() > 0; }
+       PropertyList<Activity*> getActivities()         { return mActivities; }
+       void setActivity(Activity* activity)            { mActivities.clear(); addActivity(activity); }
+       void addActivity(Activity* activity)            { mActivities.append(activity); }
        Activity* firstActivity();
        Activity* newActivity(QString identifier = QString());
 
index 42d8440ed67436a92b5b500d10a18368635a8244..c358484fda4ece4eec83f93c7be7b12b9b8bc368 100755 (executable)
@@ -22,8 +22,8 @@ Person::Person(Person* r) : PhysicalEntity(r)
 
 void Person::clearReferences(QSet<GraphItem*>* trash)
 {
-       INIT_CLEAR(Obj,trash);
-       FINISH_CLEAR(Obj,trash);
+       INIT_CLEAR(PhysicalEntity,trash);
+       FINISH_CLEAR(PhysicalEntity,trash);
 }
 
 Resource* Person::serialize(Model* model)
index e4f3e831c985a4eac78b2b6bb69c03e66abd8755..6fbea25a33052159a33341ef65e49944a048a190 100755 (executable)
@@ -42,5 +42,5 @@ void Provenance::parse(Statement* statement)
        PARSE_PROPERTY(PROPERTY__GENERATIONMETHOD, addGenerationMethod, Variant)
        PARSE_PROPERTY(PROPERTY__DATASOURCE, addDataSource, Variant)
        PARSE_PROPERTY(PROPERTY__SMARTAPI_PROPERTY, addProperty, Variant)
-       FINISH_PARSE(Obj)
+       FINISH_PARSE(Evaluation)
 }
index 3b3ac50b7e70b7fbae4d3de040dd909844ff7f87..81808d2e785e90a45da9bf989522af21203f90f8 100755 (executable)
@@ -94,5 +94,5 @@ void Restriction::parse(Statement* statement)
        PARSE_PROPERTY(PROPERTY__ONPROPERTY, addOnProperty, Obj)
        PARSE_PROPERTY(PROPERTY__OPTIONAL, setOptional, Variant)
        PARSE_PROPERTY(PROPERTY__ONDATARANGE, setDataRange, Obj)
-       FINISH_PARSE(Obj)
+       FINISH_PARSE(Evaluation)
 }
index c59f2a804b8ef6e7bddb0b49b5b44b09e3ee9a59..72649cb27beacb7bc5a8fb4de172263a54b3d82b 100755 (executable)
@@ -2,17 +2,17 @@
 #include "smartapi/common/PROPERTY.h"
 
 SystemOfInterest::SystemOfInterest(QString uri) :
-    Entity(uri)
+       Entity(uri)
 {
-    setType(RESOURCE__SYSTEMOFINTEREST);
-    INIT_PROPERTY(mRealizedBy);
+       setType(RESOURCE__SYSTEMOFINTEREST);
+       INIT_PROPERTY(mRealizedBy);
 }
 
 SystemOfInterest::SystemOfInterest(SystemOfInterest* s)
        : Entity(s)
 {
        SET_PROPERTY_REFERENCE(PROPERTY__REALIZEDBY, mRealizedBy, PhysicalEntity)
-    setType(RESOURCE__SYSTEMOFINTEREST);
+       setType(RESOURCE__SYSTEMOFINTEREST);
 }
 
 SystemOfInterest::~SystemOfInterest()
index 583b81a138950eeee931e2973410083bcb00eb24..ad6719ab2bc8a0a0943cc0280483a644a02f9825 100755 (executable)
@@ -64,8 +64,8 @@ TemporalContext::TemporalContext(TemporalContext* t) : Obj(t)
 {
        SET_PROPERTY_REFERENCE(PROPERTY__START, mStart, Variant)
        SET_PROPERTY_REFERENCE(PROPERTY__END, mEnd, Variant)
-    SET_PROPERTY_REFERENCE(PROPERTY__DURATION, mDuration, Variant)
-    SET_PROPERTY_REFERENCE(PROPERTY__DURING, mDuring, Variant)
+       SET_PROPERTY_REFERENCE(PROPERTY__DURATION, mDuration, Variant)
+       SET_PROPERTY_REFERENCE(PROPERTY__DURING, mDuring, Variant)
        setType(RESOURCE__TEMPORALCONTEXT);
 }
 
@@ -90,7 +90,7 @@ void TemporalContext::parse(Statement* statement)
        INIT_PARSE(statement)
        PARSE_PROPERTY(PROPERTY__START, setStart, Variant)
        PARSE_PROPERTY(PROPERTY__END, setEnd, Variant)
-    PARSE_PROPERTY(PROPERTY__DURATION, setDuration, Variant)
-    PARSE_PROPERTY(PROPERTY__DURING, setDuring, Variant)
+       PARSE_PROPERTY(PROPERTY__DURATION, setDuration, Variant)
+       PARSE_PROPERTY(PROPERTY__DURING, setDuring, Variant)
        FINISH_PARSE(Obj)
 }