|
KiCad PCB EDA Suite
|
An Allegro database that represents a .brd file (amd presumably .dra) More...
#include <allegro_db.h>
Classes | |
| class | OBJ_FACTORY |
| Converts blocks of "raw" binary-ish data into a DB_OBJ of the appropriate type to be stored in the DB. More... | |
Public Types | |
| using | FP_DEF_VISITOR = std::function<void( const FOOTPRINT_DEF& aFpDef )> |
Public Member Functions | |
| BRD_DB () | |
| void | InsertBlock (std::unique_ptr< BLOCK_BASE > aBlock) override |
| void | ReserveCapacity (size_t aObjectCount, size_t aStringCount) |
| Pre-allocate storage for the expected number of objects and strings. | |
| void | SetLeanMode (bool aLean) |
| When true, InsertBlock skips DB_OBJ creation for high-volume block types (segments, graphics, arcs) that the BOARD_BUILDER accesses only through raw BLOCK_BASE. | |
| bool | ResolveAndValidate () |
| Iterate all the links we know about and fill in the object links. | |
| void | VisitFootprintDefs (FP_DEF_VISITOR aFpDef) const |
| Access the footprint defs in the database. | |
| void | VisitFootprintInstances (VIEW_OBJS_VISITOR aVisitor) const |
| Access the footprint instances in the database. | |
| void | visitFootprintInstances (const FOOTPRINT_DEF &aFpDef, VIEW_OBJS_VISITOR aVisitor) const |
| void | VisitFunctionInstances (VIEW_OBJS_VISITOR aVisitor) const |
| Access the function instances in the database. | |
| void | VisitComponents (VIEW_OBJS_VISITOR aVisitor) const |
| void | VisitComponentPins (VIEW_OBJS_VISITOR aVisitor) const |
| Visit all component pins in the database. | |
| void | VisitNets (VIEW_OBJS_VISITOR aVisitor) const |
| void | VisitConnectedGeometry (VIEW_OBJS_VISITOR aVisitor) const |
| const BLOCK_BASE * | GetObjectByKey (uint32_t aKey) const |
| Get a raw block by its key (for compatibility with BOARD_BUILDER). | |
| const wxString & | GetString (uint32_t aKey) const |
| Get a string from the string table by key. | |
| 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_OBJ * | Resolve (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) |
Public Attributes | |
| FMT_VER | m_FmtVer |
| std::unique_ptr< FILE_HEADER > | m_Header |
| std::vector< std::unique_ptr< BLOCK_BASE > > | m_Blocks |
| std::unordered_map< uint32_t, BLOCK_BASE * > | m_ObjectKeyMap |
| 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 | |
| OBJ_FACTORY | m_ObjFactory |
| bool | m_leanMode |
| std::unordered_map< uint32_t, std::unique_ptr< DB_OBJ > > | m_Objects |
| std::unordered_set< uint32_t > | m_SentinelKeys |
An Allegro database that represents a .brd file (amd presumably .dra)
Definition at line 849 of file allegro_db.h.
| using ALLEGRO::BRD_DB::FP_DEF_VISITOR = std::function<void( const FOOTPRINT_DEF& aFpDef )> |
Definition at line 901 of file allegro_db.h.
| BRD_DB::BRD_DB | ( | ) |
Definition at line 1575 of file allegro_db.cpp.
References m_FmtVer, m_leanMode, m_ObjFactory, and ALLEGRO::V_UNKNOWN.
Referenced by ALLEGRO::BRD_DB::OBJ_FACTORY::OBJ_FACTORY().
|
inherited |
Definition at line 407 of file allegro_db.cpp.
References m_Objects.
Referenced by ALLEGRO::BRD_DB::InsertBlock().
|
inlineinherited |
Definition at line 289 of file allegro_db.h.
References m_SentinelKeys.
Referenced by collectSentinelKeys().
|
inlineinherited |
Definition at line 261 of file allegro_db.h.
References m_StringTable.
Referenced by ReadStringMap().
|
inline |
Get a raw block by its key (for compatibility with BOARD_BUILDER).
Definition at line 942 of file allegro_db.h.
References m_ObjectKeyMap.
|
inlineinherited |
Definition at line 263 of file allegro_db.h.
References m_Objects.
Referenced by ALLEGRO::PARSER::readObjects().
|
inline |
Get a string from the string table by key.
Definition at line 951 of file allegro_db.h.
References empty(), and ALLEGRO::DB::m_StringTable.
|
overridevirtual |
Implements ALLEGRO::DB.
Definition at line 217 of file allegro_db.cpp.
References ALLEGRO::DB::AddObject(), m_Blocks, m_leanMode, m_ObjectKeyMap, and m_ObjFactory.
Referenced by ALLEGRO::PARSER::readObjects().
|
inlineoverridevirtualinherited |
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().
| void BRD_DB::ReserveCapacity | ( | size_t | aObjectCount, |
| size_t | aStringCount ) |
Pre-allocate storage for the expected number of objects and strings.
Avoids incremental rehashing as elements are inserted.
Definition at line 208 of file allegro_db.cpp.
References m_Blocks, m_ObjectKeyMap, ALLEGRO::DB::m_StringTable, and ALLEGRO::DB::reserveObjects().
|
inlineprotectedinherited |
Definition at line 301 of file allegro_db.h.
References m_Objects.
Referenced by ALLEGRO::BRD_DB::ReserveCapacity().
|
overridevirtualinherited |
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().
| bool BRD_DB::ResolveAndValidate | ( | ) |
Iterate all the links we know about and fill in the object links.
This means that when we come to use the objects, we don't have to keep looking them up in the DB and handling failures.
Definition at line 1583 of file allegro_db.cpp.
References collectSentinelKeys(), m_FmtVer, m_Header, m_leanMode, IO_ERROR::Problem(), ALLEGRO::DB::ResolveObjectLinks(), ALLEGRO::DB::ResolveObjectLinksBestEffort(), and ALLEGRO::V_180.
|
inherited |
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().
|
protectedinherited |
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().
|
overridevirtualinherited |
Implements ALLEGRO::DB_OBJ_RESOLVER.
Definition at line 424 of file allegro_db.cpp.
References m_StringTable.
|
inline |
When true, InsertBlock skips DB_OBJ creation for high-volume block types (segments, graphics, arcs) that the BOARD_BUILDER accesses only through raw BLOCK_BASE.
Types needed by VisitNets (NET, FIELD, etc.) still get full DB_OBJ resolution.
Definition at line 891 of file allegro_db.h.
References m_leanMode.
| void BRD_DB::VisitComponentPins | ( | VIEW_OBJS_VISITOR | aVisitor | ) | const |
Visit all component pins in the database.
Definition at line 1748 of file allegro_db.cpp.
References ALLEGRO::PLACED_PAD::GetNet(), ALLEGRO::VIEW_OBJS::m_Net, ALLEGRO::VIEW_OBJS::m_Pad, ALLEGRO::COMPONENT_INST::m_Pads, ALLEGRO::DB_REF_CHAIN::Visit(), and VisitComponents().
| void BRD_DB::VisitComponents | ( | VIEW_OBJS_VISITOR | aVisitor | ) | const |
Definition at line 1700 of file allegro_db.cpp.
References ALLEGRO::DB_NULLREF, ALLEGRO::COMPONENT_INST::GetFunctionInstance(), ALLEGRO::VIEW_OBJS::m_Board, ALLEGRO::VIEW_OBJS::m_Component, ALLEGRO::VIEW_OBJS::m_ComponentInstance, ALLEGRO::VIEW_OBJS::m_Function, m_Header, ALLEGRO::COMPONENT::m_Instances, ALLEGRO::COMPONENT::m_Next, ALLEGRO::DB_REF_CHAIN::Visit(), and ALLEGRO::DB::visitLinkedList().
Referenced by VisitComponentPins(), and VisitFunctionInstances().
| void BRD_DB::VisitConnectedGeometry | ( | VIEW_OBJS_VISITOR | aVisitor | ) | const |
Definition at line 1816 of file allegro_db.cpp.
References ALLEGRO::VIEW_OBJS::m_Board, and VisitNets().
| void BRD_DB::VisitFootprintDefs | ( | BRD_DB::FP_DEF_VISITOR | aVisitor | ) | const |
Access the footprint defs in the database.
This iterates the 0x2B linked list.
Definition at line 1617 of file allegro_db.cpp.
References ALLEGRO::DB_NULLREF, m_Header, ALLEGRO::FOOTPRINT_DEF::m_Next, and ALLEGRO::DB::visitLinkedList().
Referenced by VisitFootprintInstances().
| void BRD_DB::VisitFootprintInstances | ( | VIEW_OBJS_VISITOR | aVisitor | ) | const |
Access the footprint instances in the database.
This iterates the 0x2D linked list for a given footprint def.
Definition at line 1670 of file allegro_db.cpp.
References ALLEGRO::VIEW_OBJS::m_Board, VisitFootprintDefs(), and visitFootprintInstances().
| void BRD_DB::visitFootprintInstances | ( | const FOOTPRINT_DEF & | aFpDef, |
| VIEW_OBJS_VISITOR | aVisitor ) const |
Definition at line 1635 of file allegro_db.cpp.
References ALLEGRO::FOOTPRINT_INSTANCE::GetComponentInstance(), ALLEGRO::COMPONENT_INST::GetFunctionInstance(), ALLEGRO::DB_OBJ::GetKey(), ALLEGRO::COMPONENT_INST::GetParentComponent(), ALLEGRO::VIEW_OBJS::m_Board, ALLEGRO::VIEW_OBJS::m_Component, ALLEGRO::VIEW_OBJS::m_FootprintInstance, ALLEGRO::VIEW_OBJS::m_Function, ALLEGRO::FOOTPRINT_DEF::m_Instances, and ALLEGRO::DB_REF_CHAIN::Visit().
Referenced by VisitFootprintInstances().
| void BRD_DB::VisitFunctionInstances | ( | VIEW_OBJS_VISITOR | aVisitor | ) | const |
Access the function instances in the database.
This iterates the 0x06 linked list and finds the functions.
If the function is assigned to a component, the component is set. If the component is placed, the symbol is also set.
Definition at line 1686 of file allegro_db.cpp.
References VisitComponents().
|
protectedinherited |
Definition at line 459 of file allegro_db.cpp.
References IsSentinel(), ALLEGRO::FILE_HEADER::LINKED_LIST::m_Head, ALLEGRO::FILE_HEADER::LINKED_LIST::m_Tail, ALLEGRO::DB_REF::m_Target, ALLEGRO::DB_REF::m_TargetKey, Resolve(), and THROW_IO_ERROR.
Referenced by ALLEGRO::BRD_DB::VisitComponents(), ALLEGRO::BRD_DB::VisitFootprintDefs(), and ALLEGRO::BRD_DB::VisitNets().
| void BRD_DB::VisitNets | ( | VIEW_OBJS_VISITOR | aVisitor | ) | const |
Definition at line 1788 of file allegro_db.cpp.
References ALLEGRO::DB_NULLREF, ALLEGRO::VIEW_OBJS::m_Board, m_Header, ALLEGRO::VIEW_OBJS::m_Net, ALLEGRO::NET::m_Next, and ALLEGRO::DB::visitLinkedList().
Referenced by VisitConnectedGeometry().
| std::vector<std::unique_ptr<BLOCK_BASE> > ALLEGRO::BRD_DB::m_Blocks |
Definition at line 966 of file allegro_db.h.
Referenced by InsertBlock(), and ReserveCapacity().
| FMT_VER ALLEGRO::BRD_DB::m_FmtVer |
Definition at line 962 of file allegro_db.h.
Referenced by BRD_DB(), ALLEGRO::PARSER::readObjects(), and ResolveAndValidate().
| std::unique_ptr<FILE_HEADER> ALLEGRO::BRD_DB::m_Header |
Definition at line 963 of file allegro_db.h.
Referenced by ALLEGRO::COMPONENT::COMPONENT(), ALLEGRO::FOOTPRINT_DEF::FOOTPRINT_DEF(), ALLEGRO::GRAPHIC_SEG::GRAPHIC_SEG(), ALLEGRO::NET::NET(), ALLEGRO::PARSER::readObjects(), ALLEGRO::RECT_OBJ::RECT_OBJ(), ResolveAndValidate(), ALLEGRO::SHAPE::SHAPE(), VisitComponents(), VisitFootprintDefs(), and VisitNets().
|
private |
Definition at line 973 of file allegro_db.h.
Referenced by BRD_DB(), InsertBlock(), ResolveAndValidate(), and SetLeanMode().
| std::unordered_map<uint32_t, BLOCK_BASE*> ALLEGRO::BRD_DB::m_ObjectKeyMap |
Definition at line 967 of file allegro_db.h.
Referenced by GetObjectByKey(), InsertBlock(), and ReserveCapacity().
|
privateinherited |
Definition at line 311 of file allegro_db.h.
Referenced by AddObject(), GetObjectCount(), reserveObjects(), Resolve(), ResolveObjectLinks(), and ResolveObjectLinksBestEffort().
|
private |
Definition at line 971 of file allegro_db.h.
Referenced by BRD_DB(), and InsertBlock().
|
privateinherited |
Definition at line 314 of file allegro_db.h.
Referenced by AddSentinelKey(), and IsSentinel().
|
inherited |
Definition at line 317 of file allegro_db.h.
Referenced by AddString(), ALLEGRO::BRD_DB::GetString(), ALLEGRO::BRD_DB::ReserveCapacity(), and ResolveString().