# sch-rnd modularization

## Why bother...

I believe good software should be modular. This is especially important in the context of large software, such as CAD applications. There should be a thin core that can model the world and provide the basic operations defined on it but anything else should go in separate modules.

Sch-rnd is built up from scratch with modularity in mind.

I believe such modularization has benefits on multiple levels:

- it is possible to compile smaller, potentially faster executables by omitting features the specific user would never use anyway
- in a distribution dynamic-link plugins can be distributed as separate packages providing the user with the option to decide what features to install
- such plugins have to have some sort of APIs if they want to reference each other or if the code needs to reference them; such an API may not (and often did not) exist when the code is part of the core

## Code size in charts

### Overall distribution

All numbers are in SLOC and are acquired running sloccount on the given directory. While lines of code alone is not a true measure of complexity, it's a good estimation. The slices of pie charts are the major components of the sch-rnd executable.

Main components

The main components are:

- libcschem: library that is operating the data model and the modular compiler
- sch-rnd app: application code: main() and the central infrastructure
- 3rd minilibs: 3rd-party minilibs shipped with sch-rnd; these minilibs are specialized in narrow tasks
- plugins: optional modules implementing the actual functionality (each can be disabled)

### Zooming on to the plugins

total size per class
IO plugins

feature plugins
export plugins

GUI plugins
engine plugins

(Red means the plugin doesn't really work).

## Progress in numbers

Below is a table with the summary of core plugins.

module | size [sloc] | status | configure default | class | description
--- | --- | --- | --- | --- | ---
act_draw | 280 | works | buildin | feature | Actions for drawing objects on a graphical sheet or symbol
act_read | 388 | works | buildin | feature | Data access related API as actions
attbl_csv | 238 | works | buildin | export | export and import attribute table in CSV format
attbl_json | 311 | works | buildin | export | export and import attribute table in json format
attbl_lht | 234 | works | buildin | export | export and import attribute table in lihata format
attbl_tedax | 270 | works | buildin | export | export and import attribute table in tEDAx format
backann | 1490 | works | buildin | feature | interactive back annotation
construct | 467 | works | buildin | feature | construct complex objects from atoms, break up groups
diag | 200 | works | buildin | feature | Actions for sch-rnd core diagnostics, intended for developers. These are not in core because end users normally don't need these. As a plugin, due to dynamic loading, it can be dropped on an existing sch-rnd installation with minimal risk of scaring away a reproducible bug.
export_abst | 208 | works | buildin | export | export project's abstract model to text
export_accel | 304 | works | buildin | export | export netlist to Accel
export_allegro | 247 | works | buildin | export | export netlist to Allegro
export_bae | 232 | works | buildin | export | export netlist to Bae
export_bom | 334 | works | buildin | export | export a BoM based on the components of the abstract model, using configurable templates
export_boxsym | 349 | works | buildin | export | export hierarchic child sheet terminals as a boxsym source
export_cadstar | 210 | works | buildin | export | export netlist to Cadstar (RINF/RIFN/RNIF format)
export_calay | 352 | works | buildin | export | export netlist in Calay's format
export_eagle | 218 | works | buildin | export | export netlist to Eagle
export_eagle5 | 286 | works | buildin | export | export to Eagle5 tabular netlist+bom format
export_easyeda | 195 | works | buildin | export | export netlist to Easyeda
export_edif | 489 | works | buildin | export | export netlist to Edif
export_ewnet | 293 | works | buildin | export | export netlist to Ewnet
export_fritzing | 204 | works | buildin | export | export netlist to Fritzing
export_futurenet2 | 235 | works | buildin | export | export netlist to Futurenet dash
export_jsonnet | 304 | works | buildin | export | export netlist to generic JSON
export_kicad | 400 | works | buildin | export | export netlist to KiCAD's format for pcbnew
export_lpr | 14 | works | buildin | export | Export to lpr (using export_ps to generate postscript)
export_maxascii | 218 | works | buildin | export | export netlist to Maxascii
export_orcad | 177 | works | buildin | export | export netlist to Orcad
export_osmond | 239 | works | buildin | export | export netlist to Osmond
export_pads_ascii | 222 | works | buildin | export | export netlist to PASD (in ASCII format)
export_png | 267 | works | buildin | export | png, jpeg and gif render
export_protelII | 239 | works | buildin | export | export netlist to ProtelII
export_ps | 576 | works | buildin | export | PostScript, Encapsulated PostScript exporter
export_redac | 197 | works | buildin | export | export netlist to Racal-Redac
export_spice | 474 | works | buildin | export | SPICE netlist exporter for circuit simulation
export_svg | 236 | works | buildin | export | Scalable Vector Graphics exporter
export_systemc | 288 | works | buildin | export | export netlist to Systemc
export_tango | 213 | works | buildin | export | export netlist to Tango
export_tedax | 221 | works | buildin | export | export netlist as a tEDAx netlist block
export_tedax_footprint | 242 | works | buildin | export | export sheet to tEDAx silk footprint for use on a PCB
export_tinycad | 265 | works | buildin | export | export netlist to TinyCAD
export_xmlnet | 273 | works | buildin | export | export netlist to generic XML
extobj_chart | 799 | works | buildin | feature | extended objects: block, arrow
funcmap | 1746 | works | buildin | engine | Handles alternate functionality of device ports (e.g. MCU pins)
gui | 1461 | works | buildin | gui | sch-rnd-specific GUI elements
hlibrary_fs | 76 | works | buildin | symlib | access libraries of hierarchic child sheets stored on the local file system
io_altium | 2472 | works | buildin | io | Load schematics from altium schdoc
io_bxl | 2499 | works | buildin | io | Load symbol from BXL format.
io_easyeda | 3605 | works | buildin | io | Load easyeda schematics and symbols
io_eeschema | 5201 | works | buildin | io | Load schematics and symbols from KiCAD's eeschema formats.
io_geda | 1313 | works | buildin | io | Load schematics and symbols from gEDA format.
io_lihata | 1629 | works | buildin | io | Load and save the schematics and symbols in the native lihata format.
io_ngrp_fawk | 259 | works | buildin | io | non-graphical schematic sheets in form of fawk scripts.
io_ngrp_tedax | 301 | works | buildin | io | Load non-graphical schematic sheets in tEDAx format.
io_orcad | 6336 | works | buildin | io | Load schematics from OrCad dsn
io_tinycad | 1511 | works | buildin | io | Load schematics from TinyCAD .dsn xml format.
lib_alien | 625 | works | buildin | io | Format-independent helper functions for reading alien files
lib_anymap | 383 | works | buildin | export | Common code usable for map-like engine plugins
lib_attbl | 749 | works | buildin | export | Helper functions for importing/exporting attribute tables
lib_nanojson | 15 | works | buildin | io | Wrapper around the nanojson library so multiple plugins can use it
lib_netlist_exp | 102 | works | buildin | export | Helper functions for exporting netlists
lib_ngrp | 296 | works | buildin | io | Helper functions for handling non-graphical sheets
lib_plot | 671 | works | disable-all | gui | subdialog for plotting and navigating graphs
lib_target | 136 | works | buildin | export | Helper functions for implementing target plugins
lib_tedax | 127 | works | buildin | io | Helper functions for implementing parsing and writing tEDAx files
lib_ucdf | 13 | works | buildin | io | Helper functions for reading (unpacking) ucdf files
place | 137 | works | buildin | feature | place complex objects such as terminals from template
propedit | 2268 | works | buildin | feature | List and edit properties of a group of objects.
query | 4336 | works | buildin | feature | sch-rnd query language: execute expressions on objects and rules for the programmed drc.
renumber | 379 | works | buildin | feature | Systematically change the name of selected symbols
sch_dialogs | 6669 | works | buildin | gui | Standard schematics editor dialog boxes
sim | 1667 | works | buildin | feature | abstract differences of circuit simiulation implementations, provide an unified interface (infrastructure, CLI and actions)
sim_gui | 2165 | works | buildin | feature | GUI for the the a unified high level simulation interface
sim_ngspice | 474 | works | buildin | feature | ngspice specific execution glue (for the GUI)
std_cschem | 399 | works | buildin | engine | Handles: component connect
std_devmap | 748 | works | buildin | engine | Handles slotting, device mapping and port mapping
std_forge | 2109 | works | buildin | engine | Handles: attribute forging
std_tools | 1825 | works | buildin | feature | Tools for drawing standard cschem concrete primitives
suite | 483 | works | buildin | feature | Suite integration: features spanning across tools in the suite
symlib_fs | 119 | works | buildin | symlib | access symbol libraries stored on the local file system
symlib_local | 697 | works | buildin | symlib | access symbol library stored within the sheet
target_none | 46 | works | buildin | engine | Display original names
target_pcb | 187 | works | buildin | engine | Attribute transformations for the PCB workflow
target_spice | 1138 | works | buildin | engine | Attribute transformations for the SPICE workflow

### Classes

Each plugin implements a class (rarely a set of classes). Classes are:

name | description
--- | ---
feature | random features directly accessible for the user, usually actions
lib | support code library for other plugins (core doesn't depend on these); functionality not directly accessible for the user but other plugins may depend on it
import | load alien formats into the design space
export | save (parts of) the design space in alien formats
io | native file format (save & load) implementation

### Status

Common status column values mean:

name | description
--- | ---
works | production quality code - configures, compiles, tested
WIP | work in progress: the plugin may be avaialble for testing but is not yet production quality
abandoned | unmaintained plugin; may be in working condition but there is no developer supporting it
deprecated | legacy plugin scheduled for removal; may still work but will soon be removed; if your workflow depends on it, please report ASAP

### Plugin dependency map