2 #include "LightBulb_Skeleton.hpp"
6 LightBulb_Skeleton::LightBulb_Skeleton(LightBulb *_mainObj, int _portSend, int _portRecv) {
9 rmiComm = new IoTRMICommServer(_portSend, _portRecv, &_bResult);
10 IoTRMIUtil::mapSkel->insert(make_pair(_mainObj, this));
11 IoTRMIUtil::mapSkelId->insert(make_pair(_mainObj, objectId));
12 rmiComm->registerSkeleton(objectId, &methodReceived);
13 thread th1 (&LightBulb_Skeleton::___waitRequestInvokeMethod, this, this);
17 LightBulb_Skeleton::LightBulb_Skeleton(LightBulb *_mainObj, IoTRMIComm *_rmiComm, int _objectId) {
18 bool _bResult = false;
22 rmiComm->registerSkeleton(objectId, &methodReceived);
25 LightBulb_Skeleton::~LightBulb_Skeleton() {
26 if (rmiComm != NULL) {
32 bool LightBulb_Skeleton::didInitWaitInvoke() {
33 return didAlreadyInitWaitInvoke;
36 void LightBulb_Skeleton::init() {
40 void LightBulb_Skeleton::turnOff() {
44 void LightBulb_Skeleton::turnOn() {
48 bool LightBulb_Skeleton::getState() {
49 return mainObj->getState();
52 void LightBulb_Skeleton::setColor(double _hue, double _saturation, double _brightness) {
53 mainObj->setColor(_hue, _saturation, _brightness);
56 void LightBulb_Skeleton::setTemperature(int _temperature) {
57 mainObj->setTemperature(_temperature);
60 double LightBulb_Skeleton::getBrightness() {
61 return mainObj->getBrightness();
64 double LightBulb_Skeleton::getHue() {
65 return mainObj->getHue();
68 double LightBulb_Skeleton::getSaturation() {
69 return mainObj->getSaturation();
72 int LightBulb_Skeleton::getTemperature() {
73 return mainObj->getTemperature();
76 double LightBulb_Skeleton::getBrightnessRangeLowerBound() {
77 return mainObj->getBrightnessRangeLowerBound();
80 double LightBulb_Skeleton::getBrightnessRangeUpperBound() {
81 return mainObj->getBrightnessRangeUpperBound();
84 double LightBulb_Skeleton::getHueRangeLowerBound() {
85 return mainObj->getHueRangeLowerBound();
88 double LightBulb_Skeleton::getHueRangeUpperBound() {
89 return mainObj->getHueRangeUpperBound();
92 double LightBulb_Skeleton::getSaturationRangeLowerBound() {
93 return mainObj->getSaturationRangeLowerBound();
96 double LightBulb_Skeleton::getSaturationRangeUpperBound() {
97 return mainObj->getSaturationRangeUpperBound();
100 int LightBulb_Skeleton::getTemperatureRangeLowerBound() {
101 return mainObj->getTemperatureRangeLowerBound();
104 int LightBulb_Skeleton::getTemperatureRangeUpperBound() {
105 return mainObj->getTemperatureRangeUpperBound();
108 void LightBulb_Skeleton::___init(LightBulb_Skeleton* skel) {
109 char* localMethodBytes = new char[methodLen];
110 memcpy(localMethodBytes, skel->methodBytes, methodLen);
111 didGetMethodBytes.exchange(true);
112 string paramCls[] = { };
114 void* paramObj[] = { };
115 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
117 delete[] localMethodBytes;
120 void LightBulb_Skeleton::___turnOff(LightBulb_Skeleton* skel) {
121 char* localMethodBytes = new char[methodLen];
122 memcpy(localMethodBytes, skel->methodBytes, methodLen);
123 didGetMethodBytes.exchange(true);
124 string paramCls[] = { };
126 void* paramObj[] = { };
127 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
129 delete[] localMethodBytes;
132 void LightBulb_Skeleton::___turnOn(LightBulb_Skeleton* skel) {
133 char* localMethodBytes = new char[methodLen];
134 memcpy(localMethodBytes, skel->methodBytes, methodLen);
135 didGetMethodBytes.exchange(true);
136 string paramCls[] = { };
138 void* paramObj[] = { };
139 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
141 delete[] localMethodBytes;
144 void LightBulb_Skeleton::___getState(LightBulb_Skeleton* skel) {
145 char* localMethodBytes = new char[methodLen];
146 memcpy(localMethodBytes, skel->methodBytes, methodLen);
147 didGetMethodBytes.exchange(true);
148 string paramCls[] = { };
150 void* paramObj[] = { };
151 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
152 bool retVal = getState();
153 void* retObj = &retVal;
154 rmiComm->sendReturnObj(retObj, "boolean", localMethodBytes);
155 delete[] localMethodBytes;
158 void LightBulb_Skeleton::___setColor(LightBulb_Skeleton* skel) {
159 char* localMethodBytes = new char[methodLen];
160 memcpy(localMethodBytes, skel->methodBytes, methodLen);
161 didGetMethodBytes.exchange(true);
162 string paramCls[] = { "double", "double", "double" };
167 void* paramObj[] = { &_hue, &_saturation, &_brightness };
168 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
169 setColor(_hue, _saturation, _brightness);
170 delete[] localMethodBytes;
173 void LightBulb_Skeleton::___setTemperature(LightBulb_Skeleton* skel) {
174 char* localMethodBytes = new char[methodLen];
175 memcpy(localMethodBytes, skel->methodBytes, methodLen);
176 didGetMethodBytes.exchange(true);
177 string paramCls[] = { "int" };
180 void* paramObj[] = { &_temperature };
181 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
182 setTemperature(_temperature);
183 delete[] localMethodBytes;
186 void LightBulb_Skeleton::___getBrightness(LightBulb_Skeleton* skel) {
187 char* localMethodBytes = new char[methodLen];
188 memcpy(localMethodBytes, skel->methodBytes, methodLen);
189 didGetMethodBytes.exchange(true);
190 string paramCls[] = { };
192 void* paramObj[] = { };
193 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
194 double retVal = getBrightness();
195 void* retObj = &retVal;
196 rmiComm->sendReturnObj(retObj, "double", localMethodBytes);
197 delete[] localMethodBytes;
200 void LightBulb_Skeleton::___getHue(LightBulb_Skeleton* skel) {
201 char* localMethodBytes = new char[methodLen];
202 memcpy(localMethodBytes, skel->methodBytes, methodLen);
203 didGetMethodBytes.exchange(true);
204 string paramCls[] = { };
206 void* paramObj[] = { };
207 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
208 double retVal = getHue();
209 void* retObj = &retVal;
210 rmiComm->sendReturnObj(retObj, "double", localMethodBytes);
211 delete[] localMethodBytes;
214 void LightBulb_Skeleton::___getSaturation(LightBulb_Skeleton* skel) {
215 char* localMethodBytes = new char[methodLen];
216 memcpy(localMethodBytes, skel->methodBytes, methodLen);
217 didGetMethodBytes.exchange(true);
218 string paramCls[] = { };
220 void* paramObj[] = { };
221 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
222 double retVal = getSaturation();
223 void* retObj = &retVal;
224 rmiComm->sendReturnObj(retObj, "double", localMethodBytes);
225 delete[] localMethodBytes;
228 void LightBulb_Skeleton::___getTemperature(LightBulb_Skeleton* skel) {
229 char* localMethodBytes = new char[methodLen];
230 memcpy(localMethodBytes, skel->methodBytes, methodLen);
231 didGetMethodBytes.exchange(true);
232 string paramCls[] = { };
234 void* paramObj[] = { };
235 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
236 int retVal = getTemperature();
237 void* retObj = &retVal;
238 rmiComm->sendReturnObj(retObj, "int", localMethodBytes);
239 delete[] localMethodBytes;
242 void LightBulb_Skeleton::___getBrightnessRangeLowerBound(LightBulb_Skeleton* skel) {
243 char* localMethodBytes = new char[methodLen];
244 memcpy(localMethodBytes, skel->methodBytes, methodLen);
245 didGetMethodBytes.exchange(true);
246 string paramCls[] = { };
248 void* paramObj[] = { };
249 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
250 double retVal = getBrightnessRangeLowerBound();
251 void* retObj = &retVal;
252 rmiComm->sendReturnObj(retObj, "double", localMethodBytes);
253 delete[] localMethodBytes;
256 void LightBulb_Skeleton::___getBrightnessRangeUpperBound(LightBulb_Skeleton* skel) {
257 char* localMethodBytes = new char[methodLen];
258 memcpy(localMethodBytes, skel->methodBytes, methodLen);
259 didGetMethodBytes.exchange(true);
260 string paramCls[] = { };
262 void* paramObj[] = { };
263 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
264 double retVal = getBrightnessRangeUpperBound();
265 void* retObj = &retVal;
266 rmiComm->sendReturnObj(retObj, "double", localMethodBytes);
267 delete[] localMethodBytes;
270 void LightBulb_Skeleton::___getHueRangeLowerBound(LightBulb_Skeleton* skel) {
271 char* localMethodBytes = new char[methodLen];
272 memcpy(localMethodBytes, skel->methodBytes, methodLen);
273 didGetMethodBytes.exchange(true);
274 string paramCls[] = { };
276 void* paramObj[] = { };
277 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
278 double retVal = getHueRangeLowerBound();
279 void* retObj = &retVal;
280 rmiComm->sendReturnObj(retObj, "double", localMethodBytes);
281 delete[] localMethodBytes;
284 void LightBulb_Skeleton::___getHueRangeUpperBound(LightBulb_Skeleton* skel) {
285 char* localMethodBytes = new char[methodLen];
286 memcpy(localMethodBytes, skel->methodBytes, methodLen);
287 didGetMethodBytes.exchange(true);
288 string paramCls[] = { };
290 void* paramObj[] = { };
291 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
292 double retVal = getHueRangeUpperBound();
293 void* retObj = &retVal;
294 rmiComm->sendReturnObj(retObj, "double", localMethodBytes);
295 delete[] localMethodBytes;
298 void LightBulb_Skeleton::___getSaturationRangeLowerBound(LightBulb_Skeleton* skel) {
299 char* localMethodBytes = new char[methodLen];
300 memcpy(localMethodBytes, skel->methodBytes, methodLen);
301 didGetMethodBytes.exchange(true);
302 string paramCls[] = { };
304 void* paramObj[] = { };
305 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
306 double retVal = getSaturationRangeLowerBound();
307 void* retObj = &retVal;
308 rmiComm->sendReturnObj(retObj, "double", localMethodBytes);
309 delete[] localMethodBytes;
312 void LightBulb_Skeleton::___getSaturationRangeUpperBound(LightBulb_Skeleton* skel) {
313 char* localMethodBytes = new char[methodLen];
314 memcpy(localMethodBytes, skel->methodBytes, methodLen);
315 didGetMethodBytes.exchange(true);
316 string paramCls[] = { };
318 void* paramObj[] = { };
319 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
320 double retVal = getSaturationRangeUpperBound();
321 void* retObj = &retVal;
322 rmiComm->sendReturnObj(retObj, "double", localMethodBytes);
323 delete[] localMethodBytes;
326 void LightBulb_Skeleton::___getTemperatureRangeLowerBound(LightBulb_Skeleton* skel) {
327 char* localMethodBytes = new char[methodLen];
328 memcpy(localMethodBytes, skel->methodBytes, methodLen);
329 didGetMethodBytes.exchange(true);
330 string paramCls[] = { };
332 void* paramObj[] = { };
333 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
334 int retVal = getTemperatureRangeLowerBound();
335 void* retObj = &retVal;
336 rmiComm->sendReturnObj(retObj, "int", localMethodBytes);
337 delete[] localMethodBytes;
340 void LightBulb_Skeleton::___getTemperatureRangeUpperBound(LightBulb_Skeleton* skel) {
341 char* localMethodBytes = new char[methodLen];
342 memcpy(localMethodBytes, skel->methodBytes, methodLen);
343 didGetMethodBytes.exchange(true);
344 string paramCls[] = { };
346 void* paramObj[] = { };
347 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
348 int retVal = getTemperatureRangeUpperBound();
349 void* retObj = &retVal;
350 rmiComm->sendReturnObj(retObj, "int", localMethodBytes);
351 delete[] localMethodBytes;
354 void LightBulb_Skeleton::___waitRequestInvokeMethod(LightBulb_Skeleton* skel) {
355 skel->didAlreadyInitWaitInvoke = true;
357 if (!methodReceived) {
360 skel->methodBytes = skel->rmiComm->getMethodBytes();
361 skel->methodLen = skel->rmiComm->getMethodLength();
362 methodReceived = false;
363 int _objectId = skel->rmiComm->getObjectId(skel->methodBytes);
364 int methodId = skel->rmiComm->getMethodId(skel->methodBytes);
365 if (_objectId == objectId) {
366 if (set0Allowed.find(methodId) == set0Allowed.end()) {
367 cerr << "Object with object Id: " << _objectId << " is not allowed to access method: " << methodId << endl;
376 thread th0 (&LightBulb_Skeleton::___init, std::ref(skel), skel);
380 thread th1 (&LightBulb_Skeleton::___turnOff, std::ref(skel), skel);
384 thread th2 (&LightBulb_Skeleton::___turnOn, std::ref(skel), skel);
388 thread th3 (&LightBulb_Skeleton::___getState, std::ref(skel), skel);
392 thread th4 (&LightBulb_Skeleton::___setColor, std::ref(skel), skel);
396 thread th5 (&LightBulb_Skeleton::___setTemperature, std::ref(skel), skel);
400 thread th6 (&LightBulb_Skeleton::___getBrightness, std::ref(skel), skel);
404 thread th7 (&LightBulb_Skeleton::___getHue, std::ref(skel), skel);
408 thread th8 (&LightBulb_Skeleton::___getSaturation, std::ref(skel), skel);
412 thread th9 (&LightBulb_Skeleton::___getTemperature, std::ref(skel), skel);
416 thread th10 (&LightBulb_Skeleton::___getBrightnessRangeLowerBound, std::ref(skel), skel);
417 th10.detach(); break;
420 thread th11 (&LightBulb_Skeleton::___getBrightnessRangeUpperBound, std::ref(skel), skel);
421 th11.detach(); break;
424 thread th12 (&LightBulb_Skeleton::___getHueRangeLowerBound, std::ref(skel), skel);
425 th12.detach(); break;
428 thread th13 (&LightBulb_Skeleton::___getHueRangeUpperBound, std::ref(skel), skel);
429 th13.detach(); break;
432 thread th14 (&LightBulb_Skeleton::___getSaturationRangeLowerBound, std::ref(skel), skel);
433 th14.detach(); break;
436 thread th15 (&LightBulb_Skeleton::___getSaturationRangeUpperBound, std::ref(skel), skel);
437 th15.detach(); break;
440 thread th16 (&LightBulb_Skeleton::___getTemperatureRangeLowerBound, std::ref(skel), skel);
441 th16.detach(); break;
444 thread th17 (&LightBulb_Skeleton::___getTemperatureRangeUpperBound, std::ref(skel), skel);
445 th17.detach(); break;
448 cerr << "Method Id " << methodId << " not recognized!" << endl;
454 extern "C" void* createLightBulb_Skeleton(void** params) {
455 // Args: *_mainObj, int _portSend, int _portRecv
456 return new LightBulb_Skeleton((LightBulb*) params[0], *((int*) params[0]), *((int*) params[1]));
459 extern "C" void destroyLightBulb_Skeleton(void* t) {
460 LightBulb_Skeleton* obj = (LightBulb_Skeleton*) t;
464 extern "C" void initLightBulb_Skeleton(void* t) {