OpenSplice ISO C++ 2 DCPS  v6.x
ISO C++ 2 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
LoanedSamples.hpp
Go to the documentation of this file.
1 /*
2  * Vortex OpenSplice
3  *
4  * This software and documentation are Copyright 2006 to 2021 ADLINK
5  * Technology Limited, its affiliated companies and licensors. All rights
6  * reserved.
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 #ifndef OMG_SUB_DETAIL_LOANED_SAMPLES_IMPL_HPP_
21 #define OMG_SUB_DETAIL_LOANED_SAMPLES_IMPL_HPP_
22 
28 namespace dds
29 {
30 namespace sub
31 {
32 namespace detail
33 {
34 
35 template <typename T>
36 class LoanedSamples
37 {
38 public:
39 
40  typedef std::vector< dds::sub::Sample<T, dds::sub::detail::Sample> > LoanedSamplesContainer;
41  typedef typename std::vector< dds::sub::Sample<T, dds::sub::detail::Sample> >::iterator iterator;
42  typedef typename std::vector< dds::sub::Sample<T, dds::sub::detail::Sample> >::const_iterator const_iterator;
43 
44 public:
45  LoanedSamples() { }
46 
47  ~LoanedSamples()
48  {
49 
50  }
51 
52 public:
53 
54  iterator mbegin()
55  {
56  return samples_.begin();
57  }
58 
59  const_iterator begin() const
60  {
61  return samples_.begin();
62  }
63 
64  const_iterator end() const
65  {
66  return samples_.end();
67  }
68 
69  uint32_t length() const
70  {
71  return static_cast<uint32_t>(samples_.size());
72  }
73 
74  void reserve(uint32_t s)
75  {
76  samples_.reserve(s);
77  }
78 
79  void resize(uint32_t s)
80  {
81  samples_.resize(s);
82  }
83 
84  dds::sub::Sample<T, dds::sub::detail::Sample>& operator[] (uint32_t i)
85  {
86  return this->samples_[i];
87  }
88 
90  return this->samples_.data();
91  }
92 
93 
94 private:
95  LoanedSamplesContainer samples_;
96 };
97 
98 }
99 }
100 }
101 
104 #endif /* OMG_SUB_DETAIL_LOANED_SAMPLES_IMPL_HPP_ */
const DataType & data() const
Definition: SampleImpl.hpp:49
Definition: array.hpp:23
This class encapsulates the data and info meta-data associated with DDS samples.
Definition: Sample.hpp:30