Removing printing statements from C++ RMI library - this will cause SO files to get...
[iot2.git] / iotjava / iotrmi / C++ / sample / TestClass.hpp
index f8b9ffb154d7d26b135b059978c5bd93cd6652f8..fe13e6e11c305e6ce8242264ec77c82e19cc021a 100644 (file)
@@ -2,6 +2,8 @@
 #define _TESTCLASS_HPP__
 
 #include <iostream>
+#include <thread>
+#include <chrono>
 #include "TestClassInterface.hpp"
 #include "StructC.hpp"
 
@@ -23,7 +25,11 @@ class TestClass : public TestClassInterface {
                void                            registerCallback(CallBackInterface* _cb);
                void                            registerCallback(vector<CallBackInterface*> _cb);
                int                                     callBack();
-               void                            handleStruct(vector<data> vecData);
+               vector<data>            handleStruct(vector<data> vecData);
+               vector<EnumC>           handleEnum(vector<EnumC> vecEn);
+
+               void                            thread1();
+               void                            thread2();
 
        private:                
                int                                                     intA;
@@ -125,7 +131,7 @@ void TestClass::registerCallback(vector<CallBackInterface*> _cb) {
 }
 
 
-void TestClass::handleStruct(vector<data> vecData) {
+vector<data> TestClass::handleStruct(vector<data> vecData) {
 
        for (data dat : vecData) {
 
@@ -133,6 +139,23 @@ void TestClass::handleStruct(vector<data> vecData) {
                cout << "Value: " << dat.value << endl;
                cout << "Year: " << dat.year << endl;
        }
+       data newData;
+       newData.name = "Anonymous";
+       newData.value = 1.33;
+       newData.year = 2016;
+       vecData.push_back(newData);
+
+       return vecData;
+}
+
+
+vector<EnumC> TestClass::handleEnum(vector<EnumC> vecEn) {
+
+       for (EnumC en : vecEn) {
+               cout << "Enum: " << en << endl;
+       }
+       
+       return vecEn;
 }
 
 
@@ -140,6 +163,23 @@ void TestClass::handleStruct(vector<data> vecData) {
 //     return cb.printInt();
 //}
 
+void TestClass::thread1() {
+
+       CallBackInterface* cb = cbvec[0];
+       for(int i = 0; i < 10; i++) {
+               cb->printInt();
+               this_thread::sleep_for(chrono::seconds(1));
+       }       
+}
+
+void TestClass::thread2() {
+
+       CallBackInterface* cb = cbvec[1];
+       for(int i = 0; i < 10; i++) {
+               cb->printInt();
+               this_thread::sleep_for(chrono::seconds(1));
+       }       
+}
 
 int TestClass::callBack() {
 
@@ -149,6 +189,13 @@ int TestClass::callBack() {
        }
 
        return sum;
+/*     thread th1 (&TestClass::thread1, this);
+       thread th2 (&TestClass::thread2, this);
+
+       th1.join();
+       th2.join();
+
+       return 1;*/
 }
 
 #endif