29#include <unordered_map>
30#include <unordered_set>
56 explicit constexpr DB_REF( uint32_t aTargetKey ) :
102 void Visit( std::function<
void(
const DB_OBJ& aObj )> aVisitor )
const;
103 void Visit( std::function<
void(
DB_OBJ& aObj )> aVisitor );
154 virtual bool IsSentinel( uint32_t aKey )
const {
return false; }
259 void AddObject( std::unique_ptr<DB_OBJ> aObject );
282 const wxString*
ResolveString( uint32_t aRef )
const override;
295 virtual void InsertBlock( std::unique_ptr<BLOCK_BASE> aBlock ) = 0;
299 std::function<
const DB_REF&(
const DB_OBJ& aObj )> aVisitor )
const;
311 std::unordered_map<uint32_t, std::unique_ptr<DB_OBJ>>
m_Objects;
396 std::optional<std::variant<wxString, uint32_t>>
GetOptField( uint16_t aFieldCode )
const;
534 const wxString*
GetName()
const;
553 const wxString*
GetName()
const;
572 const wxString*
GetName()
const;
655 const wxString*
GetName()
const;
746 const wxString*
GetName()
const;
876 void InsertBlock( std::unique_ptr<BLOCK_BASE> aBlock )
override;
952 static const wxString
empty;
The base class for all blocks in the main body of an Allegro file.
Converts blocks of "raw" binary-ish data into a DB_OBJ of the appropriate type to be stored in the DB...
std::unique_ptr< DB_OBJ > CreateObject(const BLOCK_BASE &aBlock) const
OBJ_FACTORY(const BRD_DB &aBrdDb)
An Allegro database that represents a .brd file (amd presumably .dra)
void VisitConnectedGeometry(VIEW_OBJS_VISITOR aVisitor) const
std::unordered_map< uint32_t, BLOCK_BASE * > m_ObjectKeyMap
std::unique_ptr< FILE_HEADER > m_Header
void SetLeanMode(bool aLean)
When true, InsertBlock skips DB_OBJ creation for high-volume block types (segments,...
std::vector< std::unique_ptr< BLOCK_BASE > > m_Blocks
void visitFootprintInstances(const FOOTPRINT_DEF &aFpDef, VIEW_OBJS_VISITOR aVisitor) const
void VisitNets(VIEW_OBJS_VISITOR aVisitor) const
void VisitFunctionInstances(VIEW_OBJS_VISITOR aVisitor) const
Access the function instances in the database.
std::function< void(const FOOTPRINT_DEF &aFpDef)> FP_DEF_VISITOR
const wxString & GetString(uint32_t aKey) const
Get a string from the string table by key.
void VisitFootprintDefs(FP_DEF_VISITOR aFpDef) const
Access the footprint defs in the database.
void ReserveCapacity(size_t aObjectCount, size_t aStringCount)
Pre-allocate storage for the expected number of objects and strings.
bool ResolveAndValidate()
Iterate all the links we know about and fill in the object links.
void VisitComponents(VIEW_OBJS_VISITOR aVisitor) const
void VisitFootprintInstances(VIEW_OBJS_VISITOR aVisitor) const
Access the footprint instances in the database.
void InsertBlock(std::unique_ptr< BLOCK_BASE > aBlock) override
const BLOCK_BASE * GetObjectByKey(uint32_t aKey) const
Get a raw block by its key (for compatibility with BOARD_BUILDER).
void VisitComponentPins(VIEW_OBJS_VISITOR aVisitor) const
Visit all component pins in the database.
Some interface that can yield DB_OBJs for keys.
virtual DB_OBJ * Resolve(uint32_t aKey) const =0
Resolve the given reference.
virtual bool IsSentinel(uint32_t aKey) const
In v18+ files, linked list sentinel nodes are real blocks with small keys.
virtual const wxString * ResolveString(uint32_t aKey) const =0
virtual ~DB_OBJ_RESOLVER()
const wxString * ResolveString(uint32_t aRef) const override
std::unordered_map< uint32_t, wxString > m_StringTable
void AddObject(std::unique_ptr< DB_OBJ > aObject)
void ResolveObjectLinksBestEffort()
Resolve all DB_OBJ references without throwing on failure.
std::unordered_map< uint32_t, std::unique_ptr< DB_OBJ > > m_Objects
void AddSentinelKey(uint32_t aKey)
void AddString(uint32_t aKey, wxString &&aStr)
void visitLinkedList(const FILE_HEADER::LINKED_LIST aLList, std::function< const DB_REF &(const DB_OBJ &aObj)> aVisitor) const
bool IsSentinel(uint32_t aKey) const override
In v18+ files, linked list sentinel nodes are real blocks with small keys.
void ResolveObjectLinks()
Iterate the database and resolve links.
std::unordered_set< uint32_t > m_SentinelKeys
virtual void InsertBlock(std::unique_ptr< BLOCK_BASE > aBlock)=0
DB_OBJ * Resolve(uint32_t aRef) const override
Implement the object resolver interface.
size_t GetObjectCount() const
void reserveObjects(size_t aCount)
A field list is a linked list of 0x03.
std::optional< int > GetOptFieldExpectInt(uint16_t aFieldCode) const
Get the integer value of the field with the given code, if in the list.
FIELD_LIST(DB_REF_CHAIN &aChain)
const wxString * GetOptFieldExpectString(uint16_t aFieldCode) const
std::optional< std::variant< wxString, uint32_t > > GetOptField(uint16_t aFieldCode) const
Get the raw variant value of the field with the given code, if present.
bool ResolveRefs(const DB_OBJ_RESOLVER &aResolver) override
Called when all objects in the DB are read and can be resolved by their IDs by other objects.
SHAPE(const BRD_DB &aBrd, const BLK_0x28_SHAPE &aBlk)
bool ResolveRefs(const DB_OBJ_RESOLVER &aResolver) override
Called when all objects in the DB are read and can be resolved by their IDs by other objects.
UNKNOWN_0x20(const BRD_DB &aBrd, const BLK_0x20_UNKNOWN &aBlk)
static bool empty(const wxTextEntryBase *aCtrl)
static constexpr DB_STR_REF DB_STRNULLREF
std::function< void(const VIEW_OBJS &aViewObjs)> VIEW_OBJS_VISITOR
static constexpr DB_REF DB_NULLREF
FMT_VER
The format of an Allego file.
bool ResolveRefs(const DB_OBJ_RESOLVER &aResolver) override
Called when all objects in the DB are read and can be resolved by their IDs by other objects.
ARC(const BLK_0x01_ARC &aBlk)
Arc segment used in tracks, zone outlines, and shape boundaries.
Field/property references with variable-typed substructs.
Net assignment linking a net (0x1B) to its member objects.
Component/symbol definitions.
Component instance reference data.
Pin number within a component.
Shape/fill segment linking a copper shape to its parent footprint.
Function slot in a multi-slot component (e.g.
Function instance linking a component instance (0x07) to its schematic function, pin cross-references...
Pin name within a component, linked from function slots (0x0F).
Cross-reference between objects.
Graphics container holding a chain of line segments and arcs.
0x15 , 0x16, 0x17 are segments:
Polygon shape defined by a linked list of segments starting at m_FirstSegmentPtr (0x15/0x16/0x17 line...
Connection point at a track junction or pad-to-track transition.
Placed pad instance linking a pad definition (0x0D via m_PadPtr) to its parent footprint (m_ParentFp)...
Via instance with board position, padstack reference (m_Padstack for drill/annular ring definitions),...
COMPONENT_INST 0x07 objects.
const wxString * GetRefDesStr() const
COMPONENT * m_ParentComponent
const COMPONENT_INST * GetNextInstance() const
COMPONENT_INST(const BLK_0x07_COMPONENT_INST &aBlk)
const COMPONENT * GetParentComponent() const
bool ResolveRefs(const DB_OBJ_RESOLVER &aResolver) override
Called when all objects in the DB are read and can be resolved by their IDs by other objects.
const PLACED_PAD & GetFirstPad() const
const FUNCTION_INSTANCE & GetFunctionInstance() const
const wxString * GetComponentDeviceType() const
bool ResolveRefs(const DB_OBJ_RESOLVER &aResolver) override
Called when all objects in the DB are read and can be resolved by their IDs by other objects.
DB_STR_REF m_CompDeviceType
COMPONENT(const BRD_DB &aBrd, const BLK_0x06_COMPONENT &aBlk)
const COMPONENT_INST & GetComponentInstance() const
CONNECTION_OBJ(const BRD_DB &aBrd, const BLK_0x2E_CONNECTION &aBlk)
bool ResolveRefs(const DB_OBJ_RESOLVER &aResolver) override
Called when all objects in the DB are read and can be resolved by their IDs by other objects.
A DB_OBJ represents one object in an Allegro database.
DB_OBJ(TYPE aType, uint32_t aKey)
virtual bool ResolveRefs(const DB_OBJ_RESOLVER &aResolver)=0
Called when all objects in the DB are read and can be resolved by their IDs by other objects.
Chain of DB references that lead from the head to the tail.
std::vector< DB_OBJ * > m_Chain
DB_REF_CHAIN(uint32_t aHead, uint32_t aTail)
void Visit(std::function< void(const DB_OBJ &aObj)> aVisitor) const
Visit all objects in the chain.
std::function< uint32_t(const DB_OBJ &)> m_NextKeyGetter
bool Resolve(const DB_OBJ_RESOLVER &aResolver) override
constexpr DB_REF(uint32_t aTargetKey)
bool Resolve(const DB_OBJ_RESOLVER &aResolver) override
constexpr DB_STR_REF(uint32_t aTargetKey)
const wxString * m_String
bool Resolve(const DB_OBJ_RESOLVER &aResolver) override
const wxString & ExpectString() const
bool ResolveRefs(const DB_OBJ_RESOLVER &aResolver) override
Called when all objects in the DB are read and can be resolved by their IDs by other objects.
std::variant< wxString, uint32_t > m_FieldValue
FIELD(const BLK_0x03_FIELD &aBlk)
A FUNCTION (0x10) object represents a logical function, which is an instance of a single function slo...
const FUNCTION_SLOT & GetFunctionSlot() const
const COMPONENT_INST & GetComponentInstance() const
FUNCTION_INSTANCE(const BLK_0x10_FUNCTION_INST &aBlk)
const wxString * GetName() const
DB_REF m_ComponentInstance
bool ResolveRefs(const DB_OBJ_RESOLVER &aResolver) override
Called when all objects in the DB are read and can be resolved by their IDs by other objects.
DB_STR_REF m_FunctionName
FUNCTION_SLOT(const BLK_0x0F_FUNCTION_SLOT &aBlk)
const wxString * GetName() const
wxString m_CompDeviceType
bool ResolveRefs(const DB_OBJ_RESOLVER &aResolver) override
Called when all objects in the DB are read and can be resolved by their IDs by other objects.
GRAPHIC_SEG(const BRD_DB &aBrd, const BLK_0x14_GRAPHIC &aBlk)
bool ResolveRefs(const DB_OBJ_RESOLVER &aResolver) override
Called when all objects in the DB are read and can be resolved by their IDs by other objects.
bool ResolveRefs(const DB_OBJ_RESOLVER &aResolver) override
Called when all objects in the DB are read and can be resolved by their IDs by other objects.
LINE(const BLK_0x15_16_17_SEGMENT &aBlk)
const NET & GetNet() const
bool ResolveRefs(const DB_OBJ_RESOLVER &aResolver) override
Called when all objects in the DB are read and can be resolved by their IDs by other objects.
DB_REF m_Next
Reference to an 0x1B NET object.
NET_ASSIGN(const BRD_DB &aBrd, const BLK_0x04_NET_ASSIGNMENT &aBlk)
DB_REF m_Net
Reference to an 0x05 TRACK or 0x32 PLACED_PAD object.
const wxString * GetLogicalPath() const
std::optional< int > GetNetMaxNeckLength() const
NET(const BRD_DB &aBrd, const BLK_0x1B_NET &aBlk)
std::optional< int > GetNetMinLineWidth() const
std::optional< int > GetNetMaxLineWidth() const
bool ResolveRefs(const DB_OBJ_RESOLVER &aResolver) override
Called when all objects in the DB are read and can be resolved by their IDs by other objects.
const wxString * GetName() const
DB_REF_CHAIN m_FieldsChain
DB_REF_CHAIN m_NetAssignments
std::optional< int > GetNetMinNeckWidth() const
const PIN_NUMBER * GetPinNumber() const
bool ResolveRefs(const DB_OBJ_RESOLVER &aResolver) override
Called when all objects in the DB are read and can be resolved by their IDs by other objects.
PIN_NAME(const BLK_0x11_PIN_NAME &aBlk)
const wxString * GetName() const
DB_STR_REF m_PinNumberStr
const wxString * GetNumber() const
PIN_NUMBER(const BLK_0x08_PIN_NUMBER &aBlk)
bool ResolveRefs(const DB_OBJ_RESOLVER &aResolver) override
Called when all objects in the DB are read and can be resolved by their IDs by other objects.
const PIN_NAME * GetPinName() const
const NET * GetNet() const
PLACED_PAD(const BRD_DB &aBrd, const BLK_0x32_PLACED_PAD &aBlk)
const wxString * GetPinName() const
bool ResolveRefs(const DB_OBJ_RESOLVER &aResolver) override
Called when all objects in the DB are read and can be resolved by their IDs by other objects.
const wxString * GetPinNumber() const
virtual bool Resolve(const DB_OBJ_RESOLVER &aResolver)=0
bool ResolveRefs(const DB_OBJ_RESOLVER &aResolver) override
Called when all objects in the DB are read and can be resolved by their IDs by other objects.
SHAPE_SEG_OBJ(const BRD_DB &aBrd, const BLK_0x0E_SHAPE_SEG &aBlk)
TRACK(const BRD_DB &aBrd, const BLK_0x05_TRACK &aBlk)
bool ResolveRefs(const DB_OBJ_RESOLVER &aResolver) override
Called when all objects in the DB are read and can be resolved by their IDs by other objects.
VIA(const BRD_DB &aBrd, const BLK_0x33_VIA &aBlk)
bool ResolveRefs(const DB_OBJ_RESOLVER &aResolver) override
Called when all objects in the DB are read and can be resolved by their IDs by other objects.
When processing a view, some objects are available and some are not.
const FOOTPRINT_INSTANCE * m_FootprintInstance
const FUNCTION_INSTANCE * m_Function
const COMPONENT * m_Component
const COMPONENT_INST * m_ComponentInstance
XREF_OBJ(const BLK_0x12_XREF &aBlk)
bool ResolveRefs(const DB_OBJ_RESOLVER &aResolver) override
Called when all objects in the DB are read and can be resolved by their IDs by other objects.
VECTOR2< int32_t > VECTOR2I