CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
RxModuleSoftReference.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2022, 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-2022 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
45template <class TModule = OdRxModule>
46class OdRxModuleSoftReference : protected OdStaticRxObject<OdRxDLinkerReactor> {
47 TModule* m_pModule;
48protected:
51 if( pModule==m_pModule ) {
52 clear();
53 }
54 }
55public:
59 OdRxModuleSoftReference() : m_pModule(0) {}
60
65
72 OdSmartPtr<TModule> pRes = m_pModule;
73 if( pRes.isNull() ) {
74 pRes = ::odrxDynamicLinker()->loadApp( appName );
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;
95 }
96 }
97};
98
99#include "TD_PackPop.h"
100
101#endif // _ODRXMODULESOFTREFERENCE_H_
102
FIRSTDLL_EXPORT OdRxDynamicLinker * odrxDynamicLinker()
bool isNull() const
Definition: BaseObjectPtr.h:86
virtual OdRxModulePtr loadApp(const OdString &applicationName, bool silent=true)=0
virtual void addReactor(OdRxDLinkerReactor *pReactor)=0
virtual void removeReactor(OdRxDLinkerReactor *pReactor)=0
void rxAppWillBeUnloaded(OdRxModule *pModule)
OdSmartPtr< TModule > getModule(const OdString &appName)
const T * get() const
Definition: SmartPtr.h:339