Adding callback for C++ (still has bug for return values); adding struct as method...
[iot2.git] / iotjava / iotrmi / C++ / sample / TestClass.hpp
index efa4f2ae6b8561c61ef90175786be7965b75683f..61dd2e3bd79a6458becd64b5920b75ff42a5be08 100644 (file)
@@ -1,5 +1,9 @@
+#ifndef _TESTCLASS_HPP__
+#define _TESTCLASS_HPP__
+
 #include <iostream>
 #include "TestClassInterface.hpp"
+#include "StructC.hpp"
 
 using namespace std;
 
@@ -19,6 +23,7 @@ class TestClass : public TestClassInterface {
                void                            registerCallback(CallBackInterface* _cb);
                void                            registerCallback(vector<CallBackInterface*> _cb);
                int                                     callBack();
+               void                            handleStruct(vector<data> vecData);
 
        private:                
                int                                                     intA;
@@ -120,6 +125,17 @@ void TestClass::registerCallback(vector<CallBackInterface*> _cb) {
 }
 
 
+void TestClass::handleStruct(vector<data> vecData) {
+
+       for (data dat : vecData) {
+
+               cout << "Name: " << dat.name << endl;
+               cout << "Value: " << dat.value << endl;
+               cout << "Year: " << dat.year << endl;
+       }
+}
+
+
 //int TestClass::callBack() {
 //     return cb.printInt();
 //}
@@ -129,7 +145,20 @@ int TestClass::callBack() {
 
        int sum = 0;
        for (CallBackInterface* cb : cbvec) {
-               sum = sum + cb->printInt();
+               //cout << "Sum: " << sum << endl;
+               //sum = sum + cb->printInt();
+               cb->setInt(sum++);
        }
+       //CallBackInterface* cb = cbvec[0];
+       //sum = cb->printInt();
+       //sum = sum + cb->printInt();
+       //cb->printInt();
+       //CallBackInterface* cb1 = cbvec[0];
+       //cb1->printInt();
+
+
+       return sum;
 }
 
+#endif
+