Qore Programming Language  0.8.7
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
AbstractPrivateData.h
1 /* -*- mode: c++; indent-tabs-mode: nil -*- */
2 /*
3  AbstractPrivateData.h
4 
5  abstract class for private data in objects
6 
7  Qore Programming Language
8 
9  Copyright 2003 - 2013 David Nichols
10 
11  This library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU Lesser General Public
13  License as published by the Free Software Foundation; either
14  version 2.1 of the License, or (at your option) any later version.
15 
16  This library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  Lesser General Public License for more details.
20 
21  You should have received a copy of the GNU Lesser General Public
22  License along with this library; if not, write to the Free Software
23  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 */
25 
26 #ifndef _QORE_ABSTRACTPRIVATEDATA_H
27 
28 #define _QORE_ABSTRACTPRIVATEDATA_H
29 
30 #include <qore/QoreReferenceCounter.h>
31 
33 
37  protected:
39  DLLLOCAL virtual ~AbstractPrivateData() {}
40 
41  public:
43  DLLLOCAL void ref() {
44  ROreference();
45  }
46 
48 
51  DLLLOCAL virtual void deref(class ExceptionSink *xsink) {
52  if (ROdereference())
53  delete this;
54  }
55 
57  DLLLOCAL virtual void deref() {
58  if (ROdereference())
59  delete this;
60  }
61 };
62 
63 #endif // _QORE_ABSTRACTPRIVATEDATA_H