00001 #ifndef OMG_DDS_PUB_DETAIL_ANY_DATA_WRITER_HPP_ 00002 #define OMG_DDS_PUB_DETAIL_ANY_DATA_WRITER_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 <string> 00023 #include <dds/pub/parent.hpp> 00024 #include <dds/pub/qos/DataWriterQos.hpp> 00025 00026 namespace dds { namespace pub { namespace detail { 00027 class DWHolderBase { 00028 public: 00029 virtual ~DWHolderBase() { } 00030 virtual const dds::pub::qos::DataWriterQos qos() const = 0; 00031 00032 virtual void qos(const dds::pub::qos::DataWriterQos& qos) = 0; 00033 00034 virtual const std::string topic_name() const = 0; 00035 00036 virtual const std::string type_name() const = 0; 00037 00038 virtual dds::pub::Publisher parent() const = 0; 00039 00040 virtual void wait_for_acknowledgments(const dds::core::Duration& timeout) = 0; 00041 00042 virtual void close() = 0; 00043 00044 virtual void retain(bool b) = 0; 00045 }; 00046 00047 template <typename T> 00048 class DWHolder : public DWHolderBase { 00049 public: 00050 DWHolder(const dds::pub::DataWriter<T>& dw) : dw_(dw) { } 00051 virtual ~DWHolder() { } 00052 public: 00053 virtual const dds::pub::qos::DataWriterQos qos() const { 00054 return dw_.qos(); 00055 } 00056 00057 virtual void qos(const dds::pub::qos::DataWriterQos& the_qos) { 00058 return dw_.qos(the_qos); 00059 } 00060 00061 virtual const std::string topic_name() const { 00062 return dw_.topic().name(); 00063 } 00064 00065 virtual const std::string type_name() const { 00066 return dw_.topic().type_name(); 00067 } 00068 00069 virtual dds::pub::Publisher parent() const { 00070 return dds::pub::parent(dw_); 00071 } 00072 00073 virtual void wait_for_acknowledgments(const dds::core::Duration& timeout) { 00074 dw_.wait_for_acknowledgments(timeout); 00075 } 00076 00077 virtual void close() { 00078 dw_.close(); 00079 } 00080 00081 virtual void retain(bool b) { } 00082 00083 const dds::pub::DataWriter<T>& get() const { return dw_; } 00084 00085 private: 00086 dds::pub::DataWriter<T> dw_; 00087 }; 00088 } } } 00089 00090 #endif /* OMG_DDS_PUB_DETAIL_ANY_DATA_WRITER_HPP_ */
1.7.1