DDS-PSM-C++  1.0
ISO C++ API for OpenSplice DDS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
TDataReader.hpp
Go to the documentation of this file.
1 #ifndef OMG_DDS_SUB_TDATA_READER_HPP_
2 #define OMG_DDS_SUB_TDATA_READER_HPP_
3 
4 /* Copyright 2010, Object Management Group, Inc.
5  * Copyright 2010, PrismTech, Corp.
6  * Copyright 2010, Real-Time Innovations, Inc.
7  * All rights reserved.
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
22 #include <dds/core/TEntity.hpp>
26 
27 namespace dds {
28  namespace sub {
29  class Query;
30 
31  template <typename T, template <typename Q> class DELEGATE>
32  class DataReader;
33 
34  template <typename T>
35  class DataReaderListener;
36  }
37 }
38 
39 template <typename T, template <typename Q> class DELEGATE>
40 class dds::sub::DataReader : public dds::core::TEntity< DELEGATE<T> > {
41 
42 public:
43  typedef T DataType;
44  typedef ::dds::sub::DataReaderListener<T> Listener;
45 
46 public:
47 
54  class Selector {
55  public:
56  Selector(DataReader& dr);
57 
60  Selector& state(const dds::sub::status::DataState& s);
61  Selector& content(const dds::sub::Query& query);
62  Selector& max_samples(uint32_t n);
63 
66 
67  // --- Forward Iterators: --- //
68  template <typename SamplesFWIterator>
69  uint32_t
70  read(SamplesFWIterator sfit, uint32_t max_samples);
71 
72  template <typename SamplesFWIterator>
73  uint32_t
74  take(SamplesFWIterator sfit, uint32_t max_samples);
75 
76  // --- Back-Inserting Iterators: --- //
77  template <typename SamplesBIIterator>
78  uint32_t
79  read(SamplesBIIterator sbit);
80 
81 
82  template <typename SamplesBIIterator>
83  uint32_t
84  take(SamplesBIIterator sbit);
85 
86  private:
87  typename DELEGATE<T>::Selector impl_;
88  };
89 
94  public:
96 
97  bool read_mode();
98  void read_mode(bool b);
99 
100  ManipulatorSelector& max_samples(uint32_t n);
103  ManipulatorSelector& state(const dds::sub::status::DataState& s);
105 
108 
111 
112  template <typename Functor>
114  operator >> (Functor f);
115 
116  private:
117  typename DELEGATE<T>::ManipulatorSelector impl_;
118 
119  };
120 
121 public:
123 
124 public:
132  DataReader(const dds::sub::Subscriber& sub,
133  const ::dds::topic::Topic<T>& topic);
143  DataReader(const dds::sub::Subscriber& sub,
144  const ::dds::topic::Topic<T>& topic,
145  const dds::sub::qos::DataReaderQos& qos,
146  dds::sub::DataReaderListener<T>* listener = NULL,
147  const dds::core::status::StatusMask& mask = ::dds::core::status::StatusMask::all());
148 
149 #ifdef OMG_DDS_CONTENT_SUBSCRIPTION_SUPPORT
150 
160  DataReader(const dds::sub::Subscriber& sub,
161  const ::dds::topic::ContentFilteredTopic<T>& topic);
162 
174  DataReader(const dds::sub::Subscriber& sub,
175  const ::dds::topic::ContentFilteredTopic<T>& topic,
176  const dds::sub::qos::DataReaderQos& qos,
179 #endif /* OMG_DDS_CONTENT_SUBSCRIPTION_SUPPORT */
180 
181 #ifdef OMG_DDS_MULTI_TOPIC_SUPPORT
182 
192  DataReader(const dds::sub::Subscriber& sub,
193  const ::dds::topic::MultiTopic<T>& topic);
194 
195 
207  DataReader(const dds::sub::Subscriber& sub,
208  const ::dds::topic::MultiTopic<T>& topic,
209  const dds::sub::qos::DataReaderQos& qos,
212 
213 #endif /* OMG_DDS_MULTI_TOPIC_SUPPORT */
214 public:
215  ~DataReader();
216 
217 
218 public:
219  // == ReadState Management
220 
225  const dds::sub::status::DataState& default_filter_state();
226 
232  DataReader& default_filter_state(const dds::sub::status::DataState& state);
233 
234  //== Streaming read/take
235 
244 
247 
248  template <typename Functor>
250  operator >> (Functor f);
251 
252 
254 public:
255  //== Loan Read/Take API ==================================================
256 
265 
274 
275  //== Copy Read/Take API ==================================================
276 
277  // --- Forward Iterators: --- //
278 
288  template <typename SamplesFWIterator>
289  uint32_t
290  read(SamplesFWIterator sfit,
291  uint32_t max_samples);
292 
302  template <typename SamplesFWIterator>
303  uint32_t
304  take(SamplesFWIterator sfit,
305  uint32_t max_samples);
306 
307 
308  // --- Back-Inserting Iterators: --- //
309 
319  template <typename SamplesBIIterator>
320  uint32_t
321  read(SamplesBIIterator sbit);
322 
332  template <typename SamplesBIIterator>
333  uint32_t
334  take(SamplesBIIterator sbit);
335 public:
336  //========================================================================
337  //== DSL Method for dealing with instances, content and status filters.
338 
354  Selector select();
355 
356  //========================================================================
357  //== Instance Management
358 public:
369 
379  T& key_value(T& sample, const dds::core::InstanceHandle& h);
380 
392  lookup_instance(const T& key) const;
393 
394  //==========================================================================
395  // -- Entity Navigation API
396 public:
401 
405  const dds::sub::Subscriber& subscriber() const;
406 
413  void listener(Listener* the_listener,
414  const dds::core::status::StatusMask& event_mask);
415 
419  Listener* listener() const;
420 
421  // -- Qos Getter/Setter
422 
427  qos() const;
428 
434  void qos(const dds::sub::qos::DataReaderQos& the_qos);
435 
440 
447 
454  void
456 
457  //========================================================================
458  //== Status API
461 
463  sample_rejected_status() const;
464 
466  sample_lost_status() const;
467 
470 
473 
476 };
477 
478 
479 #endif /* OMG_DDS_SUB_TDATA_READER_HPP_ */