Crazy Eddie's GUI System  ${CEGUI_VERSION}
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
shared_proxy_impl.hpp
1 // This file has been generated by Py++.
2 
3 //
4 // Header file shared_proxy_impl.hpp
5 //
6 // The shared implementation of the element proxy (const and non-const
7 // versions). Multiple proxy pointers can refer to the same shared
8 // implementation, meaning that only one object requires updating to
9 // affect all proxy pointers that ultimately refer to the same index
10 // in the container.
11 //
12 // Copyright (c) 2003 Raoul M. Gough
13 //
14 // Use, modification and distribution is subject to the Boost Software
15 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy
16 // at http://www.boost.org/LICENSE_1_0.txt)
17 //
18 // History
19 // =======
20 // 2003/ 8/29 rmg File creation from container_proxy.hh
21 // 2008/12/08 Roman Change indexing suite layout
22 //
23 // $Id: shared_proxy_impl.hpp,v 1.1.2.8 2003/11/24 14:28:31 raoulgough Exp $
24 //
25 
26 #ifndef BOOST_PYTHON_INDEXING_SHARED_PROXY_IMPL_HPP
27 #define BOOST_PYTHON_INDEXING_SHARED_PROXY_IMPL_HPP
28 
29 #include <memory>
30 #include <indexing_suite/workaround.hpp>
31 
32 namespace boost { namespace python { namespace indexing {
33  template<class ContainerProxy>
35  {
36  public:
37  typedef typename ContainerProxy::raw_value_type value_type;
38  typedef value_type &reference;
39  typedef value_type *pointer;
40  typedef void iterator_category; // Fudge for boost::indirect_iterator
41  typedef void difference_type; // Fudge for boost::indirect_iterator
42 
43  reference operator*() const;
44  pointer operator->() const { return &(**this); }
45 
46  ContainerProxy *owner() const { return m_owner_ptr; }
47  size_t index() const { return m_index; }
48 
49  shared_proxy_impl (value_type const &copy);
50  // Creates value-only (detached) proxy
51 
52 #if defined (BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
53  public:
54 #else
55  private:
56  template<class C, class A, class G> friend class container_proxy;
57 #endif
58 
59  shared_proxy_impl (ContainerProxy *, size_t);
60  void detach ();
61 
62  ContainerProxy *m_owner_ptr; // When attached
63  size_t m_index; // When attached
64  std::auto_ptr<value_type> m_element_ptr; // When detached
65 
66  private:
67  // Not implemented
69  shared_proxy_impl &operator= (shared_proxy_impl const &);
70  };
71 
72  template<class ContainerProxy>
74  size_t index)
75  : m_owner_ptr (owner),
76  m_index (index),
77  m_element_ptr ()
78  {
79  }
80 
81  template<class ContainerProxy>
82  shared_proxy_impl<ContainerProxy>::shared_proxy_impl (value_type const &val)
83  : m_owner_ptr (0),
84  m_index (static_cast<size_t>(-1)),
85  m_element_ptr (new value_type (val))
86  {
87  }
88 
89  template<class ContainerProxy>
90  typename shared_proxy_impl<ContainerProxy>::reference
91  shared_proxy_impl<ContainerProxy>::operator* () const
92  {
93  return m_owner_ptr
94  ? m_owner_ptr->raw_container().BOOST_PYTHON_INDEXING_AT (m_index)
95  : *m_element_ptr;
96  }
97 
98  template<class ContainerProxy>
99  void shared_proxy_impl<ContainerProxy>::detach ()
100  {
101  BOOST_PYTHON_INDEXING_RESET_AUTO_PTR(
102  m_element_ptr, new value_type (**this));
103  m_owner_ptr = 0;
104  m_index = static_cast<size_t>(-1);
105  }
106 } } }
107 
108 #endif // BOOST_PYTHON_INDEXING_SHARED_PROXY_IMPL_HPP
109 
110 
111 
Definition: python_CEGUI.h:11
Definition: container_proxy.hpp:103
Definition: shared_proxy_impl.hpp:34