Geant4  10.02.p03
boost::python::detail::proxy_group< Proxy > Class Template Reference

#include <indexing_suite_detail.hpp>

Collaboration diagram for boost::python::detail::proxy_group< Proxy >:

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
 
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
 
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
 
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 source/boost/detail/indexing_suite_detail.hpp.

Member Typedef Documentation

◆ const_iterator [1/2]

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

◆ const_iterator [2/2]

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

◆ index_type [1/2]

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

◆ index_type [2/2]

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

◆ iterator [1/2]

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

◆ iterator [2/2]

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

◆ policies_type [1/2]

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

◆ policies_type [2/2]

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

Member Function Documentation

◆ add() [1/2]

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

Definition at line 89 of file source/boost/detail/indexing_suite_detail.hpp.

90  {
92  // Add a proxy
93  proxies.insert(
94  first_proxy(extract<Proxy&>(prox)().get_index()), prox);
96  }
#define BOOST_PYTHON_INDEXING_CHECK_INVARIANT

◆ add() [2/2]

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

Definition at line 89 of file tests/test12/module/include/detail/indexing_suite_detail.hpp.

90  {
92  // Add a proxy
93  proxies.insert(
94  first_proxy(extract<Proxy&>(prox)().get_index()), prox);
96  }

◆ check_invariant() [1/2]

template<class Proxy >
void boost::python::detail::proxy_group< Proxy >::check_invariant ( ) const
inlineprivate

Definition at line 215 of file source/boost/detail/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  }
std::vector< PyObject * >::const_iterator const_iterator

◆ check_invariant() [2/2]

template<class Proxy >
void boost::python::detail::proxy_group< Proxy >::check_invariant ( ) const
inlineprivate

Definition at line 215 of file tests/test12/module/include/detail/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  }
std::vector< PyObject * >::const_iterator const_iterator

◆ erase() [1/6]

template<class Proxy >
void boost::python::detail::proxy_group< Proxy >::erase ( index_type  i,
mpl::false_   
)
inline

Definition at line 99 of file source/boost/detail/indexing_suite_detail.hpp.

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

◆ erase() [2/6]

template<class Proxy >
void boost::python::detail::proxy_group< Proxy >::erase ( index_type  i,
mpl::false_   
)
inline

Definition at line 99 of file tests/test12/module/include/detail/indexing_suite_detail.hpp.

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)

◆ erase() [3/6]

template<class Proxy >
void boost::python::detail::proxy_group< Proxy >::erase ( index_type  i,
mpl::true_   
)
inline

Definition at line 108 of file source/boost/detail/indexing_suite_detail.hpp.

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

◆ erase() [4/6]

template<class Proxy >
void boost::python::detail::proxy_group< Proxy >::erase ( index_type  i,
mpl::true_   
)
inline

Definition at line 108 of file tests/test12/module/include/detail/indexing_suite_detail.hpp.

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  }

◆ erase() [5/6]

template<class Proxy >
void boost::python::detail::proxy_group< Proxy >::erase ( index_type  from,
index_type  to 
)
inline

Definition at line 126 of file tests/test12/module/include/detail/indexing_suite_detail.hpp.

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)

◆ erase() [6/6]

template<class Proxy >
void boost::python::detail::proxy_group< Proxy >::erase ( index_type  from,
index_type  to 
)
inline

Definition at line 126 of file source/boost/detail/indexing_suite_detail.hpp.

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

◆ find() [1/2]

template<class Proxy >
PyObject* boost::python::detail::proxy_group< Proxy >::find ( index_type  i)
inline

Definition at line 186 of file source/boost/detail/indexing_suite_detail.hpp.

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

◆ find() [2/2]

template<class Proxy >
PyObject* boost::python::detail::proxy_group< Proxy >::find ( index_type  i)
inline

Definition at line 186 of file tests/test12/module/include/detail/indexing_suite_detail.hpp.

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  }

◆ first_proxy() [1/2]

template<class Proxy >
iterator boost::python::detail::proxy_group< Proxy >::first_proxy ( index_type  i)
inline

Definition at line 64 of file tests/test12/module/include/detail/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  }

◆ first_proxy() [2/2]

template<class Proxy >
iterator boost::python::detail::proxy_group< Proxy >::first_proxy ( index_type  i)
inline

Definition at line 64 of file source/boost/detail/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  }

◆ remove() [1/2]

template<class Proxy >
void boost::python::detail::proxy_group< Proxy >::remove ( Proxy &  proxy)
inline

Definition at line 73 of file source/boost/detail/indexing_suite_detail.hpp.

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  }
#define BOOST_PYTHON_INDEXING_CHECK_INVARIANT

◆ remove() [2/2]

template<class Proxy >
void boost::python::detail::proxy_group< Proxy >::remove ( Proxy &  proxy)
inline

Definition at line 73 of file tests/test12/module/include/detail/indexing_suite_detail.hpp.

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  }

◆ replace() [1/2]

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 tests/test12/module/include/detail/indexing_suite_detail.hpp.

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  }

◆ replace() [2/2]

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 source/boost/detail/indexing_suite_detail.hpp.

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  }
#define BOOST_PYTHON_INDEXING_CHECK_INVARIANT

◆ size() [1/2]

template<class Proxy >
std::vector<PyObject*>::size_type boost::python::detail::proxy_group< Proxy >::size ( ) const
inline

Definition at line 204 of file source/boost/detail/indexing_suite_detail.hpp.

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

◆ size() [2/2]

template<class Proxy >
std::vector<PyObject*>::size_type boost::python::detail::proxy_group< Proxy >::size ( ) const
inline

Definition at line 204 of file tests/test12/module/include/detail/indexing_suite_detail.hpp.

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

Member Data Documentation

◆ proxies

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

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