Adding class LabRoom for IoTRelation testing with C++ IoTSlave
[iot2.git] / benchmarks / Cpp / Lifxtest / RoomSmart_Stub.hpp
1 #ifndef _ROOMSMART_STUB_HPP__
2 #define _ROOMSMART_STUB_HPP__
3 #include <iostream>
4 #include <fstream>
5 #include "RoomSmart.hpp"
6
7 using namespace std;
8
9 class RoomSmart_Stub : public RoomSmart
10 {
11         private:
12
13         IoTRMICall *rmiCall;
14         string callbackAddress;
15         vector<int> ports;
16
17         const static int objectId = 0;
18         
19         ofstream log;
20         public:
21
22         RoomSmart_Stub() { }
23         
24         RoomSmart_Stub(int _port, const char* _skeletonAddress, string _callbackAddress, int _rev, bool* _bResult, vector<int> _ports) {
25                 callbackAddress = _callbackAddress;
26                 ports = _ports;
27                 // Logging
28                 log.open("RoomSmart_Stub_cpp.log");
29                 log << "Port: " << _port << endl;
30                 log << "Skeleton address: " << _skeletonAddress << endl;
31                 log << "Callback address: " << callbackAddress << endl;
32                 log << "Rev: " << _rev << endl;
33                 log << "bResult: " << *_bResult << endl;
34                 log << "Ports: " << _ports[0] << endl;
35                 rmiCall = new IoTRMICall(_port, _skeletonAddress, _rev, _bResult);
36                 log << "Established connection with skeleton!" << endl;
37         }
38
39         ~RoomSmart_Stub() {
40                 if (rmiCall != NULL) {
41                         delete rmiCall;
42                         rmiCall = NULL;
43                 }
44         }
45         
46         int getRoomID() {
47                 log << "Calling getRoomID() in stub!" << endl;
48                 int methodId = 0;
49                 string retType = "int";
50                 int numParam = 0;
51                 string paramCls[] = {  };
52                 void* paramObj[] = {  };
53                 int retVal = 0;
54                 void* retObj = &retVal;
55                 log << "About to remote call!" << endl;
56                 rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
57                 log << "Remote call performed!" << endl;
58                 return retVal;
59         }
60
61 };
62 #endif