#ifndef _LIGHTBULBTEST_STUB_HPP__
#define _LIGHTBULBTEST_STUB_HPP__
#include <iostream>
+#include <thread>
+#include <mutex>
+#include <vector>
+#include <set>
+#include "IoTRMIComm.hpp"
+#include "IoTRMICommClient.hpp"
+#include "IoTRMICommServer.hpp"
+
#include "LightBulbTest.hpp"
using namespace std;
{
private:
- IoTRMICall *rmiCall;
- string callbackAddress;
- vector<int> ports;
-
- const static int objectId = 0;
+ IoTRMIComm *rmiComm;
+ int objectId = 1;
+ // Synchronization variables
+ bool retValueReceived6 = false;
+ bool retValueReceived3 = false;
+ bool retValueReceived8 = false;
+ bool retValueReceived7 = false;
+ bool retValueReceived9 = false;
public:
- LightBulbTest_Stub() { }
-
- LightBulbTest_Stub(int _port, const char* _skeletonAddress, string _callbackAddress, int _rev, bool* _bResult, vector<int> _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;
- }
-
+ LightBulbTest_Stub();
+ LightBulbTest_Stub(int _portSend, int _portRecv, const char* _skeletonAddress, int _rev, bool* _bResult);
+ LightBulbTest_Stub(IoTRMIComm* _rmiComm, int _objectId);
+ ~LightBulbTest_Stub();
+ void turnOn();
+ double getBrightness();
+ void turnOff();
+ bool getState();
+ void setColor(double _hue, double _saturation, double _brightness);
+ double getSaturation();
+ void init();
+ void setTemperature(int _temperature);
+ double getHue();
+ int getTemperature();
};
-
-//typedef LightBulbTest_Stub* create_t(int _port, const char* _skeletonAddress, string _callbackAddress, int _rev, bool* _bResult, vector<int> _ports);
-//typedef void destroy_t(LightBulbTest_Stub*);
#endif