00001 /* 00002 AbstractPrivateData.h 00003 00004 abstract class for private data in objects 00005 00006 Qore Programming Language 00007 00008 Copyright 2003 - 2009 David Nichols 00009 00010 This library is free software; you can redistribute it and/or 00011 modify it under the terms of the GNU Lesser General Public 00012 License as published by the Free Software Foundation; either 00013 version 2.1 of the License, or (at your option) any later version. 00014 00015 This library is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 Lesser General Public License for more details. 00019 00020 You should have received a copy of the GNU Lesser General Public 00021 License along with this library; if not, write to the Free Software 00022 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00023 */ 00024 00025 #ifndef _QORE_ABSTRACTPRIVATEDATA_H 00026 00027 #define _QORE_ABSTRACTPRIVATEDATA_H 00028 00029 #include <qore/QoreReferenceCounter.h> 00030 00032 00035 class AbstractPrivateData : public QoreReferenceCounter 00036 { 00037 protected: 00039 DLLEXPORT virtual ~AbstractPrivateData() {} 00040 00041 public: 00043 DLLEXPORT void ref() 00044 { 00045 ROreference(); 00046 } 00047 00049 00052 DLLEXPORT virtual void deref(class ExceptionSink *xsink) 00053 { 00054 if (ROdereference()) 00055 delete this; 00056 } 00057 00059 DLLEXPORT virtual void deref() 00060 { 00061 if (ROdereference()) 00062 delete this; 00063 } 00064 }; 00065 00066 #endif // _QORE_ABSTRACTPRIVATEDATA_H