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