KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ALLEGRO::DB Class Referenceabstract

An ALLEGRO::DB is the represention of the actual data stored within an Allegro file, without specific reference to the format on disk. More...

#include <allegro_db.h>

Inheritance diagram for ALLEGRO::DB:
ALLEGRO::DB_OBJ_RESOLVER ALLEGRO::BRD_DB

Public Member Functions

 DB ()
 
 ~DB ()
 
void AddObject (std::unique_ptr< DB_OBJ > aObject)
 
void AddString (uint32_t aKey, wxString &&aStr)
 
size_t GetObjectCount () const
 
void ResolveObjectLinks ()
 Iterate the database and resolve links.
 
DB_OBJResolve (uint32_t aRef) const override
 Implement the object resolver interface.
 
const wxString * ResolveString (uint32_t aRef) const override
 
bool IsSentinel (uint32_t aKey) const override
 In v18+ files, linked list sentinel nodes are real blocks with small keys.
 
void AddSentinelKey (uint32_t aKey)
 
virtual void InsertBlock (std::unique_ptr< BLOCK_BASE > aBlock)=0
 

Public Attributes

std::unordered_map< uint32_t, wxString > m_StringTable
 

Protected Member Functions

void visitLinkedList (const FILE_HEADER::LINKED_LIST aLList, std::function< const DB_REF &(const DB_OBJ &aObj)> aVisitor) const
 
void reserveObjects (size_t aCount)
 
void ResolveObjectLinksBestEffort ()
 Resolve all DB_OBJ references without throwing on failure.
 

Private Attributes

std::unordered_map< uint32_t, std::unique_ptr< DB_OBJ > > m_Objects
 
std::unordered_set< uint32_t > m_SentinelKeys
 

Detailed Description

An ALLEGRO::DB is the represention of the actual data stored within an Allegro file, without specific reference to the format on disk.

Mostly, this DB handles objects in lists.

Definition at line 252 of file allegro_db.h.

Constructor & Destructor Documentation

◆ DB()

DB::DB ( )

Definition at line 397 of file allegro_db.cpp.

◆ ~DB()

DB::~DB ( )

Definition at line 402 of file allegro_db.cpp.

Member Function Documentation

◆ AddObject()

void DB::AddObject ( std::unique_ptr< DB_OBJ > aObject)

Definition at line 407 of file allegro_db.cpp.

References m_Objects.

Referenced by ALLEGRO::BRD_DB::InsertBlock().

◆ AddSentinelKey()

void ALLEGRO::DB::AddSentinelKey ( uint32_t aKey)
inline

Definition at line 289 of file allegro_db.h.

References m_SentinelKeys.

Referenced by collectSentinelKeys().

◆ AddString()

void ALLEGRO::DB::AddString ( uint32_t aKey,
wxString && aStr )
inline

Definition at line 261 of file allegro_db.h.

References m_StringTable.

Referenced by ReadStringMap().

◆ GetObjectCount()

size_t ALLEGRO::DB::GetObjectCount ( ) const
inline

Definition at line 263 of file allegro_db.h.

References m_Objects.

Referenced by ALLEGRO::PARSER::readObjects().

◆ InsertBlock()

virtual void ALLEGRO::DB::InsertBlock ( std::unique_ptr< BLOCK_BASE > aBlock)
pure virtual

Implemented in ALLEGRO::BRD_DB.

◆ IsSentinel()

bool ALLEGRO::DB::IsSentinel ( uint32_t aKey) const
inlineoverridevirtual

In v18+ files, linked list sentinel nodes are real blocks with small keys.

References pointing to these sentinels are logically null (end-of-chain).

Reimplemented from ALLEGRO::DB_OBJ_RESOLVER.

Definition at line 284 of file allegro_db.h.

References m_SentinelKeys.

Referenced by visitLinkedList().

◆ reserveObjects()

void ALLEGRO::DB::reserveObjects ( size_t aCount)
inlineprotected

Definition at line 301 of file allegro_db.h.

References m_Objects.

Referenced by ALLEGRO::BRD_DB::ReserveCapacity().

◆ Resolve()

DB_OBJ * DB::Resolve ( uint32_t aRef) const
overridevirtual

Implement the object resolver interface.

Implements ALLEGRO::DB_OBJ_RESOLVER.

Definition at line 413 of file allegro_db.cpp.

References m_Objects.

Referenced by visitLinkedList().

◆ ResolveObjectLinks()

void DB::ResolveObjectLinks ( )

Iterate the database and resolve links.

This has to be done after all the objects are read, as they are not necessarily read in order.

This is done once per DB after loading. We can just resolve everything on-demand (with or without caching), but resolving upfront means we can detect bad references earlier which is useful when the DB data is not fully known.

Definition at line 436 of file allegro_db.cpp.

References m_Objects, and THROW_IO_ERROR.

Referenced by ALLEGRO::BRD_DB::ResolveAndValidate().

◆ ResolveObjectLinksBestEffort()

void DB::ResolveObjectLinksBestEffort ( )
protected

Resolve all DB_OBJ references without throwing on failure.

Objects that can't fully resolve are marked invalid but processing continues.

Definition at line 452 of file allegro_db.cpp.

References m_Objects.

Referenced by ALLEGRO::BRD_DB::ResolveAndValidate().

◆ ResolveString()

const wxString * DB::ResolveString ( uint32_t aRef) const
overridevirtual

Implements ALLEGRO::DB_OBJ_RESOLVER.

Definition at line 424 of file allegro_db.cpp.

References m_StringTable.

◆ visitLinkedList()

Member Data Documentation

◆ m_Objects

std::unordered_map<uint32_t, std::unique_ptr<DB_OBJ> > ALLEGRO::DB::m_Objects
private

◆ m_SentinelKeys

std::unordered_set<uint32_t> ALLEGRO::DB::m_SentinelKeys
private

Definition at line 314 of file allegro_db.h.

Referenced by AddSentinelKey(), and IsSentinel().

◆ m_StringTable

std::unordered_map<uint32_t, wxString> ALLEGRO::DB::m_StringTable

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