Files
essim/src/core/app/load.hpp
François b36af3167a Extract load into core (app::load_module); thin the command.
Move the import orchestration — System::Load + drop_singleton_signals +
infer_signal_types + the post-import counts — out of the `load` command into
core/app/load.{hpp,cpp}: app::load_module(System*, name, path, ImportType)
returns a LoadResult (ok/error, parts, signals, dropped, power/gnd/kept_other)
with no Print/dialog/FTXUI. The "mentor|altium|ods" string→enum mapping moves
to app::import_type_from_name (mirrors export_format_from_path). The command
only parses the type and renders the counts; output is byte-identical.

Add tests/test_load.cpp (core, no UI): the name mapping; a minimal Mentor
netlist that imports two parts and drops one singleton signal; and a pin test
of the pre-existing missing-file behaviour (ImportBase doesn't check is_open(),
so a missing file yields an empty module rather than an error — preserved by
the extraction and pinned so any future hardening is a deliberate change).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 20:18:35 +02:00

37 lines
1.3 KiB
C++

#ifndef _APP_LOAD_HPP_
#define _APP_LOAD_HPP_
#include "core/domain/system.hpp" // ImportType
#include <string>
// Application layer: UI-independent operations that any frontend (TUI, GUI, …)
// can call. No console, no dialogs, no FTXUI — just System in, result out.
namespace app {
// Map an import-type name (mentor / altium / ods, case-insensitive) to an
// ImportType. Returns false if the name is none of those.
bool import_type_from_name(const std::string &name, ImportType &out);
// Outcome of loading a module: the post-import counts the caller renders.
struct LoadResult {
bool ok = false;
std::string error; ///< human-readable, set when !ok
int parts = 0;
int signals = 0;
int dropped = 0; ///< singleton/NC signals removed after import
int power = 0; ///< signals inferred Power (name + structure)
int gnd = 0; ///< signals inferred GndShield (name)
int kept_other = 0; ///< name said Power but evidence too weak → kept Other
};
// Import a module from a netlist/pinout file into `sys`, drop singleton signals,
// then infer signal types. Returns the counts or an error. Pure core — safe to
// call from any frontend.
LoadResult load_module(System *sys, const std::string &module_name,
const std::string &path, ImportType type);
} // namespace app
#endif // _APP_LOAD_HPP_