LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
boost::python::map_indexing_suite< Container, NoProxy, DerivedPolicies > Class Template Reference

#include "map_indexing_suite.hpp"

Inheritance diagram for boost::python::map_indexing_suite< Container, NoProxy, DerivedPolicies >:
boost::python::indexing_suite< Container, DerivedPolicies, NoProxy, true, Container::value_type::second_type, Container::key_type, Container::key_type >

Public Types

typedef Container::value_type value_type
 
typedef Container::value_type::second_type data_type
 
typedef Container::key_type key_type
 
typedef Container::key_type index_type
 
typedef Container::size_type size_type
 
typedef Container::difference_type difference_type
 

Public Member Functions

void visit (Class &cl) const
 

Static Public Member Functions

template<class Class >
static void extension_def (Class &cl)
 
static object print_elem (typename Container::value_type const &e)
 
static mpl::if_< is_class< data_type >, data_type &, data_type >::type get_data (typename Container::value_type &e)
 
static Container::key_type get_key (typename Container::value_type &e)
 
static data_typeget_item (Container &container, index_type i_)
 
static void set_item (Container &container, index_type i, data_type const &v)
 
static void delete_item (Container &container, index_type i)
 
static size_t size (Container &container)
 
static bool contains (Container &container, key_type const &key)
 
static bool compare_index (Container &container, index_type a, index_type b)
 
static index_type convert_index (Container &container, PyObject *i_)
 

Detailed Description

template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_map_derived_policies<Container, NoProxy>>
class boost::python::map_indexing_suite< Container, NoProxy, DerivedPolicies >

Definition at line 18 of file map_indexing_suite.hpp.

Member Typedef Documentation

template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_map_derived_policies<Container, NoProxy>>
typedef Container::value_type::second_type boost::python::map_indexing_suite< Container, NoProxy, DerivedPolicies >::data_type

Definition at line 63 of file map_indexing_suite.hpp.

template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_map_derived_policies<Container, NoProxy>>
typedef Container::difference_type boost::python::map_indexing_suite< Container, NoProxy, DerivedPolicies >::difference_type

Definition at line 67 of file map_indexing_suite.hpp.

template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_map_derived_policies<Container, NoProxy>>
typedef Container::key_type boost::python::map_indexing_suite< Container, NoProxy, DerivedPolicies >::index_type

Definition at line 65 of file map_indexing_suite.hpp.

template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_map_derived_policies<Container, NoProxy>>
typedef Container::key_type boost::python::map_indexing_suite< Container, NoProxy, DerivedPolicies >::key_type

Definition at line 64 of file map_indexing_suite.hpp.

template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_map_derived_policies<Container, NoProxy>>
typedef Container::size_type boost::python::map_indexing_suite< Container, NoProxy, DerivedPolicies >::size_type

Definition at line 66 of file map_indexing_suite.hpp.

template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_map_derived_policies<Container, NoProxy>>
typedef Container::value_type boost::python::map_indexing_suite< Container, NoProxy, DerivedPolicies >::value_type

Definition at line 62 of file map_indexing_suite.hpp.

Member Function Documentation

template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_map_derived_policies<Container, NoProxy>>
static bool boost::python::map_indexing_suite< Container, NoProxy, DerivedPolicies >::compare_index ( Container &  container,
index_type  a,
index_type  b 
)
inlinestatic

Definition at line 153 of file map_indexing_suite.hpp.

154  {
155  return container.key_comp()(a, b);
156  }
template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_map_derived_policies<Container, NoProxy>>
static bool boost::python::map_indexing_suite< Container, NoProxy, DerivedPolicies >::contains ( Container &  container,
key_type const &  key 
)
inlinestatic

Definition at line 147 of file map_indexing_suite.hpp.

148  {
149  return container.find(key) != container.end();
150  }
template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_map_derived_policies<Container, NoProxy>>
static index_type boost::python::map_indexing_suite< Container, NoProxy, DerivedPolicies >::convert_index ( Container &  container,
PyObject *  i_ 
)
inlinestatic

Definition at line 159 of file map_indexing_suite.hpp.

160  {
161  extract<key_type const&> i(i_);
162  if (i.check())
163  {
164  return i();
165  }
166  else
167  {
168  extract<key_type> i(i_);
169  if (i.check())
170  return i();
171  }
172 
173  PyErr_SetString(PyExc_TypeError, "Invalid index type");
174  throw_error_already_set();
175  return index_type();
176  }
template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_map_derived_policies<Container, NoProxy>>
static void boost::python::map_indexing_suite< Container, NoProxy, DerivedPolicies >::delete_item ( Container &  container,
index_type  i 
)
inlinestatic

Definition at line 135 of file map_indexing_suite.hpp.

136  {
137  container.erase(i);
138  }
template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_map_derived_policies<Container, NoProxy>>
template<class Class >
static void boost::python::map_indexing_suite< Container, NoProxy, DerivedPolicies >::extension_def ( Class &  cl)
inlinestatic

Definition at line 71 of file map_indexing_suite.hpp.

72  {
73  // Wrap the map's element (value_type)
74  std::string elem_name = "map_indexing_suite_";
75  object class_name(cl.attr("__name__"));
76  extract<std::string> class_name_extractor(class_name);
77  elem_name += class_name_extractor();
78  elem_name += "_entry";
79 
80  typedef typename mpl::if_<
81  is_class<data_type>
82  , return_internal_reference<>
83  , default_call_policies
84  >::type get_data_return_policy;
85 
86  class_<value_type>(elem_name.c_str())
87  .def("__repr__", &DerivedPolicies::print_elem)
88  .def("data", &DerivedPolicies::get_data, get_data_return_policy())
89  .def("key", &DerivedPolicies::get_key)
90  ;
91  }
template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_map_derived_policies<Container, NoProxy>>
static mpl::if_< is_class<data_type> , data_type& , data_type >::type boost::python::map_indexing_suite< Container, NoProxy, DerivedPolicies >::get_data ( typename Container::value_type &  e)
inlinestatic

Definition at line 105 of file map_indexing_suite.hpp.

106  {
107  return e.second;
108  }
Float_t e
Definition: plot.C:35
template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_map_derived_policies<Container, NoProxy>>
static data_type& boost::python::map_indexing_suite< Container, NoProxy, DerivedPolicies >::get_item ( Container &  container,
index_type  i_ 
)
inlinestatic

Definition at line 117 of file map_indexing_suite.hpp.

118  {
119  typename Container::iterator i = container.find(i_);
120  if (i == container.end())
121  {
122  PyErr_SetString(PyExc_KeyError, "Invalid key");
123  throw_error_already_set();
124  }
125  return i->second;
126  }
intermediate_table::iterator iterator
template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_map_derived_policies<Container, NoProxy>>
static Container::key_type boost::python::map_indexing_suite< Container, NoProxy, DerivedPolicies >::get_key ( typename Container::value_type &  e)
inlinestatic

Definition at line 111 of file map_indexing_suite.hpp.

112  {
113  return e.first;
114  }
Float_t e
Definition: plot.C:35
template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_map_derived_policies<Container, NoProxy>>
static object boost::python::map_indexing_suite< Container, NoProxy, DerivedPolicies >::print_elem ( typename Container::value_type const &  e)
inlinestatic

Definition at line 94 of file map_indexing_suite.hpp.

95  {
96  return "(%s, %s)" % python::make_tuple(e.first, e.second);
97  }
Float_t e
Definition: plot.C:35
template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_map_derived_policies<Container, NoProxy>>
static void boost::python::map_indexing_suite< Container, NoProxy, DerivedPolicies >::set_item ( Container &  container,
index_type  i,
data_type const &  v 
)
inlinestatic

Definition at line 129 of file map_indexing_suite.hpp.

130  {
131  container[i] = v;
132  }
template<class Container, bool NoProxy = false, class DerivedPolicies = detail::final_map_derived_policies<Container, NoProxy>>
static size_t boost::python::map_indexing_suite< Container, NoProxy, DerivedPolicies >::size ( Container &  container)
inlinestatic

Definition at line 141 of file map_indexing_suite.hpp.

142  {
143  return container.size();
144  }
void boost::python::indexing_suite< Container, DerivedPolicies, NoProxy, NoSlice, Container::value_type::second_type , Container::key_type , Container::key_type >::visit ( Class &  cl) const
inlineinherited

Definition at line 173 of file indexing_suite.hpp.

174  {
175  // Hook into the class_ generic visitation .def function
176  proxy_handler::register_container_element();
177 
178  cl
179  .def("__len__", base_size)
180  .def("__setitem__", &base_set_item)
181  .def("__delitem__", &base_delete_item)
182  .def("__getitem__", &base_get_item)
183  .def("__contains__", &base_contains)
184  .def("__iter__", def_iterator())
185  ;
186 
187  DerivedPolicies::extension_def(cl);
188  }

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