50 ERS_ASSERT_MSG(exists(),
"FIFO "<< c_full_name() <<
" does not exist.");
52 ers::warning(OksSystem::Exception(
ERS_HERE, std::string(c_full_name()) + std::string(
" is not a FIFO")));
55 char buffer[MAX_MESSAGE_LEN];
57 const int status = connection_fd.
read(buffer,
sizeof(buffer)-1);
60 buffer[status] =
'\0';
61 return std::string(buffer);
68 ERS_ASSERT_MSG(exists(),
"FIFO "<< c_full_name() <<
" does not exist. Cannot put "<< message <<
" into FIFO.");
70 ers::warning(OksSystem::Exception(
ERS_HERE, std::string(c_full_name()) + std::string(
" is not a FIFO")));
72 const unsigned int l = message.size();
75 connection_fd.
write(message.data(),l);
90 const unsigned int l = message.size();
92 m_fifo_fd->write(message.data(),l);
107 char buffer[MAX_MESSAGE_LEN];
109 const int status = m_fifo_fd->read(buffer,
sizeof(buffer)-1);
112 buffer[status] =
'\0';
113 return std::string(buffer);
115 if (m_is_blocking ==
false && status == 0)
return std::string(
"");
130 int flags = O_RDONLY;
133 flags = O_RDONLY|O_NONBLOCK;
134 m_is_blocking =
false;
140 catch(OksSystem::OpenFileIssue &ex) {
161 int flags = O_WRONLY;
164 flags = O_WRONLY|O_NONBLOCK;
165 m_is_blocking =
false;
171 catch(OksSystem::OpenFileIssue &ex) {
194 flags = O_RDWR|O_NONBLOCK;
195 m_is_blocking =
false;
201 catch(OksSystem::OpenFileIssue &ex) {
234 return m_fifo_fd->fd();
#define ERS_ASSERT_MSG(expression, message)
#define ERS_RANGE_CHECK(min, val, max)
#define ERS_ASSERT(expression)
File descriptor / Socket wrapper.
int read(void *buffer, size_t number) const
int write(const void *buffer, size_t number) const
FIFOConnection(const std::string &name)
void close()
It closes the FIFO file descriptor.
void send(const std::string &message) const
It writes a message to a FIFO.
void send_message(const std::string &message) const
OksSystem::Descriptor * open_rw(bool block=true)
It opens the FIFO in read and write mode.
std::string read_message() const
static const unsigned int MAX_MESSAGE_LEN
void make(mode_t perm=0622) const
OksSystem::Descriptor * m_fifo_fd
int fd() const
It gets the FIFO file descriptor.
OksSystem::Descriptor * open_w(bool block=true)
It opens the FIFO in write-only mode.
std::string read() const
It reads a single message (string) from a FIFO.
OksSystem::Descriptor * open_r(bool block=true)
It opens the FIFO in read-only mode.
Wrapper for file operations.
void make_fifo(mode_t permissions) const
creates a FIFO (named pipe) */
void warning(const Issue &issue)