00001 /*---------------------------------------------------------------------------*\ 00002 * OpenSG * 00003 * * 00004 * * 00005 * Copyright 2000-2002 by OpenSG Forum * 00006 * * 00007 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de * 00008 * * 00009 \*---------------------------------------------------------------------------*/ 00010 /*---------------------------------------------------------------------------*\ 00011 * License * 00012 * * 00013 * This library is free software; you can redistribute it and/or modify it * 00014 * under the terms of the GNU Library General Public License as published * 00015 * by the Free Software Foundation, version 2. * 00016 * * 00017 * This library is distributed in the hope that it will be useful, but * 00018 * WITHOUT ANY WARRANTY; without even the implied warranty of * 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00020 * Library General Public License for more details. * 00021 * * 00022 * You should have received a copy of the GNU Library General Public * 00023 * License along with this library; if not, write to the Free Software * 00024 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 00025 * * 00026 \*---------------------------------------------------------------------------*/ 00027 /*---------------------------------------------------------------------------*\ 00028 * Changes * 00029 * * 00030 * * 00031 * * 00032 * * 00033 * * 00034 * * 00035 \*---------------------------------------------------------------------------*/ 00036 00037 #ifdef OSG_DOC_FILES_IN_MODULE 00038 00041 #endif 00042 00043 #include <stdlib.h> 00044 #include <stdio.h> 00045 00046 OSG_BEGIN_NAMESPACE 00047 00048 // RefPtr methods 00049 00050 template< class Ref > 00051 RefPtr<Ref>::RefPtr(void) : _ref(NullFC) 00052 {} 00053 00054 template< class Ref > 00055 RefPtr<Ref>::RefPtr(const Ref& ref) : _ref(ref) 00056 { 00057 addRefCP(_ref); 00058 } 00059 00060 template< class Ref > 00061 RefPtr<Ref>::RefPtr(const RefPtr<Ref>& ptr) : _ref(ptr._ref) 00062 { 00063 addRefCP(_ref); 00064 } 00065 00066 template< class Ref > 00067 RefPtr<Ref>::~RefPtr() 00068 { 00069 if(_ref != NullFC) 00070 subRefCP(_ref); 00071 } 00072 00073 template< class Ref > 00074 RefPtr<Ref>::operator Ref(void) const 00075 { 00076 return _ref; 00077 } 00078 00079 template< class Ref > 00080 typename Ref::StoredObjectType* RefPtr<Ref>::operator->(void) const 00081 { 00082 return &(*_ref); 00083 } 00084 00085 template< class Ref > 00086 typename Ref::StoredObjectType* RefPtr<Ref>::getCPtr(void) const 00087 { 00088 return &(*_ref); 00089 } 00090 00091 template< class Ref > 00092 Ref RefPtr<Ref>::get(void) const 00093 { 00094 return _ref; 00095 } 00096 00097 template< class Ref > 00098 RefPtr<Ref>& RefPtr<Ref>::operator =(const Ref& fcp) 00099 { 00100 setRef(fcp); 00101 00102 return *this; 00103 } 00104 00105 template< class Ref > 00106 RefPtr<Ref>& RefPtr<Ref>::operator =(const RefPtr<Ref>& rcp) 00107 { 00108 setRef(rcp._ref); 00109 00110 return *this; 00111 } 00112 00113 template< class Ref > 00114 RefPtr<Ref>& RefPtr<Ref>::operator =(const NullFieldContainerPtr&) 00115 { 00116 setRef(NullFC); 00117 00118 return *this; 00119 } 00120 00121 00122 template< class Ref > 00123 bool RefPtr<Ref>::operator < (const NullFieldContainerPtr&) const 00124 { 00125 return false; 00126 } 00127 00128 template< class Ref > 00129 bool RefPtr<Ref>::operator ==(const NullFieldContainerPtr&) const 00130 { 00131 return _ref == NullFC; 00132 } 00133 00134 template< class Ref > 00135 bool RefPtr<Ref>::operator !=(const NullFieldContainerPtr&) const 00136 { 00137 return _ref != NullFC; 00138 } 00139 00140 00141 template< class Ref > 00142 bool RefPtr<Ref>::operator < (const FieldContainerPtr &other) const 00143 { 00144 return _ref < other; 00145 } 00146 00147 template< class Ref > 00148 bool RefPtr<Ref>::operator ==(const FieldContainerPtr &other) const 00149 { 00150 return _ref == other; 00151 } 00152 00153 template< class Ref > 00154 bool RefPtr<Ref>::operator !=(const FieldContainerPtr &other) const 00155 { 00156 return !(_ref == other); 00157 } 00158 00159 00160 template< class Ref > 00161 bool RefPtr<Ref>::operator < (const RefPtr<Ref> &other) const 00162 { 00163 return _ref < other._ref; 00164 } 00165 00166 template< class Ref > 00167 bool RefPtr<Ref>::operator ==(const RefPtr<Ref> &other) const 00168 { 00169 return _ref == other._ref; 00170 } 00171 00172 template< class Ref > 00173 bool RefPtr<Ref>::operator !=(const RefPtr<Ref> &other) const 00174 { 00175 return !(_ref == other._ref); 00176 } 00177 00178 template< class Ref > 00179 bool RefPtr<Ref>::operator ! (void) const 00180 { 00181 return _ref == NullFC; 00182 } 00183 00184 template< class Ref > 00185 RefPtr<Ref>::operator typename RefPtr<Ref>::unspecified_bool_type (void) const 00186 { 00187 return !*this ? 0 : &RefPtr<Ref>::_ref; 00188 } 00189 00190 00191 template< class Ref > 00192 void RefPtr<Ref>::setRef(const Ref &ref) 00193 { 00194 if(_ref == ref) 00195 return; 00196 00197 if(_ref != NullFC) 00198 subRefCP(_ref); 00199 00200 _ref = ref; 00201 00202 if(_ref != NullFC) 00203 addRefCP(_ref); 00204 } 00205 00206 OSG_END_NAMESPACE 00207 00208 #define OSGREFPTR_INLINE_CVSID "@(#)$Id: OSGRefPtr.inl,v 1.6 2006/02/21 16:40:08 dirk Exp $" 00209
1.5.5