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