派生自 development/c++

pansen
2019-03-05 ed223aee5fe5f3b222488549597976f34c679c3d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef _DB_TEST_____
#define _DB_TEST_____
 
#include "myThread.h"
#include <vector>
#include "LDBTool.h"
#include <string>
#include <QString>
 
class DbTest : public mythread<std::string> {
    using TASK_FUNCTION = std::function<void(std::shared_ptr<int> &)>;
public:
    DbTest(TASK_FUNCTION task_f = nullptr) : m_task_function(task_f) {}
 
    ~DbTest() {
 
    }
 
private:
    virtual void doFunc(std::shared_ptr<std::string> param) {
        static int i = 0;
        db_mtest.searchChannelTableCamType();
        std::cout << i++ << std::endl;
//        if (m_task_function != nullptr) {
//            auto fp_task(std::make_shared<int>(ret));
//            m_task_function(fp_task);
//            std::cout << i++ << std::endl;
//        } else {
//            //std::cout << "m_task_function == nullptr" << std::endl;
//            return;
//        }
    }
 
private:
    TASK_FUNCTION m_task_function;
    LDBTool db_mtest;
};
 
struct CallBackFunc{
    int callback_func(std::shared_ptr<int> in)
    {
        static int i = 0;
        std::cout << *in.get() << ":" << i++ << std::endl;
    }
};
#endif