polybar-dwm/include/components/ipc.hpp

47 lines
799 B
C++
Raw Normal View History

2016-11-13 19:05:30 +01:00
#pragma once
2021-02-20 21:26:45 +01:00
#include <uv.h>
2016-11-13 19:05:30 +01:00
#include "common.hpp"
2017-01-11 03:07:28 +01:00
#include "settings.hpp"
2016-11-20 23:04:31 +01:00
#include "utils/concurrency.hpp"
2016-11-13 19:05:30 +01:00
2016-11-19 06:22:44 +01:00
POLYBAR_NS
2016-11-13 19:05:30 +01:00
2017-01-11 03:07:28 +01:00
class signal_emitter;
class logger;
2016-11-13 19:05:30 +01:00
/**
* Component used for inter-process communication.
*
* A unique messaging channel will be setup for each
* running process which will allow messages and
* events to be sent to the process externally.
*/
class ipc {
public:
2016-12-09 09:40:46 +01:00
using make_type = unique_ptr<ipc>;
static make_type make();
2016-12-09 09:02:47 +01:00
explicit ipc(signal_emitter& emitter, const logger& logger);
2016-11-13 19:05:30 +01:00
~ipc();
2021-09-13 19:56:24 +02:00
string get_path() const;
void receive_data(string buf);
void receive_eof();
2016-11-13 19:05:30 +01:00
private:
signal_emitter& m_sig;
2016-11-13 19:05:30 +01:00
const logger& m_log;
string m_path{};
/**
* Buffer for the currently received IPC message.
*/
string m_buffer{};
2016-11-13 19:05:30 +01:00
};
2016-11-19 06:22:44 +01:00
POLYBAR_NS_END