TrueReality  v0.1.1912
SmrtClass.h
Go to the documentation of this file.
1 /*
2 * True Reality Open Source Game and Simulation Engine
3 * Copyright © 2021 Acid Rain Studios LLC
4 *
5 * This library is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Lesser General Public License as published by the Free
7 * Software Foundation; either version 3.0 of the License, or (at your option)
8 * any later version.
9 *
10 * This library is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this library; if not, write to the Free Software Foundation, Inc.,
17 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * @author Maxim Serebrennik
20 */
21 
22 #pragma once
23 
24 #include <trBase/Export.h>
25 
26 #include <osg/Referenced>
27 
28 #include <string>
29 
30 namespace trBase
31 {
38  class TR_BASE_EXPORT SmrtClass : public osg::Referenced
39  {
40  public:
41 
42  using BaseClass = osg::Referenced;
43 
49  SmrtClass() : osg::Referenced()
50  {}
51 
59  explicit SmrtClass(bool threadSafeRefUnref) : osg::Referenced(threadSafeRefUnref)
60  {}
61 
69  SmrtClass(const SmrtClass& inst) : osg::Referenced(inst)
70  {}
71 
79  virtual bool GetThreadSafeRefUnref();
80 
88  OpenThreads::Mutex* GetRefMutex() const;
89 
98  static OpenThreads::Mutex* GetGlobalReferencedMutex();
99 
108  inline int Ref() const;
109 
119  inline int Unref() const;
120 
132  int UnRefNoDelete() const;
133 
141  inline int ReferenceCount() const;
142 
150  virtual const std::string& GetType() const = 0;
151 
152  protected:
154  {}
155  };
156 }
157 
158 
#define TR_BASE_EXPORT
Definition: trBase/Export.h:34
SmrtClass(const SmrtClass &inst)
Copy constructor.
Definition: SmrtClass.h:69
This class is part of the internal garbage collection system.
Definition: SmrtClass.h:38
Definition: FrameStamp.h:37
SmrtClass()
Adds an easy and swappable access to the base class.
Definition: SmrtClass.h:49
osg::Referenced BaseClass
Definition: SmrtClass.h:42
SmrtClass(bool threadSafeRefUnref)
Constructor.
Definition: SmrtClass.h:59