forked from Streptoco/EmbeddedProgrammingInLinux
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpipe_handler.h
More file actions
53 lines (35 loc) · 1.53 KB
/
pipe_handler.h
File metadata and controls
53 lines (35 loc) · 1.53 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef PIPE_HANDLER_H
#define PIPE_HANDLER_H
#include <iostream>
#include <unistd.h>
#include <sys/wait.h>
#include <functional>
#include "myLibrary.h"
#include "full_schedule.h"
#include "arrivals.h"
#include "airplane.h"
#include "signal_handler.h"
#include "node.h"
// Function to handle pipe creation
void createPipe(const string& type, int pipe[]);
void closePipe(int pipe[]);
void exitProcess(int exitCode, int pipeToNotify);
// Function to handle pipe reading for integer values
int readFromPipe(int pipe);
// Function to handle pipe writing for integer values
void writeToPipe(int pipe, int value);
// Function to handle pipe reading for string values
char* readStringFromPipe(int pipe);
// Function to handle pipe writing for string values
void writeStringToPipe(int pipe, const string& value);
// Function to handle node creation from pipe
Node* createNodeFromPipe(int pipe);
// Function to handle node writing to pipe
void writeNodeToPipe(int pipe, Node* node);
void readStringVectorFromPipe(int pipe, vector<string>& result);
void writeStringVectorToPipe(int pipe, vector<string>& input);
void printNodeVectorFromPipe(const string& inputNames, int pipe, function<void(vector<Node*>&, const string&)> printFunction);
void printMultiNodeVectorFromPipe(vector<string>& inputNames, int pipe, function<void(vector<Node*>&, const string&)> printFunction);
void writeNodeVectorToPipe(int pipe, vector<Node*>& input);
pid_t tryFork();
#endif //PIPE_HANDLER_H