OpenDDS  Snapshot(2023/04/28-20:55)
UpdateReceiver_T.h
Go to the documentation of this file.
1 /*
2  *
3  *
4  * Distributed under the OpenDDS License.
5  * See: http://www.opendds.org/license.html
6  */
7 
8 #ifndef UPDATE_RECEIVER_T_H
9 #define UPDATE_RECEIVER_T_H
10 
11 #if !defined (ACE_LACKS_PRAGMA_ONCE)
12 #pragma once
13 #endif /* ACE_LACKS_PRAGMA_ONCE */
14 
15 #include "ace/Task.h"
16 #include "dds/DCPS/unique_ptr.h"
17 
18 #include <list>
19 
21 
22 namespace DDS {
23 
24 struct SampleInfo;
25 
26 } // namespace DDS
27 
28 namespace OpenDDS {
29 namespace Federator {
30 
31 template<class DataType>
32 class UpdateProcessor;
33 
34 template<class DataType>
35 class UpdateReceiver : public virtual ACE_Task_Base {
36 public:
37  /// Construct with a processor reference.
39 
40  virtual ~UpdateReceiver();
41 
42  // ACE_Task_Base methods.
43 
44  virtual int open(void*);
45  virtual int svc();
46  virtual int close(u_long flags = 0);
47 
48  /**
49  * @brief Sample enqueueing.
50  *
51  * @param sample - pointer to the received sample to be processed
52  * @param info - pointer to the info about the sample to be processed.
53  *
54  * NOTE: We take ownership of this data and delete it when we are
55  * done processing it.
56  */
58 
59  /// Synchronous termination.
60  void stop();
61 
62 private:
63  /// The object that we delegate update processing to.
65 
66  /// Termination flag.
67  bool stop_;
68 
69  /// Protect queue modifications.
71 
72  /// Work to do indicator.
74 
75  /// Contents of the queue.
76  typedef std::pair<DataType*, DDS::SampleInfo* > DataInfo;
77 
78  /// Queue of publication data to process.
79  std::list<DataInfo> queue_;
80 };
81 
82 } // namespace Federator
83 } // namespace OpenDDS
84 
86 
87 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
88 #include "UpdateReceiver_T.cpp"
89 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
90 
91 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
92 #pragma message ("UpdateReceiver_T.cpp template inst")
93 #pragma implementation ("UpdateReceiver_T.cpp")
94 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
95 
96 #endif /* UPDATE_RECEIVER_T_H */
#define ACE_SYNCH_MUTEX
Interface for managing update publications.
UpdateProcessor< DataType > & processor_
The object that we delegate update processing to.
int close(ACE_HANDLE handle)
ACE_HANDLE open(const char *filename, int mode, mode_t perms=ACE_DEFAULT_OPEN_PERMS, LPSECURITY_ATTRIBUTES sa=0)
The End User API.
std::list< DataInfo > queue_
Queue of publication data to process.
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
std::pair< DataType *, DDS::SampleInfo *> DataInfo
Contents of the queue.
ACE_Condition< ACE_SYNCH_MUTEX > workAvailable_
Work to do indicator.
ACE_SYNCH_MUTEX lock_
Protect queue modifications.
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28