ROOM » Utilities » C++ Classes » PrimitiveResolver

PrimitiveResolver Class

Indexes attached *.symbol.room files (PDK, commonLib, design-library cells) so Qucs and Xschem exporters can resolve Lib / devices/*.sym references. More…

Header:#include "primitive_resolver.h"
CMake:target_link_libraries(mytarget PRIVATE ROOM::room_utils)

Public Types

struct ResolvedPrimitiveLookup result: ROOM path, cell name, tech library.

Public Functions

void setTechLibrary(const std::string & techLibrary)Semicolon-separated tech/design library names (e.g. commonLib;ihp_sg13g2).
void setQucsLibrary(const std::string & qucsLibrary)Qucs <Lib> library name for PDK cells.
void addCorePath(const std::string & roomPath)Register one *.symbol.room file.
void loadFromEnvironment()Read paths and library names from process environment.
ResolvedPrimitive resolveReference(const std::string & ref) constResolve res, sg13g2_pr/rppd, devices/lab_pin.sym, …
static std::vector<std::string> primitiveCorePathsFromEnvironment()Parse primitive path list without building the index.

Environment variables

LibMan and integrated editors set these when opening a schematic view with attached tech libraries:

VariableFormatDescription
CORE_PRIMITIVE_LIBS_FILE Path to a text file Preferred for large libraries (100+ symbols). One absolute path per line. Avoids oversized environment strings on Windows/WSL.
CORE_PRIMITIVE_LIBS ; or : separated paths Fallback when no list file is set.
CORE_PRIMITIVE_LIB Single path Legacy single-symbol attachment.
LIBMAN_TECH_LIBRARY ; separated names Logical library prefixes for symbol keys (e.g. commonLib, sg13g2_pr).
QUCS_PRIMITIVE_LIB Library name Qucs <Lib> name written by QucsExporter for PDK primitives.

primitiveCorePathsFromEnvironment() checks CORE_PRIMITIVE_LIBS_FILE first, then CORE_PRIMITIVE_LIBS, then CORE_PRIMITIVE_LIB.

Detailed Description

Each registered <cell>.symbol.room is indexed under multiple keys: bare cell.sym, <lib>/cell.sym, and (for commonLib) devices/cell.sym for Xschem compatibility. Alias tables map Qucs component types to Xschem device names (e.g. res ↔ R, gnd ↔ GND).

QucsExporter uses the resolver to emit native Qucs components where possible (res → R, iopin → Port) and <Lib> only for PDK/hierarchy cells without a built-in mapping. Xschem-only decorations (lab_wire, code_shown, launcher) are skipped in Qucs via isQucsSchematicDecoration().

Member Type Documentation

struct ResolvedPrimitive

MemberDescription
bool foundtrue when ref matched an indexed symbol core.
std::string roomPathAbsolute path to the *.symbol.room file.
std::string cellNameCell stem (e.g. lab_pin, rppd).
std::string techLibraryLibrary directory prefix when known.
std::string logicalRefNormalized lookup key.

Example

room::PrimitiveResolver resolver;
resolver.loadFromEnvironment();
// or manually:
resolver.setTechLibrary("commonLib;sg13g2_pr");
resolver.addCorePath("/data/commonLib/lab_pin/lab_pin.symbol.room");

const room::ResolvedPrimitive hit = resolver.resolveReference("devices/lab_pin.sym");
if (hit.found) {
    // use hit.roomPath in export/materialize
}