Updating skeletons and stubs for C++; Fixing one bug in IoTCompiler for C++ skeleton...
[iot2.git] / benchmarks / Cpp / Lifxtest / RoomSmart_Stub.hpp
index 8c0f3cfd32595702d39e75d37a68a11676463f5f..d978c185c0e2c5949713e00c125ce68f9c713718 100644 (file)
@@ -1,8 +1,16 @@
 #ifndef _ROOMSMART_STUB_HPP__
 #define _ROOMSMART_STUB_HPP__
 #include <iostream>
-#include <fstream>
+#include <thread>
+#include <mutex>
+#include <vector>
+#include <set>
+#include "IoTRMIComm.hpp"
+#include "IoTRMICommClient.hpp"
+#include "IoTRMICommServer.hpp"
+
 #include "RoomSmart.hpp"
+#include <fstream>
 
 using namespace std;
 
@@ -10,59 +18,18 @@ class RoomSmart_Stub : public RoomSmart
 {
        private:
 
-       IoTRMICall *rmiCall;
-       string callbackAddress;
-       vector<int> ports;
-
-       const static int objectId = 0;
-       
+       IoTRMIComm *rmiComm;
+       int objectId = 0;
+       // Synchronization variables
+       bool retValueReceived0 = false;
        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
-               int i=0;
-               string file = "RoomSmart_Stub_cpp" + to_string(i) + ".log";
-               while (ifstream(file.c_str())) {
-                       i++;
-                       file = "RoomSmart_Stub_cpp" + to_string(i) + ".log";
-               }
-               log.open(file);
-               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;
-       }
+       public:
 
+       RoomSmart_Stub();
+       RoomSmart_Stub(int _portSend, int _portRecv, const char* _skeletonAddress, int _rev, bool* _bResult);
+       RoomSmart_Stub(IoTRMIComm* _rmiComm, int _objectId);
+       ~RoomSmart_Stub();
+       int getRoomID();
 };
 #endif