CARMA C++
PublisherStage.h
1 #ifndef CARMA_PIPELINE_PUBLISHERSTAGE_H
2 #define CARMA_PIPELINE_PUBLISHERSTAGE_H
3 
4 
5 #include "carma/pipeline/pipelineUtils.h"
6 #include "carma/pipeline/Stage.h"
7 #include "carma/util/ConcurrentQueue.h"
8 #include "carma/util/PthreadMutex.h"
9 #include "carma/util/SimpleStatisticsAccumulators.h"
10 #include "carma/util/ThreadQuit.h"
11 
12 #include <boost/shared_ptr.hpp>
13 #include <map>
14 #include <string>
15 
16 namespace carma {
17 namespace correlator {
18 namespace lib {
19  class CorrelatorData;
20 } // namespace carma::correlator::lib
21 
22 namespace obsRecord2 {
23  class CorbaCorrProducer;
24 } // namespace carma::correlator::obsRecord2
25 } // namespace carma::correlator
26 
27 namespace monitor {
28  class PipelineSubsystem;
29 } // namespace carma::monitor
30 
31 namespace pipeline {
32 
37  class Publisher: public Stage {
38  public:
39 
41  Publisher(
43  const std::string & channelName,
44  const std::string & servedObjectName,
45  carma::pipeline::PipelineType plType );
46 
48  virtual ~Publisher( );
49 
50  private:
51 
52  void preprocess( carma::correlator::lib::CorrelatorDataPtr cd );
53 
54  void processBand( carma::correlator::lib::CorrelatorBand * cb );
55 
56  carma::correlator::lib::CorrelatorDataPtr
57  postprocess( carma::correlator::lib::CorrelatorDataPtr cd );
58 
59  void fillMonitorData( );
60 
61  static void publishCorrDataThread( Publisher & This );
62 
63  class PublishCorrDataTQRH :
64  public carma::util::ThreadQuitRequestHandler {
65  public:
66 
67  explicit PublishCorrDataTQRH( Publisher & mom );
68 
69  virtual ~PublishCorrDataTQRH( );
70 
71  void HandleQuitRequest( ::pthread_t thread );
72 
73  private:
74 
75  Publisher & mom_;
76  };
77 
78  struct PublishRequest {
79  carma::correlator::lib::CorrelatorDataPtr data;
80  };
81 
82  typedef carma::util::ConcurrentQueue<PublishRequest> PublishQueue;
83 
84  struct Shared {
85  Shared( );
86  mutable carma::util::PthreadMutex mutex;
87  carma::util::FloatStatAccumulator corbaSendTimeAcc;
88  float lastCorbaSendMillis;
89  float lastCorbaSendKilobytes;
90  };
91 
92  Shared shared_;
93  PublishQueue publishRequestQueue_;
94 
95  carma::monitor::PipelineSubsystem & monitorData_;
96 
98  typedef ::boost::shared_ptr< CorrProducer > CorrProducerPtr;
99  typedef ::std::map< int, CorrProducerPtr > CorrProducerMap;
100 
101  CorrProducerMap corrProducers_;
102  ::pthread_t publisherThreadId_;
103 
104  const PublishQueue::size_type maxQueueRequests_;
105  }; // class Publisher
106 
107 } // namespace carma::pipeline
108 } // namespace carma
109 #endif
Base interface for a correlator pipeline stage.
Definition: Stage.h:39
Class to hold a Band of Correlator Data.
Implements interface for serving correlator data using CORBA.
Tagged: Wed Jun 29 11:00:27 PDT 2005.
Class used to publish Correlator Data and send data out via a notification channel.
Abstract base class for retrieving pipeline monitor system components common between the spectral lin...
Publisher(carma::monitor::PipelineSubsystem &monitor, const std::string &channelName, const std::string &servedObjectName, carma::pipeline::PipelineType plType)
Constructor.
A simple wrapper class that makes use of ::pthread_mutex_t easier in a C++ world. ...
Definition: PthreadMutex.h:41
virtual ~Publisher()
Destructor.