00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00048 #ifndef STLSOFT_INCL_STLSOFT_SMARTPTR_HPP_PROXY_PTR
00049 #define STLSOFT_INCL_STLSOFT_SMARTPTR_HPP_PROXY_PTR
00050
00051 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00052 # define STLSOFT_VER_STLSOFT_SMARTPTR_HPP_PROXY_PTR_MAJOR 5
00053 # define STLSOFT_VER_STLSOFT_SMARTPTR_HPP_PROXY_PTR_MINOR 1
00054 # define STLSOFT_VER_STLSOFT_SMARTPTR_HPP_PROXY_PTR_REVISION 1
00055 # define STLSOFT_VER_STLSOFT_SMARTPTR_HPP_PROXY_PTR_EDIT 72
00056 #endif
00057
00058
00059
00060
00061
00062 #ifndef STLSOFT_INCL_STLSOFT_H_STLSOFT
00063 # include <stlsoft/stlsoft.h>
00064 #endif
00065
00066
00067
00068
00069
00070 #ifndef _STLSOFT_NO_NAMESPACE
00071 namespace stlsoft
00072 {
00073 #endif
00074
00075
00076
00077
00078
00079
00088 template <ss_typename_param_k T>
00089 class proxy_ptr
00090 {
00091 public:
00093 typedef T value_type;
00095 typedef proxy_ptr<T> class_type;
00096
00097 typedef value_type* resource_type;
00098 typedef value_type const* const_resource_type;
00099
00100
00101 public:
00103 ss_explicit_k proxy_ptr(value_type *t)
00104 : m_value(t)
00105 {}
00107 proxy_ptr& operator =(value_type *t)
00108 {
00109 m_value = t;
00110
00111 return *this;
00112 }
00113
00114
00115 public:
00117 operator value_type *()
00118 {
00119 return m_value;
00120 }
00122 operator value_type const* () const
00123 {
00124 return m_value;
00125 }
00126
00130 value_type& operator *()
00131 {
00132 STLSOFT_MESSAGE_ASSERT("Dereferencing a null pointer!", NULL != m_value);
00133
00134 return *m_value;
00135 }
00139 value_type const& operator *() const
00140 {
00141 STLSOFT_MESSAGE_ASSERT("Dereferencing a null pointer!", NULL != m_value);
00142
00143 return *m_value;
00144 }
00148 value_type* operator ->()
00149 {
00150 STLSOFT_MESSAGE_ASSERT("Dereferencing a null pointer!", NULL != m_value);
00151
00152 return m_value;
00153 }
00157 value_type const* operator ->() const
00158 {
00159 STLSOFT_MESSAGE_ASSERT("Dereferencing a null pointer!", NULL != m_value);
00160
00161 return m_value;
00162 }
00163
00168 value_type* get_ptr() const
00169 {
00170 return get();
00171 }
00172
00174 value_type* get() const
00175 {
00176 return m_value;
00177 }
00178
00182 value_type* GetPointer() const
00183 {
00184 return m_value;
00185 }
00186
00188 void clear()
00189 {
00190 m_value = NULL;
00191 }
00192
00193
00194 private:
00195 value_type *m_value;
00196 };
00197
00198
00199
00200
00201
00202
00207 template <ss_typename_param_k T>
00208 inline T* get_ptr(proxy_ptr<T> const& p)
00209 {
00210 return p.get();
00211 }
00212
00214
00215
00216 #ifdef STLSOFT_UNITTEST
00217 # include "./unittest/proxy_ptr_unittest_.h"
00218 #endif
00219
00220
00221
00222 #ifndef _STLSOFT_NO_NAMESPACE
00223 }
00224 #endif
00225
00226
00227
00228 #endif
00229
00230