ROOM » Core » C++ Classes » Lib
Lib Class
Named library of cells stored inside a Database. Moreā¦
| Header: | #include "lib.h" |
|---|---|
| CMake: | target_link_libraries(mytarget PRIVATE ROOM::room) |
Public Functions
| explicit Lib(std::string name) | Constructs a library with the given name. |
| const std::string & name() const | Returns the library name. |
| std::vector<Property> & properties() | Returns the library metadata list for modification. |
| const std::vector<Property> & properties() const | Returns the library metadata list for read-only access. |
| std::vector<Cell> & cells() | Returns all cells in this library for modification. |
| const std::vector<Cell> & cells() const | Returns all cells in this library for read-only access. |
| std::vector<LayerSpec> & layers() | Returns the shared layer table for modification. |
| const std::vector<LayerSpec> & layers() const | Returns the shared layer table for read-only access. |
| Cell * findCell(const std::string & name) | Searches for a cell by name. |
| const Cell * findCell(const std::string & name) const | Searches for a cell by name (const overload). |
| Cell & getOrCreateCell(const std::string & name) | Returns an existing cell or appends a new one with the given name. |
| void recomputeAllBBoxes(ViewType view = Layout) | Recomputes cached bboxes on all layout blocks. |
| void refreshIndex(ViewType view = Layout) | Rebuilds the derived LibIndex from cell contents. |
| const LibIndex & index() const | Returns the persisted derived index (top cells, hierarchy, bboxes). |
| bool hasIndex() const | Whether index() has been built or loaded. |
Detailed Description
A room::Lib is a named collection of Cell objects and a shared LayerSpec table. Each Database owns exactly one library (default name "default").
Shapes and terminals store a layerId index into Lib::layers(), not GDS layer numbers directly. Importers such as GdsImporter build this table once per library while scanning the file.
A derived LibIndex (top cells, reference counts, child refs, per-cell bboxes) is stored on Lib in the .room file. Call refreshIndex() after edits, or recomputeAllBBoxes() when only geometry changed.
Member Function Documentation
explicit Lib(std::string name)
Constructs a library with the given name.
| Parameter | Description |
|---|---|
name | Library name stored in the database and serialized to the .room file. |
const std::string & name() const
Returns the library name.
Returns: The name passed to the constructor or read from a loaded file.
std::vector<Property> & properties()
Returns the library metadata list for modification.
Returns: Mutable reference to name/value Property pairs attached to this library.
const std::vector<Property> & properties() const
Returns the library metadata list for read-only access.
Returns: Const reference to name/value properties.
std::vector<Cell> & cells()
Returns all cells in this library for modification.
Returns: Mutable reference to the cell vector. Use getOrCreateCell() to add cells by name.
const std::vector<Cell> & cells() const
Returns all cells in this library for read-only access.
Returns: Const reference to the cell vector.
std::vector<LayerSpec> & layers()
Returns the shared layer table for modification.
Returns: Mutable reference to LayerSpec entries. The index of each entry is used as layerId in shapes and terms across all cells in this library.
const std::vector<LayerSpec> & layers() const
Returns the shared layer table for read-only access.
Returns: Const reference to the layer table.
Cell * findCell(const std::string & name)
Searches for a cell by name.
| Parameter | Description |
|---|---|
name | Cell name to look up (exact match). |
Returns: Pointer to the matching Cell, or nullptr if no cell with that name exists.
const Cell * findCell(const std::string & name) const
Searches for a cell by name (const overload).
| Parameter | Description |
|---|---|
name | Cell name to look up (exact match). |
Returns: Const pointer to the matching cell, or nullptr if not found.
Cell & getOrCreateCell(const std::string & name)
Returns an existing cell or appends a new one with the given name.
| Parameter | Description |
|---|---|
name | Cell name. If a cell with this name already exists, that cell is returned; otherwise a new empty cell is created. |
Returns: Reference to the existing or newly created Cell.
void recomputeAllBBoxes(ViewType view = ViewType::Layout)
Walks all cells and recomputes block().bbox() for the given view type.
void refreshIndex(ViewType view = ViewType::Layout)
Rebuilds LibIndex from instance hierarchy and layout bboxes, then marks the index present.
const LibIndex & index() const
Returns the derived index persisted in Lib.index on save.
bool hasIndex() const
Returns whether an index is available (built, refreshed, or loaded from disk).
Private Variables
Private members are implementation details. Do not access them from user code.
std::string m_name | Library name. |
std::vector<Property> m_properties | Library-level metadata. |
std::vector<LayerSpec> m_layers | Shared layer table. |
std::vector<Cell> m_cells | Cells owned by this library. |
LibIndex m_index | Derived hierarchy and bbox index. |
bool m_hasIndex | Whether m_index is valid. |
Example
room::Lib lib("my_pdk");
lib.properties().push_back({"author", "team"});
lib.layers().push_back({1, 0, "MET1", room::LayerPurpose::Drawing});
lib.layers().push_back({8, 25, "L8/D25", room::LayerPurpose::Label});
room::Cell & top = lib.getOrCreateCell("TOP");
room::CellContent & layout = top.getOrCreateContent(room::ViewType::Layout);
layout.block().shapes().emplace_back(
room::Shape::RectData{{0, 0, 1000, 1000}, 0});