Cleaning up callback code generation; Fixing a few minor issues, e.g. indentation...
[iot2.git] / iotjava / iotrmi / C++ / basics / TestClass.hpp
index 24fe1acc0ebc24480e91451033eb016ca6d60703..492d3d996dc59fa26d4f780bab6706d3b8fc3983 100644 (file)
@@ -5,6 +5,7 @@
 #include <thread>
 #include <chrono>
 #include "TestClassInterface.hpp"
+#include "CallBackInterfaceWithCallBack.hpp"
 
 using namespace std;
 
@@ -29,6 +30,19 @@ class TestClass : public TestClassInterface {
                vector<bool>            getBooleanArray(vector<bool> in);
                vector<char>            getCharArray(vector<char> in);
 
+               vector<char>            getByteList(vector<char> in);
+               vector<short>           getShortList(vector<short> in);
+               vector<int64_t>         getLongList(vector<int64_t> in);
+               vector<float>           getFloatList(vector<float> in);
+               vector<double>          getDoubleList(vector<double> in);
+               vector<bool>            getBooleanList(vector<bool> in);
+               vector<char>            getCharList(vector<char> in);
+
+               // Callbacks
+               void                            registerCallback(CallBackInterfaceWithCallBack* _cb);
+               //void                          registerCallback(vector<CallBackInterfaceWithCallBack*> _cb);
+               int                                     callBack();
+
                int                                     getA();
                void                            setA(int _int);
                void                            setB(float _float);
@@ -38,9 +52,10 @@ class TestClass : public TestClassInterface {
                int                                     setACAndGetA(string newC, int newA);
 
        private:                
-               int                                                     intA;
-               float                                           floatB;
-               string                                          stringC;
+               int                                                                             intA;
+               float                                                                   floatB;
+               string                                                                  stringC;
+               vector<CallBackInterfaceWithCallBack*>  cbvec;
 };
 
 
@@ -62,6 +77,33 @@ TestClass::TestClass(int _int, float _float, string _string) {
 }
 
 
+void TestClass::registerCallback(CallBackInterfaceWithCallBack* _cb) {
+
+       cbvec.push_back(_cb);
+       cout << "Registering callback object!" << endl;
+}
+
+
+/*void TestClass::registerCallback(vector<CallBackInterfaceWithCallBack*> _cb) {
+
+       for (CallBackInterface* cb : _cb) {
+               cbvec.push_back(cb);
+               cout << "Registering callback object!" << endl;
+       }
+}*/
+
+
+int TestClass::callBack() {
+
+       int sum = 0;
+       for (CallBackInterfaceWithCallBack* cb : cbvec) {
+               sum = sum + cb->printInt();
+       }
+
+       return sum;
+}
+
+
 // Single variables
 char TestClass::getByte(char in) {
 
@@ -147,6 +189,48 @@ vector<char> TestClass::getCharArray(vector<char> in) {
        return in;
 }
 
+// List
+vector<char> TestClass::getByteList(vector<char> in) {
+
+       return in;
+}
+
+
+vector<short> TestClass::getShortList(vector<short> in) {
+
+       return in;
+}
+
+
+vector<int64_t> TestClass::getLongList(vector<int64_t> in) {
+
+       return in;
+}
+
+
+vector<float> TestClass::getFloatList(vector<float> in) {
+
+       return in;
+}
+
+
+vector<double> TestClass::getDoubleList(vector<double> in) {
+
+       return in;
+}
+
+
+vector<bool> TestClass::getBooleanList(vector<bool> in) {
+
+       return in;
+}
+
+
+vector<char> TestClass::getCharList(vector<char> in) {
+
+       return in;
+}
+
 
 int TestClass::getA() {