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)

List of all members

Public Types

struct SaveOptionsControls compact vs verbose geometry when writing .room files.

Public Functions

Database()Constructs an empty in-memory database.
const std::string & version() constReturns the file format version string.
void setVersion(std::string value)Sets the format version written on save.
const std::string & generator() constReturns the name of the creating tool.
void setGenerator(std::string value)Records which program produced this database.
const std::string & technology() constReturns 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() constReturns the root cell library (const).
ViewType fileView() constPrimary view kind for this file.
const FileSummary & fileSummary() constDenormalized 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

MemberDefaultDescription
bool compactGeometrytrueWhen 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.

ParameterDescription
valueVersion 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).

ParameterDescription
valueTool 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.

ParameterDescription
valueTechnology 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.

ParameterDescription
pathOutput path — prefer roomFileName(cell, fileView).
fileViewPrimary view stored in FileSummary.
optionsSaveOptions (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().

ParameterDescription
pathInput 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_versionFile format version (default "1.0").
std::string m_generatorCreating tool name.
std::string m_technologyTechnology or PDK identifier.
Lib m_libRoot 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";