API reference - Class ReportDatabase

Notation used in Ruby API documentation

Module: rdb

Description: The report database object

A report database is organized around a set of items which are associated with cells and categories. Categories can be organized hierarchically by created sub-categories of other categories. Cells are associated with layout database cells and can come with a example instantiation if the layout database does not allow a unique association of the cells. Items in the database can have a variety of attributes: values, tags and an image object. Values are geometrical objects for example. Tags are a set of boolean flags and an image can be attached to an item to provide a screenshot for visualization for example. This is the main report database object. The basic use case of this object is to create one inside a LayoutView and populate it with items, cell and categories or load it from a file. Another use case is to create a standalone ReportDatabase object and use the methods provided to perform queries or to populate it.

Public constructors

new ReportDatabase ptrnew(string name)Creates a report database

Public methods

void_createEnsures the C++ object is created
void_destroyExplicitly destroys the object
[const]bool_destroyed?Returns a value indicating whether the object was already destroyed
[const]bool_is_const_object?Returns a value indicating whether the reference is a const reference
void_manageMarks the object as managed by the script side.
void_unmanageMarks the object as no longer owned by the script side.
[const]const RdbCategory ptrcategory_by_id(unsigned long id)Gets a category by ID
[const]const RdbCategory ptrcategory_by_path(string path)Gets a category by path
[const]const RdbCell ptrcell_by_id(unsigned long id)Returns the cell for a given ID
[const]const RdbCell ptrcell_by_qname(string qname)Returns the cell for a given qualified name
RdbCategory ptrcreate_category(string name)Creates a new top level category
RdbCategory ptrcreate_category(RdbCategory ptr parent,
string name)
Creates a new sub-category
RdbCell ptrcreate_cell(string name)Creates a new cell
RdbCell ptrcreate_cell(string name,
string variant)
Creates a new cell, potentially as a variant for a cell with the same name
RdbItem ptrcreate_item(unsigned long cell_id,
unsigned long category_id)
Creates a new item for the given cell/category combination
RdbItem ptrcreate_item(RdbCell ptr cell,
RdbCategory ptr category)
Creates a new item for the given cell/category combination
voidcreate_item(unsigned long cell_id,
unsigned long category_id,
const CplxTrans trans,
const Shape shape)
Creates a new item from a single shape
voidcreate_items(unsigned long cell_id,
unsigned long category_id,
const RecursiveShapeIterator iter)
Creates new items from a shape iterator
voidcreate_items(unsigned long cell_id,
unsigned long category_id,
const CplxTrans trans,
const Shapes shapes)
Creates new items from a shape container
voidcreate_items(unsigned long cell_id,
unsigned long category_id,
const CplxTrans trans,
const Region region)
Creates new polygon items for the given cell/category combination
voidcreate_items(unsigned long cell_id,
unsigned long category_id,
const CplxTrans trans,
const Edges edges)
Creates new edge items for the given cell/category combination
voidcreate_items(unsigned long cell_id,
unsigned long category_id,
const CplxTrans trans,
const EdgePairs edge_pairs)
Creates new edge pair items for the given cell/category combination
voidcreate_items(unsigned long cell_id,
unsigned long category_id,
const CplxTrans trans,
Polygon[] array)
Creates new polygon items for the given cell/category combination
voidcreate_items(unsigned long cell_id,
unsigned long category_id,
const CplxTrans trans,
Edge[] array)
Creates new edge items for the given cell/category combination
voidcreate_items(unsigned long cell_id,
unsigned long category_id,
const CplxTrans trans,
EdgePair[] array)
Creates new edge pair items for the given cell/category combination
[const]stringdescriptionGets the databases description
voiddescription=(string desc)Sets the databases description
[const,iter]RdbCategoryeach_categoryIterates over all top-level categories
[const,iter]RdbCelleach_cellIterates over all cells
[const,iter]RdbItemeach_itemIterates over all items inside the database
[const,iter]RdbItemeach_item_per_category(unsigned long category_id)Iterates over all items inside the database which are associated with the given category
[const,iter]RdbItemeach_item_per_cell(unsigned long cell_id)Iterates over all items inside the database which are associated with the given cell
[const,iter]RdbItemeach_item_per_cell_and_category(unsigned long cell_id,
unsigned long category_id)
Iterates over all items inside the database which are associated with the given cell and category
[const]stringfilenameGets the file name and path where the report database is stored
[const]stringgeneratorGets the databases generator
voidgenerator=(string generator)Sets the generator string
[const]boolis_modified?Returns a value indicating whether the database has been modified
voidload(string filename)Loads the database from the given file
[const]stringnameGets the database name
[const]unsigned longnum_itemsReturns the number of items inside the database
[const]unsigned longnum_items(unsigned long cell_id,
unsigned long category_id)
Returns the number of items inside the database for a given cell/category combination
[const]unsigned longnum_items_visitedReturns the number of items already visited inside the database
[const]unsigned longnum_items_visited(unsigned long cell_id,
unsigned long category_id)
Returns the number of items visited already for a given cell/category combination
[const]stringoriginal_fileGets the original file name and path
voidoriginal_file=(string path)Sets the original file name and path
voidreset_modifiedReset the modified flag
voidsave(string filename)Saves the database to the given file
voidset_item_visited(const RdbItem ptr item,
bool visited)
Modifies the visited state of an item
voidset_tag_description(unsigned long tag_id,
string description)
Sets the tag description for the given tag ID
[const]stringtag_description(unsigned long tag_id)Gets the tag description for the given tag ID
[const]unsigned longtag_id(string name)Gets the tag ID for a given tag name
[const]stringtag_name(unsigned long tag_id)Gets the tag name for the given tag ID
[const]stringtop_cell_nameGets the top cell name
voidtop_cell_name=(string cell_name)Sets the top cell name string
[const]unsigned longuser_tag_id(string name)Gets the tag ID for a given user tag name
unsigned long[]variants(string name)Gets the variants for a given cell name

Deprecated methods (protected, public, static, non-static and constructors)

voidcreateUse of this method is deprecated. Use _create instead
voiddestroyUse of this method is deprecated. Use _destroy instead
[const]booldestroyed?Use of this method is deprecated. Use _destroyed? instead
[const]boolis_const_object?Use of this method is deprecated. Use _is_const_object? instead

Detailed description

_create

Signature: void _create

Description: Ensures the C++ object is created

Use this method to ensure the C++ object is created, for example to ensure that resources are allocated. Usually C++ objects are created on demand and not necessarily when the script object is created.

_destroy

Signature: void _destroy

Description: Explicitly destroys the object

Explicitly destroys the object on C++ side if it was owned by the script interpreter. Subsequent access to this object will throw an exception. If the object is not owned by the script, this method will do nothing.

_destroyed?

Signature: [const] bool _destroyed?

Description: Returns a value indicating whether the object was already destroyed

This method returns true, if the object was destroyed, either explicitly or by the C++ side. The latter may happen, if the object is owned by a C++ object which got destroyed itself.

_is_const_object?

Signature: [const] bool _is_const_object?

Description: Returns a value indicating whether the reference is a const reference

This method returns true, if self is a const reference. In that case, only const methods may be called on self.

_manage

Signature: void _manage

Description: Marks the object as managed by the script side.

After calling this method on an object, the script side will be responsible for the management of the object. This method may be called if an object is returned from a C++ function and the object is known not to be owned by any C++ instance. If necessary, the script side may delete the object if the script's reference is no longer required.

Usually it's not required to call this method. It has been introduced in version 0.24.

_unmanage

Signature: void _unmanage

Description: Marks the object as no longer owned by the script side.

Calling this method will make this object no longer owned by the script's memory management. Instead, the object must be managed in some other way. Usually this method may be called if it is known that some C++ object holds and manages this object. Technically speaking, this method will turn the script's reference into a weak reference. After the script engine decides to delete the reference, the object itself will still exist. If the object is not managed otherwise, memory leaks will occur.

Usually it's not required to call this method. It has been introduced in version 0.24.

category_by_id

Signature: [const] const RdbCategory ptr category_by_id (unsigned long id)

Description: Gets a category by ID

Returns:The (const) category object or nil if the ID is not valid

category_by_path

Signature: [const] const RdbCategory ptr category_by_path (string path)

Description: Gets a category by path

path:The full path to the category starting from the top level (subcategories separated by dots)
Returns:The (const) category object or nil if the name is not valid

cell_by_id

Signature: [const] const RdbCell ptr cell_by_id (unsigned long id)

Description: Returns the cell for a given ID

id:The ID of the cell
Returns:The cell object or nil if no cell with that ID exists

cell_by_qname

Signature: [const] const RdbCell ptr cell_by_qname (string qname)

Description: Returns the cell for a given qualified name

qname:The qualified name of the cell (name plus variant name optionally)
Returns:The cell object or nil if no such cell exists

create

Signature: void create

Description: Ensures the C++ object is created

Use of this method is deprecated. Use _create instead

Use this method to ensure the C++ object is created, for example to ensure that resources are allocated. Usually C++ objects are created on demand and not necessarily when the script object is created.

create_category

(1) Signature: RdbCategory ptr create_category (string name)

Description: Creates a new top level category

name:The name of the category

(2) Signature: RdbCategory ptr create_category (RdbCategory ptr parent, string name)

Description: Creates a new sub-category

parent:The category under which the category should be created
name:The name of the category

create_cell

(1) Signature: RdbCell ptr create_cell (string name)

Description: Creates a new cell

name:The name of the cell

(2) Signature: RdbCell ptr create_cell (string name, string variant)

Description: Creates a new cell, potentially as a variant for a cell with the same name

name:The name of the cell
variant:The variant name of the cell

create_item

(1) Signature: RdbItem ptr create_item (unsigned long cell_id, unsigned long category_id)

Description: Creates a new item for the given cell/category combination

cell_id:The ID of the cell to which the item is associated
category_id:The ID of the category to which the item is associated

A more convenient method that takes cell and category objects instead of ID's is the other version of create_item.

(2) Signature: RdbItem ptr create_item (RdbCell ptr cell, RdbCategory ptr category)

Description: Creates a new item for the given cell/category combination

cell:The cell to which the item is associated
category:The category to which the item is associated

This convenience method has been added in version 0.25.

(3) Signature: void create_item (unsigned long cell_id, unsigned long category_id, const CplxTrans trans, const Shape shape)

Description: Creates a new item from a single shape

cell_id:The ID of the cell to which the item is associated
category_id:The ID of the category to which the item is associated
shape:The shape to take the geometrical object from
trans:The transformation to apply

This method produces an item from the given shape. It accepts various kind of shapes, such as texts, polygons, boxes and paths and converts them to a corresponding item. The transformation argument can be used to supply the transformation that applies the database unit for example.

This method has been introduced in version 0.25.3.

create_items

(1) Signature: void create_items (unsigned long cell_id, unsigned long category_id, const RecursiveShapeIterator iter)

Description: Creates new items from a shape iterator

cell_id:The ID of the cell to which the item is associated
category_id:The ID of the category to which the item is associated
iter:The iterator (a RecursiveShapeIterator object) from which to take the items

This method takes the shapes from the given iterator and produces items from them. It accepts various kind of shapes, such as texts, polygons, boxes and paths and converts them to corresponding items. This method will produce a flat version of the shapes iterated by the shape iterator. A similar method, which is intended for production of polygon or edge error layers and also provides hierarchical database construction is RdbCategory#scan_shapes.

This method has been introduced in version 0.25.3.

(2) Signature: void create_items (unsigned long cell_id, unsigned long category_id, const CplxTrans trans, const Shapes shapes)

Description: Creates new items from a shape container

cell_id:The ID of the cell to which the item is associated
category_id:The ID of the category to which the item is associated
shapes:The shape container from which to take the items
trans:The transformation to apply

This method takes the shapes from the given container and produces items from them. It accepts various kind of shapes, such as texts, polygons, boxes and paths and converts them to corresponding items. The transformation argument can be used to supply the transformation that applies the database unit for example.

This method has been introduced in version 0.25.3.

(3) Signature: void create_items (unsigned long cell_id, unsigned long category_id, const CplxTrans trans, const Region region)

Description: Creates new polygon items for the given cell/category combination

cell_id:The ID of the cell to which the item is associated
category_id:The ID of the category to which the item is associated
trans:The transformation to apply
region:The region (a Region object) containing the polygons for which to create items

For each polygon in the region a single item will be created. The value of the item will be this polygon. A transformation can be supplied which can be used for example to convert the object's dimensions to micron units by scaling by the database unit.

This method will also produce a flat version of the shapes inside the region. RdbCategory#scan_collection is a similar method which also supports construction of hierarchical databases from deep regions.

This method has been introduced in version 0.23.

(4) Signature: void create_items (unsigned long cell_id, unsigned long category_id, const CplxTrans trans, const Edges edges)

Description: Creates new edge items for the given cell/category combination

cell_id:The ID of the cell to which the item is associated
category_id:The ID of the category to which the item is associated
trans:The transformation to apply
edges:The list of edges (an Edges object) for which the items are created

For each edge a single item will be created. The value of the item will be this edge. A transformation can be supplied which can be used for example to convert the object's dimensions to micron units by scaling by the database unit.

This method will also produce a flat version of the edges inside the edge collection. RdbCategory#scan_collection is a similar method which also supports construction of hierarchical databases from deep edge collections.

This method has been introduced in version 0.23.

(5) Signature: void create_items (unsigned long cell_id, unsigned long category_id, const CplxTrans trans, const EdgePairs edge_pairs)

Description: Creates new edge pair items for the given cell/category combination

cell_id:The ID of the cell to which the item is associated
category_id:The ID of the category to which the item is associated
trans:The transformation to apply
edges:The list of edge pairs (an EdgePairs object) for which the items are created

For each edge pair a single item will be created. The value of the item will be this edge pair. A transformation can be supplied which can be used for example to convert the object's dimensions to micron units by scaling by the database unit.

This method will also produce a flat version of the edge pairs inside the edge pair collection. RdbCategory#scan_collection is a similar method which also supports construction of hierarchical databases from deep edge pair collections.

This method has been introduced in version 0.23.

(6) Signature: void create_items (unsigned long cell_id, unsigned long category_id, const CplxTrans trans, Polygon[] array)

Description: Creates new polygon items for the given cell/category combination

cell_id:The ID of the cell to which the item is associated
category_id:The ID of the category to which the item is associated
trans:The transformation to apply
polygons:The list of polygons for which the items are created

For each polygon a single item will be created. The value of the item will be this polygon. A transformation can be supplied which can be used for example to convert the object's dimensions to micron units by scaling by the database unit.

This method has been introduced in version 0.23.

(7) Signature: void create_items (unsigned long cell_id, unsigned long category_id, const CplxTrans trans, Edge[] array)

Description: Creates new edge items for the given cell/category combination

cell_id:The ID of the cell to which the item is associated
category_id:The ID of the category to which the item is associated
trans:The transformation to apply
edges:The list of edges for which the items are created

For each edge a single item will be created. The value of the item will be this edge. A transformation can be supplied which can be used for example to convert the object's dimensions to micron units by scaling by the database unit.

This method has been introduced in version 0.23.

(8) Signature: void create_items (unsigned long cell_id, unsigned long category_id, const CplxTrans trans, EdgePair[] array)

Description: Creates new edge pair items for the given cell/category combination

cell_id:The ID of the cell to which the item is associated
category_id:The ID of the category to which the item is associated
trans:The transformation to apply
edge_pairs:The list of edge_pairs for which the items are created

For each edge pair a single item will be created. The value of the item will be this edge pair. A transformation can be supplied which can be used for example to convert the object's dimensions to micron units by scaling by the database unit.

This method has been introduced in version 0.23.

description

Signature: [const] string description

Description: Gets the databases description

Returns:The description string

The description is a general purpose string that is supposed to further describe the database and it's content in a human-readable form.

Python specific notes:
The object exposes a readable attribute 'description'. This is the getter.

description=

Signature: void description= (string desc)

Description: Sets the databases description

desc:The description string

Python specific notes:
The object exposes a writable attribute 'description'. This is the setter.

destroy

Signature: void destroy

Description: Explicitly destroys the object

Use of this method is deprecated. Use _destroy instead

Explicitly destroys the object on C++ side if it was owned by the script interpreter. Subsequent access to this object will throw an exception. If the object is not owned by the script, this method will do nothing.

destroyed?

Signature: [const] bool destroyed?

Description: Returns a value indicating whether the object was already destroyed

Use of this method is deprecated. Use _destroyed? instead

This method returns true, if the object was destroyed, either explicitly or by the C++ side. The latter may happen, if the object is owned by a C++ object which got destroyed itself.

each_category

Signature: [const,iter] RdbCategory each_category

Description: Iterates over all top-level categories

each_cell

Signature: [const,iter] RdbCell each_cell

Description: Iterates over all cells

each_item

Signature: [const,iter] RdbItem each_item

Description: Iterates over all items inside the database

each_item_per_category

Signature: [const,iter] RdbItem each_item_per_category (unsigned long category_id)

Description: Iterates over all items inside the database which are associated with the given category

category_id:The ID of the category for which all associated items should be retrieved

each_item_per_cell

Signature: [const,iter] RdbItem each_item_per_cell (unsigned long cell_id)

Description: Iterates over all items inside the database which are associated with the given cell

cell_id:The ID of the cell for which all associated items should be retrieved

each_item_per_cell_and_category

Signature: [const,iter] RdbItem each_item_per_cell_and_category (unsigned long cell_id, unsigned long category_id)

Description: Iterates over all items inside the database which are associated with the given cell and category

cell_id:The ID of the cell for which all associated items should be retrieved
category_id:The ID of the category for which all associated items should be retrieved

filename

Signature: [const] string filename

Description: Gets the file name and path where the report database is stored

Returns:The file name and path

This property is set when a database is saved or loaded. It cannot be set manually.

generator

Signature: [const] string generator

Description: Gets the databases generator

Returns:The generator string

The generator string describes how the database was created, i.e. DRC tool name and tool options. In a later version this will allow re-running the tool that created the report.

Python specific notes:
The object exposes a readable attribute 'generator'. This is the getter.

generator=

Signature: void generator= (string generator)

Description: Sets the generator string

generator:The generator string

Python specific notes:
The object exposes a writable attribute 'generator'. This is the setter.

is_const_object?

Signature: [const] bool is_const_object?

Description: Returns a value indicating whether the reference is a const reference

Use of this method is deprecated. Use _is_const_object? instead

This method returns true, if self is a const reference. In that case, only const methods may be called on self.

is_modified?

Signature: [const] bool is_modified?

Description: Returns a value indicating whether the database has been modified

load

Signature: void load (string filename)

Description: Loads the database from the given file

filename:The file from which to load the database

The reader recognizes the format automatically and will choose the appropriate decoder. 'gzip' compressed files are uncompressed automatically.

name

Signature: [const] string name

Description: Gets the database name

Returns:The database name

The name of the database is supposed to identify the database within a layout view context. The name is modified to be unique when a database is entered into a layout view.

new

Signature: [static] new ReportDatabase ptr new (string name)

Description: Creates a report database

name:The name of the database

The name of the database will be used in the user interface to refer to a certain database.

Python specific notes:
This method is the default initializer of the object

num_items

(1) Signature: [const] unsigned long num_items

Description: Returns the number of items inside the database

Returns:The total number of items

(2) Signature: [const] unsigned long num_items (unsigned long cell_id, unsigned long category_id)

Description: Returns the number of items inside the database for a given cell/category combination

cell_id:The ID of the cell for which to retrieve the number
category_id:The ID of the category for which to retrieve the number
Returns:The total number of items for the given cell and the given category

num_items_visited

(1) Signature: [const] unsigned long num_items_visited

Description: Returns the number of items already visited inside the database

Returns:The total number of items already visited

(2) Signature: [const] unsigned long num_items_visited (unsigned long cell_id, unsigned long category_id)

Description: Returns the number of items visited already for a given cell/category combination

cell_id:The ID of the cell for which to retrieve the number
category_id:The ID of the category for which to retrieve the number
Returns:The total number of items visited for the given cell and the given category

original_file

Signature: [const] string original_file

Description: Gets the original file name and path

Returns:The original file name and path

The original file name is supposed to describe the file from which this report database was generated.

Python specific notes:
The object exposes a readable attribute 'original_file'. This is the getter.

original_file=

Signature: void original_file= (string path)

Description: Sets the original file name and path

path:The path

Python specific notes:
The object exposes a writable attribute 'original_file'. This is the setter.

reset_modified

Signature: void reset_modified

Description: Reset the modified flag

save

Signature: void save (string filename)

Description: Saves the database to the given file

filename:The file to which to save the database

The database is always saved in KLayout's XML-based format.

set_item_visited

Signature: void set_item_visited (const RdbItem ptr item, bool visited)

Description: Modifies the visited state of an item

item:The item to modify
visited:True to set the item to visited state, false otherwise

set_tag_description

Signature: void set_tag_description (unsigned long tag_id, string description)

Description: Sets the tag description for the given tag ID

tag_id:The ID of the tag
description:The description string

See tag_id for a details about tags.

tag_description

Signature: [const] string tag_description (unsigned long tag_id)

Description: Gets the tag description for the given tag ID

tag_id:The ID of the tag
Returns:The description string

See tag_id for a details about tags.

tag_id

Signature: [const] unsigned long tag_id (string name)

Description: Gets the tag ID for a given tag name

name:The tag name
Returns:The corresponding tag ID

Tags are used to tag items in the database and to specify tagged (named) values. This method will always succeed and the tag will be created if it does not exist yet. Tags are basically names. There are user tags (for free assignment) and system tags which are used within the system. Both are separated to avoid name clashes.

tag_id handles system tags while user_tag_id handles user tags.

tag_name

Signature: [const] string tag_name (unsigned long tag_id)

Description: Gets the tag name for the given tag ID

tag_id:The ID of the tag
Returns:The name of the tag

See tag_id for a details about tags.

This method has been introduced in version 0.24.10.

top_cell_name

Signature: [const] string top_cell_name

Description: Gets the top cell name

Returns:The top cell name

The top cell name identifies the top cell of the design for which the report was generated. This property must be set to establish a proper hierarchical context for a hierarchical report database.

Python specific notes:
The object exposes a readable attribute 'top_cell_name'. This is the getter.

top_cell_name=

Signature: void top_cell_name= (string cell_name)

Description: Sets the top cell name string

cell_name:The top cell name

Python specific notes:
The object exposes a writable attribute 'top_cell_name'. This is the setter.

user_tag_id

Signature: [const] unsigned long user_tag_id (string name)

Description: Gets the tag ID for a given user tag name

name:The user tag name
Returns:The corresponding tag ID

This method will always succeed and the tag will be created if it does not exist yet. See tag_id for a details about tags.

This method has been added in version 0.24.

variants

Signature: unsigned long[] variants (string name)

Description: Gets the variants for a given cell name

name:The basic name of the cell
Returns:An array of ID's representing cells that are variants for the given base name