1 ///////////////////////////////////////////////////////////////////////////////
2 // BSD 3-Clause License
3 //
4 // Copyright (c) 2019, Nefelus Inc
5 // All rights reserved.
6 //
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions are met:
9 //
10 // * Redistributions of source code must retain the above copyright notice, this
11 //   list of conditions and the following disclaimer.
12 //
13 // * Redistributions in binary form must reproduce the above copyright notice,
14 //   this list of conditions and the following disclaimer in the documentation
15 //   and/or other materials provided with the distribution.
16 //
17 // * Neither the name of the copyright holder nor the names of its
18 //   contributors may be used to endorse or promote products derived from
19 //   this software without specific prior written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 // POSSIBILITY OF SUCH DAMAGE.
32 
33 #pragma once
34 
35 #include "odb.h"
36 namespace utl {
37 class Logger;
38 }
39 namespace odb {
40 
41 ///
42 /// When adding a new database object, you must add a dbObjectType enumerator
43 /// and edit dbObject.cpp and assign an unique "character" code for its
44 /// database-name. See the methods:
45 ///    void getDbName( char name[max_name_length] );
46 ///    static dbObject * resolveDbName( dbDatabase * db, const char * name );
47 /// in dbObject.cpp
48 ///
49 class _dbDatabase;
50 class dbOStream;
51 class dbIStream;
52 class dbObjectPage;
53 class dbObjectTable;
54 class dbDiff;
55 class _dbObject;
56 
57 ///
58 /// Steps to add new objects -
59 ///      - add the "name_tbl" entry in dbObject.cpp
60 ///      - add the table entry to the getObjectTable method of the container
61 ///      object.
62 ///
63 enum dbObjectType
64 {
65   dbDatabaseObj,
66 
67   // Design Objects
68   dbChipObj,
69   dbBlockObj,
70   dbInstHdrObj,
71   dbInstObj,
72   dbNetObj,
73   dbBTermObj,
74   dbITermObj,
75   dbBoxObj,
76   dbViaObj,
77   dbTrackGridObj,
78   dbObstructionObj,
79   dbBlockageObj,
80   dbWireObj,
81   dbSWireObj,
82   dbSBoxObj,
83   dbCapNodeObj,
84   dbRSegObj,
85   dbCCSegObj,
86   dbRowObj,
87   dbFillObj,
88   dbRegionObj,
89   dbHierObj,
90   dbBPinObj,
91   // Generator Code Begin DbObjectType
92   dbTechLayerObj,
93   dbTechLayerSpacingEolRuleObj,
94   dbTechLayerMinStepRuleObj,
95   dbTechLayerCornerSpacingRuleObj,
96   dbTechLayerSpacingTablePrlRuleObj,
97   dbTechLayerEolKeepOutRuleObj,
98   dbTechLayerCutClassRuleObj,
99   dbTechLayerCutSpacingRuleObj,
100   dbTechLayerCutSpacingTableOrthRuleObj,
101   dbTechLayerCutSpacingTableDefRuleObj,
102   dbTechLayerCutEnclosureRuleObj,
103   dbTechLayerEolExtensionRuleObj,
104   dbModuleObj,
105   dbModInstObj,
106   dbGroupObj,
107   dbGCellGridObj,
108   // Generator Code End DbObjectType
109 
110   // Lib Objects
111   dbLibObj,
112   dbSiteObj,
113   dbMasterObj,
114   dbMPinObj,
115   dbMTermObj,
116   dbTargetObj,
117   dbTechAntennaPinModelObj,
118 
119   // Tech Objects
120   dbTechObj,
121   dbTechViaObj,
122   dbTechNonDefaultRuleObj,  // also a design object
123   dbTechLayerRuleObj,       // also a design object
124   dbTechSameNetRuleObj,
125   dbTechLayerSpacingRuleObj,
126   dbTechMinCutRuleObj,
127   dbTechMinEncRuleObj,
128   dbTechV55InfluenceEntryObj,
129   dbTechLayerAntennaRuleObj,
130   dbTechViaRuleObj,
131   dbTechViaGenerateRuleObj,
132   dbTechViaLayerRuleObj,
133 
134   // Property
135   dbPropertyObj,
136   dbNameObj
137 };
138 
139 class dbDatabase;
140 
141 class dbObject
142 {
143  public:
144   dbObjectType getObjectType() const;
145   dbDatabase* getDb() const;
146   uint getId() const;
147   static const int max_name_length = 256;
148   void getDbName(char name[max_name_length]) const;
149   const char* getObjName() const;
150 
151   static dbObject* resolveDbName(dbDatabase* db, const char* name);
152   static const char* getObjName(dbObjectType type);
153   // These are not intended for client use as the returned class is
154   // not exported.  They are for internal db convenience.
155   _dbObject* getImpl();
156   const _dbObject* getImpl() const;
157 
158  protected:
dbObject()159   dbObject() {}
~dbObject()160   ~dbObject() {}
161 };
162 
163 }  // namespace odb
164