TestClass_Skeleton(TestClassInterface* _tc, int _port);
~TestClass_Skeleton();
- void waitRequestInvokeMethod();
+ void ___waitRequestInvokeMethod();
void setA(int _int);
void setB(float _float);
void setC(string _string);
void registerCallback(vector<CallBackInterface*> _cb);
int callBack();
void handleStruct(vector<data> vecData);
+
+ void ___setA();
+ void ___setB();
+ void ___setC();
+ void ___sumArray();
+ //int64_t ____sumArray();
+ void ___setAndGetA();
+ void ___setACAndGetA();
+ void ___registerCallback();
+ void ____registerCallback();
+ // For array of callbacks
+ void ___regCB();
+ void ___callBack();
+ // For array of structs
+ int ___structSize();
+ void ___handleStruct(int structsize1);
const static int size = 12;
const static string methodSignatures[size];
bool _bResult = false;
tc = _tc;
- cout << "Reached here 1!" << endl;
rmiObj = new IoTRMIObject(_port, &_bResult, methodSignatures, size);
- cout << "Reached here 2!" << endl;
- waitRequestInvokeMethod();
+ ___waitRequestInvokeMethod();
}
}
-void TestClass_Skeleton::waitRequestInvokeMethod() {
-
- int structsize1 = 0;
- // Loop continuously waiting for incoming bytes
- while (true) {
+void TestClass_Skeleton::setA(int _int) {
- rmiObj->getMethodBytes();
- string methodSign = rmiObj->getSignature();
- cout << "Method sign: " << methodSign << endl;
-
- if (methodSign.compare("voidsetA(int)") == 0) {
- string paramCls[] = { "int" };
- int numParam = 1;
- int param1 = 0;
- void* paramObj[] = { ¶m1 };
- rmiObj->getMethodParams(paramCls, numParam, paramObj);
- setA(param1);
- } else if (methodSign.compare("voidsetB(float)") == 0) {
- string paramCls[] = { "float" };
- int numParam = 1;
- float param1 = 0.0;
- void* paramObj[] = { ¶m1 };
- rmiObj->getMethodParams(paramCls, numParam, paramObj);
- setB(param1);
- } else if (methodSign.compare("voidsetC(string)") == 0) {
- string paramCls[] = { "string" };
- int numParam = 1;
- string param1 = "";
- void* paramObj[] = { ¶m1 };
- rmiObj->getMethodParams(paramCls, numParam, paramObj);
- setC(param1);
- } else if (methodSign.compare("sumArray(string[])") == 0) {
- string paramCls[] = { "string[]" };
- int numParam = 1;
- vector<string> param1;
- void* paramObj[] = { ¶m1 };
- rmiObj->getMethodParams(paramCls, numParam, paramObj);
- string retVal = sumArray(param1);
- void* retObj = &retVal;
- rmiObj->sendReturnObj(retObj, "string");
- /*} else if (methodSign.compare("sumArray(int[])") == 0) {
- string paramCls[] = { "int[]" };
- int numParam = 1;
- vector<int> param1;
- void* paramObj[] = { ¶m1 };
- rmiObj->getMethodParams(paramCls, numParam, paramObj);
- int64_t retVal = sumArray(param1);
- void* retObj = &retVal;
- rmiObj->sendReturnObj(retObj, "long");*/
- } else if (methodSign.compare("intsetAndGetA(int)") == 0) {
- string paramCls[] = { "int" };
- int numParam = 1;
- int param1 = 0;
- void* paramObj[] = { ¶m1 };
- rmiObj->getMethodParams(paramCls, numParam, paramObj);
- int retVal = setAndGetA(param1);
- void* retObj = &retVal;
- rmiObj->sendReturnObj(retObj, "int");
- } else if (methodSign.compare("intsetACAndGetA(string,int)") == 0) {
- string paramCls[] = { "string", "int" };
- int numParam = 2;
- string param1 = "";
- int param2 = 0;
- void* paramObj[] = { ¶m1, ¶m2 };
- rmiObj->getMethodParams(paramCls, numParam, paramObj);
- int retVal = setACAndGetA(param1, param2);
- void* retObj = &retVal;
- rmiObj->sendReturnObj(retObj, "int");
- /*} else if (methodSign.compare("voidregisterCallBack(CallBackInterface)") == 0) {
- //*/
- } else if (methodSign.compare("voidregisterCallBack(CallBackInterface[])") == 0) {
- string paramCls[] = { "int" };
- int numParam = 1;
- int numStubs = 0;
- void* paramObj[] = { &numStubs };
- rmiObj->getMethodParams(paramCls, numParam, paramObj);
- vector<CallBackInterface*> stub;
- for (int objId = 0; objId < numStubs; objId++) {
- CallBackInterface* cb = new CallBack_CBStub(rmiCall, objIdCnt);
- stub.push_back(cb);
- vecCBObj.push_back(cb);
- objIdCnt++;
- }
- registerCallback(stub);
- } else if (methodSign.compare("registercallback") == 0) {
- string paramCls[] = { "int", "string", "int" };
- int numParam = 3;
- int param1 = 0;
- string param2 = "";
- int param3 = 0;
- void* paramObj[] = { ¶m1, ¶m2, ¶m3 };
- cout << "Get here! Registering callback!" << endl;
- rmiObj->getMethodParams(paramCls, numParam, paramObj);
- // Instantiate IoTRMICall object
- bool bResult = false;
- rmiCall = new IoTRMICall(param1, param2.c_str(), param3, &bResult,
- CallBack_CBStub::methodSignatures, CallBack_CBStub::size);
- } else if (methodSign.compare("intcallBack()") == 0) {
- cout << "Get here inside callback!!!" << endl;
- int retVal = callBack();
- cout << "Return value in TestClass_Skeleton: " << retVal << endl;
- void* retObj = &retVal;
- rmiObj->sendReturnObj(retObj, "int");
- // Handle struct
- } else if (methodSign.compare("structsize") == 0) {
- string paramCls[] = { "int" };
- int numParam = 1;
- int param1 = 0;
- void* paramObj[] = { ¶m1 };
- rmiObj->getMethodParams(paramCls, numParam, paramObj);
- structsize1 = param1;
- cout << "Struct size: " << structsize1 << endl;
- } else if (methodSign.compare("handleStruct(StructJ[])") == 0) {
- string paramCls[3*structsize1];
- void* paramObj[3*structsize1];
- int numParam = 3*structsize1;
- // define array of everything
- string param1[structsize1];
- float param2[structsize1];
- int param3[structsize1];
- int pos = 0;
- for(int i=0; i < structsize1; i++) {
- paramCls[pos] = "string";
- paramObj[pos++] = ¶m1[i];
- paramCls[pos] = "float";
- paramObj[pos++] = ¶m2[i];
- paramCls[pos] = "int";
- paramObj[pos++] = ¶m3[i];
- }
- rmiObj->getMethodParams(paramCls, numParam, paramObj);
- vector<data> dat(structsize1);
- pos = 0;
- for (int i=0; i < structsize1; i++) {
- dat[i].name = param1[i];
- dat[i].value = param2[i];
- dat[i].year = param3[i];
- }
- handleStruct(dat);
- } else {
- string error = "Signature unrecognized: " + string(methodSign);
- throw error;
- }
- }
+ tc->setA(_int);
}
-void TestClass_Skeleton::setA(int _int) {
+void TestClass_Skeleton::___setA() {
- tc->setA(_int);
+ string paramCls[] = { "int" };
+ int numParam = 1;
+ int param1 = 0;
+ void* paramObj[] = { ¶m1 };
+ rmiObj->getMethodParams(paramCls, numParam, paramObj);
+ setA(param1);
}
}
+void TestClass_Skeleton::___setB() {
+
+ string paramCls[] = { "float" };
+ int numParam = 1;
+ float param1 = 0.0;
+ void* paramObj[] = { ¶m1 };
+ rmiObj->getMethodParams(paramCls, numParam, paramObj);
+ setB(param1);
+}
+
+
void TestClass_Skeleton::setC(string _string) {
tc->setC(_string);
}
+void TestClass_Skeleton::___setC() {
+
+ string paramCls[] = { "string" };
+ int numParam = 1;
+ string param1 = "";
+ void* paramObj[] = { ¶m1 };
+ rmiObj->getMethodParams(paramCls, numParam, paramObj);
+ setC(param1);
+}
+
+
string TestClass_Skeleton::sumArray(vector<string> newA) {
- return tc->sumArray(newA);;
+ return tc->sumArray(newA);
+}
+
+
+void TestClass_Skeleton::___sumArray() {
+
+ string paramCls[] = { "string[]" };
+ int numParam = 1;
+ vector<string> param1;
+ void* paramObj[] = { ¶m1 };
+ rmiObj->getMethodParams(paramCls, numParam, paramObj);
+ string retVal = sumArray(param1);
+ void* retObj = &retVal;
+ rmiObj->sendReturnObj(retObj, "string");
}
}*/
+/*int64_t TestClass_Skeleton::____sumArray() {
+
+}*/
+
+
int TestClass_Skeleton::setAndGetA(int newA) {
return tc->setAndGetA(newA);
}
+void TestClass_Skeleton::___setAndGetA() {
+
+ string paramCls[] = { "int" };
+ int numParam = 1;
+ int param1 = 0;
+ void* paramObj[] = { ¶m1 };
+ rmiObj->getMethodParams(paramCls, numParam, paramObj);
+ int retVal = setAndGetA(param1);
+ void* retObj = &retVal;
+ rmiObj->sendReturnObj(retObj, "int");
+}
+
+
int TestClass_Skeleton::setACAndGetA(string newC, int newA) {
return tc->setACAndGetA(newC, newA);
}
+void TestClass_Skeleton::___setACAndGetA() {
+
+ string paramCls[] = { "string", "int" };
+ int numParam = 2;
+ string param1 = "";
+ int param2 = 0;
+ void* paramObj[] = { ¶m1, ¶m2 };
+ rmiObj->getMethodParams(paramCls, numParam, paramObj);
+ int retVal = setACAndGetA(param1, param2);
+ void* retObj = &retVal;
+ rmiObj->sendReturnObj(retObj, "int");
+}
+
+
void TestClass_Skeleton::registerCallback(CallBackInterface* _cb) {
tc->registerCallback(_cb);
}
+void TestClass_Skeleton::___registerCallback() {
+
+}
+
+
void TestClass_Skeleton::registerCallback(vector<CallBackInterface*> _cb) {
tc->registerCallback(_cb);
}
+void TestClass_Skeleton::___regCB() {
+
+ string paramCls[] = { "int", "string", "int" };
+ int numParam = 3;
+ int param1 = 0;
+ string param2 = "";
+ int param3 = 0;
+ void* paramObj[] = { ¶m1, ¶m2, ¶m3 };
+ rmiObj->getMethodParams(paramCls, numParam, paramObj);
+ // Instantiate IoTRMICall object
+ bool bResult = false;
+ rmiCall = new IoTRMICall(param1, param2.c_str(), param3, &bResult,
+ CallBack_CBStub::methodSignatures, CallBack_CBStub::size);
+}
+
+
+void TestClass_Skeleton::____registerCallback() {
+
+ string paramCls[] = { "int" };
+ int numParam = 1;
+ int numStubs = 0;
+ void* paramObj[] = { &numStubs };
+ rmiObj->getMethodParams(paramCls, numParam, paramObj);
+ vector<CallBackInterface*> stub;
+ for (int objId = 0; objId < numStubs; objId++) {
+ CallBackInterface* cb = new CallBack_CBStub(rmiCall, objIdCnt);
+ stub.push_back(cb);
+ vecCBObj.push_back(cb);
+ objIdCnt++;
+ }
+ registerCallback(stub);
+}
+
+
int TestClass_Skeleton::callBack() {
tc->callBack();
}
+void TestClass_Skeleton::___callBack() {
+
+ int retVal = callBack();
+ void* retObj = &retVal;
+ rmiObj->sendReturnObj(retObj, "int");
+}
+
+
+int TestClass_Skeleton::___structSize() {
+
+ string paramCls[] = { "int" };
+ int numParam = 1;
+ int param1 = 0;
+ void* paramObj[] = { ¶m1 };
+ rmiObj->getMethodParams(paramCls, numParam, paramObj);
+ return param1;
+}
+
+
void TestClass_Skeleton::handleStruct(vector<data> vecData) {
tc->handleStruct(vecData);
}
+
+void TestClass_Skeleton::___handleStruct(int structsize1) {
+
+ string paramCls[3*structsize1];
+ void* paramObj[3*structsize1];
+ int numParam = 3*structsize1;
+ // define array of everything
+ string param1[structsize1];
+ float param2[structsize1];
+ int param3[structsize1];
+ int pos = 0;
+ for(int i=0; i < structsize1; i++) {
+ paramCls[pos] = "string";
+ paramObj[pos++] = ¶m1[i];
+ paramCls[pos] = "float";
+ paramObj[pos++] = ¶m2[i];
+ paramCls[pos] = "int";
+ paramObj[pos++] = ¶m3[i];
+ }
+ rmiObj->getMethodParams(paramCls, numParam, paramObj);
+ vector<data> dat(structsize1);
+ pos = 0;
+ for (int i=0; i < structsize1; i++) {
+ dat[i].name = param1[i];
+ dat[i].value = param2[i];
+ dat[i].year = param3[i];
+ }
+ handleStruct(dat);
+}
+
+
+void TestClass_Skeleton::___waitRequestInvokeMethod() {
+
+ int structsize1 = 0;
+ // Loop continuously waiting for incoming bytes
+ while (true) {
+
+ rmiObj->getMethodBytes();
+ string methodSign = rmiObj->getSignature();
+ cout << "Method sign: " << methodSign << endl;
+
+ if (methodSign.compare("voidsetA(int)") == 0) {
+ ___setA();
+ } else if (methodSign.compare("voidsetB(float)") == 0) {
+ ___setB();
+ } else if (methodSign.compare("voidsetC(string)") == 0) {
+ ___setC();
+ } else if (methodSign.compare("sumArray(string[])") == 0) {
+ ___sumArray();
+ /*} else if (methodSign.compare("sumArray(int[])") == 0) {
+ ____sumArray();*/
+ } else if (methodSign.compare("intsetAndGetA(int)") == 0) {
+ ___setAndGetA();
+ } else if (methodSign.compare("intsetACAndGetA(string,int)") == 0) {
+ ___setACAndGetA();
+ } else if (methodSign.compare("voidregisterCallBack(CallBackInterface)") == 0) {
+ //
+ } else if (methodSign.compare("voidregisterCallBack(CallBackInterface[])") == 0) {
+ ____registerCallback();
+ } else if (methodSign.compare("registercallback") == 0) {
+ ___regCB();
+ } else if (methodSign.compare("intcallBack()") == 0) {
+ ___callBack();
+ // Handle struct
+ } else if (methodSign.compare("structsize") == 0) {
+ structsize1 = ___structSize();
+ } else if (methodSign.compare("handleStruct(StructJ[])") == 0) {
+ ___handleStruct(structsize1);
+ } else {
+ string error = "Signature unrecognized: " + string(methodSign);
+ throw error;
+ }
+ }
+}
+
+
#endif