ROOM » Core » C++ Classes » Database
Database Class
The Database class is the root object of a ROOM design file. It holds file metadata and one Lib. More…
| Header: | #include "database.h" |
|---|---|
| CMake: | find_package(ROOM REQUIRED)target_link_libraries(mytarget PRIVATE ROOM::room) |
Public Types
| struct SaveOptions | Controls compact vs verbose geometry when writing .room files. |
Public Functions
| Database() | Constructs an empty in-memory database. |
| const std::string & version() const | Returns the file format version string. |
| void setVersion(std::string value) | Sets the format version written on save. |
| const std::string & generator() const | Returns the name of the creating tool. |
| void setGenerator(std::string value) | Records which program produced this database. |
| const std::string & technology() const | Returns the technology or PDK identifier. |
| void setTechnology(std::string value) | Associates a technology or PDK name. |
| Lib & lib() | Returns the root cell library (mutable). |
| const Lib & lib() const | Returns the root cell library (const). |
| ViewType fileView() const | Primary view kind for this file. |
| const FileSummary & fileSummary() const | Denormalized header for sniff. |
| void saveToFile(path, ViewType fileView, SaveOptions = {}) | Serializes to .room with summary. |
| static Database loadFromFile(const std::string & path) | Reads a database from a .room file. |
Detailed Description
A room::Database is the top-level container for layout and schematic topology. It stores version, generator, and technology metadata plus a single Lib of cells. Persistence uses Cap'n Proto; view-specific files use <cell>.<view>.room (see ROOM path helpers). saveToFile(path, fileView) writes a FileSummary for fast sniffing without loading geometry.
Member Type Documentation
struct SaveOptions
| Member | Default | Description |
|---|---|---|
bool compactGeometry | true | When true, geometry is written to payload.compact; when false, verbose payload.block is used. |
Member Function Documentation
Database()
Default constructor. Creates an empty in-memory database.
Postcondition: version() is "1.0", metadata strings are empty, and lib() is a library named "default" with no cells.
const std::string & version() const
Returns the ROOM file format version stored in this database.
Returns: Format version string (default "1.0" for a newly constructed database).
void setVersion(std::string value)
Sets the format version written to the file header on save.
| Parameter | Description |
|---|---|
value | Version string (for example "1.0"). |
const std::string & generator() const
Returns the name of the tool or program that created this database.
Returns: Generator name; empty if not set.
void setGenerator(std::string value)
Records which program produced this database (stored in the file metadata).
| Parameter | Description |
|---|---|
value | Tool name (for example "ROOM GdsImporter" or "MyTool"). |
const std::string & technology() const
Returns the technology or PDK identifier associated with this design.
Returns: Free-form technology string; empty if not set.
void setTechnology(std::string value)
Associates a technology or PDK name with the database.
| Parameter | Description |
|---|---|
value | Technology string (for example "sg13g2"). |
Lib & lib()
Returns the root cell library for read/write access.
Returns: Reference to the single Lib owned by this database.
const Lib & lib() const
Returns the root cell library for read-only access.
Returns: Const reference to the single Lib owned by this database.
void saveToFile(const std::string & path, ViewType fileView, SaveOptions options = {})
Serializes this database to a binary Cap'n Proto file and writes Database.summary for sniff.
| Parameter | Description |
|---|---|
path | Output path — prefer roomFileName(cell, fileView). |
fileView | Primary view stored in FileSummary. |
options | SaveOptions (default: compact geometry). |
Throws: std::runtime_error if the file cannot be opened for writing.
static Database loadFromFile(const std::string & path)
Reads a database from a binary Cap'n Proto file previously written by saveToFile().
| Parameter | Description |
|---|---|
path | Input file path of an existing .room file. |
Returns: A new Database populated from the file.
Throws: std::runtime_error if the file cannot be read or parsed.
Private Variables
Private members are implementation details. Do not access them from user code.
std::string m_version | File format version (default "1.0"). |
std::string m_generator | Creating tool name. |
std::string m_technology | Technology or PDK identifier. |
Lib m_lib | Root cell library owned by this database. |
Example
room::Database db;
db.setGenerator("MyTool");
db.setTechnology("sg13g2");
db.lib().getOrCreateCell("TOP");
db.saveToFile("inv.schematic.room", room::ViewType::Schematic);
room::Database loaded = room::Database::loadFromFile("inv.schematic.room");
std::cout << loaded.lib().cells().size() << " cells\n";