1 #ifndef _LIGHTBULBTEST_STUB_HPP__
2 #define _LIGHTBULBTEST_STUB_HPP__
5 #include "LightBulbTest.hpp"
9 class LightBulbTest_Stub : public LightBulbTest
14 string callbackAddress;
17 const static int objectId = 0;
23 LightBulbTest_Stub() { }
25 LightBulbTest_Stub(int _port, const char* _skeletonAddress, string _callbackAddress, int _rev, bool* _bResult, vector<int> _ports) {
26 callbackAddress = _callbackAddress;
30 string file = "LightBulbTest_Stub_cpp" + to_string(i) + ".log";
31 while (ifstream(file.c_str())) {
33 file = "LightBulbTest_Stub_cpp" + to_string(i) + ".log";
36 log << "Port: " << _port << endl;
37 log << "Skeleton address: " << _skeletonAddress << endl;
38 log << "Callback address: " << callbackAddress << endl;
39 log << "Rev: " << _rev << endl;
40 log << "bResult: " << *_bResult << endl;
41 log << "Ports: " << _ports[0] << endl;
42 rmiCall = new IoTRMICall(_port, _skeletonAddress, _rev, _bResult);
43 log << "Established connection with skeleton!" << endl;
47 ~LightBulbTest_Stub() {
48 if (rmiCall != NULL) {
55 log << "Calling turnOn() in stub!" << endl;
57 string retType = "void";
59 string paramCls[] = { };
60 void* paramObj[] = { };
62 log << "About to remote call!" << endl;
63 rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
64 log << "Remote call performed!" << endl;
67 double getBrightness() {
69 string retType = "double";
71 string paramCls[] = { };
72 void* paramObj[] = { };
74 void* retObj = &retVal;
75 rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
80 log << "Calling turnOff() in stub!" << endl;
82 string retType = "void";
84 string paramCls[] = { };
85 void* paramObj[] = { };
87 log << "About to remote call!" << endl;
88 rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
89 log << "Remote call performed!" << endl;
94 string retType = "boolean";
96 string paramCls[] = { };
97 void* paramObj[] = { };
99 void* retObj = &retVal;
100 rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
104 void setColor(double _hue, double _saturation, double _brightness) {
106 string retType = "void";
108 string paramCls[] = { "double", "double", "double" };
109 void* paramObj[] = { &_hue, &_saturation, &_brightness };
111 rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
114 double getSaturation() {
116 string retType = "double";
118 string paramCls[] = { };
119 void* paramObj[] = { };
121 void* retObj = &retVal;
122 rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
127 log << "Calling init() in stub!" << endl;
129 string retType = "void";
131 string paramCls[] = { };
132 void* paramObj[] = { };
134 log << "About to remote call!" << endl;
135 rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
136 log << "Remote call performed!" << endl;
140 void setTemperature(int _temperature) {
142 string retType = "void";
144 string paramCls[] = { "int" };
145 void* paramObj[] = { &_temperature };
147 rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
152 string retType = "double";
154 string paramCls[] = { };
155 void* paramObj[] = { };
157 void* retObj = &retVal;
158 rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
162 int getTemperature() {
164 string retType = "int";
166 string paramCls[] = { };
167 void* paramObj[] = { };
169 void* retObj = &retVal;
170 rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);