CARMA C++
FiberIFThread.h
1 #ifndef CARMA_LINELENGTH_FIBERIFTHREAD_H
2 #define CARMA_LINELENGTH_FIBERIFTHREAD_H
3 
4 #include <carma/util/PthreadMutex.h>
5 
6 #include <boost/circular_buffer.hpp>
7 #include <boost/shared_ptr.hpp>
8 
9 #include <vector>
10 
11 namespace carma {
12 namespace linelength {
13 
14 // Simple structure to hold a sample of LineLength Board1 Data
15 struct FiberIFData
16 {
17  // 24 channels of Polarization #1 IF data (mW)
18  std::vector<double> pol1;
19  // 24 channels of Polarization #2 IF data (mW)
20  std::vector<double> pol2;
21 };
22 
23 typedef boost::shared_ptr<struct FiberIFData> FiberIFDataPtr;
24 
25 class FiberIFThread
26 {
27  public:
28  FiberIFThread(const std::string &device);
29  ~FiberIFThread();
30 
31  // Thread
32  static void thread(FiberIFThread &This) { This.run(); };
33  void run();
34 
35  // Data Interface
36  bool empty() const;
37  size_t size() const;
38  FiberIFDataPtr getData();
39 
40  private:
41  // device file to use
42  const std::string device_;
43 
44  // data buffer
45  mutable carma::util::PthreadMutex mutex_;
46  boost::circular_buffer<FiberIFDataPtr> buffer_;
47 };
48 
49 } // namespace carma::linelength
50 } // namespace carma
51 
52 #endif // CARMA_LINELENGTH_FIBERIFTHREAD_H
53 // vim: set expandtab ts=4 sts=4 sw=4:
A simple wrapper class that makes use of ::pthread_mutex_t easier in a C++ world. ...
Definition: PthreadMutex.h:41