LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
boost::python::detail::proxy_group< Proxy > Class Template Reference

#include "indexing_suite_detail.hpp"

Public Types

typedef std::vector< PyObject * >::const_iterator const_iterator
 
typedef std::vector< PyObject * >::iterator iterator
 
typedef Proxy::index_type index_type
 
typedef Proxy::policies_type policies_type
 

Public Member Functions

iterator first_proxy (index_type i)
 
void remove (Proxy &proxy)
 
void add (PyObject *prox)
 
void erase (index_type i, mpl::false_)
 
void erase (index_type i, mpl::true_)
 
void erase (index_type from, index_type to)
 
void replace (index_type from, index_type to, typename std::vector< PyObject * >::size_type len)
 
PyObject * find (index_type i)
 
std::vector< PyObject * >::size_type size () const
 

Private Member Functions

void check_invariant () const
 

Private Attributes

std::vector< PyObject * > proxies
 

Detailed Description

template<class Proxy>
class boost::python::detail::proxy_group< Proxy >

Definition at line 54 of file indexing_suite_detail.hpp.

Member Typedef Documentation

template<class Proxy >
typedef std::vector<PyObject*>::const_iterator boost::python::detail::proxy_group< Proxy >::const_iterator

Definition at line 58 of file indexing_suite_detail.hpp.

template<class Proxy >
typedef Proxy::index_type boost::python::detail::proxy_group< Proxy >::index_type

Definition at line 60 of file indexing_suite_detail.hpp.

template<class Proxy >
typedef std::vector<PyObject*>::iterator boost::python::detail::proxy_group< Proxy >::iterator

Definition at line 59 of file indexing_suite_detail.hpp.

template<class Proxy >
typedef Proxy::policies_type boost::python::detail::proxy_group< Proxy >::policies_type

Definition at line 61 of file indexing_suite_detail.hpp.

Member Function Documentation

template<class Proxy >
void boost::python::detail::proxy_group< Proxy >::add ( PyObject *  prox)
inline

Definition at line 89 of file indexing_suite_detail.hpp.

References BOOST_PYTHON_INDEXING_CHECK_INVARIANT.

90  {
92  // Add a proxy
93  proxies.insert(
94  first_proxy(extract<Proxy&>(prox)().get_index()), prox);
96  }
#define BOOST_PYTHON_INDEXING_CHECK_INVARIANT
template<class Proxy >
void boost::python::detail::proxy_group< Proxy >::check_invariant ( ) const
inlineprivate

Definition at line 215 of file indexing_suite_detail.hpp.

216  {
217  for (const_iterator i = proxies.begin(); i != proxies.end(); ++i)
218  {
219  if ((*i)->ob_refcnt <= 0)
220  {
221  PyErr_SetString(PyExc_RuntimeError,
222  "Invariant: Proxy vector in an inconsistent state");
223  throw_error_already_set();
224  }
225 
226  if (i+1 != proxies.end())
227  {
228  if (extract<Proxy&>(*(i+1))().get_index() ==
229  extract<Proxy&>(*(i))().get_index())
230  {
231  PyErr_SetString(PyExc_RuntimeError,
232  "Invariant: Proxy vector in an inconsistent state (duplicate proxy)");
233  throw_error_already_set();
234  }
235  }
236  }
237  }
template<class Proxy >
void boost::python::detail::proxy_group< Proxy >::erase ( index_type  i,
mpl::false_   
)
inline

Definition at line 99 of file indexing_suite_detail.hpp.

References BOOST_PYTHON_INDEXING_CHECK_INVARIANT.

100  {
102  // Erase the proxy with index i
103  replace(i, i+1, 0);
105  }
void replace(index_type from, index_type to, typename std::vector< PyObject * >::size_type len)
#define BOOST_PYTHON_INDEXING_CHECK_INVARIANT
template<class Proxy >
void boost::python::detail::proxy_group< Proxy >::erase ( index_type  i,
mpl::true_   
)
inline

Definition at line 108 of file indexing_suite_detail.hpp.

References BOOST_PYTHON_INDEXING_CHECK_INVARIANT.

109  {
111  // Erase the proxy with index i
112 
113  iterator iter = first_proxy(i);
114  extract<Proxy&> p(*iter);
115 
116  if (iter != proxies.end() && p().get_index() == i)
117  {
118  extract<Proxy&> p(*iter);
119  p().detach();
120  proxies.erase(iter);
121  }
123  }
#define BOOST_PYTHON_INDEXING_CHECK_INVARIANT
template<class Proxy >
void boost::python::detail::proxy_group< Proxy >::erase ( index_type  from,
index_type  to 
)
inline

Definition at line 126 of file indexing_suite_detail.hpp.

References BOOST_PYTHON_INDEXING_CHECK_INVARIANT.

127  {
128  // note: this cannot be called when container is not sliceable
129 
131  // Erase all proxies with indexes from..to
132  replace(from, to, 0);
134  }
void replace(index_type from, index_type to, typename std::vector< PyObject * >::size_type len)
#define BOOST_PYTHON_INDEXING_CHECK_INVARIANT
template<class Proxy >
PyObject* boost::python::detail::proxy_group< Proxy >::find ( index_type  i)
inline

Definition at line 186 of file indexing_suite_detail.hpp.

References BOOST_PYTHON_INDEXING_CHECK_INVARIANT.

187  {
189  // Find the proxy with *exact* index i.
190  // Return 0 (null) if no proxy with the
191  // given index is found.
192  iterator iter = first_proxy(i);
193  if (iter != proxies.end()
194  && extract<Proxy&>(*iter)().get_index() == i)
195  {
197  return *iter;
198  }
200  return 0;
201  }
#define BOOST_PYTHON_INDEXING_CHECK_INVARIANT
template<class Proxy >
iterator boost::python::detail::proxy_group< Proxy >::first_proxy ( index_type  i)
inline

Definition at line 64 of file indexing_suite_detail.hpp.

65  {
66  // Return the first proxy with index <= i
67  return boost::detail::lower_bound(
68  proxies.begin(), proxies.end(),
69  i, compare_proxy_index<Proxy>());
70  }
template<class Proxy >
void boost::python::detail::proxy_group< Proxy >::remove ( Proxy &  proxy)
inline

Definition at line 73 of file indexing_suite_detail.hpp.

References BOOST_PYTHON_INDEXING_CHECK_INVARIANT.

74  {
75  // Remove a proxy
76  for (iterator iter = first_proxy(proxy.get_index());
77  iter != proxies.end(); ++iter)
78  {
79  if (&extract<Proxy&>(*iter)() == &proxy)
80  {
81  proxies.erase(iter);
82  break;
83  }
84  }
86  }
Encloses LArSoft data product proxy objects and utilities.See this doxygen module for an introduction...
#define BOOST_PYTHON_INDEXING_CHECK_INVARIANT
template<class Proxy >
void boost::python::detail::proxy_group< Proxy >::replace ( index_type  from,
index_type  to,
typename std::vector< PyObject * >::size_type  len 
)
inline

Definition at line 137 of file indexing_suite_detail.hpp.

References BOOST_PYTHON_INDEXING_CHECK_INVARIANT, art::left(), and art::right().

141  {
142  // note: this cannot be called when container is not sliceable
143 
145  // Erase all proxies with indexes from..to.
146  // Adjust the displaced indexes such that the
147  // final effect is that we have inserted *len*
148  // number of proxies in the vacated region. This
149  // procedure involves adjusting the indexes of
150  // the proxies.
151 
152  iterator left = first_proxy(from);
153  iterator right = proxies.end(); // we'll adjust this later
154 
155  for (iterator iter = left; iter != right; ++iter)
156  {
157  if (extract<Proxy&>(*iter)().get_index() > to)
158  {
159  right = iter; // adjust right
160  break;
161  }
162  extract<Proxy&> p(*iter);
163  p().detach();
164  }
165 
166  typename std::vector<PyObject*>::size_type
167  offset = left-proxies.begin();
168  proxies.erase(left, right);
169  right = proxies.begin()+offset;
170 
171  while (right != proxies.end())
172  {
173  typedef typename Proxy::container_type::difference_type difference_type;
174  extract<Proxy&> p(*right);
175  p().set_index(
176  extract<Proxy&>(*right)().get_index()
177  - (difference_type(to) - from - len)
178  );
179 
180  ++right;
181  }
183  }
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:112
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:104
#define BOOST_PYTHON_INDEXING_CHECK_INVARIANT
template<class Proxy >
std::vector<PyObject*>::size_type boost::python::detail::proxy_group< Proxy >::size ( void  ) const
inline

Definition at line 204 of file indexing_suite_detail.hpp.

References BOOST_PYTHON_INDEXING_CHECK_INVARIANT.

205  {
207  // How many proxies are there so far?
208  return proxies.size();
209  }
#define BOOST_PYTHON_INDEXING_CHECK_INVARIANT

Member Data Documentation

template<class Proxy >
std::vector<PyObject*> boost::python::detail::proxy_group< Proxy >::proxies
private

Definition at line 240 of file indexing_suite_detail.hpp.


The documentation for this class was generated from the following file: