Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: installer/src/installer-lib/DLL.cpp

Issue 22887001: Custom action library, initial version (Closed)
Patch Set: Created Oct. 28, 2013, 9:37 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld