Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
cpipe.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 
5 #ifndef CPIPE_H
6 #define CPIPE_H 1
7 
8 #include <pthread.h>
9 #include <unistd.h>
10 #include <fcntl.h>
11 #include <inttypes.h>
12 
13 #include "rofl/common/croflexception.h"
14 
15 namespace rofl
16 {
17 
18 class ePipeBase : public RoflException {};
19 class ePipeInit : public ePipeBase {}; // initialization of pipe failed
20 class ePipeInval : public ePipeBase {}; // invalid parameter
21 
22 class cpipe
23 {
24  enum cpipe_cmd_t {
25  CPIPE_WAKEUP = 1,
26  };
27 
28 public:
29 
33  cpipe();
34 
38  ~cpipe();
39 
43  void
44  writemsg(unsigned char msg = 0);
45 
49  unsigned char
50  recvmsg();
51 
55  int
56  get_readfd() const { return pipefd[0]; };
57 
61  int
62  get_writefd() const { return pipefd[1]; };
63 
64 public:
65 
66  int pipefd[2]; // pipefd[0]: read, pipefd[1]: write
67  pthread_mutex_t pipelock; // mutex for this pipe
68 
69 };
70 
71 }; // end of namespace
72 
73 #endif
Definition: cpipe.h:18
Definition: cpipe.h:20
Definition: cpipe.h:22
Definition: cpipe.h:19
Definition: croflexception.h:27