KiCad PCB EDA Suite
BIN_MOD Struct Reference

Struct BIN_MOD pertains to a single program module, either an EXE or a DSO/DLL ("bin_mod"). More...

#include <bin_mod.h>

Public Member Functions

 BIN_MOD (const char *aName)
 
 ~BIN_MOD ()
 
void Init ()
 
void End ()
 

Public Attributes

const char * m_name
 name of this binary module, static C string. More...
 
std::unique_ptr< wxConfigBase > m_config
 maybe from $HOME/.${m_name} More...
 
FILE_HISTORYm_history
 
wxString m_help_file
 
SEARCH_STACK m_search
 

Detailed Description

Struct BIN_MOD pertains to a single program module, either an EXE or a DSO/DLL ("bin_mod").

It manages miscellaneous configuration file information pertinent to one bin_mod. Because it serves in both DSO/DLLs and in EXEs, its name is neutral.

Accessors are in containing (wrapper) classes.

Definition at line 49 of file bin_mod.h.

Constructor & Destructor Documentation

◆ BIN_MOD()

BIN_MOD::BIN_MOD ( const char *  aName)

Definition at line 31 of file bin_mod.cpp.

31  :
32  m_name( aName ),
33  m_history( 0 )
34 {
35 }
FILE_HISTORY * m_history
Definition: bin_mod.h:60
const char * m_name
name of this binary module, static C string.
Definition: bin_mod.h:57

◆ ~BIN_MOD()

BIN_MOD::~BIN_MOD ( )

Definition at line 76 of file bin_mod.cpp.

77 {
78  End();
79 }
void End()
Definition: bin_mod.cpp:63

References End().

Member Function Documentation

◆ End()

void BIN_MOD::End ( )

Definition at line 63 of file bin_mod.cpp.

64 {
65  if( m_config )
66  {
67  m_history->Save( *m_config.get() );
68  delete m_history;
69 
70  // Deleting a wxConfigBase writes its contents to disk if changed.
71  m_config.reset();
72  }
73 }
FILE_HISTORY * m_history
Definition: bin_mod.h:60
std::unique_ptr< wxConfigBase > m_config
maybe from $HOME/.${m_name}
Definition: bin_mod.h:59

References m_config, and m_history.

Referenced by PGM_KICAD::Destroy(), KIFACE_I::end_common(), and ~BIN_MOD().

◆ Init()

void BIN_MOD::Init ( )

Definition at line 38 of file bin_mod.cpp.

39 {
40  // do an OS specific wxConfig instantiation, using the bin_mod (EXE/DLL/DSO) name.
41  m_config = GetNewConfig( wxString::FromUTF8( m_name ) );
42 
43  // wxWidgets' implementation of this is *very* expensive, and we don't use them anyway.
44  m_config->SetExpandEnvVars( false );
45 
46  // get file history size from common settings
47  int fileHistorySize;
48  Pgm().CommonSettings()->Read( FILE_HISTORY_SIZE_KEY, &fileHistorySize, DEFAULT_FILE_HISTORY_SIZE );
49 
50  m_history = new FILE_HISTORY( (unsigned) std::max( 0, fileHistorySize ), ID_FILE1 );
51  m_history->Load( *m_config.get() );
52 
53  // Prepare On Line Help. Use only lower case for help file names, in order to
54  // avoid problems with upper/lower case file names under windows and unix.
55  // Help files are now using html format.
56  // Old help files used pdf format.
57  // so when searching a help file, the .html file will be searched,
58  // and if not found, the .pdf file will be searched.
59  m_help_file = wxString::FromUTF8( m_name ); // no ext given. can be .html or .pdf
60 }
std::unique_ptr< wxConfigBase > GetNewConfig(const wxString &aProgName)
Create a new wxConfig so we can put configuration files in a more proper place for each platform.
Definition: common.cpp:256
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
#define FILE_HISTORY_SIZE_KEY
Definition: pgm_base.h:54
FILE_HISTORY * m_history
Definition: bin_mod.h:60
VTBL_ENTRY wxConfigBase * CommonSettings() const
Definition: pgm_base.h:204
wxString m_help_file
Definition: bin_mod.h:61
#define max(a, b)
Definition: auxiliary.h:86
#define DEFAULT_FILE_HISTORY_SIZE
IDs range for menuitems file history: The default range file history size is 9 (compatible with defau...
Definition: id.h:69
Definition: id.h:89
const char * m_name
name of this binary module, static C string.
Definition: bin_mod.h:57
std::unique_ptr< wxConfigBase > m_config
maybe from $HOME/.${m_name}
Definition: bin_mod.h:59

References PGM_BASE::CommonSettings(), DEFAULT_FILE_HISTORY_SIZE, FILE_HISTORY_SIZE_KEY, GetNewConfig(), ID_FILE1, m_config, m_help_file, m_history, m_name, max, and Pgm().

Referenced by PGM_KICAD::OnPgmInit(), and KIFACE_I::start_common().

Member Data Documentation

◆ m_config

std::unique_ptr<wxConfigBase> BIN_MOD::m_config

maybe from $HOME/.${m_name}

Definition at line 59 of file bin_mod.h.

Referenced by End(), Init(), KIFACE_I::KifaceSettings(), and PGM_KICAD::PgmSettings().

◆ m_help_file

wxString BIN_MOD::m_help_file

Definition at line 61 of file bin_mod.h.

Referenced by PGM_KICAD::GetHelpFileName(), KIFACE_I::GetHelpFileName(), and Init().

◆ m_history

FILE_HISTORY* BIN_MOD::m_history

Definition at line 60 of file bin_mod.h.

Referenced by End(), PGM_KICAD::GetFileHistory(), KIFACE_I::GetFileHistory(), and Init().

◆ m_name

const char* BIN_MOD::m_name

name of this binary module, static C string.

Definition at line 57 of file bin_mod.h.

Referenced by Init(), and KIFACE_I::Name().

◆ m_search


The documentation for this struct was generated from the following files: