00001 #ifndef BASICNAMEDPIPE_H 00002 #define BASICNAMEDPIPE_H 00003 00004 #include <string> 00005 00006 enum StatePipe { StateCL = -1, StateOR, StateOW }; 00007 00008 class BasicNamedPipe { // pipe closed: fdOpen = StateCL 00009 private: // pipe open for O_RDONLY: fdOpen = StateOR 00010 int fd; // pipe open for O_WRONLY: fdOpen = StateOW 00011 std::string pipe_name; 00012 StatePipe fdOpen; 00013 static const int SIZE_BUF = 1024; // increase if you like 00014 00015 public: 00016 BasicNamedPipe(const char* name); 00017 ~BasicNamedPipe(); 00018 00019 void OpenPipe(int mode); 00020 void SendData(const void* buf, long long size_buf); 00021 void ReceiveData(void* buf, long long size_buf); 00022 void ClosePipe(int mode); 00023 StatePipe GetState() const { return fdOpen; } 00024 }; 00025 #endif