OpenSplice ISO C++ 2 DCPS  v6.x
ISO C++ 2 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
Sample.hpp
Go to the documentation of this file.
1 #ifndef OMG_DDS_PUB_DETAIL_SAMPLE_HPP_
2 #define OMG_DDS_PUB_DETAIL_SAMPLE_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 
28 namespace dds
29 {
30 namespace sub
31 {
32 namespace detail
33 {
34 template <typename T>
35 class Sample;
36 }}}
37 
38 #include <dds/sub/SampleInfo.hpp>
39 
40 namespace dds
41 {
42 namespace sub
43 {
44 namespace detail
45 {
46 template <typename T>
47 class Sample
48 {
49 public:
50  Sample() { }
51 
52  Sample(const T& d, const dds::sub::SampleInfo& i)
53  {
54  this->data_ = d;
55  this->info_ = i;
56  }
57 
58  Sample(const Sample& other)
59  {
60  copy(other);
61  }
62 
63  Sample& operator=(const Sample& other)
64  {
65  return copy(other);
66  }
67 
68  Sample& copy(const Sample& other)
69  {
70  this->data_ = other.data_;
71  this->info_ = other.info_;
72 
73  return *this;
74  }
75 
76 public:
77  const T& data() const
78  {
79  return data_;
80  }
81 
82  T& data()
83  {
84  return data_;
85  }
86 
87  void data(const T& d)
88  {
89  data_ = d;
90  }
91 
92  const dds::sub::SampleInfo& info() const
93  {
94  return info_;
95  }
96 
97  dds::sub::SampleInfo& info()
98  {
99  return info_;
100  }
101 
102  void info(const dds::sub::SampleInfo& i)
103  {
104  info_ = i;
105  }
106 
107  bool operator ==(const Sample& other) const
108  {
109  return false;
110  }
111 
112  T* data_ptr()
113  {
114  return &this->data_;
115  }
116 
117  dds::sub::SampleInfo *info_ptr()
118  {
119  return &this->info_;
120  }
121 
122 
123 private:
124  T data_;
125  dds::sub::SampleInfo info_;
126 };
127 
128 }
129 }
130 }
131 
134 #endif /* OMG_DDS_PUB_DETAIL_SAMPLE_HPP_ */
The SampleInfo contains information pertaining to the associated Data value.
Definition: SampleInfo.hpp:61
bool operator==(dds::core::null_type, const dds::core::Reference< D > &r)
Definition: array.hpp:23