Qore Programming Language  0.8.11
 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 - 2014 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
virtual DLLLOCAL void deref(class ExceptionSink *xsink)
decrements the reference count of the object
Definition: AbstractPrivateData.h:51
DLLEXPORT bool ROdereference() const
atomically decrements the reference count
the base class for all data to be used as private data of Qore objects
Definition: AbstractPrivateData.h:36
DLLEXPORT void ROreference() const
atomically increments the reference count
virtual DLLLOCAL ~AbstractPrivateData()
as these objects are reference counted, the destructor should be called only when the reference count...
Definition: AbstractPrivateData.h:39
provides atomic reference counting to Qore objects
Definition: QoreReferenceCounter.h:34
virtual DLLLOCAL void deref()
decrements the reference count of the object without the possibility of throwing a Qore-language exce...
Definition: AbstractPrivateData.h:57
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:35
DLLLOCAL void ref()
increments the reference count of the object
Definition: AbstractPrivateData.h:43