Main MRPT website > C++ reference for MRPT 1.9.9
ContainerReadOnlyProxyAccessor.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <cstdlib> // size_t
12 #include <mrpt/core/exceptions.h>
13 
14 namespace mrpt
15 {
16 namespace containers
17 {
18 /** \addtogroup stlext_grp
19  * @{ */
20 
21 /** A generic proxy accessor template that only allows read-only access to the
22  * original binded STL container object. */
23 template <typename STLCONTAINER>
25 {
26  /** ctor: binds to source object */
28  /** (Deleted ctor) ignore copies (keep reference to original object) */
31  /** Don't copy the reference to the source object, but copy the contained
32  * data. This is only allowed if the size of the buffers coincide. */
35  {
36  ASSERT_EQUAL_(m_source.size(), o.m_source.size());
37  m_source = o.m_source;
38  return *this;
39  }
40  /** Transparent conversion to const ref to original source object. */
41  operator const STLCONTAINER&() const { return m_source; }
42  size_t size() const { return m_source.size(); }
43  const typename STLCONTAINER::value_type& operator[](const int i) const
44  {
45  return m_source[i];
46  }
47 
49  {
50  return m_source.begin();
51  }
52  typename STLCONTAINER::const_iterator end() const { return m_source.end(); }
53  typename STLCONTAINER::const_reverse_iterator rbegin() const
54  {
55  return m_source.rbegin();
56  }
57  typename STLCONTAINER::const_reverse_iterator rend() const
58  {
59  return m_source.rend();
60  }
61 
62  private:
63  STLCONTAINER& m_source;
64 };
65 
66 /** @} */ // end of grouping
67 }
68 }
mrpt::containers::ContainerReadOnlyProxyAccessor::m_source
STLCONTAINER & m_source
Definition: ContainerReadOnlyProxyAccessor.h:63
exceptions.h
const_iterator
const Scalar * const_iterator
Definition: eigen_plugins.h:27
mrpt::containers::ContainerReadOnlyProxyAccessor::end
STLCONTAINER::const_iterator end() const
Definition: ContainerReadOnlyProxyAccessor.h:52
ASSERT_EQUAL_
#define ASSERT_EQUAL_(__A, __B)
Assert comparing two values, reporting their actual values upon failure.
Definition: exceptions.h:153
mrpt::containers::ContainerReadOnlyProxyAccessor::operator=
ContainerReadOnlyProxyAccessor< STLCONTAINER > & operator=(const ContainerReadOnlyProxyAccessor< STLCONTAINER > &o)
Don't copy the reference to the source object, but copy the contained data.
Definition: ContainerReadOnlyProxyAccessor.h:33
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::containers::ContainerReadOnlyProxyAccessor::ContainerReadOnlyProxyAccessor
ContainerReadOnlyProxyAccessor(STLCONTAINER &source)
ctor: binds to source object
Definition: ContainerReadOnlyProxyAccessor.h:27
source
GLsizei GLsizei GLchar * source
Definition: glext.h:4082
mrpt::containers::ContainerReadOnlyProxyAccessor::size
size_t size() const
Definition: ContainerReadOnlyProxyAccessor.h:42
mrpt::containers::ContainerReadOnlyProxyAccessor::begin
STLCONTAINER::const_iterator begin() const
Definition: ContainerReadOnlyProxyAccessor.h:48
mrpt::containers::ContainerReadOnlyProxyAccessor
A generic proxy accessor template that only allows read-only access to the original binded STL contai...
Definition: ContainerReadOnlyProxyAccessor.h:24
mrpt::containers::ContainerReadOnlyProxyAccessor::operator[]
const STLCONTAINER::value_type & operator[](const int i) const
Definition: ContainerReadOnlyProxyAccessor.h:43
mrpt::containers::ContainerReadOnlyProxyAccessor::rend
STLCONTAINER::const_reverse_iterator rend() const
Definition: ContainerReadOnlyProxyAccessor.h:57
mrpt::containers::ContainerReadOnlyProxyAccessor::rbegin
STLCONTAINER::const_reverse_iterator rbegin() const
Definition: ContainerReadOnlyProxyAccessor.h:53



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST