lichao
2021-04-20 ca319178f45ce6256aed7913565d445571f6db22
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
 * =====================================================================================
 *
 *       Filename:  defs.cpp
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  2021年04月06日 19时23分14秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Li Chao (), 
 *   Organization:  
 *
 * =====================================================================================
 */
#include "defs.h"
#include "shm.h"
 
namespace
{
 
const MQId kBHTopicBus = boost::uuids::string_generator()("01234567-89ab-cdef-8349-1234567890ff");
const MQId kBHTopicCenter = boost::uuids::string_generator()("12345670-89ab-cdef-8349-1234567890ff");
const MQId kBHUniCenter = boost::uuids::string_generator()("87654321-89ab-cdef-8349-1234567890ff");
 
struct LastError {
    int ec_ = 0;
    std::string msg_;
};
 
LastError &LastErrorStore()
{
    thread_local LastError le;
    return le;
}
 
} // namespace
 
const MQId &BHTopicBusAddress() { return kBHTopicBus; }
const MQId &BHTopicCenterAddress() { return kBHTopicCenter; }
const MQId &BHUniCenterAddress() { return kBHUniCenter; }
 
bhome_shm::SharedMemory &BHomeShm()
{
    static bhome_shm::SharedMemory shm("bhome_default_shm_v0", 1024 * 1024 * 512);
    return shm;
}
 
void SetLastError(const int ec, const std::string &msg)
{
    LastErrorStore().ec_ = ec;
    LastErrorStore().msg_ = msg;
}
 
void GetLastError(int &ec, std::string &msg)
{
    ec = LastErrorStore().ec_;
    msg = LastErrorStore().msg_;
}