From 47345575aebb8df39274ddf83d9cfbde7fd5ad83 Mon Sep 17 00:00:00 2001 From: rtrimana Date: Wed, 11 Jan 2017 20:06:26 -0800 Subject: [PATCH] Preparing Lifxtest as a test benchmark; making adjustments in IoTSet for C++, etc. --- benchmarks/Cpp/Lifxtest/Lifxtest.config | 1 + benchmarks/Cpp/Lifxtest/Lifxtest.cpp | 71 ++++ benchmarks/Cpp/Lifxtest/Lifxtest.hpp | 22 ++ .../Cpp/Lifxtest/LightBulbTest_Stub.hpp | 147 ++++++++ benchmarks/Cpp/Lifxtest/Makefile | 12 + .../Cpp/LifxLightBulb/LifxLightBulb.cpp | 6 - .../Cpp/LifxLightBulb/LifxLightBulb.hpp | 2 - .../Cpp/LifxLightBulb/LightBulb_Skeleton.hpp | 332 ++++++++++++++++++ benchmarks/virtuals/LightBulbTest.hpp | 36 ++ iotjava/Makefile | 3 +- iotjava/iotruntime/cpp/setrelation/IoTSet.hpp | 4 +- .../iotruntime/cpp/setrelation/Iterator.hpp | 20 ++ 12 files changed, 645 insertions(+), 11 deletions(-) create mode 100644 benchmarks/Cpp/Lifxtest/Lifxtest.config create mode 100644 benchmarks/Cpp/Lifxtest/Lifxtest.cpp create mode 100644 benchmarks/Cpp/Lifxtest/Lifxtest.hpp create mode 100644 benchmarks/Cpp/Lifxtest/LightBulbTest_Stub.hpp create mode 100755 benchmarks/Cpp/Lifxtest/Makefile create mode 100644 benchmarks/drivers/Cpp/LifxLightBulb/LightBulb_Skeleton.hpp create mode 100644 benchmarks/virtuals/LightBulbTest.hpp diff --git a/benchmarks/Cpp/Lifxtest/Lifxtest.config b/benchmarks/Cpp/Lifxtest/Lifxtest.config new file mode 100644 index 0000000..5a44766 --- /dev/null +++ b/benchmarks/Cpp/Lifxtest/Lifxtest.config @@ -0,0 +1 @@ +ADDITIONAL_ZIP_FILE=No diff --git a/benchmarks/Cpp/Lifxtest/Lifxtest.cpp b/benchmarks/Cpp/Lifxtest/Lifxtest.cpp new file mode 100644 index 0000000..39c2f44 --- /dev/null +++ b/benchmarks/Cpp/Lifxtest/Lifxtest.cpp @@ -0,0 +1,71 @@ +#include +#include +#include + +#include "Lifxtest.hpp" +#include "Iterator.hpp" + +Lifxtest::Lifxtest() { + +} + +Lifxtest::Lifxtest(IoTSet _lifx_light_bulb) { + + lifx_light_bulb = _lifx_light_bulb; +} + + +Lifxtest::~Lifxtest() { +} + + +void Lifxtest::init() { + + unordered_set* bulbSet = lifx_light_bulb.values(); + for(LightBulbTest* lifx : *bulbSet) { + + lifx->init(); + this_thread::sleep_for (chrono::milliseconds(1000)); + + for (int i = 0; i < 5; i++) { + lifx->turnOff(); + cout << "Turning off!" << endl; + this_thread::sleep_for (chrono::milliseconds(1000)); + lifx->turnOn(); + cout << "Turning on!" << endl; + this_thread::sleep_for (chrono::milliseconds(1000)); + } + + for (int i = 2500; i < 9000; i += 100) { + cout << "Adjusting Temp: "; + lifx->setTemperature(i); + this_thread::sleep_for (chrono::milliseconds(100)); + } + + for (int i = 9000; i > 2500; i -= 100) { + cout << "Adjusting Temp: "; + lifx->setTemperature(i); + this_thread::sleep_for (chrono::milliseconds(100)); + } + + for (int i = 100; i > 0; i -= 10) { + cout << "Adjusting Brightness: "; + lifx->setColor(lifx->getHue(), lifx->getSaturation(), i); + this_thread::sleep_for (chrono::milliseconds(500)); + } + + for (int i = 0; i < 100; i += 10) { + cout << "Adjusting Brightness: " << endl; + lifx->setColor(lifx->getHue(), lifx->getSaturation(), i); + this_thread::sleep_for (chrono::milliseconds(500)); + } + } +} + + +int main(int argc, char *argv[]) { + + return 0; +} + + diff --git a/benchmarks/Cpp/Lifxtest/Lifxtest.hpp b/benchmarks/Cpp/Lifxtest/Lifxtest.hpp new file mode 100644 index 0000000..41b61aa --- /dev/null +++ b/benchmarks/Cpp/Lifxtest/Lifxtest.hpp @@ -0,0 +1,22 @@ +#ifndef _LIFXTEST_HPP__ +#define _LIFXTEST_HPP__ +#include + +#include "IoTSet.hpp" +#include "LightBulbTest.hpp" + +class Lifxtest { + + private: + // IoTSet + IoTSet lifx_light_bulb; + + public: + + Lifxtest(); + Lifxtest(IoTSet _lifx_light_bulb); + ~Lifxtest(); + void init(); +}; +#endif + diff --git a/benchmarks/Cpp/Lifxtest/LightBulbTest_Stub.hpp b/benchmarks/Cpp/Lifxtest/LightBulbTest_Stub.hpp new file mode 100644 index 0000000..ccc3fe6 --- /dev/null +++ b/benchmarks/Cpp/Lifxtest/LightBulbTest_Stub.hpp @@ -0,0 +1,147 @@ +#ifndef _LIGHTBULBTEST_STUB_HPP__ +#define _LIGHTBULBTEST_STUB_HPP__ +#include +#include "LightBulbTest.hpp" + +using namespace std; + +class LightBulbTest_Stub : public LightBulbTest +{ + private: + + IoTRMICall *rmiCall; + string callbackAddress; + vector ports; + + const static int objectId = 0; + + + public: + + LightBulbTest_Stub() { } + + LightBulbTest_Stub(int _port, const char* _skeletonAddress, string _callbackAddress, int _rev, bool* _bResult, vector _ports) { + callbackAddress = _callbackAddress; + ports = _ports; + rmiCall = new IoTRMICall(_port, _skeletonAddress, _rev, _bResult); + } + + ~LightBulbTest_Stub() { + if (rmiCall != NULL) { + delete rmiCall; + rmiCall = NULL; + } + } + + void turnOn() { + int methodId = 2; + string retType = "void"; + int numParam = 0; + string paramCls[] = { }; + void* paramObj[] = { }; + void* retObj = NULL; + rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj); + } + + double getBrightness() { + int methodId = 6; + string retType = "double"; + int numParam = 0; + string paramCls[] = { }; + void* paramObj[] = { }; + double retVal = 0; + void* retObj = &retVal; + rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj); + return retVal; + } + + void turnOff() { + int methodId = 1; + string retType = "void"; + int numParam = 0; + string paramCls[] = { }; + void* paramObj[] = { }; + void* retObj = NULL; + rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj); + } + + bool getState() { + int methodId = 3; + string retType = "boolean"; + int numParam = 0; + string paramCls[] = { }; + void* paramObj[] = { }; + bool retVal = false; + void* retObj = &retVal; + rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj); + return retVal; + } + + void setColor(double _hue, double _saturation, double _brightness) { + int methodId = 4; + string retType = "void"; + int numParam = 3; + string paramCls[] = { "double", "double", "double" }; + void* paramObj[] = { &_hue, &_saturation, &_brightness }; + void* retObj = NULL; + rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj); + } + + double getSaturation() { + int methodId = 8; + string retType = "double"; + int numParam = 0; + string paramCls[] = { }; + void* paramObj[] = { }; + double retVal = 0; + void* retObj = &retVal; + rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj); + return retVal; + } + + void init() { + int methodId = 0; + string retType = "void"; + int numParam = 0; + string paramCls[] = { }; + void* paramObj[] = { }; + void* retObj = NULL; + rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj); + } + + void setTemperature(int _temperature) { + int methodId = 5; + string retType = "void"; + int numParam = 1; + string paramCls[] = { "int" }; + void* paramObj[] = { &_temperature }; + void* retObj = NULL; + rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj); + } + + double getHue() { + int methodId = 7; + string retType = "double"; + int numParam = 0; + string paramCls[] = { }; + void* paramObj[] = { }; + double retVal = 0; + void* retObj = &retVal; + rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj); + return retVal; + } + + int getTemperature() { + int methodId = 9; + string retType = "int"; + int numParam = 0; + string paramCls[] = { }; + void* paramObj[] = { }; + int retVal = 0; + void* retObj = &retVal; + rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj); + return retVal; + } + +}; +#endif diff --git a/benchmarks/Cpp/Lifxtest/Makefile b/benchmarks/Cpp/Lifxtest/Makefile new file mode 100755 index 0000000..4a98f8a --- /dev/null +++ b/benchmarks/Cpp/Lifxtest/Makefile @@ -0,0 +1,12 @@ +BASE = ../../.. + +include $(BASE)/common.mk + +all: lifxtest + +PHONY += lifxtest +lifxtest: + $(G++) ./Lifxtest.cpp $(BASE)/iotjava/iotruntime/cpp/socket/Socket.cpp -o $(BIN_DIR)/Lifxtest/Lifxtest.o --std=c++11 -pthread -pg -I$(BASE)/iotjava/iotruntime/cpp/ -I$(BASE)/iotjava/iotruntime/cpp/socket/ -I$(BASE)/iotjava/iotruntime/cpp/setrelation/ -I$(BASE)/iotjava/iotrmi/C++/ -I$(BASE)/benchmarks/virtuals/ + cp ./Lifxtest.config $(BIN_DIR)/iotcode/Lifxtest + +.PHONY: $(PHONY) diff --git a/benchmarks/drivers/Cpp/LifxLightBulb/LifxLightBulb.cpp b/benchmarks/drivers/Cpp/LifxLightBulb/LifxLightBulb.cpp index b3a99ea..669548f 100644 --- a/benchmarks/drivers/Cpp/LifxLightBulb/LifxLightBulb.cpp +++ b/benchmarks/drivers/Cpp/LifxLightBulb/LifxLightBulb.cpp @@ -1124,12 +1124,6 @@ void LifxLightBulb::handleLightStateMessageReceived(char* payloadData) { // Functions for the main function -void run(LifxLightBulb *llb) { - - llb->init(); -} - - void onOff(LifxLightBulb *llb) { for (int i = 0; i < 5; i++) { diff --git a/benchmarks/drivers/Cpp/LifxLightBulb/LifxLightBulb.hpp b/benchmarks/drivers/Cpp/LifxLightBulb/LifxLightBulb.hpp index 56bc733..79e8e9e 100644 --- a/benchmarks/drivers/Cpp/LifxLightBulb/LifxLightBulb.hpp +++ b/benchmarks/drivers/Cpp/LifxLightBulb/LifxLightBulb.hpp @@ -5,11 +5,9 @@ #include #include #include -#include #include #include -#include #include "LightBulb.hpp" #include "Socket.hpp" diff --git a/benchmarks/drivers/Cpp/LifxLightBulb/LightBulb_Skeleton.hpp b/benchmarks/drivers/Cpp/LifxLightBulb/LightBulb_Skeleton.hpp new file mode 100644 index 0000000..5b7aaaa --- /dev/null +++ b/benchmarks/drivers/Cpp/LifxLightBulb/LightBulb_Skeleton.hpp @@ -0,0 +1,332 @@ +#ifndef _LIGHTBULB_SKELETON_HPP__ +#define _LIGHTBULB_SKELETON_HPP__ +#include +#include "LightBulb.hpp" + +#include +#include +#include "IoTRMICall.hpp" +#include "IoTRMIObject.hpp" + +using namespace std; + +class LightBulb_Skeleton : public LightBulb +{ + private: + + LightBulb *mainObj; + vector ports; + string callbackAddress; + IoTRMIObject *rmiObj; + + const static int object0Id = 0; //LightBulbSmart + static set set0Allowed; + + + public: + + LightBulb_Skeleton(LightBulb *_mainObj, string _callbackAddress, int _port) { + bool _bResult = false; + mainObj = _mainObj; + callbackAddress = _callbackAddress; + rmiObj = new IoTRMIObject(_port, &_bResult); + ___waitRequestInvokeMethod(); + } + + ~LightBulb_Skeleton() { + if (rmiObj != NULL) { + delete rmiObj; + rmiObj = NULL; + } + } + + void init() { + mainObj->init(); + } + + void turnOff() { + mainObj->turnOff(); + } + + void turnOn() { + mainObj->turnOn(); + } + + bool getState() { + return mainObj->getState(); + } + + void setColor(double _hue, double _saturation, double _brightness) { + mainObj->setColor(_hue, _saturation, _brightness); + } + + void setTemperature(int _temperature) { + mainObj->setTemperature(_temperature); + } + + double getBrightness() { + return mainObj->getBrightness(); + } + + double getHue() { + return mainObj->getHue(); + } + + double getSaturation() { + return mainObj->getSaturation(); + } + + int getTemperature() { + return mainObj->getTemperature(); + } + + double getBrightnessRangeLowerBound() { + return mainObj->getBrightnessRangeLowerBound(); + } + + double getBrightnessRangeUpperBound() { + return mainObj->getBrightnessRangeUpperBound(); + } + + double getHueRangeLowerBound() { + return mainObj->getHueRangeLowerBound(); + } + + double getHueRangeUpperBound() { + return mainObj->getHueRangeUpperBound(); + } + + double getSaturationRangeLowerBound() { + return mainObj->getSaturationRangeLowerBound(); + } + + double getSaturationRangeUpperBound() { + return mainObj->getSaturationRangeUpperBound(); + } + + int getTemperatureRangeLowerBound() { + return mainObj->getTemperatureRangeLowerBound(); + } + + int getTemperatureRangeUpperBound() { + return mainObj->getTemperatureRangeUpperBound(); + } + + void ___init() { + string paramCls[] = { }; + int numParam = 0; + void* paramObj[] = { }; + rmiObj->getMethodParams(paramCls, numParam, paramObj); + init(); + } + + void ___turnOff() { + string paramCls[] = { }; + int numParam = 0; + void* paramObj[] = { }; + rmiObj->getMethodParams(paramCls, numParam, paramObj); + turnOff(); + } + + void ___turnOn() { + string paramCls[] = { }; + int numParam = 0; + void* paramObj[] = { }; + rmiObj->getMethodParams(paramCls, numParam, paramObj); + turnOn(); + } + + void ___getState() { + string paramCls[] = { }; + int numParam = 0; + void* paramObj[] = { }; + rmiObj->getMethodParams(paramCls, numParam, paramObj); + bool retVal = getState(); + void* retObj = &retVal; + rmiObj->sendReturnObj(retObj, "boolean"); + } + + void ___setColor() { + string paramCls[] = { "double", "double", "double" }; + int numParam = 3; + double _hue; + double _saturation; + double _brightness; + void* paramObj[] = { &_hue, &_saturation, &_brightness }; + rmiObj->getMethodParams(paramCls, numParam, paramObj); + setColor(_hue, _saturation, _brightness); + } + + void ___setTemperature() { + string paramCls[] = { "int" }; + int numParam = 1; + int _temperature; + void* paramObj[] = { &_temperature }; + rmiObj->getMethodParams(paramCls, numParam, paramObj); + setTemperature(_temperature); + } + + void ___getBrightness() { + string paramCls[] = { }; + int numParam = 0; + void* paramObj[] = { }; + rmiObj->getMethodParams(paramCls, numParam, paramObj); + double retVal = getBrightness(); + void* retObj = &retVal; + rmiObj->sendReturnObj(retObj, "double"); + } + + void ___getHue() { + string paramCls[] = { }; + int numParam = 0; + void* paramObj[] = { }; + rmiObj->getMethodParams(paramCls, numParam, paramObj); + double retVal = getHue(); + void* retObj = &retVal; + rmiObj->sendReturnObj(retObj, "double"); + } + + void ___getSaturation() { + string paramCls[] = { }; + int numParam = 0; + void* paramObj[] = { }; + rmiObj->getMethodParams(paramCls, numParam, paramObj); + double retVal = getSaturation(); + void* retObj = &retVal; + rmiObj->sendReturnObj(retObj, "double"); + } + + void ___getTemperature() { + string paramCls[] = { }; + int numParam = 0; + void* paramObj[] = { }; + rmiObj->getMethodParams(paramCls, numParam, paramObj); + int retVal = getTemperature(); + void* retObj = &retVal; + rmiObj->sendReturnObj(retObj, "int"); + } + + void ___getBrightnessRangeLowerBound() { + string paramCls[] = { }; + int numParam = 0; + void* paramObj[] = { }; + rmiObj->getMethodParams(paramCls, numParam, paramObj); + double retVal = getBrightnessRangeLowerBound(); + void* retObj = &retVal; + rmiObj->sendReturnObj(retObj, "double"); + } + + void ___getBrightnessRangeUpperBound() { + string paramCls[] = { }; + int numParam = 0; + void* paramObj[] = { }; + rmiObj->getMethodParams(paramCls, numParam, paramObj); + double retVal = getBrightnessRangeUpperBound(); + void* retObj = &retVal; + rmiObj->sendReturnObj(retObj, "double"); + } + + void ___getHueRangeLowerBound() { + string paramCls[] = { }; + int numParam = 0; + void* paramObj[] = { }; + rmiObj->getMethodParams(paramCls, numParam, paramObj); + double retVal = getHueRangeLowerBound(); + void* retObj = &retVal; + rmiObj->sendReturnObj(retObj, "double"); + } + + void ___getHueRangeUpperBound() { + string paramCls[] = { }; + int numParam = 0; + void* paramObj[] = { }; + rmiObj->getMethodParams(paramCls, numParam, paramObj); + double retVal = getHueRangeUpperBound(); + void* retObj = &retVal; + rmiObj->sendReturnObj(retObj, "double"); + } + + void ___getSaturationRangeLowerBound() { + string paramCls[] = { }; + int numParam = 0; + void* paramObj[] = { }; + rmiObj->getMethodParams(paramCls, numParam, paramObj); + double retVal = getSaturationRangeLowerBound(); + void* retObj = &retVal; + rmiObj->sendReturnObj(retObj, "double"); + } + + void ___getSaturationRangeUpperBound() { + string paramCls[] = { }; + int numParam = 0; + void* paramObj[] = { }; + rmiObj->getMethodParams(paramCls, numParam, paramObj); + double retVal = getSaturationRangeUpperBound(); + void* retObj = &retVal; + rmiObj->sendReturnObj(retObj, "double"); + } + + void ___getTemperatureRangeLowerBound() { + string paramCls[] = { }; + int numParam = 0; + void* paramObj[] = { }; + rmiObj->getMethodParams(paramCls, numParam, paramObj); + int retVal = getTemperatureRangeLowerBound(); + void* retObj = &retVal; + rmiObj->sendReturnObj(retObj, "int"); + } + + void ___getTemperatureRangeUpperBound() { + string paramCls[] = { }; + int numParam = 0; + void* paramObj[] = { }; + rmiObj->getMethodParams(paramCls, numParam, paramObj); + int retVal = getTemperatureRangeUpperBound(); + void* retObj = &retVal; + rmiObj->sendReturnObj(retObj, "int"); + } + + void ___waitRequestInvokeMethod() { + while (true) { + rmiObj->getMethodBytes(); + int _objectId = rmiObj->getObjectId(); + int methodId = rmiObj->getMethodId(); + if (_objectId == object0Id) { + if (set0Allowed.find(methodId) == set0Allowed.end()) { + cerr << "Object with object Id: " << _objectId << " is not allowed to access method: " << methodId << endl; + return; + } + } + else { + cerr << "Object Id: " << _objectId << " not recognized!" << endl; + return; + } + switch (methodId) { + case 0: ___init(); break; + case 1: ___turnOff(); break; + case 2: ___turnOn(); break; + case 3: ___getState(); break; + case 4: ___setColor(); break; + case 5: ___setTemperature(); break; + case 6: ___getBrightness(); break; + case 7: ___getHue(); break; + case 8: ___getSaturation(); break; + case 9: ___getTemperature(); break; + case 10: ___getBrightnessRangeLowerBound(); break; + case 11: ___getBrightnessRangeUpperBound(); break; + case 12: ___getHueRangeLowerBound(); break; + case 13: ___getHueRangeUpperBound(); break; + case 14: ___getSaturationRangeLowerBound(); break; + case 15: ___getSaturationRangeUpperBound(); break; + case 16: ___getTemperatureRangeLowerBound(); break; + case 17: ___getTemperatureRangeUpperBound(); break; + default: + cerr << "Method Id " << methodId << " not recognized!" << endl; + throw exception(); + } + } + } + +}; +set LightBulb_Skeleton::set0Allowed { 2, 10, 1, 3, 11, 8, 12, 7, 13, 9, 6, 16, 17, 4, 0, 14, 15, 5 }; +#endif diff --git a/benchmarks/virtuals/LightBulbTest.hpp b/benchmarks/virtuals/LightBulbTest.hpp new file mode 100644 index 0000000..5b60f41 --- /dev/null +++ b/benchmarks/virtuals/LightBulbTest.hpp @@ -0,0 +1,36 @@ +#ifndef _LIGHTBULBTEST_HPP__ +#define _LIGHTBULBTEST_HPP__ +#include +#include +#include +#include +#include "IoTRMICall.hpp" +#include "IoTRMIObject.hpp" + +using namespace std; + +class LightBulbTest +{ + public: + virtual void turnOn() = 0; + virtual double getBrightness() = 0; + virtual void turnOff() = 0; + virtual bool getState() = 0; + virtual void setColor(double _hue, double _saturation, double _brightness) = 0; + virtual double getSaturation() = 0; + virtual void init() = 0; + virtual void setTemperature(int _temperature) = 0; + virtual double getHue() = 0; + virtual int getTemperature() = 0; + + // Custom hasher for LightBulbTest iterator + size_t hash(LightBulbTest const& device) const { + + // Use device address for hashing + std::stringstream ss; + ss << &device; + std::hash hashVal; + return hashVal(ss.str()); + } +}; +#endif diff --git a/iotjava/Makefile b/iotjava/Makefile index e346a15..310b859 100644 --- a/iotjava/Makefile +++ b/iotjava/Makefile @@ -30,7 +30,8 @@ PHONY += run-compiler-lbtest run-compiler-lbtest: cp ../localconfig/iotpolicy/LifxLightBulb/*.pol $(BIN_DIR)/iotpolicy/ cp ../localconfig/iotpolicy/LifxLightBulb/*.req $(BIN_DIR)/iotpolicy/ - cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler lifxlightbulb.pol lifxtest.req -java Java + #cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler lifxlightbulb.pol lifxtest.req -java Java + cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler lifxlightbulb.pol lifxtest.req -cplus Cplus # SmartLightsController PHONY += run-compiler-lifx diff --git a/iotjava/iotruntime/cpp/setrelation/IoTSet.hpp b/iotjava/iotruntime/cpp/setrelation/IoTSet.hpp index f64595f..f5ba84a 100644 --- a/iotjava/iotruntime/cpp/setrelation/IoTSet.hpp +++ b/iotjava/iotruntime/cpp/setrelation/IoTSet.hpp @@ -26,7 +26,7 @@ class IoTSet { typename unordered_set::const_iterator begin(); // Iterator typename unordered_set::const_iterator end(); // Iterator int size(); // Set size - unordered_set values(); // Return set contents + unordered_set* values(); // Return set contents }; @@ -103,7 +103,7 @@ int IoTSet::size() { * Return a new copy of the set */ template -unordered_set IoTSet::values() { +unordered_set* IoTSet::values() { return new unordered_set(set); } diff --git a/iotjava/iotruntime/cpp/setrelation/Iterator.hpp b/iotjava/iotruntime/cpp/setrelation/Iterator.hpp index 9cc4416..2890af2 100644 --- a/iotjava/iotruntime/cpp/setrelation/Iterator.hpp +++ b/iotjava/iotruntime/cpp/setrelation/Iterator.hpp @@ -1,6 +1,9 @@ #ifndef _ITERATOR_HPP__ #define _ITERATOR_HPP__ +#include "IoTDeviceAddress.hpp" +#include "LightBulbTest.hpp" + namespace std { template<> struct hash @@ -17,4 +20,21 @@ bool operator==(const IoTDeviceAddress& lhs, const IoTDeviceAddress& rhs) { return lhs.hash(lhs) == rhs.hash(rhs); } + +namespace std +{ + template<> struct hash + { + size_t operator()(LightBulbTest const& device) const + { + return device.hash(device); + } + }; +} + + +bool operator==(const LightBulbTest& lhs, const LightBulbTest& rhs) { + return lhs.hash(lhs) == rhs.hash(rhs); +} + #endif -- 2.34.1