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 #ifndef _OSGREFPTR_H_ 00038 #define _OSGREFPTR_H_ 00039 #ifdef __sgi 00040 #pragma once 00041 #endif 00042 00043 #ifdef OSG_DOC_FILES_IN_MODULE 00044 00047 #endif 00048 00049 #include <OSGSystemDef.h> 00050 #include <OSGBaseTypes.h> 00051 #include <OSGFieldContainerPtr.h> 00052 00053 OSG_BEGIN_NAMESPACE 00054 00058 template< class Ref > 00059 class RefPtr 00060 { 00061 /*========================== PUBLIC =================================*/ 00062 public: 00064 typedef Ref FCPtrType; 00066 typedef typename Ref::StoredObjectType StoredObjectType; 00067 typedef const Ref RefPtr::*unspecified_bool_type; 00068 00069 /*---------------------------------------------------------------------*/ 00073 RefPtr(void); 00074 00075 // make it explicit to prevent unexpected construction/cast paths 00076 00077 explicit RefPtr(const Ref& fcp); 00078 00079 RefPtr(const RefPtr<Ref>& ptr); 00080 00082 /*---------------------------------------------------------------------*/ 00086 virtual ~RefPtr(); 00087 00089 /*---------------------------------------------------------------------*/ 00093 operator Ref(void) const; 00094 00095 typename Ref::StoredObjectType* operator->(void) const; 00096 typename Ref::StoredObjectType* getCPtr (void) const; 00097 00098 Ref get(void) const; 00099 00100 RefPtr<Ref>& operator =(const Ref &fcp); 00101 RefPtr<Ref>& operator =(const RefPtr<Ref> &rcp); 00102 RefPtr<Ref>& operator =(const NullFieldContainerPtr& ); 00103 00105 /*---------------------------------------------------------------------*/ 00109 bool operator < (const NullFieldContainerPtr & ) const; 00110 bool operator == (const NullFieldContainerPtr &other) const; 00111 bool operator != (const NullFieldContainerPtr &other) const; 00112 00113 bool operator < (const FieldContainerPtr &other) const; 00114 bool operator == (const FieldContainerPtr &other) const; 00115 bool operator != (const FieldContainerPtr &other) const; 00116 00117 bool operator < (const RefPtr<Ref> &other) const; 00118 bool operator == (const RefPtr<Ref> &other) const; 00119 bool operator != (const RefPtr<Ref> &other) const; 00120 00121 bool operator ! (void ) const; 00122 00123 operator unspecified_bool_type() const; 00124 00126 /*---------------------------------------------------------------------*/ 00127 00128 /*========================= PROTECTED ===============================*/ 00129 protected: 00130 00131 /*========================== PRIVATE ================================*/ 00132 private: 00133 00134 void setRef(const Ref& ref); 00135 00136 Ref _ref; 00137 }; 00138 00139 // Some base types 00140 00141 typedef RefPtr<FieldContainerPtr> FieldContainerRefPtr; 00142 00143 OSG_END_NAMESPACE 00144 00145 #include "OSGRefPtr.inl" 00146 00147 #define OSGREFPTR_HEADER_CVSID "@(#)$Id: OSGRefPtr.h,v 1.7 2006/09/05 01:24:28 allenb Exp $" 00148 00149 #endif /* _OSGREFPTR_H_ */
1.5.5