KiCad PCB EDA Suite
bin_mod.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2014 CERN
5  * Copyright (C) 2014 KiCad Developers, see CHANGELOG.TXT for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #include <bin_mod.h>
26 #include <common.h>
27 
28 
29 BIN_MOD::BIN_MOD( const char* aName ) :
30  m_name( aName ),
31  m_config( 0 )
32 {
33 }
34 
35 
37 {
38  // do an OS specific wxConfig instantiation, using the bin_mod (EXE/DLL/DSO) name.
39  m_config = GetNewConfig( wxString::FromUTF8( m_name ) );
40 
41  m_history.Load( *m_config );
42 
43  // Prepare On Line Help. Use only lower case for help file names, in order to
44  // avoid problems with upper/lower case file names under windows and unix.
45  // Help files are now using html format.
46  // Old help files used pdf format.
47  // so when searching a help file, the .html file will be searched,
48  // and if not found, the .pdf file will be searched.
49  m_help_file = wxString::FromUTF8( m_name ); // no ext given. can be .html or .pdf
50 }
51 
52 
54 {
55  if( m_config )
56  {
57  m_history.Save( *m_config );
58 
59  // Deleting a wxConfigBase writes its contents to disk if changed.
60  // Might be NULL if called twice, in which case nothing happens.
61  delete m_config;
62  m_config = 0;
63  }
64 }
65 
66 
68 {
69  End();
70 }
71 
void Init()
Definition: bin_mod.cpp:36
wxConfigBase * GetNewConfig(const wxString &aProgName)
Function GetNewConfig.
Definition: common.cpp:205
~BIN_MOD()
Definition: bin_mod.cpp:67
wxString m_help_file
Definition: bin_mod.h:59
wxFileHistory m_history
Definition: bin_mod.h:58
The common library.
BIN_MOD(const char *aName)
Definition: bin_mod.cpp:29
wxConfigBase * m_config
maybe from $HOME/.${m_name}
Definition: bin_mod.h:57
const char * m_name
name of this binary module, static C string.
Definition: bin_mod.h:55
void End()
Definition: bin_mod.cpp:53