CFx SDK Documentation
2020SP3
SDK
CFx
dd_inc
RxModuleSoftReference.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
#ifndef _ODRXMODULESOFTREFERENCE_H_
26
#define _ODRXMODULESOFTREFERENCE_H_
27
28
#include "
DynamicLinker.h
"
29
#include "
RxDLinkerReactor.h
"
30
#include "
StaticRxObject.h
"
31
32
#include "
TD_PackPush.h
"
33
34
45
template
<
class
TModule = OdRxModule>
46
class
OdRxModuleSoftReference
:
protected
OdStaticRxObject
<OdRxDLinkerReactor> {
47
TModule* m_pModule;
48
protected
:
50
void
rxAppWillBeUnloaded
(
OdRxModule
* pModule ) {
51
if
( pModule==m_pModule ) {
52
clear
();
53
}
54
}
55
public
:
59
OdRxModuleSoftReference
() : m_pModule(0) {}
60
64
~OdRxModuleSoftReference
() {
clear
(); }
65
71
OdSmartPtr<TModule>
getModule
(
const
OdString
& appName ) {
72
OdSmartPtr<TModule>
pRes = m_pModule;
73
if
( pRes.isNull() ) {
74
pRes =
::odrxDynamicLinker
()->
loadApp
( appName );
75
::odrxDynamicLinker
()->
addReactor
(
this
);
76
m_pModule = pRes.
get
();
77
}
78
return
pRes;
79
}
80
84
TModule*
getRef
() {
85
return
m_pModule;
86
}
87
91
void
clear
() {
92
if
( m_pModule ) {
93
m_pModule = 0;
94
::odrxDynamicLinker
()->
removeReactor
(
this
);
95
}
96
}
97
};
98
99
#include "
TD_PackPop.h
"
100
101
#endif // _ODRXMODULESOFTREFERENCE_H_
102
OdString
Definition:
OdString.h:95
odrxDynamicLinker
FIRSTDLL_EXPORT OdRxDynamicLinker * odrxDynamicLinker()
OdRxDynamicLinker::removeReactor
virtual void removeReactor(OdRxDLinkerReactor *pReactor)=0
TD_PackPop.h
OdRxModuleSoftReference::getRef
TModule * getRef()
Definition:
RxModuleSoftReference.h:84
OdRxModuleSoftReference::~OdRxModuleSoftReference
~OdRxModuleSoftReference()
Definition:
RxModuleSoftReference.h:64
OdRxModuleSoftReference
Definition:
RxModuleSoftReference.h:46
OdSmartPtr
Definition:
SmartPtr.h:58
OdSmartPtr::get
const T * get() const
Definition:
SmartPtr.h:326
DynamicLinker.h
TD_PackPush.h
StaticRxObject.h
OdRxDynamicLinker::loadApp
virtual OdRxModulePtr loadApp(const OdString &applicationName, bool silent=true)=0
RxDLinkerReactor.h
OdRxModuleSoftReference::rxAppWillBeUnloaded
void rxAppWillBeUnloaded(OdRxModule *pModule)
Definition:
RxModuleSoftReference.h:50
OdStaticRxObject
Definition:
StaticRxObject.h:57
OdRxModuleSoftReference::clear
void clear()
Definition:
RxModuleSoftReference.h:91
OdRxModuleSoftReference::getModule
OdSmartPtr< TModule > getModule(const OdString &appName)
Definition:
RxModuleSoftReference.h:71
OdRxModule
Definition:
RxModule.h:45
OdRxDynamicLinker::addReactor
virtual void addReactor(OdRxDLinkerReactor *pReactor)=0
OdRxModuleSoftReference::OdRxModuleSoftReference
OdRxModuleSoftReference()
Definition:
RxModuleSoftReference.h:59
Generated on Mon Oct 12 2020 11:49:43