KiCad PCB EDA Suite
TOOL_SETTINGS Class Reference

#include <tool_settings.h>

Public Member Functions

 TOOL_SETTINGS (TOOL_BASE *aTool=NULL)
 
 ~TOOL_SETTINGS ()
 
template<class T >
Get (const wxString &aName, T aDefaultValue) const
 
template<class T >
void Set (const wxString &aName, const T &aValue)
 

Private Member Functions

wxString getKeyName (const wxString &aEntryName) const
 
wxConfigBase * getConfigBase () const
 

Returns pointer to currently used wxConfigBase.

More...
 

Private Attributes

TOOL_BASEm_tool
 

Detailed Description

Definition at line 38 of file tool_settings.h.

Constructor & Destructor Documentation

TOOL_SETTINGS::TOOL_SETTINGS ( TOOL_BASE aTool = NULL)

Definition at line 61 of file tool_base.cpp.

61  :
62  m_tool( aTool )
63 {
64 }
TOOL_BASE * m_tool
Definition: tool_settings.h:76
TOOL_SETTINGS::~TOOL_SETTINGS ( )

Definition at line 67 of file tool_base.cpp.

68 {
69 }

Member Function Documentation

template<class T >
T TOOL_SETTINGS::Get ( const wxString &  aName,
aDefaultValue 
) const
inline

Definition at line 45 of file tool_settings.h.

References getConfigBase(), and getKeyName().

Referenced by PNS::ROUTING_SETTINGS::Load().

46  {
47  wxConfigBase* config = getConfigBase();
48 
49  if( !config )
50  return aDefaultValue;
51 
52  T tmp = aDefaultValue;
53 
54  config->Read( getKeyName( aName ), &tmp );
55  return tmp;
56  }
T
enum T contains all this lexer's tokens.
wxConfigBase * getConfigBase() const
Returns pointer to currently used wxConfigBase.
Definition: tool_base.cpp:87
wxString getKeyName(const wxString &aEntryName) const
Definition: tool_base.cpp:78
wxConfigBase * TOOL_SETTINGS::getConfigBase ( ) const
private

Returns pointer to currently used wxConfigBase.

It might be NULL, if there is no

TOOL_BASE assigned.

Definition at line 87 of file tool_base.cpp.

References TOOL_BASE::getEditFrame(), and m_tool.

Referenced by Get(), and Set().

88 {
89  if( !m_tool )
90  return NULL;
91 
92  // fixme: make independent of pcbnew (post-stable)
94  return frame->GetSettings();
95 
96  return NULL;
97 }
TOOL_BASE * m_tool
Definition: tool_settings.h:76
T * getEditFrame() const
Function getEditFrame()
Definition: tool_base.h:193
wxString TOOL_SETTINGS::getKeyName ( const wxString &  aEntryName) const
private

Definition at line 78 of file tool_base.cpp.

References TOOL_BASE::GetName(), and m_tool.

Referenced by Get(), and Set().

79 {
80  wxString key( m_tool->GetName() );
81  key += wxT( "." );
82  key += aEntryName;
83  return key;
84 }
TOOL_BASE * m_tool
Definition: tool_settings.h:76
const std::string & GetName() const
Function GetName() Returns the name of the tool.
Definition: tool_base.h:133
template<class T >
void TOOL_SETTINGS::Set ( const wxString &  aName,
const T &  aValue 
)
inline

Definition at line 59 of file tool_settings.h.

References getConfigBase(), and getKeyName().

Referenced by PNS::ROUTING_SETTINGS::Save().

60  {
61  wxConfigBase* config = getConfigBase();
62 
63  if( !config )
64  return;
65 
66  config->Write( getKeyName( aName ), aValue );
67  }
wxConfigBase * getConfigBase() const
Returns pointer to currently used wxConfigBase.
Definition: tool_base.cpp:87
wxString getKeyName(const wxString &aEntryName) const
Definition: tool_base.cpp:78

Member Data Documentation

TOOL_BASE* TOOL_SETTINGS::m_tool
private

Definition at line 76 of file tool_settings.h.

Referenced by getConfigBase(), and getKeyName().


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