Blender  V2.93
BaseObject.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
17 #pragma once
18 
25 #ifdef WITH_CXX_GUARDEDALLOC
26 # include "MEM_guardedalloc.h"
27 #endif
28 
29 namespace Freestyle {
30 
31 class BaseObject {
32  public:
33  inline BaseObject()
34  {
35  _ref_counter = 0;
36  }
37 
38  virtual ~BaseObject()
39  {
40  }
41 
45  virtual int destroy()
46  {
47  return release();
48  }
49 
51  inline int addRef()
52  {
53  return ++_ref_counter;
54  }
55 
57  inline int release()
58  {
59  if (_ref_counter) {
60  _ref_counter--;
61  }
62  return _ref_counter;
63  }
64 
65  private:
66  unsigned _ref_counter;
67 
68 #ifdef WITH_CXX_GUARDEDALLOC
69  MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:BaseObject")
70 #endif
71 };
72 
73 } /* namespace Freestyle */
Read Guarded memory(de)allocation.
virtual int destroy()
Definition: BaseObject.h:45
virtual ~BaseObject()
Definition: BaseObject.h:38
inherits from class Rep
Definition: AppCanvas.cpp:32