CARMA C++
SyslogListenerManager.h
1 //
2 // @file syslog2carmalog.cc
3 // @version $Id: SyslogListenerManager.h,v 1.1 2007/11/21 12:01:59 colby Exp $
4 // @author Colby Gutierrez-Kraybill
5 //
6 // @description
7 //
8 
9 
10 #ifndef CARMA_DBMS_SYSLOGLISTENERMANAGER_H
11 #define CARMA_DBMS_SYSLOGLISTENERMANAGER_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/PthreadMutex.h"
25 #include "carma/util/PthreadCond.h"
26 
27 #include "carma/dbms/SyslogListenerThread.h"
28 
29 namespace carma
30 {
31  namespace dbms
32  {
33  class SyslogListenerManager
34  {
35  public:
36  SyslogListenerManager ( std::string pipeFileName );
37 
38  static void thread( SyslogListenerManager &This );
39  void run();
40  void stop();
41 
42  double getStartTime() { return _timeOfStart; };
43  long long getMessageCount() { return _messageCountFromStartOfRun; };
44  long long getTotalBytes() { return _totalBytesReceived; };
45 
46  void ready();
47  std::string *waitForNextMessage();
48 
49  private:
50  log4cpp::Category &_log;
51  std::vector<std::string> _pipeFileNames;
52 
53  // book keeping
54  double _timeOfStart; // in MJD
55  long long _messageCountFromStartOfRun;
56  long long _totalBytesReceived;
57  SyslogListenerManager *_myThread;
58  int _pipeFD;
59 
60  std::map< std::string, SyslogListenerThread * > _listeners;
61 
62  static std::queue<std::string * > *_rawBufferQueue;
63 
64  static carma::util::PthreadMutex *_queueGuard;
65  static carma::util::PthreadMutex *_readyGuard;
66  static carma::util::PthreadCond *_readyCond;
67 
68  }; // class SyslogListenerManager
69  } // namespace dbms
70 } // namespace carma
71 
72 #endif // CARMA_DBMS_SYSLOGLISTENERMANAGER_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