Skip to content

Commit be6d32d

Browse files
Merge pull request #7926 from osamahammad21/odb-prop
odb: code generate dbProperty
2 parents 6ff8cb4 + 71e50a9 commit be6d32d

File tree

8 files changed

+335
-258
lines changed

8 files changed

+335
-258
lines changed

src/odb/include/odb/db.h

Lines changed: 129 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ class dbBox;
4949
class dbJournalEntry;
5050

5151
// Property objects
52-
class dbProperty;
5352
class dbBoolProperty;
5453
class dbStringProperty;
5554
class dbIntProperty;
@@ -136,6 +135,7 @@ class dbNetTrack;
136135
class dbPolygon;
137136
class dbPowerDomain;
138137
class dbPowerSwitch;
138+
class dbProperty;
139139
class dbScanChain;
140140
class dbScanInst;
141141
class dbScanList;
@@ -169,136 +169,6 @@ class dbExtControl;
169169

170170
// Custom iterators
171171
class dbModuleBusPortModBTermItr;
172-
///
173-
/// dbProperty - Property base class.
174-
///
175-
class dbProperty : public dbObject
176-
{
177-
public:
178-
enum Type
179-
{
180-
// Do not change the order or the values of this enum.
181-
STRING_PROP = 0,
182-
BOOL_PROP = 1,
183-
INT_PROP = 2,
184-
DOUBLE_PROP = 3
185-
};
186-
187-
/// Get the type of this property.
188-
Type getType();
189-
190-
/// Get thetname of this property.
191-
std::string getName();
192-
193-
/// Get the owner of this property
194-
dbObject* getPropOwner();
195-
196-
/// Find the named property. Returns nullptr if the property does not exist.
197-
static dbProperty* find(dbObject* object, const char* name);
198-
199-
/// Find the named property of the specified type. Returns nullptr if the
200-
/// property does not exist.
201-
static dbProperty* find(dbObject* object, const char* name, Type type);
202-
203-
/// Destroy a specific property
204-
static void destroy(dbProperty* prop);
205-
/// Destroy all properties of the specific object
206-
static void destroyProperties(dbObject* obj);
207-
static dbSet<dbProperty> getProperties(dbObject* object);
208-
static dbSet<dbProperty>::iterator destroy(dbSet<dbProperty>::iterator itr);
209-
// 5.8
210-
static std::string writeProperties(dbObject* object);
211-
static std::string writePropValue(dbProperty* prop);
212-
};
213-
214-
///
215-
/// dbProperty - Boolean property.
216-
///
217-
class dbBoolProperty : public dbProperty
218-
{
219-
public:
220-
/// Get the value of this property.
221-
bool getValue();
222-
223-
/// Set the value of this property.
224-
void setValue(bool value);
225-
226-
/// Create a bool property. Returns nullptr if a property with the same name
227-
/// already exists.
228-
static dbBoolProperty* create(dbObject* object, const char* name, bool value);
229-
230-
/// Find the named property of type bool. Returns nullptr if the property does
231-
/// not exist.
232-
static dbBoolProperty* find(dbObject* object, const char* name);
233-
};
234-
235-
///
236-
/// dbProperty - String property.
237-
///
238-
class dbStringProperty : public dbProperty
239-
{
240-
public:
241-
/// Get the value of this property.
242-
std::string getValue();
243-
244-
/// Set the value of this property.
245-
void setValue(const char* value);
246-
247-
/// Create a string property. Returns nullptr if a property with the same name
248-
/// already exists.
249-
static dbStringProperty* create(dbObject* object,
250-
const char* name,
251-
const char* value);
252-
253-
/// Find the named property of type string. Returns nullptr if the property
254-
/// does not exist.
255-
static dbStringProperty* find(dbObject* object, const char* name);
256-
};
257-
258-
///
259-
/// dbProperty - Int property.
260-
///
261-
class dbIntProperty : public dbProperty
262-
{
263-
public:
264-
/// Get the value of this property.
265-
int getValue();
266-
267-
/// Set the value of this property.
268-
void setValue(int value);
269-
270-
/// Create a int property. Returns nullptr if a property with the same name
271-
/// already exists.
272-
static dbIntProperty* create(dbObject* object, const char* name, int value);
273-
274-
/// Find the named property of type int. Returns nullptr if the property does
275-
/// not exist.
276-
static dbIntProperty* find(dbObject* object, const char* name);
277-
};
278-
279-
///
280-
/// dbProperty - Double property.
281-
///
282-
class dbDoubleProperty : public dbProperty
283-
{
284-
public:
285-
/// Get the value of this property.
286-
double getValue();
287-
288-
/// Set the value of this property.
289-
void setValue(double value);
290-
291-
/// Create a double property. Returns nullptr if a property with the same name
292-
/// already exists.
293-
static dbDoubleProperty* create(dbObject* object,
294-
const char* name,
295-
double value);
296-
297-
/// Find the named property of type double. Returns nullptr if the property
298-
/// does not exist.
299-
static dbDoubleProperty* find(dbObject* object, const char* name);
300-
};
301-
302172
///////////////////////////////////////////////////////////////////////////////
303173
///
304174
/// This class encapsulates a persitant ADS database.
@@ -8365,6 +8235,47 @@ class dbPowerSwitch : public dbObject
83658235
// User Code End dbPowerSwitch
83668236
};
83678237

8238+
class dbProperty : public dbObject
8239+
{
8240+
public:
8241+
// User Code Begin dbProperty
8242+
enum Type
8243+
{
8244+
// Do not change the order or the values of this enum.
8245+
STRING_PROP = 0,
8246+
BOOL_PROP = 1,
8247+
INT_PROP = 2,
8248+
DOUBLE_PROP = 3
8249+
};
8250+
8251+
/// Get the type of this property.
8252+
Type getType();
8253+
8254+
/// Get thetname of this property.
8255+
std::string getName();
8256+
8257+
/// Get the owner of this property
8258+
dbObject* getPropOwner();
8259+
8260+
/// Find the named property. Returns nullptr if the property does not exist.
8261+
static dbProperty* find(dbObject* object, const char* name);
8262+
8263+
/// Find the named property of the specified type. Returns nullptr if the
8264+
/// property does not exist.
8265+
static dbProperty* find(dbObject* object, const char* name, Type type);
8266+
8267+
/// Destroy a specific property
8268+
static void destroy(dbProperty* prop);
8269+
/// Destroy all properties of the specific object
8270+
static void destroyProperties(dbObject* obj);
8271+
static dbSet<dbProperty> getProperties(dbObject* object);
8272+
static dbSet<dbProperty>::iterator destroy(dbSet<dbProperty>::iterator itr);
8273+
// 5.8
8274+
static std::string writeProperties(dbObject* object);
8275+
static std::string writePropValue(dbProperty* prop);
8276+
// User Code End dbProperty
8277+
};
8278+
83688279
// A scan chain is a collection of dbScanLists that contains dbScanInsts. Here,
83698280
// scan_in, scan_out and scan_enable are the top level ports/pins to where this
83708281
// scan chain is connected. Each scan chain is also associated with a
@@ -10675,6 +10586,93 @@ class dbTechLayerWrongDirSpacingRule : public dbObject
1067510586
};
1067610587

1067710588
// Generator Code End ClassDefinition
10589+
///
10590+
/// dbProperty - Boolean property.
10591+
///
10592+
class dbBoolProperty : public dbProperty
10593+
{
10594+
public:
10595+
/// Get the value of this property.
10596+
bool getValue();
10597+
10598+
/// Set the value of this property.
10599+
void setValue(bool value);
10600+
10601+
/// Create a bool property. Returns nullptr if a property with the same name
10602+
/// already exists.
10603+
static dbBoolProperty* create(dbObject* object, const char* name, bool value);
10604+
10605+
/// Find the named property of type bool. Returns nullptr if the property does
10606+
/// not exist.
10607+
static dbBoolProperty* find(dbObject* object, const char* name);
10608+
};
10609+
10610+
///
10611+
/// dbProperty - String property.
10612+
///
10613+
class dbStringProperty : public dbProperty
10614+
{
10615+
public:
10616+
/// Get the value of this property.
10617+
std::string getValue();
10618+
10619+
/// Set the value of this property.
10620+
void setValue(const char* value);
10621+
10622+
/// Create a string property. Returns nullptr if a property with the same name
10623+
/// already exists.
10624+
static dbStringProperty* create(dbObject* object,
10625+
const char* name,
10626+
const char* value);
10627+
10628+
/// Find the named property of type string. Returns nullptr if the property
10629+
/// does not exist.
10630+
static dbStringProperty* find(dbObject* object, const char* name);
10631+
};
10632+
10633+
///
10634+
/// dbProperty - Int property.
10635+
///
10636+
class dbIntProperty : public dbProperty
10637+
{
10638+
public:
10639+
/// Get the value of this property.
10640+
int getValue();
10641+
10642+
/// Set the value of this property.
10643+
void setValue(int value);
10644+
10645+
/// Create a int property. Returns nullptr if a property with the same name
10646+
/// already exists.
10647+
static dbIntProperty* create(dbObject* object, const char* name, int value);
10648+
10649+
/// Find the named property of type int. Returns nullptr if the property does
10650+
/// not exist.
10651+
static dbIntProperty* find(dbObject* object, const char* name);
10652+
};
10653+
10654+
///
10655+
/// dbProperty - Double property.
10656+
///
10657+
class dbDoubleProperty : public dbProperty
10658+
{
10659+
public:
10660+
/// Get the value of this property.
10661+
double getValue();
10662+
10663+
/// Set the value of this property.
10664+
void setValue(double value);
10665+
10666+
/// Create a double property. Returns nullptr if a property with the same name
10667+
/// already exists.
10668+
static dbDoubleProperty* create(dbObject* object,
10669+
const char* name,
10670+
double value);
10671+
10672+
/// Find the named property of type double. Returns nullptr if the property
10673+
/// does not exist.
10674+
static dbDoubleProperty* find(dbObject* object, const char* name);
10675+
};
1067810676

1067910677
} // namespace odb
1068010678

src/odb/include/odb/dbObject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ enum dbObjectType
9090
dbPolygonObj,
9191
dbPowerDomainObj,
9292
dbPowerSwitchObj,
93+
dbPropertyObj,
9394
dbScanChainObj,
9495
dbScanInstObj,
9596
dbScanListObj,
@@ -143,7 +144,6 @@ enum dbObjectType
143144
dbTechViaLayerRuleObj,
144145

145146
// Property
146-
dbPropertyObj,
147147
dbNameObj
148148
};
149149

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"name": "dbProperty",
3+
"type": "dbObject",
4+
"hash": "0x66",
5+
"do_not_generate_compare" : "true",
6+
"fields": [
7+
{
8+
"name": "_type",
9+
"type": "uint",
10+
"bits": 4,
11+
"flags": ["private"]
12+
},
13+
{
14+
"name": "_owner_type",
15+
"type": "uint",
16+
"bits": 8,
17+
"flags": ["private"]
18+
},
19+
{
20+
"name": "_spare_bits",
21+
"type": "uint",
22+
"bits": 20,
23+
"flags": ["private", "no-cmp"]
24+
},
25+
{
26+
"name": "_name",
27+
"type": "uint",
28+
"flags": ["private", "no-destruct"]
29+
},
30+
{
31+
"name": "_next",
32+
"type": "dbId<_dbProperty>",
33+
"flags": ["private", "no-get"]
34+
},
35+
{
36+
"name": "_owner",
37+
"type": "uint",
38+
"default": "0",
39+
"flags": ["private", "no-cmp"]
40+
},
41+
{
42+
"name": "_value",
43+
"type": "std::variant<std::string, bool, int, double>",
44+
"flags": ["private","no-template", "no-serial"]
45+
}
46+
],
47+
"h_includes": [
48+
"odb/dbTypes.h",
49+
"odb/dbId.h"
50+
],
51+
"cpp_includes": [
52+
"dbNameCache.h",
53+
"dbPropertyItr.h",
54+
"dbBlock.h",
55+
"dbChip.h",
56+
"dbLib.h",
57+
"dbName.h",
58+
"dbTech.h"
59+
]
60+
}

src/odb/src/codeGenerator/templates/dbCompare.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//Generator Code Begin Less
22
{% for klass in schema.classes|sort(attribute='name') %}
3+
{% if not klass.do_not_generate_compare %}
34
template <>
45
struct less<odb::{{klass.name}}*>
56
{
@@ -10,5 +11,6 @@ struct less<odb::{{klass.name}}*>
1011
}
1112
};
1213

14+
{% endif %}
1315
{% endfor %}
1416
//Generator Code End Less

0 commit comments

Comments
 (0)