Adding class LabRoom for IoTRelation testing with C++ IoTSlave
[iot2.git] / benchmarks / Cpp / Lifxtest / RoomSmart_Stub.hpp
diff --git a/benchmarks/Cpp/Lifxtest/RoomSmart_Stub.hpp b/benchmarks/Cpp/Lifxtest/RoomSmart_Stub.hpp
new file mode 100644 (file)
index 0000000..b576cfc
--- /dev/null
@@ -0,0 +1,62 @@
+#ifndef _ROOMSMART_STUB_HPP__
+#define _ROOMSMART_STUB_HPP__
+#include <iostream>
+#include <fstream>
+#include "RoomSmart.hpp"
+
+using namespace std;
+
+class RoomSmart_Stub : public RoomSmart
+{
+       private:
+
+       IoTRMICall *rmiCall;
+       string callbackAddress;
+       vector<int> ports;
+
+       const static int objectId = 0;
+       
+       ofstream log;
+       public:
+
+       RoomSmart_Stub() { }
+       
+       RoomSmart_Stub(int _port, const char* _skeletonAddress, string _callbackAddress, int _rev, bool* _bResult, vector<int> _ports) {
+               callbackAddress = _callbackAddress;
+               ports = _ports;
+               // Logging
+               log.open("RoomSmart_Stub_cpp.log");
+               log << "Port: " << _port << endl;
+               log << "Skeleton address: " << _skeletonAddress << endl;
+               log << "Callback address: " << callbackAddress << endl;
+               log << "Rev: " << _rev << endl;
+               log << "bResult: " << *_bResult << endl;
+               log << "Ports: " << _ports[0] << endl;
+               rmiCall = new IoTRMICall(_port, _skeletonAddress, _rev, _bResult);
+               log << "Established connection with skeleton!" << endl;
+       }
+
+       ~RoomSmart_Stub() {
+               if (rmiCall != NULL) {
+                       delete rmiCall;
+                       rmiCall = NULL;
+               }
+       }
+       
+       int getRoomID() {
+               log << "Calling getRoomID() in stub!" << endl;
+               int methodId = 0;
+               string retType = "int";
+               int numParam = 0;
+               string paramCls[] = {  };
+               void* paramObj[] = {  };
+               int retVal = 0;
+               void* retObj = &retVal;
+               log << "About to remote call!" << endl;
+               rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
+               log << "Remote call performed!" << endl;
+               return retVal;
+       }
+
+};
+#endif