KiCad PCB EDA Suite
Loading...
Searching...
No Matches
allegro_db.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright Quilter
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#pragma once
26
27#include <cstdint>
28#include <memory>
29#include <unordered_map>
30#include <unordered_set>
31
32#include <math/vector2d.h>
33#include <math/box2.h>
34
36
37
38namespace ALLEGRO
39{
40
41class BLOCK_BASE;
42class DB_OBJ;
43class DB_OBJ_RESOLVER;
44
45
47{
48 virtual bool Resolve( const DB_OBJ_RESOLVER& aResolver ) = 0;
49
50 const char* m_DebugName = nullptr;
51};
52
53
54struct DB_REF : public RESOLVABLE
55{
56 explicit constexpr DB_REF( uint32_t aTargetKey ) :
57 m_TargetKey( aTargetKey ),
58 m_EndKey( 0 ),
59 m_Target( nullptr )
60 {
61 }
62
63 constexpr DB_REF() :
64 DB_REF( 0 )
65 {
66 }
67
68 bool Resolve( const DB_OBJ_RESOLVER& aResolver ) override;
69
70 uint32_t m_TargetKey;
71 // If the ref points to the next item, eventually this will be equal to EndKey
72 // which may not be a resolvable object (e.g. a header LinkedList tail pointer, which is
73 // an artificial value).
74 // This is not a resolution failure, but it also means the reference is null.
75 uint32_t m_EndKey;
77};
78
79static constexpr DB_REF DB_NULLREF = {};
80
84struct DB_REF_CHAIN : public RESOLVABLE
85{
86 DB_REF_CHAIN( uint32_t aHead, uint32_t aTail ) :
87 m_Head( aHead ),
88 m_Tail( aTail )
89 {
90 }
91
93 DB_REF_CHAIN( 0, 0 )
94 {
95 }
96
97 bool Resolve( const DB_OBJ_RESOLVER& aResolver ) override;
98
102 void Visit( std::function<void( const DB_OBJ& aObj )> aVisitor ) const;
103 void Visit( std::function<void( DB_OBJ& aObj )> aVisitor );
104
105 std::function<uint32_t( const DB_OBJ& )> m_NextKeyGetter;
106 uint32_t m_Head;
107 uint32_t m_Tail;
108
109 // The objects in the chain
110 std::vector<DB_OBJ*> m_Chain;
111};
112
113
114struct DB_STR_REF : public RESOLVABLE
115{
116 explicit constexpr DB_STR_REF( uint32_t aTargetKey ) :
117 m_StringKey( aTargetKey ),
118 m_String( nullptr )
119 {
120 }
121
122 constexpr DB_STR_REF() :
123 DB_STR_REF( 0 )
124 {
125 }
126
127 bool Resolve( const DB_OBJ_RESOLVER& aResolver ) override;
128
129 uint32_t m_StringKey;
130 const wxString* m_String;
131};
132
133static constexpr DB_STR_REF DB_STRNULLREF = {};
134
139{
140public:
141 virtual ~DB_OBJ_RESOLVER() {}
142
146 virtual DB_OBJ* Resolve( uint32_t aKey ) const = 0;
147
148 virtual const wxString* ResolveString( uint32_t aKey ) const = 0;
149
154 virtual bool IsSentinel( uint32_t aKey ) const { return false; }
155};
156
157
161struct DB_OBJ
162{
163 enum class TYPE
164 {
166 FIELD, // 0x03 subtype 0x68...
167 TRACK, // 0x05
168 NET_ASSIGN, // 0x04
169 COMPONENT, // 0x06
171 PIN_NUMBER, // 0x08
172 SHAPE_SEG, // 0x0E
175 PIN_NAME, // 0x11
176 XREF, // 0x12
177 GRAPHIC_SEG, // 0x14
178 LINE, // 0x15, 0x16, 0x17
179 NET, // 0x1B
180 x20, // 0x20
181 SHAPE, // 0x28
182 FP_DEF, // 0x2B
183 FP_INST, // 0x2D
184 CONNECTION, // 0x2E
185 PLACED_PAD, // 0x32
186 VIA, // 0x33
187 KEEPOUT, // 0x34
192 FILM, // 0x3a
195 };
196
197 // Where this block was in the file (for debugging)
198 struct FILE_LOC
199 {
200 size_t m_Offset;
201 uint8_t m_BlockType;
202 };
203
204 DB_OBJ( TYPE aType, uint32_t aKey ) :
205 m_Valid( false ),
206 m_Type( aType ),
207 m_Key( aKey ),
208 m_Loc( 0, 0 )
209 {
210 }
211
213 DB_OBJ( TYPE::ARC, 0 )
214 {
215 }
216
217 virtual ~DB_OBJ() {}
218
230 virtual bool ResolveRefs( const DB_OBJ_RESOLVER& aResolver ) = 0;
231
232 TYPE GetType() const { return m_Type; }
233
234 uint32_t GetKey() const { return m_Key; }
235
236 // Set to true when the object is fully resolved and valid
238 // The type of this object
240 // The unique key of this object in the DB
241 uint32_t m_Key;
242 // Location in the file (for debugging)
244};
245
246
252class DB : public DB_OBJ_RESOLVER
253{
254public:
255 DB();
256
257 ~DB();
258
259 void AddObject( std::unique_ptr<DB_OBJ> aObject );
260
261 void AddString( uint32_t aKey, wxString&& aStr ) { m_StringTable.emplace( aKey, std::move( aStr ) ); }
262
263 size_t GetObjectCount() const { return m_Objects.size(); }
264
275 void ResolveObjectLinks();
276
280 DB_OBJ* Resolve( uint32_t aRef ) const override;
281
282 const wxString* ResolveString( uint32_t aRef ) const override;
283
284 bool IsSentinel( uint32_t aKey ) const override
285 {
286 return m_SentinelKeys.count( aKey ) > 0;
287 }
288
289 void AddSentinelKey( uint32_t aKey )
290 {
291 if( aKey != 0 )
292 m_SentinelKeys.insert( aKey );
293 }
294
295 virtual void InsertBlock( std::unique_ptr<BLOCK_BASE> aBlock ) = 0;
296
297protected:
298 void visitLinkedList( const FILE_HEADER::LINKED_LIST aLList,
299 std::function<const DB_REF&( const DB_OBJ& aObj )> aVisitor ) const;
300
301 void reserveObjects( size_t aCount ) { m_Objects.reserve( aCount ); }
302
308
309private:
310 // Main store of DB objects.
311 std::unordered_map<uint32_t, std::unique_ptr<DB_OBJ>> m_Objects;
312
313 // V18+ linked list sentinel keys. References to these are null (end-of-chain).
314 std::unordered_set<uint32_t> m_SentinelKeys;
315
316public:
317 std::unordered_map<uint32_t, wxString> m_StringTable;
318};
319
320
321struct BRD_DB;
322struct COMPONENT;
323struct COMPONENT_INST;
324struct FOOTPRINT_INSTANCE;
325struct FUNCTION_INSTANCE;
326struct NET;
327struct NET_ASSIGN;
328struct PLACED_PAD;
329struct PIN_NAME;
330struct PIN_NUMBER;
331struct TRACK;
332
336struct ARC : public DB_OBJ
337{
338 ARC( const BLK_0x01_ARC& aBlk );
339
341
342 bool ResolveRefs( const DB_OBJ_RESOLVER& aResolver ) override;
343};
344
345
351struct FIELD : public DB_OBJ
352{
353 FIELD( const BLK_0x03_FIELD& aBlk );
354
355 bool ResolveRefs( const DB_OBJ_RESOLVER& aResolver ) override { return true; }
356
357 uint8_t m_SubType;
359
360 // Unclear if just hdr1 or both are needed for a complete field type determination
361 uint32_t m_Hdr1;
362 uint32_t m_Hdr2;
363
364 std::variant<wxString, uint32_t> m_FieldValue;
365
366 // Expects that the field contains a string and returns it
367 const wxString& ExpectString() const;
368};
369
370
376{
377public:
379 m_Chain( aChain )
380 {
381 }
382
388 std::optional<int> GetOptFieldExpectInt( uint16_t aFieldCode ) const;
389
390 const wxString* GetOptFieldExpectString( uint16_t aFieldCode ) const;
391
396 std::optional<std::variant<wxString, uint32_t>> GetOptField( uint16_t aFieldCode ) const;
397
398private:
400};
401
402
406struct NET_ASSIGN : public DB_OBJ
407{
408 NET_ASSIGN( const BRD_DB& aBrd, const BLK_0x04_NET_ASSIGNMENT& aBlk );
409
410 bool ResolveRefs( const DB_OBJ_RESOLVER& aResolver ) override;
411
417
418 const NET& GetNet() const;
419};
420
421
425struct TRACK : public DB_OBJ
426{
427 TRACK( const BRD_DB& aBrd, const BLK_0x05_TRACK& aBlk );
428
429 bool ResolveRefs( const DB_OBJ_RESOLVER& aResolver ) override;
430
432};
433
434
457
458
464struct COMPONENT_INST : public DB_OBJ
465{
467
468 bool ResolveRefs( const DB_OBJ_RESOLVER& aResolver ) override;
469
475
477
479
480 const wxString* GetRefDesStr() const;
481 const COMPONENT_INST* GetNextInstance() const;
483 const PLACED_PAD& GetFirstPad() const;
484};
485
486
490struct PIN_NUMBER : public DB_OBJ
491{
492 PIN_NUMBER( const BLK_0x08_PIN_NUMBER& aBlk );
493
494 bool ResolveRefs( const DB_OBJ_RESOLVER& aResolver ) override;
495
499
500 const wxString* GetNumber() const;
501 const PIN_NAME* GetPinName() const;
502};
503
504
508struct SHAPE_SEG_OBJ : public DB_OBJ
509{
510 SHAPE_SEG_OBJ( const BRD_DB& aBrd, const BLK_0x0E_SHAPE_SEG& aBlk );
511
512 bool ResolveRefs( const DB_OBJ_RESOLVER& aResolver ) override;
513
515};
516
517
521struct FUNCTION_SLOT : public DB_OBJ
522{
524
525 bool ResolveRefs( const DB_OBJ_RESOLVER& aResolver ) override;
526
529
533
534 const wxString* GetName() const;
535};
536
537
543{
545
546 bool ResolveRefs( const DB_OBJ_RESOLVER& aResolver ) override;
547
552
553 const wxString* GetName() const;
555 const FUNCTION_SLOT& GetFunctionSlot() const;
556};
557
558
562struct PIN_NAME: public DB_OBJ
563{
564 PIN_NAME( const BLK_0x11_PIN_NAME& aBlk );
565
566 bool ResolveRefs( const DB_OBJ_RESOLVER& aResolver ) override;
567
571
572 const wxString* GetName() const;
573 const PIN_NUMBER* GetPinNumber() const;
574};
575
576
580struct XREF_OBJ : public DB_OBJ
581{
582 XREF_OBJ( const BLK_0x12_XREF& aBlk );
583
584 bool ResolveRefs( const DB_OBJ_RESOLVER& aResolver ) override;
585
589};
590
591
595struct GRAPHIC_SEG: public DB_OBJ
596{
597 GRAPHIC_SEG( const BRD_DB& aBrd, const BLK_0x14_GRAPHIC& aBlk );
598
599 bool ResolveRefs( const DB_OBJ_RESOLVER& aResolver ) override;
600
603 DB_REF m_Segment; // ARC or LINE
604
605 // 0x03?
606 // DB_REF m_Ptr0x03;
607 // 0x26?
608};
609
610
614struct LINE : public DB_OBJ
615{
616 LINE( const BLK_0x15_16_17_SEGMENT& aBlk );
617
618 bool ResolveRefs( const DB_OBJ_RESOLVER& aResolver ) override;
619
622
626};
627
628
632struct NET : public DB_OBJ
633{
634 enum class STATUS
635 {
639 };
640
641 NET( const BRD_DB& aBrd, const BLK_0x1B_NET& aBlk );
642
643 bool ResolveRefs( const DB_OBJ_RESOLVER& aResolver ) override;
644
647 // Not clear if this is ever not 1 entry, but 0x04s have a next field
649
652
654
655 const wxString* GetName() const;
656 STATUS GetStatus() const;
657
658 const wxString* GetLogicalPath() const;
659
660 std::optional<int> GetNetMinLineWidth() const;
661 std::optional<int> GetNetMaxLineWidth() const;
662 std::optional<int> GetNetMinNeckWidth() const;
663 std::optional<int> GetNetMaxNeckLength() const;
664};
665
666
670class UNKNOWN_0x20 : public DB_OBJ
671{
672public:
673 UNKNOWN_0x20( const BRD_DB& aBrd, const BLK_0x20_UNKNOWN& aBlk );
674
675 bool ResolveRefs( const DB_OBJ_RESOLVER& aResolver ) override;
676
678};
679
680
684class SHAPE : public DB_OBJ
685{
686public:
687 SHAPE( const BRD_DB& aBrd, const BLK_0x28_SHAPE& aBlk );
688
689 bool ResolveRefs( const DB_OBJ_RESOLVER& aResolver ) override;
690
694};
695
696
700struct FOOTPRINT_DEF : public DB_OBJ
701{
702 FOOTPRINT_DEF( const BRD_DB& aBrd, const BLK_0x2B_FOOTPRINT_DEF& aBlk );
703
707
709
710 bool ResolveRefs( const DB_OBJ_RESOLVER& aResolver ) override;
711
719 const wxString* GetLibPath() const;
720};
721
722
727{
729
730 bool ResolveRefs( const DB_OBJ_RESOLVER& aResolver ) override;
731
734 double m_X;
735 double m_Y;
738
739 // Chain of PLACED_PADs
741
742 // Backlink to the parent footprint definition
744
746 const wxString* GetName() const;
747};
748
749
753struct CONNECTION_OBJ : public DB_OBJ
754{
755 CONNECTION_OBJ( const BRD_DB& aBrd, const BLK_0x2E_CONNECTION& aBlk );
756
757 bool ResolveRefs( const DB_OBJ_RESOLVER& aResolver ) override;
758
763
764};
765
766
770struct PLACED_PAD : public DB_OBJ
771{
772 PLACED_PAD( const BRD_DB& aBrd, const BLK_0x32_PLACED_PAD& aBlk );
773
774 bool ResolveRefs( const DB_OBJ_RESOLVER& aResolver ) override;
775
779 // DB_REF m_Ratline; // 0x23;
783 uint32_t m_Flags;
785
786 const wxString* GetPinName() const;
787 const wxString* GetPinNumber() const;
788
789 const NET* GetNet() const;
790};
791
792
796struct VIA: public DB_OBJ
797{
798 VIA( const BRD_DB& aBrd, const BLK_0x33_VIA& aBlk );
799
800 bool ResolveRefs( const DB_OBJ_RESOLVER& aResolver ) override;
801
805};
806
807
815{
817 m_Board( nullptr ),
818 m_Component( nullptr ),
819 m_Function( nullptr ),
820 m_FootprintInstance( nullptr )
821 {
822 }
823
824 // All views
826 // COMPONENT, COMPONENT_PIN, SYMBOL, FUNCTION
828
830 // FUNCTION
832 //
834
835 // COMPONENT_PIN, LOGICAL_PIN have these
837
838 const NET* m_Net;
839};
840
841
842using VIEW_OBJS_VISITOR = std::function<void( const VIEW_OBJS& aViewObjs )>;
843
844
848class BRD_DB : public DB
849{
850public:
861 {
862 public:
863 OBJ_FACTORY( const BRD_DB& aBrdDb ) :
864 m_brdDb( aBrdDb )
865 {
866 }
867
868 std::unique_ptr<DB_OBJ> CreateObject( const BLOCK_BASE& aBlock ) const;
869
870 private:
872 };
873
874 BRD_DB();
875
876 void InsertBlock( std::unique_ptr<BLOCK_BASE> aBlock ) override;
877
882 void ReserveCapacity( size_t aObjectCount, size_t aStringCount );
883
890 void SetLeanMode( bool aLean ) { m_leanMode = aLean; }
891
898 bool ResolveAndValidate();
899
900 using FP_DEF_VISITOR = std::function<void( const FOOTPRINT_DEF& aFpDef )>;
901
907 void VisitFootprintDefs( FP_DEF_VISITOR aFpDef ) const;
908
914 void VisitFootprintInstances( VIEW_OBJS_VISITOR aVisitor ) const;
915 void visitFootprintInstances( const FOOTPRINT_DEF& aFpDef, VIEW_OBJS_VISITOR aVisitor ) const;
916
925 void VisitFunctionInstances( VIEW_OBJS_VISITOR aVisitor ) const;
926
927 void VisitComponents( VIEW_OBJS_VISITOR aVisitor ) const;
928
932 void VisitComponentPins( VIEW_OBJS_VISITOR aVisitor ) const;
933
934 void VisitNets( VIEW_OBJS_VISITOR aVisitor ) const;
935
936 void VisitConnectedGeometry( VIEW_OBJS_VISITOR aVisitor ) const;
937
941 const BLOCK_BASE* GetObjectByKey( uint32_t aKey ) const
942 {
943 auto it = m_ObjectKeyMap.find( aKey );
944 return it != m_ObjectKeyMap.end() ? it->second : nullptr;
945 }
946
950 const wxString& GetString( uint32_t aKey ) const
951 {
952 static const wxString empty;
953 auto it = m_StringTable.find( aKey );
954 return it != m_StringTable.end() ? it->second : empty;
955 }
956
957 // It's not fully clear how much of the header is brd specific or is a more general
958 // DB format (or is there is a more general format). Clearly much of it (linked lists,
959 // for example) is very board-related.
960 // For now, keep it up here, but generalities can push down to DB.
962 std::unique_ptr<FILE_HEADER> m_Header;
963
964 // Raw block storage for backward compatibility with BOARD_BUILDER
965 std::vector<std::unique_ptr<BLOCK_BASE>> m_Blocks;
966 std::unordered_map<uint32_t, BLOCK_BASE*> m_ObjectKeyMap;
967
968private:
969 // The factory that will turn BLOCKs into DB_OBJs
971
973};
974
975} // namespace ALLEGRO
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
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...
Definition allegro_db.h:861
std::unique_ptr< DB_OBJ > CreateObject(const BLOCK_BASE &aBlock) const
OBJ_FACTORY(const BRD_DB &aBrdDb)
Definition allegro_db.h:863
An Allegro database that represents a .brd file (amd presumably .dra)
Definition allegro_db.h:849
void VisitConnectedGeometry(VIEW_OBJS_VISITOR aVisitor) const
std::unordered_map< uint32_t, BLOCK_BASE * > m_ObjectKeyMap
Definition allegro_db.h:966
std::unique_ptr< FILE_HEADER > m_Header
Definition allegro_db.h:962
void SetLeanMode(bool aLean)
When true, InsertBlock skips DB_OBJ creation for high-volume block types (segments,...
Definition allegro_db.h:890
std::vector< std::unique_ptr< BLOCK_BASE > > m_Blocks
Definition allegro_db.h:965
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
Definition allegro_db.h:900
const wxString & GetString(uint32_t aKey) const
Get a string from the string table by key.
Definition allegro_db.h:950
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
OBJ_FACTORY m_ObjFactory
Definition allegro_db.h:970
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).
Definition allegro_db.h:941
void VisitComponentPins(VIEW_OBJS_VISITOR aVisitor) const
Visit all component pins in the database.
Some interface that can yield DB_OBJs for keys.
Definition allegro_db.h:139
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.
Definition allegro_db.h:154
virtual const wxString * ResolveString(uint32_t aKey) const =0
const wxString * ResolveString(uint32_t aRef) const override
std::unordered_map< uint32_t, wxString > m_StringTable
Definition allegro_db.h:317
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
Definition allegro_db.h:311
void AddSentinelKey(uint32_t aKey)
Definition allegro_db.h:289
void AddString(uint32_t aKey, wxString &&aStr)
Definition allegro_db.h:261
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.
Definition allegro_db.h:284
void ResolveObjectLinks()
Iterate the database and resolve links.
std::unordered_set< uint32_t > m_SentinelKeys
Definition allegro_db.h:314
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
Definition allegro_db.h:263
void reserveObjects(size_t aCount)
Definition allegro_db.h:301
A field list is a linked list of 0x03.
Definition allegro_db.h:376
std::optional< int > GetOptFieldExpectInt(uint16_t aFieldCode) const
Get the integer value of the field with the given code, if in the list.
DB_REF_CHAIN & m_Chain
Definition allegro_db.h:399
FIELD_LIST(DB_REF_CHAIN &aChain)
Definition allegro_db.h:378
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.
DB_REF m_Segments
Definition allegro_db.h:693
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
Definition allegro_db.h:133
std::function< void(const VIEW_OBJS &aViewObjs)> VIEW_OBJS_VISITOR
Definition allegro_db.h:842
static constexpr DB_REF DB_NULLREF
Definition allegro_db.h:79
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)
DB_REF m_Parent
Definition allegro_db.h:340
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.
Track segment container.
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:
0x1B objects are nets.
Polygon shape defined by a linked list of segments starting at m_FirstSegmentPtr (0x15/0x16/0x17 line...
Footprint definition (template) shared by multiple placed instances.
Placed footprint instance on the board.
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.
Definition allegro_db.h:465
const wxString * GetRefDesStr() const
COMPONENT * m_ParentComponent
Definition allegro_db.h:476
const COMPONENT_INST * GetNextInstance() const
COMPONENT_INST(const BLK_0x07_COMPONENT_INST &aBlk)
const COMPONENT * GetParentComponent() const
Definition allegro_db.h:478
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
COMPONENT 0x06 objects.
Definition allegro_db.h:441
const wxString * GetComponentDeviceType() const
DB_REF_CHAIN m_Instances
Definition allegro_db.h:449
DB_STR_REF m_SymbolName
Definition allegro_db.h:448
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
Definition allegro_db.h:447
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.
Definition allegro_db.h:162
DB_OBJ(TYPE aType, uint32_t aKey)
Definition allegro_db.h:204
uint32_t GetKey() const
Definition allegro_db.h:234
virtual ~DB_OBJ()
Definition allegro_db.h:217
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.
TYPE GetType() const
Definition allegro_db.h:232
Chain of DB references that lead from the head to the tail.
Definition allegro_db.h:85
std::vector< DB_OBJ * > m_Chain
Definition allegro_db.h:110
DB_REF_CHAIN(uint32_t aHead, uint32_t aTail)
Definition allegro_db.h:86
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
Definition allegro_db.h:105
bool Resolve(const DB_OBJ_RESOLVER &aResolver) override
constexpr DB_REF()
Definition allegro_db.h:63
constexpr DB_REF(uint32_t aTargetKey)
Definition allegro_db.h:56
uint32_t m_EndKey
Definition allegro_db.h:75
uint32_t m_TargetKey
Definition allegro_db.h:70
DB_OBJ * m_Target
Definition allegro_db.h:76
bool Resolve(const DB_OBJ_RESOLVER &aResolver) override
constexpr DB_STR_REF(uint32_t aTargetKey)
Definition allegro_db.h:116
const wxString * m_String
Definition allegro_db.h:130
constexpr DB_STR_REF()
Definition allegro_db.h:122
bool Resolve(const DB_OBJ_RESOLVER &aResolver) override
uint32_t m_Hdr2
Definition allegro_db.h:362
uint8_t m_SubType
Definition allegro_db.h:357
const wxString & ExpectString() const
uint32_t m_Hdr1
Definition allegro_db.h:361
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.
Definition allegro_db.h:355
std::variant< wxString, uint32_t > m_FieldValue
Definition allegro_db.h:364
FIELD(const BLK_0x03_FIELD &aBlk)
This is apparently some kind of linked list that chains though subsets objects in the file.
FOOTPRINT_DEF(const BRD_DB &aBrd, const BLK_0x2B_FOOTPRINT_DEF &aBlk)
const wxString * GetLibPath() const
Get the library path for this footprint definition.
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_CHAIN m_Instances
Definition allegro_db.h:708
const wxString * GetName() 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.
FOOTPRINT_INSTANCE(const BLK_0x2D_FOOTPRINT_INST &aBlk)
const COMPONENT_INST * GetComponentInstance() const
A FUNCTION (0x10) object represents a logical function, which is an instance of a single function slo...
Definition allegro_db.h:543
const FUNCTION_SLOT & GetFunctionSlot() const
const COMPONENT_INST & GetComponentInstance() const
FUNCTION_INSTANCE(const BLK_0x10_FUNCTION_INST &aBlk)
const wxString * GetName() 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.
FUNCTION_SLOT(const BLK_0x0F_FUNCTION_SLOT &aBlk)
const wxString * GetName() 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.
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.
DB_REF m_Parent
Definition allegro_db.h:620
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.
VECTOR2I m_End
Definition allegro_db.h:624
VECTOR2I m_Start
Definition allegro_db.h:623
LINE(const BLK_0x15_16_17_SEGMENT &aBlk)
0x04 NET_ASSIGN objects
Definition allegro_db.h:407
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.
Definition allegro_db.h:412
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.
Definition allegro_db.h:414
0x1B NET objects
Definition allegro_db.h:633
DB_STR_REF m_NetNameStr
Definition allegro_db.h:646
const wxString * GetLogicalPath() const
std::optional< int > GetNetMaxNeckLength() const
NET(const BRD_DB &aBrd, const BLK_0x1B_NET &aBlk)
std::optional< int > GetNetMinLineWidth() const
DB_REF m_Next
Definition allegro_db.h:645
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
STATUS GetStatus() const
FIELD_LIST m_Fields
Definition allegro_db.h:651
DB_REF_CHAIN m_FieldsChain
Definition allegro_db.h:650
STATUS m_Status
Definition allegro_db.h:653
DB_REF_CHAIN m_NetAssignments
Definition allegro_db.h:648
std::optional< int > GetNetMinNeckWidth() const
0x11 objects.
Definition allegro_db.h:563
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)
DB_STR_REF m_PinNameStr
Definition allegro_db.h:569
const wxString * GetName() const
0x08 objects.
Definition allegro_db.h:491
DB_STR_REF m_PinNumberStr
Definition allegro_db.h:496
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
0x32 Placed Pad objects.
Definition allegro_db.h:771
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
const char * m_DebugName
Definition allegro_db.h:50
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)
0x05 TRACK
Definition allegro_db.h:426
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.
DB_REF m_NetAssign
Definition allegro_db.h:803
DB_REF m_Next
Definition allegro_db.h:802
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.
Definition allegro_db.h:815
const FOOTPRINT_INSTANCE * m_FootprintInstance
Definition allegro_db.h:833
const FUNCTION_INSTANCE * m_Function
Definition allegro_db.h:831
const NET * m_Net
Definition allegro_db.h:838
const COMPONENT * m_Component
Definition allegro_db.h:827
const COMPONENT_INST * m_ComponentInstance
Definition allegro_db.h:829
const BRD_DB * m_Board
Definition allegro_db.h:825
const PLACED_PAD * m_Pad
Definition allegro_db.h:836
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
Definition vector2d.h:695