• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

src/hpp/dds/sub/DataReader.hpp

Go to the documentation of this file.
00001 #ifndef OMG_DDS_SUB_DATA_READER_HPP_
00002 #define OMG_DDS_SUB_DATA_READER_HPP_
00003 
00004 /* Copyright 2010, Object Management Group, Inc.
00005  * Copyright 2010, PrismTech, Corp.
00006  * Copyright 2010, Real-Time Innovations, Inc.
00007  * All rights reserved.
00008  *
00009  * Licensed under the Apache License, Version 2.0 (the "License");
00010  * you may not use this file except in compliance with the License.
00011  * You may obtain a copy of the License at
00012  *
00013  *     http://www.apache.org/licenses/LICENSE-2.0
00014  *
00015  * Unless required by applicable law or agreed to in writing, software
00016  * distributed under the License is distributed on an "AS IS" BASIS,
00017  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00018  * See the License for the specific language governing permissions and
00019  * limitations under the License.
00020  */
00021 
00022 #include <dds/core/corefwd.hpp>
00023 #include <tdds/core/Entity.hpp>
00024 #include <dds/sub/subfwd.hpp>
00025 #include <dds/sub/qos/DataReaderQos.hpp>
00026 #include <dds/sub/detail/DataReader.hpp>
00027 #include <dds/sub/cond/ReadCondition.hpp>
00028 #include <dds/sub/cond/QueryCondition.hpp>
00029 #include <dds/topic/TopicDescription.hpp>
00030 #include <dds/sub/status/ReaderState.hpp>
00031 #include <dds/sub/Sample.hpp>
00032 
00033 
00034 namespace dds { namespace sub {
00035 
00036 
00037 template <typename T, template <typename Q> class DELEGATE>
00038 class DataReader : public tdds::core::Entity< DELEGATE<T> > {
00039 public:
00040         OMG_DDS_REF_TYPE(DataReader, tdds::core::Entity, DELEGATE<T>)
00041 
00042 public:
00043         typedef T                                               DataType;
00044     typedef ::dds::sub::Sample<T>                           Sample;
00045     typedef ::dds::sub::LoanedSamples<T>                    LoanedSamples;
00046         typedef ::dds::sub::DataReaderListener<DataType>        Listener;
00047         typedef ::dds::core::cond::StatusCondition<DataReader>  StatusCondition;
00048         typedef ::dds::sub::cond::ReadCondition<DataType>       ReadCondition;
00049         typedef ::dds::sub::cond::QueryCondition<DataType>      QueryCondition;
00050     typedef ::dds::sub::ReaderQuery<DataType>               ReaderQuery;
00051 
00052 public:
00053         ~DataReader() { }
00054 
00055 public:
00065         StatusCondition status_condition() const {
00066                 return this->impl()->template status_condition<DataReader>(*this);
00067         }
00068 
00069 public:
00070         // == ReadState Management
00071 
00076         dds::sub::status::ReaderState default_read_state() {
00077                 return this->impl()->read_state();
00078         }
00079         void default_read_state(const dds::sub::status::ReaderState& rs) {
00080                 return this->impl()->read_state(rs);
00081         }
00082         //== Streaming Take
00083 
00091         DataReader& operator >>(dds::sub::LoanedSamples<T>& ls) {
00092                 this->impl() >> ls;
00093         }
00094 
00096 public:
00097         //== Loan Read/Take API ==================================================
00098         LoanedSamples read() {
00099                 this->impl()->read();
00100         }
00101 
00102         LoanedSamples read(const ReaderQuery& query) {
00103                 this->impl()->read(query);
00104         }
00105 
00106         LoanedSamples take() {
00107                 return this->impl()->take();
00108         }
00109 
00110         LoanedSamples take(const ReaderQuery& query) {
00111                 return this->impl()->take(query);
00112         }
00113 
00114         //== Copy Read/Take API ==================================================
00115 
00116     // --- Forward Iterators: --- //
00117         template <typename SamplesFWIterator, typename InfoFWIterator>
00118         void
00119         read(SamplesFWIterator sfit,
00120                         InfoFWIterator ifit,
00121                         size_t max_samples)
00122         {
00123                 this->impl()->read(sfit, ifit, max_samples);
00124         }
00125 
00126         template <typename SamplesFWIterator, typename InfoFWIterator>
00127     void
00128     read(SamplesFWIterator sfit,
00129             InfoFWIterator ifit,
00130             size_t max_samples,
00131             const ReaderQuery& query)
00132     {
00133         this->impl()->read(sfit, ifit, max_samples, query);
00134     }
00135 
00136         template <typename SamplesFWIterator, typename InfoFWIterator>
00137         void
00138         take(SamplesFWIterator sfit,
00139                         InfoFWIterator ifit,
00140                         size_t max_samples)
00141         {
00142                 this->impl()->take(sfit, ifit, max_samples);
00143         }
00144 
00145         template <typename SamplesFWIterator, typename InfoFWIterator>
00146     void
00147     take(SamplesFWIterator sfit,
00148             InfoFWIterator ifit,
00149             size_t max_samples,
00150             const ReaderQuery& query)
00151     {
00152         this->impl()->take(sfit, ifit, max_samples, query);
00153     }
00154 
00155     // --- Back-Inserting Iterators: --- //
00156         template <typename SamplesBIIterator, typename InfoBIIterator>
00157         void
00158         read(SamplesBIIterator sbit,
00159                         InfoBIIterator ibit)
00160         {
00161                 this->impl()->read(sbit, ibit);
00162         }
00163 
00164         template <typename SamplesBIIterator, typename InfoBIIterator>
00165     void
00166     read(SamplesBIIterator sbit,
00167             InfoBIIterator ibit,
00168             const ReaderQuery& query)
00169     {
00170         this->impl()->read(sbit, ibit, query);
00171     }
00172 
00173 
00174         template <typename SamplesBIIterator, typename InfoBIIterator>
00175         void
00176         take(SamplesBIIterator sbit,
00177                         InfoBIIterator ibit)
00178         {
00179                 this->impl()->take(sbit, ibit);
00180         }
00181 
00182         template <typename SamplesBIIterator, typename InfoBIIterator>
00183     void
00184     take(SamplesBIIterator sbit,
00185             InfoBIIterator ibit,
00186             const ReaderQuery& query)
00187     {
00188         this->impl()->take(sbit, ibit, query);
00189     }
00190 
00191     //========================================================================
00192     //== Instance Management
00193 public:
00203     dds::topic::TopicInstance<T>& key_value(dds::topic::TopicInstance<T>& i,
00204                                             const dds::core::InstanceHandle& h) {
00205         return this->delegate()->key_value(i, h);
00206     }
00207 
00217     T& key_value(T& sample, const dds::core::InstanceHandle& h) {
00218         return this->delegate()->key_value(sample, h);
00219     }
00220 
00231     const dds::core::InstanceHandle lookup_instance(const T& key) {
00232         return this->delegate()->lookup_instance(key);
00233     }
00234 
00235     //==========================================================================
00236 public:
00237     dds::topic::TopicDescription<DataType> topic_description();
00238 
00239         // -- Listener Getter/Setter
00240         void listener(Listener* the_listener,
00241                         const dds::core::status::StatusMask& event_mask);
00242 
00243         Listener* listener() const;
00244 
00245         // -- Qos Getter/Setter
00246     using tdds::core::Entity< DELEGATE<T> >::qos;
00247 
00248         const dds::sub::qos::DataReaderQos
00249         qos() const {
00250                 return this->impl()->qos();
00251         }
00252 
00253         void qos(const dds::sub::qos::DataReaderQos& the_qos) {
00254                 this->impl()->qos(the_qos);
00255         }
00256 
00257         DataReader& operator <<(const dds::sub::qos::DataReaderQos& the_qos) {
00258                 this->impl()->qos(the_qos);
00259                 return *this;
00260         }
00261 
00262         DataReader& operator >> (dds::sub::qos::DataReaderQos& the_qos) {
00263                 the_qos = this->impl()->qos();
00264                 return *this;
00265         }
00266 
00267         void
00268         wait_for_historical_data(const dds::core::Duration& timeout) {
00269                 this->impl()->wait_for_historical_data(timeout);
00270         }
00272         // -- Condition API--
00273 public:
00274     ReadCondition create_readcondition(
00275             const dds::sub::status::ReaderState& read_state =
00276                     dds::sub::status::ReaderState::any()) {
00277         return ReadCondition(new dds::sub::cond::detail::ReadConditionImpl<T>(
00278             typename dds::sub::cond::detail::ReadConditionImpl<T>::DRHolder(
00279                 new dds::sub::detail::DataReaderHolder<T>(*this))));
00280     }
00281 
00282 #ifdef  OMG_DDS_CONTENT_SUBSCRIPTION_SUPPORT
00283     QueryCondition create_querycondition(
00284             const std::string& query_expression,
00285             const dds::core::StringSeq& query_parameters,
00286             const dds::sub::status::ReaderState& read_state =
00287                     dds::sub::status::ReaderState::any()) {
00288         return QueryCondition(new dds::sub::cond::detail::QueryCondition<T>());
00289     }
00290 #endif  // OMG_DDS_CONTENT_SUBSCRIPTION_SUPPORT
00291 };
00292 
00293 } }
00294 
00295 #endif /* OMG_DDS_SUB_DATA_READER_HPP_ */

Generated on Tue Nov 9 2010 02:16:21 for dds-psm-cxx-doc by  doxygen 1.7.1