CARMA C++
PipeQ.h
Go to the documentation of this file.
1 #ifndef PIPEQ_h
2 #define PIPEQ_h
3 
11 #include "Pipe.h"
12 
13 namespace sza {
14  namespace util {
15 
19  template<class Msg>
20  class PipeQ {
21 
22  public:
23 
27  PipeQ();
28 
32  ~PipeQ();
33 
39  void sendMsg(Msg* msg);
40 
46  void readMsg(Msg* msg);
47 
52  int fd();
53 
58  fd_set rfds();
59 
60  private:
61 
65  Pipe pipe_;
66  };
67 
73  template<class Msg>
74  void PipeQ<Msg>::sendMsg(Msg* msg)
75  {
76  pipe_.writePipe((void*) msg, sizeof(Msg), -1);
77  };
78 
84  template<class Msg>
85  void PipeQ<Msg>::readMsg(Msg* msg)
86  {
87  pipe_.readPipe((void*) msg, sizeof(Msg), -1);
88  };
89 
93  template<class Msg>
95  {
96  return pipe_.fd();
97  };
98 
102  template<class Msg>
104  {
105  return pipe_.rfds();
106  };
107 
113  template<class Msg>
115 
121  template<class Msg>
123 
124  }; // End namespace util
125 }; // End namespace sza
126 
127 #endif
int fd()
Return the selectable file descriptor associated with this message queue.
Definition: PipeQ.h:94
Tagged: Fri Nov 14 12:39:34 UTC 2003.
fd_set rfds()
Return an intialized set of readable file descriptors associated with this queue. ...
Definition: PipeQ.h:103
void sendMsg(Msg *msg)
Method to send a message to the message queue.
Definition: PipeQ.h:74
Template class for a message queue implemented using pipes.
Definition: PipeQ.h:20
A class to encapsulate a pipe.
Definition: Pipe.h:49
void readMsg(Msg *msg)
Read message method simply gets the next message off the pipe.
Definition: PipeQ.h:85
PipeQ()
Constructor.
Definition: PipeQ.h:114
~PipeQ()
Destructor.
Definition: PipeQ.h:122