Testing enum and callback combination
authorrtrimana <rtrimana@uci.edu>
Thu, 8 Dec 2016 19:51:07 +0000 (11:51 -0800)
committerrtrimana <rtrimana@uci.edu>
Thu, 8 Dec 2016 19:51:07 +0000 (11:51 -0800)
config/iotpolicy/testclasspolicy_advanced.pol
iotjava/iotrmi/C++/basics/TestClass.hpp
iotjava/iotrmi/C++/basics/TestClassAdvanced_Stub.cpp
iotjava/iotrmi/Java/basics/TestClass.java
iotjava/iotrmi/Java/basics/TestClassAdvanced_Stub.java

index aa269fa..9867b23 100644 (file)
@@ -19,6 +19,7 @@ public interface TestClassInterface {
        public void registerCallbackList(List<CallBackInterface> _cb);
        public void registerCallbackComplex(int in, List<CallBackInterface> _cb, double db);
        public int callBack();
+       public Enum[] handleCallbackEnum(Enum en[], char c, List<CallBackInterface> _cb);
 
        public Enum[] handleAll(Enum en[], List<Struct> str, char c, List<CallBackInterface> _cb);
 
@@ -38,6 +39,7 @@ public interface TestClassInterface {
                method = "handleStructComplex2(int in, char c, Struct str[])";
 
                method = "handleEnumStruct(Enum en[], List<Struct> str, char c)";
+               method = "handleCallbackEnum(Enum en[], char c, List<CallBackInterface> _cb)";
                method = "handleAll(Enum en[], List<Struct> str, char c, List<CallBackInterface> _cb)";
        }
 
index f33dbf2..a052c0d 100644 (file)
@@ -44,6 +44,7 @@ class TestClass : public TestClassInterface {
                void                            registerCallbackList(vector<CallBackInterfaceWithCallBack*> _cb);
                void                            registerCallbackComplex(int in, vector<CallBackInterfaceWithCallBack*> _cb, double db);
                int                                     callBack();
+               vector<Enum>            handleCallbackEnum(vector<Enum> en, char c, vector<CallBackInterfaceWithCallBack*> _cb);
 
                // Enum
                Enum                            handleEnum(Enum en);
@@ -468,6 +469,19 @@ vector<Enum> TestClass::handleAll(vector<Enum> en, vector<Struct> str, char c, v
 }
 
 
+vector<Enum> TestClass::handleCallbackEnum(vector<Enum> en, char c, vector<CallBackInterfaceWithCallBack*> _cb) {
+
+       for (CallBackInterfaceWithCallBack* cb : _cb) {
+               cbvec.push_back(cb);
+               cout << "Registering callback object in array!" << endl;
+       }
+
+       cout << "Char: " << c << endl;
+
+       return en;
+}
+
+
 string TestClass::sumArray(vector<string> newA) {
 
        string sum = "";
index 02aa8bb..8e23210 100644 (file)
@@ -109,10 +109,15 @@ int main(int argc, char *argv[])
 //     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 << "Return value from callback: " << tcStub->callBack() << endl;
        vector<Enum> vecRes5 = tcStub->handleAll(vecEn, vecStr, 'c', cblist);
        for (Enum en : vecRes5) {
                cout << "Enum value: " << en << endl;
+       }*/
+
+       vector<Enum> vecRes6 = tcStub->handleCallbackEnum(vecEn, 'c', cblist);
+       for (Enum en : vecRes6) {
+               cout << "Enum value: " << en << endl;
        }
 
        return 0;
index 51aed4c..411e7db 100644 (file)
@@ -413,6 +413,19 @@ public class TestClass implements TestClassInterface {
        }
 
 
+       public Enum[] handleCallbackEnum(Enum en[], char c, List<CallBackInterfaceWithCallBack> _cb) {
+
+               for (CallBackInterfaceWithCallBack cb : _cb) {
+                       cblist.add(cb);
+                       System.out.println("Registering callback objects in list!");
+               }
+
+               System.out.println("Char: " + c);
+
+               return en;
+       }
+
+
        // Getters
        public String sumArray(String[] newA) {
 
index b8b7e24..759d3a6 100644 (file)
@@ -46,20 +46,20 @@ public class TestClassAdvanced_Stub {
                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("Year: " + st.year);
-               }*/
+               }
                List<Struct> stList = new ArrayList(Arrays.asList(arrStr));
-/*             List<Struct> stRetList = tcstub.handleStructList(stList);
+               List<Struct> stRetList = tcstub.handleStructList(stList);
                for(Struct st : stRetList) {
                        System.out.println("Name: " + st.name);
                        System.out.println("Value: " + st.value);
@@ -92,8 +92,11 @@ public class TestClassAdvanced_Stub {
 //             System.out.println("Return value from callback: " + tcstub.callBack());
 
 /*             tcstub.registerCallbackComplex(23, cblist, 0.1234);
-               System.out.println("Return value from callback: " + tcstub.callBack());*/
+               System.out.println("Return value from callback: " + tcstub.callBack());
                Enum[] resArr4 = tcstub.handleAll(enArr, stList, 'c', cblist);
-               System.out.println("Enum members: " + Arrays.toString(resArr4));
+               System.out.println("Enum members: " + Arrays.toString(resArr4));*/
+
+               Enum[] resArr5 = tcstub.handleCallbackEnum(enArr, 'c', cblist);
+               System.out.println("Enum members: " + Arrays.toString(resArr5));
        }
 }