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
 
void ConvertTimestampToUuid ()
 Change an existing time stamp based UUID into a true UUID. More...
 
void Increment ()
 Generates a deterministic replacement for a given ID. More...
 
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. More...
 
static void CreateNilUuids (bool aNil=true)
 A performance optimization which disables/enables the generation of pseudo-random UUIDs. More...
 
static void SeedGenerator (unsigned int aSeed)
 Re-initialize the UUID generator with a given seed (for testing or QA purposes) More...
 

Private Attributes

boost::uuids::uuid m_uuid
 
timestamp_t m_cached_timestamp
 

Detailed Description

Definition at line 48 of file kiid.h.

Constructor & Destructor Documentation

◆ KIID() [1/6]

KIID::KIID ( )

Definition at line 74 of file kiid.cpp.

References g_createNilUuids, m_cached_timestamp, m_uuid, nilGenerator, randomGenerator, and rng_mutex.

◆ KIID() [2/6]

KIID::KIID ( int  null)

Definition at line 104 of file kiid.cpp.

◆ KIID() [3/6]

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

Definition at line 112 of file kiid.cpp.

References IsLegacyTimestamp(), m_cached_timestamp, m_uuid, randomGenerator, and stringGenerator.

◆ KIID() [4/6]

KIID::KIID ( const char *  aString)

Definition at line 167 of file kiid.cpp.

◆ KIID() [5/6]

KIID::KIID ( const wxString &  aString)

Definition at line 173 of file kiid.cpp.

◆ KIID() [6/6]

KIID::KIID ( timestamp_t  aTimestamp)

Definition at line 207 of file kiid.cpp.

References AsLegacyTimestampString(), m_cached_timestamp, and m_uuid.

Member Function Documentation

◆ AsLegacyTimestamp()

timestamp_t KIID::AsLegacyTimestamp ( ) const

◆ AsLegacyTimestampString()

wxString KIID::AsLegacyTimestampString ( ) const

Definition at line 263 of file kiid.cpp.

References AsLegacyTimestamp().

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

◆ AsString()

◆ Clone()

void KIID::Clone ( const KIID aUUID)

Definition at line 250 of file kiid.cpp.

References m_cached_timestamp, and m_uuid.

◆ 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 269 of file kiid.cpp.

References IsLegacyTimestamp(), m_cached_timestamp, 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 294 of file kiid.cpp.

References g_createNilUuids.

Referenced by SYMBOL_TREE_MODEL_ADAPTER::AddLibraries(), KIID_NIL_SET_RESET::KIID_NIL_SET_RESET(), SYMBOL_VIEWER_FRAME::loadAllLibraries(), and KIID_NIL_SET_RESET::~KIID_NIL_SET_RESET().

◆ Hash()

size_t KIID::Hash ( ) const

Definition at line 236 of file kiid.cpp.

References m_uuid.

Referenced by BOOST_AUTO_TEST_CASE().

◆ 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 279 of file kiid.cpp.

References m_uuid.

◆ IsLegacyTimestamp()

bool KIID::IsLegacyTimestamp ( ) const

Definition at line 224 of file kiid.cpp.

References m_uuid.

Referenced by ConvertTimestampToUuid(), and KIID().

◆ operator!=()

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

Definition at line 111 of file kiid.h.

References m_uuid.

◆ operator<()

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

Definition at line 116 of file kiid.h.

References m_uuid.

◆ operator==()

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

Definition at line 106 of file kiid.h.

References m_uuid.

◆ operator>()

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

Definition at line 121 of file kiid.h.

References 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 300 of file kiid.cpp.

References randomGenerator, and rng.

Referenced by 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 179 of file kiid.cpp.

References AsString(), and niluuid.

Referenced by searchAreas().

Member Data Documentation

◆ m_cached_timestamp

timestamp_t KIID::m_cached_timestamp
private

Definition at line 129 of file kiid.h.

Referenced by AsLegacyTimestamp(), Clone(), ConvertTimestampToUuid(), and KIID().

◆ m_uuid

boost::uuids::uuid KIID::m_uuid
private

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