Ferenc Szontágh
2024-06-27 920507bff803647c79dfce27c4c265b2caee7f8d
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
#ifndef IPC_H
#define IPC_H
 
#include <queue>
#include <mutex>
#include <condition_variable>
#include <memory>
#include <optional>
#include "tser/tser.hpp"
#include "Serialize.h"
#include "PluginInterface.h"  // Include your IPlugin interface header
#include "Command.h"  // Include your Command structure header
#include <glog/logging.h>
 
class IPC
{
public:
    IPC();
    ~IPC();
 
    void registerHandler(std::shared_ptr<IPlugin> handler);
    void sendMessage(const Command &cmd);
    std::optional<Command> receiveMessage();
 
private:
    std::queue<std::string> messageQueue;
    std::vector<std::shared_ptr<IPlugin>> handlers;
    std::mutex queueMutex;
    std::condition_variable queueCondVar;
};
 
#endif // IPC_H