-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmq_manager.hpp
More file actions
executable file
·41 lines (33 loc) · 985 Bytes
/
mq_manager.hpp
File metadata and controls
executable file
·41 lines (33 loc) · 985 Bytes
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
#ifndef message_manager_hpp
#define message_manager_hpp
#include <stdio.h>
#include <boost/archive/text_oarchive.hpp>
#include <boost/interprocess/ipc/message_queue.hpp>
#include <boost/serialization/string.hpp>
#include <map>
#include <string>
#include "message.hpp"
using namespace boost::interprocess;
using namespace std;
#define MESSAGE_MAX_SIZE 1000
#define MESSAGE_MAX_NUMB 10000
class MessageQueueManager {
public:
MessageQueueManager();
virtual ~MessageQueueManager();
/**
* Get instance from singleton object
*/
static MessageQueueManager &GetInstance();
/**
* Create message queue
*/
message_queue *CreateQueue(int type, string name);
message_queue *GetQueue(const string name);
int SendMessage(string name, const Message &msg);
int ReadMessage(string name, Message &msg);
private:
static MessageQueueManager instance;
map<string, message_queue *> msg_queues;
};
#endif /* message_manager_hpp */