00001 00002 // MathCore = a WYSIWYG equation editor + a powerful math engine // 00003 // Copyright (C) 2003 by Francesco Montorsi // 00004 // // 00005 // This library is free software; you can redistribute it and/or // 00006 // modify it under the terms of the GNU Lesser General Public // 00007 // License as published by the Free Software Foundation; either // 00008 // version 2.1 of the License, or (at your option) any later // 00009 // version. // 00010 // // 00011 // This library is distributed in the hope that it will be useful, // 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of // 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 00014 // GNU Lesser General Public License for more details. // 00015 // // 00016 // You should have received a copy of the GNU Lesser General Public // 00017 // License along with this program; if not, write to the Free // 00018 // Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, // 00019 // MA 02111-1307, USA. // 00020 // // 00021 // For any comment, suggestion or feature request, please contact // 00022 // the administrator of the project at frm@users.sourceforge.net // 00023 // // 00030 00031 00032 00033 #ifndef OBJECT_H 00034 #define OBJECT_H 00035 00036 // optimization for GCC compiler 00037 #ifdef __GNUG__ 00038 #pragma interface "Object.h" 00039 #endif 00040 00041 // defined later 00042 class mcObjectRefData; 00043 00044 00047 class mcObject 00048 { 00049 protected: 00050 00052 mcObjectRefData *mdata_refData; 00053 00054 public: 00055 00057 mcObject() : mdata_refData(NULL) {} 00058 00060 mcObject(const mcObject& other) : mdata_refData(NULL) { data_Ref(other); } 00061 00063 virtual ~mcObject() { data_UnRef(); } 00064 00065 00067 mcObject &operator=(const mcObject& other) { 00068 if (this != &other) { 00069 data_UnRef(); 00070 data_Ref(other); 00071 } 00072 return *this; 00073 } 00074 00075 00077 mcObjectRefData *data_GetRefData() const { return mdata_refData; } 00078 00080 void data_SetRefData(mcObjectRefData *data) { mdata_refData = data; } 00081 00083 virtual void data_Ref(const mcObject &clone); 00084 00087 virtual void data_UnRef(); 00088 00090 virtual mcObjectRefData *data_MakePrivateCopy() = 0; 00091 }; 00092 00093 00094 00100 class mcObjectRefData 00101 { 00102 public: 00103 mcObjectRefData() : mdata_count(1) {} 00104 virtual ~mcObjectRefData() {} 00105 00106 int data_GetRefCount() const { return mdata_count; } 00107 void data_SetRefCount(int n) { mdata_count = n; } 00108 00109 void data_IncRefCount() { mdata_count++; } 00110 void data_DecRefCount() { mdata_count--; } 00111 00112 private: 00113 int mdata_count; 00114 }; 00115 00116 00117 #endif // OBJECT_H 00118
[ Top ] |