OpenSplice ISO C++ 2 DCPS  v6.x
ISO C++ 2 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
DataWriter.hpp
Go to the documentation of this file.
1 #ifndef OMG_DDS_PUB_DETAIL_DATA_WRITER_HPP_
2 #define OMG_DDS_PUB_DETAIL_DATA_WRITER_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  */
21 
22 #include <dds/topic/Topic.hpp>
25 #include <org/opensplice/core/EntityDelegate.hpp>
26 #include <org/opensplice/topic/TopicTraits.hpp>
27 #include <org/opensplice/core/ScopedLock.hpp>
28 #include <org/opensplice/pub/AnyDataWriterDelegate.hpp>
29 
35 namespace dds {
36  namespace pub {
37 
38  template <typename T>
39  class DataWriterListener;
40 
41  namespace detail {
42  template <typename T>
43  class DataWriter;
44  }
45 
46  template <typename T>
47  class DataWriter;
48  }
49 }
50 
51 
52 
53 /***************************************************************************
54  *
55  * dds/pub/detail/DataWriter<> DELEGATE declaration.
56  * Implementation can be found in dds/pub/detail/DataWriterImpl.hpp
57  *
58  ***************************************************************************/
59 template <typename T>
60 class dds::pub::detail::DataWriter : public ::org::opensplice::pub::AnyDataWriterDelegate {
61 public:
62 
63  typedef typename ::dds::core::smart_ptr_traits< DataWriter<T> >::ref_type ref_type;
64  typedef typename ::dds::core::smart_ptr_traits< DataWriter<T> >::weak_ref_type weak_ref_type;
65 
66  DataWriter(const dds::pub::Publisher& pub,
67  const ::dds::topic::Topic<T>& topic,
70  const dds::core::status::StatusMask& mask);
71 
72  virtual ~DataWriter();
73 
74  void init(ObjectDelegate::weak_ref_type weak_ref);
75 
76  void write(const T& sample);
77 
78  void write(const T& sample, const dds::core::Time& timestamp);
79 
80  void write(const T& sample, const ::dds::core::InstanceHandle& instance);
81 
82  void write(const T& sample,
83  const ::dds::core::InstanceHandle& instance,
84  const dds::core::Time& timestamp);
85 
86  void write(const dds::topic::TopicInstance<T>& i);
87 
88  void write(const dds::topic::TopicInstance<T>& i,
89  const dds::core::Time& timestamp);
90 
91  void writedispose(const T& sample);
92 
93  void writedispose(const T& sample, const dds::core::Time& timestamp);
94 
95  void writedispose(const T& sample, const ::dds::core::InstanceHandle& instance);
96 
97  void writedispose(const T& sample,
98  const ::dds::core::InstanceHandle& instance,
99  const dds::core::Time& timestamp);
100 
101  void writedispose(const dds::topic::TopicInstance<T>& i);
102 
103  void writedispose(const dds::topic::TopicInstance<T>& i,
104  const dds::core::Time& timestamp);
105 
106  template <typename FWIterator>
107  void writedispose(const FWIterator& begin, const FWIterator& end);
108 
109  template <typename FWIterator>
110  void writedispose(const FWIterator& begin, const FWIterator& end,
111  const dds::core::Time& timestamp);
112 
113  template <typename SamplesFWIterator, typename HandlesFWIterator>
114  void writedispose(const SamplesFWIterator& data_begin,
115  const SamplesFWIterator& data_end,
116  const HandlesFWIterator& handle_begin,
117  const HandlesFWIterator& handle_end);
118 
119  template <typename SamplesFWIterator, typename HandlesFWIterator>
120  void writedispose(const SamplesFWIterator& data_begin,
121  const SamplesFWIterator& data_end,
122  const HandlesFWIterator& handle_begin,
123  const HandlesFWIterator& handle_end,
124  const dds::core::Time& timestamp);
125 
126  const ::dds::core::InstanceHandle register_instance(const T& key,
127  const dds::core::Time& timestamp);
128 
129  void unregister_instance(const ::dds::core::InstanceHandle& handle,
130  const dds::core::Time& timestamp);
131 
132  void unregister_instance(const T& sample,
133  const dds::core::Time& timestamp);
134 
135  void dispose_instance(const ::dds::core::InstanceHandle& handle,
136  const dds::core::Time& timestamp);
137 
138  void dispose_instance(const T& sample,
139  const dds::core::Time& timestamp);
140 
142  const ::dds::core::InstanceHandle& h);
143 
144  T& key_value(T& sample, const ::dds::core::InstanceHandle& h);
145 
146  dds::core::InstanceHandle lookup_instance(const T& key);
147 
148  const dds::topic::Topic<T>& topic() const;
149 
150  virtual const dds::pub::Publisher& publisher() const;
151 
152  void listener(DataWriterListener<T>* listener,
153  const ::dds::core::status::StatusMask& mask);
154 
155  DataWriterListener<T>* listener() const;
156 
157  virtual void close();
158 
160 
161  virtual void listener_notify(ObjectDelegate::ref_type source,
162  uint32_t triggerMask,
163  void *eventData,
164  void *listener);
165 
166 private:
167  dds::pub::Publisher pub_;
168  dds::topic::Topic<T> topic_;
169 };
170 
174 #endif /* OMG_DDS_PUB_DETAIL_DATA_WRITER_HPP_ */
DataWriter allows the application to set the value of the sample to be published under a given Topic...
Definition: DataWriter.hpp:88
A TopicInstance encapsulates a dds::sub::Sample and its associated dds::core::InstanceHandle.
Topic is the most basic description of the data to be published and subscribed.
Definition: Topic.hpp:36
Class to hold the handle associated with in sample instance.
Definition: array.hpp:23
StatusMask is a bitmap or bitset field.
Definition: State.hpp:144
DataWriter events Listener.
This object provides the basic mechanism for an application to specify Quality of Service attributes ...
The Publisher acts on the behalf of one or several DataWriter objects that belong to it...
Definition: Publisher.hpp:55
dds::sub::functors::InstanceManipulatorFunctor instance(const dds::core::InstanceHandle &h)