CARMA C++
SyslogListenerThread.h
1 //
2 // @file syslog2carmalog.cc
3 // @version $Id: SyslogListenerThread.h,v 1.3 2007/11/28 07:57:53 colby Exp $
4 // @author Colby Gutierrez-Kraybill
5 //
6 // @description
7 //
8 
9 
10 #ifndef CARMA_DBMS_SYSLOGLISTENERTHREAD_H
11 #define CARMA_DBMS_SYSLOGLISTENERTHREAD_H
12 
13 // System includes
14 #include <string>
15 #include <queue>
16 #include <unistd.h>
17 
18 // CARMA tools includes
19 #include "log4cpp/Category.hh"
20 
21 // CARMA software includes
22 #include "carma/util/Time.h"
23 #include "carma/util/PthreadMutex.h"
24 #include "carma/util/PthreadCond.h"
25 
26 namespace carma
27 {
28  namespace dbms
29  {
30  class SyslogListenerThread
31  {
32  public:
33  SyslogListenerThread (
34  std::string pipeFileName,
35  std::queue<std::string * > *rawBufferQueue,
36  carma::util::PthreadMutex *queueGuard,
37  carma::util::PthreadMutex *readyGuard,
38  carma::util::PthreadCond *readyCond
39  );
40 
41  static void thread( SyslogListenerThread &This );
42  void run();
43  void stop();
44 
45  double getStartTime() { return _timeOfStart; };
46  long long getMessageCount() { return _messageCountFromStartOfRun; };
47  long long getTotalBytes() { return _totalBytesReceived; };
48 
49  void ready();
50  std::string *waitForNextMessage();
51 
52  private:
53  log4cpp::Category &_log;
54  std::string _pipeFileName;
55 
56  // book keeping
57  double _timeOfStart; // in MJD
58  long long _messageCountFromStartOfRun;
59  long long _totalBytesReceived;
60  SyslogListenerThread *_myThread;
61  int _pipeFD;
62 
63  std::string _logName;
64  std::string::size_type _newMsgReset;
65 
66  // passed in from SyslogListenerManager
67  std::queue<std::string * > *_rawBufferQueue;
68  carma::util::PthreadMutex *_queueGuard;
69  carma::util::PthreadMutex *_readyGuard;
70  carma::util::PthreadCond *_readyCond;
71 
72  }; // class SyslogListenerThread
73  } // namespace dbms
74 } // namespace carma
75 
76 #endif // CARMA_DBMS_SYSLOGLISTENERTHREAD_H
Common time functions.
A simple wrapper class that makes use of ::pthread_cond_t easier in a C++ world.
Definition: PthreadCond.h:43
A simple wrapper class that makes use of ::pthread_mutex_t easier in a C++ world. ...
Definition: PthreadMutex.h:41