00001 #ifndef OMG_DDS_SUB_SAMPLE_HPP_ 00002 #define OMG_DDS_SUB_SAMPLE_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/Exception.hpp> 00023 #include <dds/core/Value.hpp> 00024 #include <dds/core/Time.hpp> 00025 #include <dds/sub/subfwd.hpp> 00026 #include <dds/sub/detail/Sample.hpp> 00027 #include <dds/sub/status/ReaderState.hpp> 00028 #include <dds/sub/detail/Sample.hpp> 00029 00030 00031 namespace tdds {namespace sub { 00032 template <typename DELEGATE> 00033 class SampleInfo : dds::core::Value<DELEGATE> { 00034 public: 00035 SampleInfo(); 00036 SampleInfo(const SampleInfo& src); 00037 ~SampleInfo(); 00038 00039 public: 00040 // implementation-defined: 00041 SampleInfo(const dds::sub::detail::SampleInfo& src); 00042 00043 public: 00044 const dds::core::Time timestamp() const { 00045 return this->delegate().timestamp(); 00046 } 00047 00048 const dds::sub::status::ReaderState state() const { 00049 return this->delegate().state(); 00050 } 00051 const dds::sub::GenerationCount generation_count() const { 00052 return this->delegate().generation_count(); 00053 } 00054 const dds::sub::Rank rank() const { 00055 return this->delegate().rank(); 00056 } 00057 bool valid() const { 00058 return this->delegate().valid(); 00059 } 00060 }; 00061 00062 } } 00063 namespace dds { namespace sub { 00064 00065 template <typename T, typename DELEGATE> 00066 class Sample : public dds::core::Value<DELEGATE> 00067 { 00068 public: 00069 typedef T DataType; 00070 public: 00071 const DataType& data() const { 00072 return this->delegate().data(); 00073 } 00074 const SampleInfo& info() const { 00075 info_ = this->delegate().info(); 00076 return info_; 00077 } 00078 00079 private: 00080 mutable SampleInfo info_; 00081 }; 00082 00083 template <typename T, typename DELEGATE> 00084 class LoanedSamples : public dds::core::Value<DELEGATE> 00085 { 00086 public: 00087 typedef T DataType; 00088 typedef Sample<DataType> SampleType; 00089 00090 public: 00091 LoanedSamples() { /* implementation-defined */ } 00092 LoanedSamples(const LoanedSamples& src); 00093 00097 ~LoanedSamples() { /* implementation-defined */ } 00098 00099 public: 00100 class Iterator : public std::iterator<std::forward_iterator_tag, const SampleType> 00101 { 00102 public: 00103 Iterator() { /* implementation-defined */ } 00104 Iterator(const Iterator& src) { /* implementation-defined */ } 00105 ~Iterator() { /* implementation-defined */ } 00106 00107 public: 00108 Iterator& operator=(const Iterator& src); 00109 00110 bool operator==(const Iterator& other) const { 00111 // implementation-defined 00112 return false; 00113 } 00114 bool operator!=(const Iterator& other) const { 00115 // implementation-defined 00116 return false; 00117 } 00118 00119 Iterator& operator++() { // prefix 00120 // implementation-defined 00121 throw dds::core::UnsupportedError("LoanedSamples::Iterator::++"); 00122 } 00123 Iterator operator++(int) { // postfix 00124 // implementation-defined 00125 throw dds::core::UnsupportedError("LoanedSamples::Iterator::++"); 00126 } 00127 00128 const SampleType& operator*() { 00129 // implementation-defined 00130 throw dds::core::UnsupportedError("LoanedSamples::begin"); 00131 } 00132 const SampleType* operator->() { 00133 // implementation-defined 00134 throw dds::core::UnsupportedError("LoanedSamples::end"); 00135 } 00136 }; 00137 00138 public: 00139 const Iterator begin() const { 00140 // implementation-defined 00141 throw dds::core::UnsupportedError("LoanedSamples::begin"); 00142 } 00143 00144 const Iterator end() const { 00145 // implementation-defined 00146 throw dds::core::UnsupportedError("LoanedSamples::end"); 00147 } 00148 00149 public: 00150 void return_loan(); // explicitly return loan 00151 00152 }; 00153 00154 00155 } } 00156 00157 #endif /* OMG_DDS_SUB_SAMPLE_HPP_ */
1.7.1