KiCad PCB EDA Suite
Loading...
Searching...
No Matches
KIID Class Reference

#include <kiid.h>

Public Member Functions

 KIID ()
 
 KIID (int null)
 
 KIID (const std::string &aString)
 
 KIID (const char *aString)
 
 KIID (const wxString &aString)
 
 KIID (timestamp_t aTimestamp)
 
void Clone (const KIID &aUUID)
 
size_t Hash () const
 
bool IsLegacyTimestamp () const
 
timestamp_t AsLegacyTimestamp () const
 
wxString AsString () const
 
wxString AsLegacyTimestampString () const
 
std::string AsStdString () const
 
void ConvertTimestampToUuid ()
 Change an existing time stamp based UUID into a true UUID.
 
void Increment ()
 Generates a deterministic replacement for a given ID.
 
bool operator== (KIID const &rhs) const
 
bool operator!= (KIID const &rhs) const
 
bool operator< (KIID const &rhs) const
 
bool operator> (KIID const &rhs) const
 

Static Public Member Functions

static bool SniffTest (const wxString &aCandidate)
 Returns true if a string has the correct formatting to be a KIID.
 
static void CreateNilUuids (bool aNil=true)
 A performance optimization which disables/enables the generation of pseudo-random UUIDs.
 
static void SeedGenerator (unsigned int aSeed)
 Re-initialize the UUID generator with a given seed (for testing or QA purposes)
 
static KIID Combine (const KIID &aFirst, const KIID &aSecond)
 Creates a deterministic KIID from two input KIIDs by XORing their underlying UUIDs.
 
static KIID FromDeterministicString (const wxString &aName)
 Build a deterministic UUID from an arbitrary name string.
 

Private Attributes

boost::uuids::uuid m_uuid
 

Detailed Description

Definition at line 43 of file kiid.h.

Constructor & Destructor Documentation

◆ KIID() [1/6]

◆ KIID() [2/6]

KIID::KIID ( int null)

Definition at line 100 of file kiid.cpp.

References m_uuid, and nilGenerator.

◆ KIID() [3/6]

KIID::KIID ( const std::string & aString)

Definition at line 107 of file kiid.cpp.

References m_uuid.

◆ KIID() [4/6]

KIID::KIID ( const char * aString)

Definition at line 162 of file kiid.cpp.

References KIID().

◆ KIID() [5/6]

KIID::KIID ( const wxString & aString)

Definition at line 168 of file kiid.cpp.

References KIID().

◆ KIID() [6/6]

KIID::KIID ( timestamp_t aTimestamp)

Definition at line 202 of file kiid.cpp.

References m_uuid.

Member Function Documentation

◆ AsLegacyTimestamp()

timestamp_t KIID::AsLegacyTimestamp ( ) const

◆ AsLegacyTimestampString()

wxString KIID::AsLegacyTimestampString ( ) const

Definition at line 254 of file kiid.cpp.

References AsLegacyTimestamp().

Referenced by BOOST_AUTO_TEST_CASE(), and SCH_IO_KICAD_LEGACY::saveSymbol().

◆ AsStdString()

std::string KIID::AsStdString ( ) const

◆ AsString()

wxString KIID::AsString ( ) const

Definition at line 242 of file kiid.cpp.

References m_uuid.

Referenced by KIID_PATH::AsString(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_DATA_TEST_CASE(), BOOST_DATA_TEST_CASE(), BOOST_DATA_TEST_CASE(), BOOST_DATA_TEST_CASE(), BOOST_DATA_TEST_CASE_F(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), TMATCH::CONNECTION_GRAPH::breakTieBySymbolUuid(), SCH_SHEET_LIST::BuildSheetList(), SCH_SHEET_PATH::CheckForMissingSymbolInstances(), PCB_IO_IPC2581::componentName(), LIB_FIELDS_EDITOR_GRID_DATA_MODEL::CreateDerivedSymbol(), KIGFX::SCH_PAINTER::draw(), KIGFX::SCH_PAINTER::draw(), MULTICHANNEL_TOOL::findOtherItemsInRuleArea(), MULTICHANNEL_TOOL::findRoutingInRuleArea(), SCH_EDITOR_CONTROL::FindSymbolAndItem(), formatArc(), formatBezier(), formatCircle(), formatEllipse(), formatEllipseArc(), formatPoly(), formatRect(), KICAD_FORMAT::FormatUuid(), from_json(), SCH_PIN::GetDefaultNetName(), RC_ITEM::GetJsonViolation(), GetMsgPanelDisplayUuid(), PROJECT::GetSheetName(), DRC_ENGINE::loadImplicitRules(), FOOTPRINT_EDITOR_TAB_CONTEXT::MakeInstanceTabKey(), SYMBOL_EDITOR_TAB_CONTEXT::MakeInstanceTabKey(), NETLIST_EXPORTER_XML::makeSymbols(), SCH_EDIT_FRAME::OpenProjectFiles(), PackSymbol(), PCB_IO_KICAD_SEXPR_PARSER::parseBOARD_unchecked(), SCH_SHEET_PATH::PathAsString(), BOARD::RebindItemUuid(), DIALOG_GENERATORS::RebuildModels(), CONNECTION_GRAPH::ReplaceNetChainTerminalPin(), PCB_IO_KICAD_SEXPR_PARSER::resolveGroups(), SCH_MARKER::SerializeToString(), testGroupEqual(), to_json(), to_json(), DIALOG_LIB_FIELDS_TABLE::TransferDataFromWindow(), NET_CHAIN_MENU::update(), SCH_EDITOR_CONTROL::updatePastedSymbol(), and NETLIST_EXPORTER_ORCADPCB2::WriteNetlist().

◆ Clone()

void KIID::Clone ( const KIID & aUUID)

Definition at line 236 of file kiid.cpp.

References KIID(), and m_uuid.

◆ Combine()

KIID KIID::Combine ( const KIID & aFirst,
const KIID & aSecond )
static

Creates a deterministic KIID from two input KIIDs by XORing their underlying UUIDs.

This is useful for generating stable IDs for derived objects (like teardrops) that are created from the combination of two parent objects.

Parameters
aFirstthe first KIID to combine
aSecondthe second KIID to combine
Returns
a new KIID that is the XOR combination of the two inputs

Definition at line 284 of file kiid.cpp.

References KIID(), m_uuid, and result.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), TEARDROP_MANAGER::createTeardrop(), and TEARDROP_MANAGER::createTeardropMask().

◆ ConvertTimestampToUuid()

void KIID::ConvertTimestampToUuid ( )

Change an existing time stamp based UUID into a true UUID.

If this is not a time stamp based UUID, then no change is made.

Definition at line 260 of file kiid.cpp.

References IsLegacyTimestamp(), m_uuid, and randomGenerator.

◆ CreateNilUuids()

void KIID::CreateNilUuids ( bool aNil = true)
static

A performance optimization which disables/enables the generation of pseudo-random UUIDs.

NB: uses a global. Not thread safe!

Definition at line 325 of file kiid.cpp.

References g_createNilUuids.

Referenced by KIID_NIL_SET_RESET::KIID_NIL_SET_RESET(), and KIID_NIL_SET_RESET::~KIID_NIL_SET_RESET().

◆ FromDeterministicString()

KIID KIID::FromDeterministicString ( const wxString & aName)
static

Build a deterministic UUID from an arbitrary name string.

The same input always yields the same UUID, and distinct inputs almost always yield distinct UUIDs. This is useful for keying objects that have a stable name but no native UUID (e.g. library symbols / footprints, which are file-name keyed rather than UUID keyed) so that two callsites derive the identical id for the same name.

The output bytes are part of the diff/merge engine's on-disk contract; the hashing here must not change once persisted artifacts depend on it.

Hashing is over wxChar code units, so for non-ASCII input the result differs between platforms with 16-bit vs 32-bit wxChar (Windows vs Linux/macOS); do not rely on cross-platform stability for non-ASCII names.

Parameters
aNamethe source string to hash.
Returns
a deterministic KIID derived from aName.

Definition at line 295 of file kiid.cpp.

References KIID().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), KICAD_DIFF::PCB_DIFFER::diffFootprintChildren(), and KICAD_DIFF::LibraryItemKiidPath().

◆ Hash()

size_t KIID::Hash ( ) const

Definition at line 230 of file kiid.cpp.

References m_uuid.

Referenced by BOOST_AUTO_TEST_CASE(), and std::hash< KIID >::operator()().

◆ Increment()

void KIID::Increment ( )

Generates a deterministic replacement for a given ID.

NB: destroys uniform distribution! But it's the only thing we have when a deterministic replacement for a duplicate ID is required.

Definition at line 269 of file kiid.cpp.

References m_uuid.

Referenced by BOOST_AUTO_TEST_CASE(), and TEARDROP_MANAGER::createTeardropMask().

◆ IsLegacyTimestamp()

bool KIID::IsLegacyTimestamp ( ) const

Definition at line 211 of file kiid.cpp.

References m_uuid.

Referenced by ConvertTimestampToUuid().

◆ operator!=()

bool KIID::operator!= ( KIID const & rhs) const
inline

Definition at line 140 of file kiid.h.

References KIID(), and m_uuid.

◆ operator<()

bool KIID::operator< ( KIID const & rhs) const
inline

Definition at line 145 of file kiid.h.

References KIID(), and m_uuid.

◆ operator==()

bool KIID::operator== ( KIID const & rhs) const
inline

Definition at line 135 of file kiid.h.

References KIID(), and m_uuid.

◆ operator>()

bool KIID::operator> ( KIID const & rhs) const
inline

Definition at line 150 of file kiid.h.

References KIID(), and m_uuid.

◆ SeedGenerator()

void KIID::SeedGenerator ( unsigned int aSeed)
static

Re-initialize the UUID generator with a given seed (for testing or QA purposes)

WARNING: Do not call this function from within KiCad or via a Python action plugin. It is only to be used inside QA tests or in external Python scripts. Resetting the UUID generator in the middle of a KiCad GUI run will potentially have harmful effects on file integrity.

Parameters
aSeedis a seed to pass to the boost::mt19937 pseudo-random number generator

Definition at line 331 of file kiid.cpp.

References randomGenerator, and rng.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ SniffTest()

bool KIID::SniffTest ( const wxString & aCandidate)
static

Returns true if a string has the correct formatting to be a KIID.

Definition at line 174 of file kiid.cpp.

References niluuid.

Referenced by searchAreas().

Member Data Documentation

◆ m_uuid


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