Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/python/back_reference.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Copyright David Abrahams 2002.
0002 // Distributed under the Boost Software License, Version 1.0. (See
0003 // accompanying file LICENSE_1_0.txt or copy at
0004 // http://www.boost.org/LICENSE_1_0.txt)
0005 #ifndef BACK_REFERENCE_DWA2002510_HPP
0006 # define BACK_REFERENCE_DWA2002510_HPP
0007 
0008 # include <boost/python/detail/prefix.hpp>
0009 
0010 # include <boost/python/object_fwd.hpp>
0011 # include <boost/python/detail/dependent.hpp>
0012 # include <boost/python/detail/raw_pyobject.hpp>
0013 
0014 namespace boost { namespace python { 
0015 
0016 template <class T>
0017 struct back_reference
0018 {
0019  private: // types
0020     typedef typename detail::dependent<object,T>::type source_t;
0021  public:
0022     typedef T type;
0023     
0024     back_reference(PyObject*, T);
0025     source_t const& source() const;
0026     T get() const;
0027  private:
0028     source_t m_source;
0029     T m_value;
0030 };
0031 
0032 template<typename T>
0033 class is_back_reference
0034 {
0035  public:
0036     BOOST_STATIC_CONSTANT(bool, value = false); 
0037 };
0038 
0039 template<typename T>
0040 class is_back_reference<back_reference<T> >
0041 {
0042  public:
0043     BOOST_STATIC_CONSTANT(bool, value = true);
0044 };
0045 
0046 
0047 //
0048 // implementations
0049 //
0050 template <class T>
0051 back_reference<T>::back_reference(PyObject* p, T x)
0052     : m_source(detail::borrowed_reference(p))
0053       , m_value(x)
0054 {
0055 }
0056 
0057 template <class T>
0058 typename back_reference<T>::source_t const& back_reference<T>::source() const
0059 {
0060     return m_source;
0061 }
0062 
0063 template <class T>
0064 T back_reference<T>::get() const
0065 {
0066     return m_value;
0067 }
0068 
0069 }} // namespace boost::python
0070 
0071 #endif // BACK_REFERENCE_DWA2002510_HPP