# $(G++) iotrmi/C++/sample/CallBack_Stub.cpp -o $(BIN_DIR)/iotrmi/C++/sample/CallBack_Stub.out --std=c++11
# $(G++) iotrmi/C++/sample/CallBack_Skeleton.cpp -o $(BIN_DIR)/iotrmi/C++/sample/CallBack_Skeleton.out --std=c++11
#$(G++) iotrmi/C++/sample/TestClass.cpp -o $(BIN_DIR)/iotrmi/C++/sample/TestClass.out --std=c++11
- $(G++) iotrmi/C++/sample/TestClass_Stub.cpp -o $(BIN_DIR)/iotrmi/C++/sample/TestClass_Stub.out --std=c++11 -pthread
- $(G++) iotrmi/C++/sample/TestClass_Skeleton.cpp -o $(BIN_DIR)/iotrmi/C++/sample/TestClass_Skeleton.out --std=c++11 -pthread
+ $(G++) iotrmi/C++/sample/TestClass_Stub.cpp -o $(BIN_DIR)/iotrmi/C++/sample/TestClass_Stub.out --std=c++11 -pthread -pg
+ $(G++) iotrmi/C++/sample/TestClass_Skeleton.cpp -o $(BIN_DIR)/iotrmi/C++/sample/TestClass_Skeleton.out --std=c++11 -pthread -pg
#$(G++) iotrmi/C++/sample/Test.cpp -o ../bin/iotrmi/C++/sample/Test.out --std=c++11 -lpthread
#$(G++) iotrmi/C++/sample/Test2.cpp -o ../bin/iotrmi/C++/sample/Test2.out --std=c++11 -pthread -pg
# $(G++) iotrmi/C++/sample/StructC.cpp -o ../bin/iotrmi/C++/sample/StructC.out --std=c++11
#define _TESTCLASS_HPP__
#include <iostream>
+#include <thread>
+#include <chrono>
#include "TestClassInterface.hpp"
#include "StructC.hpp"
void handleStruct(vector<data> vecData);
vector<EnumC> handleEnum(vector<EnumC> vecEn);
+ void thread1();
+ void thread2();
+
private:
int intA;
float floatB;
// 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() {
- int sum = 0;
+ /*int sum = 0;
for (CallBackInterface* cb : cbvec) {
sum = sum + cb->printInt();
}
- return sum;
+ return sum;*/
+ thread th1 (&TestClass::thread1, this);
+ thread th2 (&TestClass::thread2, this);
+
+ th1.join();
+ th2.join();
+
+ return 1;
}
#endif
int main(int argc, char *argv[])
{
- int port = 5011;
+ int port = 5010;
TestClassInterface *tc = new TestClass(3, 5.0, "7911");
TestClass_Skeleton *tcSkel = new TestClass_Skeleton(tc, port);
//tcSkel->waitRequestInvokeMethod();
int main(int argc, char *argv[])
{
- int port = 5011;
+ int port = 5010;
const char* address = "localhost";
int rev = 0;
bool bResult = false;
vector<int> ports;
- ports.push_back(12346);
+ ports.push_back(12345);
//ports.push_back(13234);
TestClassInterface *tcStub = new TestClass_Stub(port, address, rev, &bResult, ports);
cb.push_back(cb2);
cb.push_back(cb3);
tcStub->registerCallback(cb);
- /*CallBackInterface *cb4 = new CallBack(53);
+ CallBackInterface *cb4 = new CallBack(53);
CallBackInterface *cb5 = new CallBack(63);
CallBackInterface *cb6 = new CallBack(73);
vector<CallBackInterface*> cbsec;
- cb.push_back(cb4);
- cb.push_back(cb5);
- cb.push_back(cb6);
- tcStub->registerCallback(cbsec);*/
+ cbsec.push_back(cb4);
+ cbsec.push_back(cb5);
+ cbsec.push_back(cb6);
+ tcStub->registerCallback(cbsec);
cout << "Return value from callback: " << tcStub->callBack() << endl;
vector<data> dataset;