C++: Added Validity, Voucher
authorjani <jani@asema.com>
Thu, 29 Aug 2019 12:16:28 +0000 (15:16 +0300)
committerjani <jani@asema.com>
Thu, 29 Aug 2019 12:16:28 +0000 (15:16 +0300)
Common/C++/SmartAPI/smartapi/model/Validity.cpp [new file with mode: 0755]
Common/C++/SmartAPI/smartapi/model/Validity.h [new file with mode: 0644]
Common/C++/SmartAPI/smartapi/model/Voucher.cpp [new file with mode: 0755]
Common/C++/SmartAPI/smartapi/model/Voucher.h [new file with mode: 0644]

diff --git a/Common/C++/SmartAPI/smartapi/model/Validity.cpp b/Common/C++/SmartAPI/smartapi/model/Validity.cpp
new file mode 100755 (executable)
index 0000000..0b5f2c9
--- /dev/null
@@ -0,0 +1,48 @@
+#include "Waypoint.h"
+#include "smartapi/common/PROPERTY.h"
+#include "smartapi/common/Tools.h"
+#include "smartapi/rdf/List.h"
+
+Waypoint::Waypoint() :
+       Obj()
+{
+       setType(RESOURCE__WAYPOINT);
+       INIT_PROPERTY(mCoordinates)
+       INIT_PROPERTY(mAddress)
+       INIT_PROPERTY(mRoute)
+}
+
+Waypoint::Waypoint(Waypoint* w) : Obj(w)
+{
+       SET_PROPERTY_REFERENCE(PROPERTY__LOCATION, mCoordinates, Coordinates)
+       SET_PROPERTY_REFERENCE(PROPERTY__HASADDRESS, mAddress, Address)
+       SET_PROPERTY_REFERENCE(PROPERTY__INSTANT, mInstant, Variant)
+       SET_PROPERTY_REFERENCE(PROPERTY__ROUTE, mRoute, Route)
+       setType(RESOURCE__WAYPOINT);
+}
+
+Waypoint::~Waypoint()
+{
+}
+
+void Waypoint::clearReferences(QSet<GraphItem*>* trash)
+{
+       INIT_CLEAR(Obj,trash);
+       FINISH_CLEAR(Obj,trash);
+}
+
+Resource* Waypoint::serialize(Model* model)
+{
+       INIT_SERIALIZE(Obj,model)
+       FINISH_SERIALIZE(Obj)
+}
+
+void Waypoint::parse(Statement* statement)
+{
+       INIT_PARSE(statement)
+       PARSE_PROPERTY(PROPERTY__LOCATION, setCoordinates, Coordinates)
+       PARSE_PROPERTY(PROPERTY__HASADDRESS, setAddress, Address)
+       PARSE_PROPERTY(PROPERTY__INSTANT, setInstant, Variant)
+       PARSE_PROPERTY(PROPERTY__ROUTE, setRoute, Route)
+       FINISH_PARSE(Obj)
+}
diff --git a/Common/C++/SmartAPI/smartapi/model/Validity.h b/Common/C++/SmartAPI/smartapi/model/Validity.h
new file mode 100644 (file)
index 0000000..cf4e3a8
--- /dev/null
@@ -0,0 +1,49 @@
+#ifndef _WAYPOINT_H_
+#define _WAYPOINT_H_
+
+#include "smartapi/model/Coordinates.h"
+#include "smartapi/model/Address.h"
+#include "smartapi/model/Route.h"
+#include "smartapi/rdf/Resource.h"
+#include "smartapi/rdf/Statement.h"
+#include "smartapi/rdf/Model.h"
+
+#include <QString>
+#include <QDateTime>
+
+class Waypoint : public Obj
+{
+public:
+       Waypoint();
+       Waypoint(Waypoint* l);
+       ~Waypoint();
+
+       Resource* serialize(Model* model);
+       void parse(Statement* statement);
+       void clearReferences(QSet<GraphItem*>* trash);
+       
+       Coordinates* getCoordinates()                   { return mCoordinates; }
+       bool hasCoordinates()                                   { return (mCoordinates != NULL); }
+       void setCoordinates(Coordinates* l)             { add(PROPERTY__LOCATION, l); mCoordinates = l; }
+
+       Address* getAddress()                                   { return mAddress; }
+       bool hasAddress()                                               { return (mAddress != NULL); }
+       void setAddress(Address* l)                             { add(PROPERTY__HASADDRESS, l); mAddress = l; }
+       
+       QDateTime getInstant()                                  { PROPERTYVAL(mInstant, asDateTime, QDateTime()); }
+       bool hasInstant()                                               { return mInstant != NULL; }
+       void setInstant(Variant* l)                             { set(PROPERTY__INSTANT, l); mInstant = l; }
+       void setInstant(QDateTime l)                    { setInstant(new Variant(l)); }
+
+       Route* getRoute()                                               { return mRoute; }
+       bool hasRoute()                                                 { return (mRoute != NULL); }
+       void setRoute(Route* l)                                 { add(PROPERTY__ROUTE, l); mRoute = l; }
+
+private:
+       Coordinates* mCoordinates;
+       Address* mAddress;
+       Route* mRoute;
+       Variant* mInstant;
+};
+
+#endif // _WAYPOINT_H_
diff --git a/Common/C++/SmartAPI/smartapi/model/Voucher.cpp b/Common/C++/SmartAPI/smartapi/model/Voucher.cpp
new file mode 100755 (executable)
index 0000000..4ce684c
--- /dev/null
@@ -0,0 +1,47 @@
+#include "Voucher.h"
+
+#include "smartapi/common/PROPERTY.h"
+#include "smartapi/common/RESOURCE.h"
+
+
+Voucher::Voucher(QString identifierUri)
+       : Offering(identifierUri)
+{
+       setType(RESOURCE__VOUCHER);
+       INIT_PROPERTY(mMaxAvailable)
+}
+
+Voucher::Voucher(QString identifierUri, QString name, QString description)
+       : Offering(identifierUri, name, description)
+{
+       setType(RESOURCE__VOUCHER);
+}
+
+Voucher::Voucher(Voucher* o) : Offering(o)
+{
+       SET_PROPERTY_REFERENCE(PROPERTY__MAXAVAILABLE, mMaxAvailable, Variant);
+       setType(RESOURCE__VOUCHER);
+}
+
+Voucher::~Voucher()
+{
+}
+
+void Voucher::clearReferences(QSet<GraphItem*>* trash)
+{
+       INIT_CLEAR(Offering,trash);
+       FINISH_CLEAR(Offering,trash);
+}
+
+Resource* Voucher::serialize(Model *model)
+{
+       INIT_SERIALIZE(Offering,model)
+       FINISH_SERIALIZE(Offering)
+}
+
+void Voucher::parse(Statement* statement)
+{
+       INIT_PARSE(statement)
+       PARSE_PROPERTY(PROPERTY__MAXAVAILABLE, setMaxAvailable, Variant)
+       FINISH_PARSE(Offering)
+}
diff --git a/Common/C++/SmartAPI/smartapi/model/Voucher.h b/Common/C++/SmartAPI/smartapi/model/Voucher.h
new file mode 100644 (file)
index 0000000..4ee26cd
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef _VOUCHER_H_
+#define _VOUCHER_H_
+
+#include "smartapi/model/Offering.h"
+
+class Voucher : public Offering
+{
+public:
+       Voucher(QString identifierUri = QString());
+       Voucher(QString identifierUri, QString name, QString description);
+       Voucher(Voucher* o);
+       ~Voucher();
+
+       Resource* serialize(Model* model);
+       void parse(Statement* statement);
+       virtual void clearReferences(QSet<GraphItem*>* trash);
+
+       bool hasMaxAvailable()                                                                                          { return mMaxAvailable != NULL; }
+       void setMaxAvailable(Variant* m)                                                                        { add(PROPERTY__MAXAVAILABLE, m); mMaxAvailable = m; }
+       void setMaxAvailable(int m)                                                                                     { setBusinessFunction(new Variant(m)); }
+       int getMaxAvailable()                                                                                           { PROPERTYVAL(mMaxAvailable, asInt, -1); }
+
+private:
+       Variant* mMaxAvailable;
+};
+
+#endif // _OFFERING_H_