CFx SDK Documentation  2020SP3
RxObjectImpl.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2017, Open Design Alliance (the "Alliance").
3 // All rights reserved.
4 //
5 // This software and its documentation and related materials are owned by
6 // the Alliance. The software may only be incorporated into application
7 // programs owned by members of the Alliance, subject to a signed
8 // Membership Agreement and Supplemental Software License Agreement with the
9 // Alliance. The structure and organization of this software are the valuable
10 // trade secrets of the Alliance and its suppliers. The software is also
11 // protected by copyright law and international treaty provisions. Application
12 // programs incorporating this software must include the following statement
13 // with their copyright notices:
14 //
15 // This application incorporates Teigha(R) software pursuant to a license
16 // agreement with Open Design Alliance.
17 // Teigha(R) Copyright (C) 2002-2017 by Open Design Alliance.
18 // All rights reserved.
19 //
20 // By use of this software, its documentation or related materials, you
21 // acknowledge and accept the above terms.
23 
24 
25 
26 
27 #if !defined(OdRxObjectImpl_INCLUDED_)
28 #define OdRxObjectImpl_INCLUDED_
29 
30 #include "OdaCommon.h"
31 #include "TD_PackPush.h"
32 
33 #include "RxObject.h"
34 #include "OdMutex.h"
35 
53 template<class T, class TInterface = T>
54 class OdRxObjectImpl : public T
55 {
59  OdRefCounter m_nRefCounter;
60 
64  OdRxObjectImpl& operator = (const OdRxObjectImpl&);
65 
66 protected:
68 
69 public:
74  {
75  m_nRefCounter = 1;
76  }
77 
81  void addRef()
82  {
83  ++m_nRefCounter;
84  }
85 
90  void release()
91  {
92  ODA_ASSERT((m_nRefCounter > 0));
93  if (!(--m_nRefCounter))
94  {
95  delete this;
96  }
97  }
98 
102  long numRefs() const { return m_nRefCounter; }
103 
108  {
109  return OdSmartPtr<TInterface>(static_cast<TInterface*>(new OdRxObjectImpl<T, TInterface>), kOdRxObjAttach);
110  }
111 };
112 
113 
117 #define RXIMPL_CONSTR(ClassName) OdRxObjectImpl<ClassName>::createObject()
118 
122 #define ABSTRACTIMPL_CONSTR(CLASS) OdRxObjectImpl<CLASS##Impl>::createObject()
123 
124 #include "TD_PackPop.h"
125 
126 #endif // !defined(OdRxObjectImpl_INCLUDED_)
127 
OdRxObjectImpl::release
void release()
Definition: RxObjectImpl.h:90
OdRefCounter
int OdRefCounter
Definition: OdMutex.h:436
TD_PackPop.h
RxObject.h
OdRxObjectImpl::numRefs
long numRefs() const
Definition: RxObjectImpl.h:102
OdRxObjectImpl::ODRX_HEAP_OPERATORS
ODRX_HEAP_OPERATORS()
OdRxObjectImpl::addRef
void addRef()
Definition: RxObjectImpl.h:81
OdSmartPtr
Definition: SmartPtr.h:58
OdMutex.h
OdaCommon.h
TD_PackPush.h
OdRxObjectImpl::OdRxObjectImpl
OdRxObjectImpl()
Definition: RxObjectImpl.h:73
OdRxObjectImpl::createObject
static OdSmartPtr< TInterface > createObject()
Definition: RxObjectImpl.h:107
ODA_ASSERT
#define ODA_ASSERT(exp)
Definition: DebugStuff.h:49
kOdRxObjAttach
@ kOdRxObjAttach
Definition: RxObject.h:56
OdRxObjectImpl
Definition: RxObjectImpl.h:55