UpdateReceiver_T.h

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Distributed under the OpenDDS License.
00005  * See: http://www.opendds.org/license.html
00006  */
00007 
00008 #ifndef UPDATE_RECEIVER_T_H
00009 #define UPDATE_RECEIVER_T_H
00010 
00011 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00012 #pragma once
00013 #endif /* ACE_LACKS_PRAGMA_ONCE */
00014 
00015 #include "ace/Condition_T.h"
00016 #include "ace/Task.h"
00017 
00018 #include <list>
00019 
00020 namespace DDS {
00021 
00022 struct SampleInfo;
00023 
00024 } // namespace DDS
00025 
00026 namespace OpenDDS {
00027 namespace Federator {
00028 
00029 template<class DataType>
00030 class UpdateProcessor;
00031 
00032 template<class DataType>
00033 class  UpdateReceiver : public virtual ACE_Task_Base {
00034 public:
00035   /// Construct with a processor reference.
00036   UpdateReceiver(UpdateProcessor<DataType>& processor);
00037 
00038   /// Virtual destructor.
00039   virtual ~UpdateReceiver();
00040 
00041   // ACE_Task_Base methods.
00042 
00043   virtual int open(void*);
00044   virtual int svc();
00045   virtual int close(u_long flags = 0);
00046 
00047   /**
00048    * @brief Sample enqueueing.
00049    *
00050    * @param sample - pointer to the received sample to be processed
00051    * @param info   - pointer to the info about the sample to be processed.
00052    *
00053    * NOTE: We take ownership of this data and delete it when we are
00054    *       done processing it.
00055    */
00056   void add(DataType* sample, DDS::SampleInfo* info);
00057 
00058   /// Synchronous termination.
00059   void stop();
00060 
00061 private:
00062   /// The object that we delegate update processing to.
00063   UpdateProcessor<DataType>& processor_;
00064 
00065   /// Termination flag.
00066   bool stop_;
00067 
00068   /// Protect queue modifications.
00069   ACE_SYNCH_MUTEX lock_;
00070 
00071   /// Work to do indicator.
00072   ACE_Condition<ACE_SYNCH_MUTEX> workAvailable_;
00073 
00074   /// Contents of the queue.
00075   typedef std::pair<DataType*, DDS::SampleInfo* > DataInfo;
00076 
00077   /// Queue of publication data to process.
00078   std::list<DataInfo> queue_;
00079 };
00080 
00081 } // namespace Federator
00082 } // namespace OpenDDS
00083 
00084 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
00085 #include "UpdateReceiver_T.cpp"
00086 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
00087 
00088 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
00089 #pragma message ("UpdateReceiver_T.cpp template inst")
00090 #pragma implementation ("UpdateReceiver_T.cpp")
00091 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
00092 
00093 #endif  /* UPDATE_RECEIVER_T_H */

Generated on Fri Feb 12 20:05:29 2016 for OpenDDS by  doxygen 1.4.7