Adding return value support for enumeration (both Java and C++
[iot2.git] / iotjava / iotrmi / C++ / sample / TestClass_Stub.hpp
index 63457fe69fefa006d51499c91da0c911c1d8b35f..8e470efdf6cecd8baa90a4dd3f60bf71bbb38f73 100644 (file)
@@ -28,7 +28,7 @@ class TestClass_Stub : public TestClassInterface {
                void                            registerCallback(vector<CallBackInterface*>_cb);
                int                                     callBack();
                void                            handleStruct(vector<data> vecData);
                void                            registerCallback(vector<CallBackInterface*>_cb);
                int                                     callBack();
                void                            handleStruct(vector<data> vecData);
-               void                            handleEnum(vector<EnumC> vecEn);
+               vector<EnumC>           handleEnum(vector<EnumC> vecEn);
                void                            ____init_CallBack();    // thread
                void                            ____registerCallBack(); // tell the other side that we are ready
 
                void                            ____init_CallBack();    // thread
                void                            ____registerCallBack(); // tell the other side that we are ready
 
@@ -303,7 +303,7 @@ void TestClass_Stub::handleStruct(vector<data> vecData) {
 }
 
 
 }
 
 
-void TestClass_Stub::handleEnum(vector<EnumC> vecEn) {
+vector<EnumC> TestClass_Stub::handleEnum(vector<EnumC> vecEn) {
 
        int numParam = 1;
        int methodId = 13;
 
        int numParam = 1;
        int methodId = 13;
@@ -316,18 +316,28 @@ void TestClass_Stub::handleEnum(vector<EnumC> vecEn) {
 
        int numParam2 = vecEn.size();
        int methodId2 = 12;
 
        int numParam2 = vecEn.size();
        int methodId2 = 12;
-       string retType2 = "void";
+       string retType2 = "int[]";
        string paramCls2[numParam2];
        // Need to define this container for integer version of enum
        int paramEnum[numParam2];
        void* paramObj2[numParam2];
        string paramCls2[numParam2];
        // Need to define this container for integer version of enum
        int paramEnum[numParam2];
        void* paramObj2[numParam2];
-       for(int i = 0; i < vecEn.size(); i++) {
+       for(int i = 0; i < numParam2; i++) {
                paramCls2[i] = "int";
                paramEnum[i] = (int) vecEn[i]; // cast enum to integer
                paramObj2[i] = &paramEnum[i];
        }
                paramCls2[i] = "int";
                paramEnum[i] = (int) vecEn[i]; // cast enum to integer
                paramObj2[i] = &paramEnum[i];
        }
-       void* retObj2 = NULL;
+       vector<int> retEnumInt(numParam2);
+       // if no return value just
+       // void* retObj2 = NULL;
+       // This is with return value:
+       void* retObj2 = &retEnumInt;
        rmiCall->remoteCall(objectId, methodId2, retType2, paramCls2, paramObj2, numParam2, retObj2);
        rmiCall->remoteCall(objectId, methodId2, retType2, paramCls2, paramObj2, numParam2, retObj2);
+       int enumsize1 = retEnumInt.size();
+       vector<EnumC> retVal(enumsize1);
+       for (int i=0; i < enumsize1; i++) {
+               retVal[i] = (EnumC) retEnumInt[i];
+       }
+       return retVal;
 }
 
 
 }