KiCad PCB EDA Suite
Loading...
Searching...
No Matches
UTIL Namespace Reference

A model subscriber implementation using links to represent connections. More...

Namespaces

namespace  DETAIL
 

Classes

class  LINK
 Simple RAII-handle to a subscription. More...
 
class  OBSERVABLE
 

Typedefs

template<typename T >
using CFG_MAP = std::vector< std::pair< T, long > >
 A config value table is a list of native values (usually enums) to a different set of values, for example, the values used to represent the enum in a config file, or the index used to represent it in a selection list.
 
template<typename MAP >
using CFG_NATIVE_VAL = typename MAP::value_type::first_type
 The "native" type of a CFG_MAP: probably an enum type.
 

Functions

wxString GetRefDesPrefix (const wxString &aRefDes)
 Get the (non-numeric) prefix from a refdes - e.g.
 
wxString GetRefDesUnannotated (const wxString &aRefDes)
 Return an unannotated refdes from either a prefix or an existing refdes.
 
int GetRefDesNumber (const wxString &aRefDes)
 Get the numeric suffix from a refdes - e.g.
 
template<typename MAP >
static long GetConfigForVal (const MAP &aMap, CFG_NATIVE_VAL< MAP > aVal)
 Get the mapped config value (the one to write to file, or use in an index) from the given native (probably enum) value.
 
template<typename MAP >
static CFG_NATIVE_VAL< MAP > GetValFromConfig (const MAP &aMap, long aConf)
 Get the native value corresponding to the config value (read from file or UI, probably) and find it in the mapping table.
 

Detailed Description

A model subscriber implementation using links to represent connections.

Subscribers can be removed during notification. If no observers are registered, size is the size of a shared_ptr.

Typedef Documentation

◆ CFG_MAP

template<typename T >
using UTIL::CFG_MAP = typedef std::vector<std::pair<T, long> >

A config value table is a list of native values (usually enums) to a different set of values, for example, the values used to represent the enum in a config file, or the index used to represent it in a selection list.

It can be important to decouple from the internal representation, especially in the case of persistent config files, as adding, removing or modifying the order of items internally can easily result in configs being read incorrectly, and, even if otherwise carefully managed, results in obsolete values being kept in enums as placeholders.

The first item in the list is used default if no matching value is found during lookup.

Definition at line 49 of file config_map.h.

◆ CFG_NATIVE_VAL

template<typename MAP >
using UTIL::CFG_NATIVE_VAL = typedef typename MAP::value_type::first_type

The "native" type of a CFG_MAP: probably an enum type.

Definition at line 55 of file config_map.h.

Function Documentation

◆ GetConfigForVal()

template<typename MAP >
static long UTIL::GetConfigForVal ( const MAP &  aMap,
CFG_NATIVE_VAL< MAP >  aVal 
)
static

Get the mapped config value (the one to write to file, or use in an index) from the given native (probably enum) value.

The default (first item) is returned if the value is not found in the list.

Parameters
aMapthe value-config mapping table
aValthe value to look up

Definition at line 69 of file config_map.h.

Referenced by PANEL_PCB_DISPLAY_OPTIONS::loadPCBSettings(), and GAL_DISPLAY_OPTIONS_IMPL::WriteConfig().

◆ GetRefDesNumber()

int UTIL::GetRefDesNumber ( const wxString &  aRefDes)

Get the numeric suffix from a refdes - e.g.

R1 -> 1 IC34 -> 34 R? -> -1

Parameters
aRefDesfull refdes
Returns
the suffix, or -1 if nothing found

Definition at line 54 of file refdes_utils.cpp.

Referenced by DIALOG_BOARD_REANNOTATE::BuildUnavailableRefsList(), and DIALOG_CHANGE_SYMBOLS::processSymbols().

◆ GetRefDesPrefix()

wxString UTIL::GetRefDesPrefix ( const wxString &  aRefDes)

Get the (non-numeric) prefix from a refdes - e.g.

R1 -> R IC34 -> IC U? -> U

Parameters
aRefDesfull refdes
Returns
the prefix, or empty string if nothing found

Definition at line 35 of file refdes_utils.cpp.

References res.

Referenced by BOOST_AUTO_TEST_CASE(), compareFootprintsbyRef(), TMATCH::COMPONENT::COMPONENT(), FOOTPRINT::GetNextPadNumber(), GetRefDesUnannotated(), FOOTPRINT::IncrementReference(), SCH_SYMBOL::IsReferenceStringValid(), DIALOG_CHANGE_SYMBOLS::processSymbols(), SCH_SYMBOL::SCH_SYMBOL(), and SCH_SYMBOL::SetRef().

◆ GetRefDesUnannotated()

wxString UTIL::GetRefDesUnannotated ( const wxString &  aRefDes)

Return an unannotated refdes from either a prefix or an existing refdes.

R -> R? IC34 -> IC? U? -> U?

Parameters
aRefDes
Returns

Definition at line 48 of file refdes_utils.cpp.

References GetRefDesPrefix().

Referenced by SCH_SHEET_PATH::CheckForMissingSymbolInstances(), SCH_SYMBOL::ClearAnnotation(), SCH_SYMBOL::GetRef(), DIALOG_CHANGE_SYMBOLS::processSymbols(), SCH_SYMBOL::SCH_SYMBOL(), and SCH_SYMBOL::SetUnitSelection().

◆ GetValFromConfig()

template<typename MAP >
static CFG_NATIVE_VAL< MAP > UTIL::GetValFromConfig ( const MAP &  aMap,
long  aConf 
)
static

Get the native value corresponding to the config value (read from file or UI, probably) and find it in the mapping table.

The default item is returned if the mapping fails.

Parameters
aMapthe value-config mapping table
aConfthe config value to look up

Definition at line 96 of file config_map.h.

Referenced by GAL_DISPLAY_OPTIONS_IMPL::ReadWindowSettings(), and PANEL_PCB_DISPLAY_OPTIONS::TransferDataFromWindow().