lichao
2021-06-23 c1e39e20ca42b21eeac8b5068fa1f921bf9a070f
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
/*
 * =====================================================================================
 *
 *       Filename:  center_topic_node.h
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  2021年05月20日 12时44分42秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Li Chao (), lichao@aiotlink.com
 *   Organization:  
 *
 * =====================================================================================
 */
#ifndef CENTER_TOPIC_NODE_YCI0P9KC
#define CENTER_TOPIC_NODE_YCI0P9KC
 
#include "bh_util.h"
#include "shm.h"
#include <atomic>
#include <memory>
#include <thread>
 
class TopicNode;
class NodeCenter;
// center as a topic node.
class CenterTopicNode
{
public:
    typedef std::shared_ptr<Synced<NodeCenter>> CenterPtr;
    CenterTopicNode(CenterPtr center, bhome_shm::SharedMemory &shm);
    ~CenterTopicNode();
    bool Start();
    void Stop();
 
private:
    CenterPtr pscenter_;
    std::unique_ptr<TopicNode> pnode_;
    std::thread worker_;
    std::atomic<bool> run_;
};
 
#endif // end of include guard: CENTER_TOPIC_NODE_YCI0P9KC