CFx SDK Documentation
2026 SP0
Loading...
Searching...
No Matches
SDK
CFx
dd_inc
RxObjectImpl.h
Go to the documentation of this file.
1
2
// Copyright (C) 2002-2024, 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 Open Design Alliance software pursuant to a license
16
// agreement with Open Design Alliance.
17
// Open Design Alliance Copyright (C) 2002-2024 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
69
OdRxObjectImpl(OdRxObjectImpl&&);
70
71
protected
:
72
ODRX_HEAP_OPERATORS
();
73
74
public
:
79
template
<
typename
... Args>
80
OdRxObjectImpl
(Args&&... args)
81
: T(std::forward<Args>(args)...)
82
{
83
m_nRefCounter = 1;
84
}
85
89
void
addRef
()
90
{
91
++m_nRefCounter;
92
}
93
98
void
release
()
ODRX_NOEXCEPT
99
{
100
ODA_ASSERT
((m_nRefCounter > 0));
101
if
(!(--m_nRefCounter))
102
{
103
delete
this
;
104
}
105
}
106
110
long
numRefs
()
const
{
return
m_nRefCounter; }
111
115
template
<
typename
... Args>
116
static
OdSmartPtr<TInterface>
createObject
(Args&&... args)
117
{
118
return
OdSmartPtr<TInterface>
(
static_cast<
TInterface*
>
(
new
OdRxObjectImpl<T, TInterface>(std::forward<Args>(args)...)),
kOdRxObjAttach
);
119
}
120
};
121
122
// VS 2013 does support arguments forwarding but does not quite support `using`
123
#if (defined(_MSC_VER) && (_MSC_VER > 1800)) || (defined(__cplusplus) && (__cplusplus > 199711L))
124
template
<
class
T,
class
TInterface = T>
using
OdRxObjectImpl2
=
OdRxObjectImpl<T, TInterface>
;
125
#else
126
#define OdRxObjectImpl2 OdRxObjectImpl
127
#endif
128
132
#define RXIMPL_CONSTR(ClassName) OdRxObjectImpl<ClassName>::createObject()
133
137
#define ABSTRACTIMPL_CONSTR(CLASS) OdRxObjectImpl<CLASS##Impl>::createObject()
138
139
template
<
class
T,
class
TImpl>
140
class
OdObjectWithImpl
:
public
T
141
{
142
protected
:
143
#ifdef ODA_NEED_TEMP_USING
144
using
T::m_pImpl;
145
#endif
146
public
:
147
TImpl
m_Impl
;
148
inline
OdObjectWithImpl
() : T(&
m_Impl
)
149
{
150
}
151
inline
~OdObjectWithImpl
()
152
{
153
m_pImpl = NULL;
154
}
155
static
OdSmartPtr<T>
createObject
()
156
{
157
return
OdSmartPtr<T>
((T*)
new
OdObjectWithImpl<T, TImpl>
,
kOdRxObjAttach
);
158
}
159
};
160
161
#define OD_IDCAT(ID, Postf) ID##Postf
162
163
#define RXIMPLOBJCONSTRUCT(ClassName) OdRxObjectImpl<OdObjectWithImpl<ClassName, OD_IDCAT(ClassName,Impl)> >::createObject()
164
165
#define IMPLOBJCONSTRUCT(ClassName) OdObjectWithImpl<ClassName, OD_IDCAT(ClassName,Impl)>::createObject()
166
167
168
#include "
TD_PackPop.h
"
169
170
#endif
// !defined(OdRxObjectImpl_INCLUDED_)
171
ODA_ASSERT
#define ODA_ASSERT(exp)
Definition
DebugStuff.h:57
OdMutex.h
OdRefCounter
int OdRefCounter
Definition
OdMutex.h:478
ODRX_NOEXCEPT
#define ODRX_NOEXCEPT
Definition
OdPlatformSettings.h:69
OdaCommon.h
RxObject.h
kOdRxObjAttach
@ kOdRxObjAttach
Definition
RxObject.h:56
OdRxObjectImpl2
#define OdRxObjectImpl2
Definition
RxObjectImpl.h:126
TD_PackPop.h
TD_PackPush.h
OdObjectWithImpl::createObject
static OdSmartPtr< T > createObject()
Definition
RxObjectImpl.h:155
OdObjectWithImpl::m_Impl
TImpl m_Impl
Definition
RxObjectImpl.h:147
OdObjectWithImpl::OdObjectWithImpl
OdObjectWithImpl()
Definition
RxObjectImpl.h:148
OdObjectWithImpl::~OdObjectWithImpl
~OdObjectWithImpl()
Definition
RxObjectImpl.h:151
OdRxObjectImpl
Definition
RxObjectImpl.h:55
OdRxObjectImpl::numRefs
long numRefs() const
Definition
RxObjectImpl.h:110
OdRxObjectImpl::OdRxObjectImpl
OdRxObjectImpl(Args &&... args)
Definition
RxObjectImpl.h:80
OdRxObjectImpl::createObject
static OdSmartPtr< TInterface > createObject(Args &&... args)
Definition
RxObjectImpl.h:116
OdRxObjectImpl::addRef
void addRef()
Definition
RxObjectImpl.h:89
OdRxObjectImpl::ODRX_HEAP_OPERATORS
ODRX_HEAP_OPERATORS()
OdRxObjectImpl::release
void release() ODRX_NOEXCEPT
Definition
RxObjectImpl.h:98
OdSmartPtr
Definition
SmartPtr.h:58
Generated on Tue Apr 15 2025 11:30:05