Testing complex callbacks invocation; fixing subtle bugs
[iot2.git] / iotjava / iotrmi / C++ / basics / TestClass.hpp
index 4dd11ff1cc3eb6c93edaac6faa6180becec9174c..fa9b877e3df4c6bc3995992a6c092a2053c6bd11 100644 (file)
@@ -40,13 +40,24 @@ class TestClass : public TestClassInterface {
 
                // Callbacks
                void                            registerCallback(CallBackInterfaceWithCallBack* _cb);
-               //void                          registerCallback(vector<CallBackInterfaceWithCallBack*> _cb);
+               void                            registerCallbackArray(vector<CallBackInterfaceWithCallBack*> _cb);
+               void                            registerCallbackList(vector<CallBackInterfaceWithCallBack*> _cb);
+               void                            registerCallbackComplex(int in, vector<CallBackInterfaceWithCallBack*> _cb, double db);
                int                                     callBack();
 
                // Enum
                Enum                            handleEnum(Enum en);
                vector<Enum>            handleEnumArray(vector<Enum> vecEn);
                vector<Enum>            handleEnumList(vector<Enum> vecEn);
+               Enum                            handleEnumComplex(Enum en, int i, char c);
+               vector<Enum>            handleEnumComplex2(vector<Enum> en, int i, char c);
+
+               // Struct
+               Struct                          handleStruct(Struct str);
+               vector<Struct>          handleStructArray(vector<Struct> vecStr);
+               vector<Struct>          handleStructList(vector<Struct> vecStr);
+               Struct                          handleStructComplex(int in, char c, Struct str);
+               vector<Struct>          handleStructComplex2(int in, char c, vector<Struct> vecStr);
 
                int                                     getA();
                void                            setA(int _int);
@@ -89,13 +100,34 @@ void TestClass::registerCallback(CallBackInterfaceWithCallBack* _cb) {
 }
 
 
-/*void TestClass::registerCallback(vector<CallBackInterfaceWithCallBack*> _cb) {
+void TestClass::registerCallbackArray(vector<CallBackInterfaceWithCallBack*> _cb) {
 
-       for (CallBackInterface* cb : _cb) {
+       for (CallBackInterfaceWithCallBack* cb : _cb) {
                cbvec.push_back(cb);
-               cout << "Registering callback object!" << endl;
+               cout << "Registering callback object in array!" << endl;
        }
-}*/
+}
+
+
+void TestClass::registerCallbackList(vector<CallBackInterfaceWithCallBack*> _cb) {
+
+       for (CallBackInterfaceWithCallBack* cb : _cb) {
+               cbvec.push_back(cb);
+               cout << "Registering callback object in list!" << endl;
+       }
+}
+
+
+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() {
@@ -290,6 +322,116 @@ vector<Enum> TestClass::handleEnumList(vector<Enum> vecEn) {
 }
 
 
+Enum TestClass::handleEnumComplex(Enum en, int i, char c) {
+
+       cout << "Enum: " << en << endl;
+       cout << "Integer: " << i << endl;
+       cout << "Char: " << c << endl;
+       
+       return en;
+}
+
+
+vector<Enum> TestClass::handleEnumComplex2(vector<Enum> vecEn, int in, char c) {
+
+       for (Enum en : vecEn) {
+               cout << "Enum: " << en << endl;
+       }
+       cout << "Integer: " << in << endl;
+       cout << "Char: " << c << endl;
+       
+       return vecEn;
+}
+
+
+
+// Struct
+Struct TestClass::handleStruct(Struct str) {
+
+       cout << "Name: " << str.name << endl;
+       cout << "Value: " << str.value << endl;
+       cout << "Year: " << str.year << endl;
+
+       Struct test;
+       test.name = "Anonymous";
+       test.value = 1.33;
+       test.year = 2016;
+       str = test;
+
+       return str;
+}
+
+
+vector<Struct> TestClass::handleStructArray(vector<Struct> vecStr) {
+
+       for (Struct str : vecStr) {
+
+               cout << "Name: " << str.name << endl;
+               cout << "Value: " << str.value << endl;
+               cout << "Year: " << str.year << endl;
+       }
+       Struct test;
+       test.name = "Anonymous";
+       test.value = 1.33;
+       test.year = 2016;
+       vecStr.push_back(test);
+
+       return vecStr;
+}
+
+
+vector<Struct> TestClass::handleStructList(vector<Struct> vecStr) {
+
+       for (Struct str : vecStr) {
+
+               cout << "Name: " << str.name << endl;
+               cout << "Value: " << str.value << endl;
+               cout << "Year: " << str.year << endl;
+       }
+       Struct test;
+       test.name = "Trimananda";
+       test.value = 1.33;
+       test.year = 2016;
+       vecStr.push_back(test);
+
+       return vecStr;
+}
+
+
+Struct TestClass::handleStructComplex(int in, char c, Struct str) {
+
+       cout << "Name: " << str.name << endl;
+       cout << "Value: " << str.value << endl;
+       cout << "Year: " << str.year << endl;
+
+       cout << "Integer: " << in << endl;
+       cout << "Char: " << c << endl;
+
+       Struct test;
+       test.name = "Anonymous";
+       test.value = 1.33;
+       test.year = 2016;
+       str = test;
+
+       return str;
+}
+
+
+vector<Struct> TestClass::handleStructComplex2(int in, char c, vector<Struct> vecStr) {
+
+       for (Struct str : vecStr) {
+               cout << "Name: " << str.name << endl;
+               cout << "Value: " << str.value << endl;
+               cout << "Year: " << str.year << endl;
+       }
+
+       cout << "Integer: " << in << endl;
+       cout << "Char: " << c << endl;
+
+       return vecStr;
+}
+
+
 string TestClass::sumArray(vector<string> newA) {
 
        string sum = "";