1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-10-27 05:23:39 -04:00
polybar/include/components/ipc.hpp
2016-11-13 19:05:30 +01:00

54 lines
989 B
C++

#pragma once
#include "common.hpp"
#include "components/logger.hpp"
LEMONBUDDY_NS
/**
* 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:
struct message_internal {
static constexpr auto prefix{"app:"};
};
struct message_command {
static constexpr auto prefix{"cmd:"};
};
struct message_custom {
static constexpr auto prefix{"custom:"};
};
explicit ipc(const logger& logger) : m_log(logger) {}
~ipc();
void receive_messages();
protected:
void parse(string payload);
private:
const logger& m_log;
stateflag m_running{false};
string m_fifo;
int m_fd;
};
namespace {
/**
* Configure injection module
*/
template <typename T = unique_ptr<ipc>>
di::injector<T> configure_ipc() {
return di::make_injector(configure_logger());
}
}
LEMONBUDDY_NS_END