Warning, file /include/boost/python/object/pickle_support.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005 #ifndef BOOST_PYTHON_OBJECT_PICKLE_SUPPORT_RWGK20020603_HPP
0006 # define BOOST_PYTHON_OBJECT_PICKLE_SUPPORT_RWGK20020603_HPP
0007
0008 # include <boost/python/detail/prefix.hpp>
0009
0010 namespace boost { namespace python {
0011
0012 namespace api
0013 {
0014 class object;
0015 }
0016 using api::object;
0017 class tuple;
0018
0019 BOOST_PYTHON_DECL object const& make_instance_reduce_function();
0020
0021 struct pickle_suite;
0022
0023 namespace error_messages {
0024
0025 template <class T>
0026 struct missing_pickle_suite_function_or_incorrect_signature {};
0027
0028 inline void must_be_derived_from_pickle_suite(pickle_suite const&) {}
0029 }
0030
0031 namespace detail { struct pickle_suite_registration; }
0032
0033 struct pickle_suite
0034 {
0035 private:
0036 struct inaccessible {};
0037 friend struct detail::pickle_suite_registration;
0038 public:
0039 static inaccessible* getinitargs() { return 0; }
0040 static inaccessible* getstate() { return 0; }
0041 static inaccessible* setstate() { return 0; }
0042 static bool getstate_manages_dict() { return false; }
0043 };
0044
0045 namespace detail {
0046
0047 struct pickle_suite_registration
0048 {
0049 typedef pickle_suite::inaccessible inaccessible;
0050
0051 template <class Class_, class Tgetinitargs>
0052 static
0053 void
0054 register_(
0055 Class_& cl,
0056 tuple (*getinitargs_fn)(Tgetinitargs),
0057 inaccessible* (* )(),
0058 inaccessible* (* )(),
0059 bool)
0060 {
0061 cl.enable_pickling_(false);
0062 cl.def("__getinitargs__", getinitargs_fn);
0063 }
0064
0065 template <class Class_,
0066 class Rgetstate, class Tgetstate,
0067 class Tsetstate, class Ttuple>
0068 static
0069 void
0070 register_(
0071 Class_& cl,
0072 inaccessible* (* )(),
0073 Rgetstate (*getstate_fn)(Tgetstate),
0074 void (*setstate_fn)(Tsetstate, Ttuple),
0075 bool getstate_manages_dict)
0076 {
0077 cl.enable_pickling_(getstate_manages_dict);
0078 cl.def("__getstate__", getstate_fn);
0079 cl.def("__setstate__", setstate_fn);
0080 }
0081
0082 template <class Class_,
0083 class Tgetinitargs,
0084 class Rgetstate, class Tgetstate,
0085 class Tsetstate, class Ttuple>
0086 static
0087 void
0088 register_(
0089 Class_& cl,
0090 tuple (*getinitargs_fn)(Tgetinitargs),
0091 Rgetstate (*getstate_fn)(Tgetstate),
0092 void (*setstate_fn)(Tsetstate, Ttuple),
0093 bool getstate_manages_dict)
0094 {
0095 cl.enable_pickling_(getstate_manages_dict);
0096 cl.def("__getinitargs__", getinitargs_fn);
0097 cl.def("__getstate__", getstate_fn);
0098 cl.def("__setstate__", setstate_fn);
0099 }
0100
0101 template <class Class_>
0102 static
0103 void
0104 register_(
0105 Class_&,
0106 ...)
0107 {
0108 typedef typename
0109 error_messages::missing_pickle_suite_function_or_incorrect_signature<
0110 Class_>::error_type error_type BOOST_ATTRIBUTE_UNUSED;
0111 }
0112 };
0113
0114 template <typename PickleSuiteType>
0115 struct pickle_suite_finalize
0116 : PickleSuiteType,
0117 pickle_suite_registration
0118 {};
0119
0120 }
0121
0122 }}
0123
0124 #endif