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

src/hpp/dds/pub/detail/DataWriter.hpp

Go to the documentation of this file.
00001 #ifndef OMG_DDS_PUB_DETAIL_DATA_WRITER_HPP_
00002 #define OMG_DDS_PUB_DETAIL_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 <dds/core/corefwd.hpp>
00023 #include <dds/core/InstanceHandle.hpp>
00024 #include <dds/topic/TopicInstance.hpp>
00025 #include <dds/topic/Topic.hpp>
00026 #include <dds/pub/detail/pubfwd.hpp>
00027 #include <dds/pub/qos/DataWriterQos.hpp>
00028 #include <idds/core/EntityImpl.hpp>
00029 
00030 
00031 namespace dds { namespace pub { namespace detail {
00032 
00033 template <typename T>
00034 class DataWriter : public idds::core::EntityImpl {
00035 public:
00036     DataWriter() { }
00037     DataWriter(const dds::topic::Topic<T>& the_topic,
00038                 const dds::core::smart_ptr_traits<dds::pub::detail::PublisherHolder>::ref_type& pub)
00039     : topic_(the_topic), pub_(pub) {    }
00040 
00041     DataWriter(const dds::topic::Topic<T>& the_topic,
00042                const dds::pub::qos::DataWriterQos& the_qos,
00043                const dds::core::smart_ptr_traits<dds::pub::detail::PublisherHolder>::ref_type& pub)
00044     : topic_(the_topic), qos_(the_qos), pub_(pub) { }
00045 
00046     virtual ~DataWriter() { }
00047 
00048 public:
00053     template <typename SELF>
00054     ::dds::core::cond::StatusCondition<SELF>
00055     status_condition(const SELF& self) const {
00056         return ::dds::core::cond::StatusCondition<SELF>(
00057                 new dds::core::cond::detail::StatusCondition<SELF>(self));
00058     }
00059 
00060 public:
00061         void write(const T& sample) {
00062                 std::cout << "write(s) >>" << sample << std::endl;
00063         }
00064 
00065         void write(const T& sample, const dds::core::Time& timestamp) {
00066                 std::cout << ">> write(s, ts) >> " << sample << std::endl;
00067         }
00068 
00069         void write(const T& sample, const dds::core::InstanceHandle& instance) {
00070                 std::cout << "write(s+i) >>" << sample << std::endl;
00071         }
00072 
00073         void write(const T& sample,
00074                const dds::core::InstanceHandle& instance,
00075                const dds::core::Time& timestamp) {
00076                 std::cout << "write(s+i, ts) >>" << sample << std::endl;
00077         }
00078 
00079         void write(const dds::topic::TopicInstance<T>& i) {
00080                 std::cout << ">> write(ti)" << std::endl;
00081         }
00082 
00083         void write(const dds::topic::TopicInstance<T>& i, const dds::core::Time& timestamp) {
00084                 std::cout << ">> write(ti, ts)" << std::endl;
00085         }
00086 
00087         const dds::core::InstanceHandle register_instance(const T& key) {
00088                 return dds::topic::TopicInstance<T>(0);
00089         }
00090 
00091 
00092         const dds::pub::qos::DataWriterQos qos() const {
00093                 return qos_;
00094         }
00095 
00096         void qos(const dds::pub::qos::DataWriterQos& the_qos) {
00097                 qos_ = the_qos;
00098         }
00099 
00100         dds::topic::Topic<T> topic() const {
00101                 return topic_;
00102         }
00103 
00104     PublisherHolder* parent() const {
00105         return pub_.get();
00106     }
00107 
00108         bool wait_for_acknowledgments(const dds::core::Duration& timeout) {
00109                 return true;
00110         }
00111 
00112 private:
00113     dds::topic::Topic<T>            topic_;
00114     dds::pub::qos::DataWriterQos    qos_;
00115     const dds::core::smart_ptr_traits<dds::pub::detail::PublisherHolder>::ref_type&  pub_;
00116 };
00117 
00118 } } }
00119 
00120 #endif /* OMG_DDS_PUB_DETAIL_DATA_WRITER_HPP_ */
00121 

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