00001 /*======================================================================= 00002 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00003 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00004 *** *** 00005 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00006 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00007 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00008 *** *** 00009 *** RESTRICTED RIGHTS LEGEND *** 00010 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00011 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00012 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00013 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00014 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00015 *** *** 00016 *** COPYRIGHT (C) 1996-2022 BY FEI S.A.S, *** 00017 *** BORDEAUX, FRANCE *** 00018 *** ALL RIGHTS RESERVED *** 00019 **=======================================================================*/ 00020 /*======================================================================= 00021 ** Author : VSG (MMM YYYY) 00022 **=======================================================================*/ 00023 00024 #ifndef SO_AUTO_REF_COUNTER_H 00025 #define SO_AUTO_REF_COUNTER_H 00026 00027 #include <Inventor/SbBase.h> 00028 #include <Inventor/misc/SoRefCounter.h> 00029 00045 class SoAutoRef 00046 { 00047 public: 00049 SoAutoRef(); 00050 00052 SoAutoRef(const SoAutoRef& that); 00053 00055 SoAutoRef(SoRefCounter* pIn); 00056 00058 virtual ~SoAutoRef(); 00059 00061 SoAutoRef& operator=(const SoAutoRef& that) 00062 { 00063 (*this) = that.m_pointer; 00064 return *this; 00065 } 00066 00068 SoAutoRef& operator=(SoRefCounter* ptr); 00069 00070 // Comparison operators with other SoAutoRef 00071 00072 bool operator==(const SoAutoRef& other) const 00073 { 00074 return m_pointer == other.m_pointer; 00075 } 00076 00077 bool operator!=(const SoAutoRef& other) const 00078 { 00079 return m_pointer != other.m_pointer; 00080 } 00081 00082 bool operator<(const SoAutoRef& other) const 00083 { 00084 return m_pointer < other.m_pointer; 00085 } 00086 00087 bool operator<=(const SoAutoRef& other) const 00088 { 00089 return m_pointer < other.m_pointer; 00090 } 00091 00092 bool operator>(const SoAutoRef& other) const 00093 { 00094 return m_pointer > other.m_pointer; 00095 } 00096 00097 bool operator>=(const SoAutoRef& other) const 00098 { 00099 return m_pointer > other.m_pointer; 00100 } 00101 00102 // Comparison operators with SoRefCounter* 00103 00104 bool operator==(const SoRefCounter* ptr) const 00105 { 00106 return m_pointer == ptr; 00107 } 00108 00109 bool operator!=(const SoRefCounter* ptr) const 00110 { 00111 return m_pointer != ptr; 00112 } 00113 00114 bool operator<(const SoRefCounter* ptr) const 00115 { 00116 return m_pointer < ptr; 00117 } 00118 00119 bool operator<=(const SoRefCounter* ptr) const 00120 { 00121 return m_pointer < ptr; 00122 } 00123 00124 bool operator>(const SoRefCounter* ptr) const 00125 { 00126 return m_pointer > ptr; 00127 } 00128 00129 bool operator>=(const SoRefCounter* ptr) const 00130 { 00131 return m_pointer > ptr; 00132 } 00133 00135 operator bool() const 00136 { 00137 return get() != nullptr; 00138 } 00139 00141 bool operator!() const 00142 { 00143 return get() == nullptr; 00144 } 00145 00147 SoRefCounter& operator*() const 00148 { return *(get()); } 00149 00151 SoRefCounter* operator->() const 00152 { return get(); } 00153 00155 SoRefCounter* ptr() const 00156 { return get(); } 00157 00158 private: 00159 SoRefCounter* get() const 00160 { return m_pointer; } 00161 00163 SoRefCounter* m_pointer; 00164 }; 00165 00166 // Reverse comparison operators with SoRefCounter* 00167 bool operator==(const SoRefCounter* ptr, const SoAutoRef& ref); 00168 bool operator!=(const SoRefCounter* ptr, const SoAutoRef& ref); 00169 bool operator<(const SoRefCounter* ptr, const SoAutoRef& ref); 00170 bool operator<=(const SoRefCounter* ptr, const SoAutoRef& ref); 00171 bool operator>(const SoRefCounter* ptr, const SoAutoRef& ref); 00172 bool operator>=(const SoRefCounter* ptr, const SoAutoRef& ref); 00173 00174 // Included here to provide this service by default everywhere SoRefCounter 00175 // is already used, avoiding app to add a #include <Inventor/misc/SoAutoRef.h> 00176 #include <Inventor/misc/SoRef.h> 00177 00178 #endif // SO_AUTO_REF_COUNTER_H 00179 00180 00181