public void registerCallback(CallBackInterface _cb);
public void registerCallbackArray(CallBackInterface _cb[]);
public void registerCallbackList(List<CallBackInterface> _cb);
+ public void registerCallbackComplex(int in, List<CallBackInterface> _cb, double db);
public int callBack();
capability EnumsStructs {
method = "registerCallback(CallBackInterface _cb)";
method = "registerCallbackArray(CallBackInterface _cb[])";
method = "registerCallbackList(List<CallBackInterface> _cb)";
+ method = "registerCallbackComplex(int in, List<CallBackInterface> _cb, double db)";
method = "callBack()";
}
for (int i = 0; i < methParams.size(); i++) {
String paramType = methPrmTypes.get(i);
String param = methParams.get(i);
- //if (callbackType.equals(paramType)) {
if (checkCallbackType(paramType, callbackType)) { // Check if this has callback object
println("try {");
String exchParamType = checkAndGetParamClass(getGenericType(paramType));
checkAndWriteEnumTypeJavaSkeleton(methParams, methPrmTypes);
Map<Integer,String> mapStubParam = null;
- if (isCallbackMethod)
+ if (isCallbackMethod) {
mapStubParam = writeCallbackJavaStubGeneration(methParams, methPrmTypes, callbackType);
+ }
// Check if this is "void"
String retType = intDecl.getMethodType(method);
if (retType.equals("void")) {
}
for (int i = 0; i < methParams.size(); i++) {
- if (isCallbackMethod) {
+ String paramType = methPrmTypes.get(i);
+ if (isCallbackMethod && checkCallbackType(paramType, callbackType)) {
print(mapStubParam.get(i)); // Get the callback parameter
- } else if (isEnumClass(getGenericType(methPrmTypes.get(i)))) { // Enum class
- print(getEnumParam(methPrmTypes.get(i), methParams.get(i), i));
- } else if (isStructClass(getGenericType(methPrmTypes.get(i)))) {
+ } else if (isEnumClass(getGenericType(paramType))) { // Enum class
+ print(getEnumParam(paramType, methParams.get(i), i));
+ } else if (isStructClass(getGenericType(paramType))) {
print("paramStruct" + i);
} else {
- String prmType = checkAndGetArray(methPrmTypes.get(i), methParams.get(i));
+ String prmType = checkAndGetArray(paramType, methParams.get(i));
if (isStructMethod)
print("(" + prmType + ") paramObj[offset" + i + "]");
else
if (checkCallbackType(paramType, callbackType)) { // Check if this has callback object
print("&___paramCB");
} else
- print(getSimpleIdentifier(methParams.get(i)));
+ print("&" + getSimpleIdentifier(methParams.get(i)));
if (i != methParams.size() - 1)
print(", ");
}
void registerCallback(CallBackInterfaceWithCallBack* _cb);
void registerCallbackArray(vector<CallBackInterfaceWithCallBack*> _cb);
void registerCallbackList(vector<CallBackInterfaceWithCallBack*> _cb);
+ void registerCallbackComplex(int in, vector<CallBackInterfaceWithCallBack*> _cb, double db);
int callBack();
// Enum
}
+void TestClass::registerCallbackComplex(int in, vector<CallBackInterfaceWithCallBack*> _cb, double db) {
+
+ for (CallBackInterfaceWithCallBack* cb : _cb) {
+ cbvec.push_back(cb);
+ cout << "Registering callback object in list!" << endl;
+ }
+
+ cout << "Integer: " << in << endl;
+ cout << "Double: " << db << endl;
+}
+
+
int TestClass::callBack() {
int sum = 0;
}*/
- cout << "==== STRUCT ====" << endl;
+/* cout << "==== STRUCT ====" << endl;
Struct str;
str.name = "Rahmadi";
str.value = 0.123;
vector<Struct> vecStr;
vecStr.push_back(str);
vecStr.push_back(str2);
-/* vector<Struct> vecRetStr = tcStub->handleStructArray(vecStr);
+ vector<Struct> vecRetStr = tcStub->handleStructArray(vecStr);
for (Struct st : vecRetStr) {
cout << "Name: " << st.name << endl;
cout << "Value:" << st.value << endl;
cout << "Name: " << st.name << endl;
cout << "Value:" << st.value << endl;
cout << "Year" << st.year << endl;
- }*/
+ }
vector<Struct> vecRetStr3 = tcStub->handleStructComplex2(23, 'c', vecStr);
for (Struct st : vecRetStr3) {
cout << "Name: " << st.name << endl;
cout << "Value:" << st.value << endl;
cout << "Year" << st.year << endl;
- }
+ }*/
-/* cout << "==== CALLBACK ====" << endl;
- CallBackInterface *cbSingle = new CallBack(2354);
+ cout << "==== CALLBACK ====" << endl;
+/* CallBackInterface *cbSingle = new CallBack(2354);
tcStub->registerCallback(cbSingle);
cout << "Return value from callback: " << tcStub->callBack() << endl;
CallBackInterface *cb1 = new CallBack(23);
cb.push_back(cb2);
cb.push_back(cb3);
tcStub->registerCallbackArray(cb);
- cout << "Return value from callback: " << tcStub->callBack() << endl;
+ cout << "Return value from callback: " << tcStub->callBack() << endl;*/
CallBackInterface *cb4 = new CallBack(53);
CallBackInterface *cb5 = new CallBack(63);
CallBackInterface *cb6 = new CallBack(73);
cblist.push_back(cb4);
cblist.push_back(cb5);
cblist.push_back(cb6);
- tcStub->registerCallbackList(cblist);
+// tcStub->registerCallbackList(cblist);
+// cout << "Return value from callback: " << tcStub->callBack() << endl;
+ tcStub->registerCallbackComplex(23, cblist, 0.1234);
cout << "Return value from callback: " << tcStub->callBack() << endl;
- cout << "==== OTHERS ====" << endl;
- cout << "Return value: " << tcStub->getA() << endl;
- cout << "Return value: " << tcStub->setAndGetA(123) << endl;
- cout << "Return value: " << tcStub->setACAndGetA("string", 123) << endl;
- vector<string> input;
- input.push_back("123");
- input.push_back("456");
- input.push_back("987");
-
- cout << "Return value: " << tcStub->sumArray(input) << endl;
-*/
return 0;
}
+++ /dev/null
-#include <iostream>
-#include <string>
-#include "TestClassComplete_Stub.hpp"
-#include "CallBack.hpp"
-#include "IoTRMICall.hpp"
-
-using namespace std;
-
-int main(int argc, char *argv[])
-{
-
- int _port = 50044;
- const char* _address = "localhost";
- //const char* address = "128.195.136.170"; // dc-9.calit2.uci.edu
- int _rev = 0;
- bool bResult = false;
-
- IoTRMICall *rmiCall = new IoTRMICall(_port, _address, _rev, &bResult);
- cout << "Successfully connecting!" << endl << endl;
- delete rmiCall;
-
- return 0;
-}
}
+ public void registerCallbackComplex(int in, List<CallBackInterfaceWithCallBack> _cb, double db) {
+
+ for (CallBackInterfaceWithCallBack cb : _cb) {
+ cblist.add(cb);
+ System.out.println("Registering callback objects in list!");
+ }
+
+ System.out.println("Integer: " + in);
+ System.out.println("Double: " + db);
+ }
+
+
public int callBack() {
int sum = 0;
int rev = 0;
TestClassComplete_Stub tcstub = new TestClassComplete_Stub(port, address, rev, ports);
- System.out.println("==== ENUM ====");
-/* Enum en = Enum.APPLE;
+/* System.out.println("==== ENUM ====");
+ Enum en = Enum.APPLE;
Enum res = tcstub.handleEnum(en);
System.out.println("Enum member: " + res);
Enum resComp = tcstub.handleEnumComplex(en, 23, 'c');
System.out.println("Enum members: " + Arrays.toString(resArr3));*/
- System.out.println("==== STRUCT ====");
+/* System.out.println("==== STRUCT ====");
Struct str = new Struct();
str.name = "Rahmadi";
str.value = 0.123f;
str.year = 2016;
-/* Struct strRes = tcstub.handleStruct(str);
+ Struct strRes = tcstub.handleStruct(str);
System.out.println("Name: " + strRes.name);
System.out.println("Value: " + strRes.value);
System.out.println("Year: " + strRes.year);
Struct strRes2 = tcstub.handleStructComplex(23, 'c', str);
System.out.println("Name: " + strRes2.name);
System.out.println("Value: " + strRes2.value);
- System.out.println("Year: " + strRes2.year);*/
+ System.out.println("Year: " + strRes2.year);
Struct str2 = new Struct();
str2.name = "Trimananda";
str2.value = 0.124f;
str2.year = 2017;
Struct[] arrStr = { str, str2 };
-/* Struct[] arrRet = tcstub.handleStructArray(arrStr);
+ Struct[] arrRet = tcstub.handleStructArray(arrStr);
for(Struct st : arrRet) {
System.out.println("Name: " + st.name);
System.out.println("Value: " + st.value);
System.out.println("Name: " + st.name);
System.out.println("Value: " + st.value);
System.out.println("Year: " + st.year);
- }*/
+ }
List<Struct> stRetList2 = tcstub.handleStructComplex2(23, 'c', arrStr);
for(Struct st : stRetList2) {
System.out.println("Name: " + st.name);
System.out.println("Value: " + st.value);
System.out.println("Year: " + st.year);
- }
+ }*/
- /*System.out.println("==== CALLBACKS ====");
- CallBackInterface cbSingle = new CallBack(2354);
+ System.out.println("==== CALLBACKS ====");
+/* CallBackInterface cbSingle = new CallBack(2354);
tcstub.registerCallback(cbSingle);
System.out.println("Return value from callback: " + tcstub.callBack());
CallBackInterface cb1 = new CallBack(23);
CallBackInterface cb3 = new CallBack(43);
CallBackInterface[] cb = { cb1, cb2, cb3 };
tcstub.registerCallbackArray(cb);
- System.out.println("Return value from callback: " + tcstub.callBack());
+ System.out.println("Return value from callback: " + tcstub.callBack());*/
List<CallBackInterface> cblist = new ArrayList<CallBackInterface>();
CallBackInterface cb4 = new CallBack(53); cblist.add(cb4);
CallBackInterface cb5 = new CallBack(63); cblist.add(cb5);
CallBackInterface cb6 = new CallBack(73); cblist.add(cb6);
- tcstub.registerCallbackList(cblist);
- System.out.println("Return value from callback: " + tcstub.callBack());*/
+// tcstub.registerCallbackList(cblist);
+// System.out.println("Return value from callback: " + tcstub.callBack());
+
+ tcstub.registerCallbackComplex(23, cblist, 0.1234);
+ System.out.println("Return value from callback: " + tcstub.callBack());
}
}
+++ /dev/null
-import java.util.Arrays;
-import java.util.List;
-import java.util.ArrayList;
-import iotrmi.Java.IoTRMICall;
-import iotruntime.master.CommunicationHandler;
-
-public class TestClass_Debug {
-
- public static void main(String[] args) throws Exception {
-
- CommunicationHandler comHan = new CommunicationHandler(true);
- int numOfPorts = 1;
- int[] ports = comHan.getCallbackPorts(numOfPorts);
-
- int _port = 56205;
- String _address = "localhost";
- //String address = "128.195.136.170"; // dc-9.calit2.uci.edu
- int _rev = 0;
-
- IoTRMICall rmiCall = new IoTRMICall(_port, _address, _rev);
- System.out.println("Creating a new connection!!!");
- }
-}