OLD | NEW |
(Empty) | |
| 1 /** |
| 2 * \file abp_ca.cpp Top-level source for custom actions. Includes DLL initializa
tion. |
| 3 */ |
| 4 #include "DLL.h" |
| 5 #include <stdexcept> |
| 6 |
| 7 std::shared_ptr< DLL_Module > DLL_Module::singleton = 0 ; |
| 8 |
| 9 DLL_Module & |
| 10 DLL_Module::module() |
| 11 { |
| 12 if ( singleton ) |
| 13 { |
| 14 return * singleton; |
| 15 } |
| 16 throw std::runtime_error( "DLL_Module::module() called when DLL module was not
attached." ); |
| 17 } |
| 18 |
| 19 /** |
| 20 * The attachment function is the _de facto_ equivalent of initialization. Under
ordinary circumstances, this should |
| 21 * only be called once, and called before everything else. |
| 22 */ |
| 23 void |
| 24 DLL_Module::attach( HINSTANCE handle ) |
| 25 { |
| 26 if ( singleton ) |
| 27 { |
| 28 throw std::runtime_error( "May not call DLL_Module::attach() in an attached
state." ); |
| 29 } |
| 30 singleton = std::shared_ptr< DLL_Module >( new DLL_Module( handle ) ) ; |
| 31 } |
| 32 |
| 33 /** |
| 34 * The detachment function is the _de facto_ equivalent of finalization. Under o
rdinary circumstances, this should |
| 35 * only be called once, and called after everything else. |
| 36 */ |
| 37 void |
| 38 DLL_Module::detach() |
| 39 { |
| 40 singleton.reset(); |
| 41 } |
| 42 |
| 43 /** |
| 44 * Since this class is mostly a replacement for a global variable, it's no surpr
ising the constructor is almost trivial. |
| 45 */ |
| 46 DLL_Module::DLL_Module( HINSTANCE handle ) |
| 47 : handle( handle ) |
| 48 { |
| 49 } |
| 50 |
| 51 std::wstring |
| 52 DLL_Module::name() |
| 53 { |
| 54 if ( _name ) |
| 55 return *_name ; |
| 56 throw std::runtime_error( "Not yet implemented" ); |
| 57 } |
OLD | NEW |