.. _dip-workflows: Workflows ========= These examples combine the native DIP calls into common tasks. The detailed pages cover query syntax, ownership rules, persistence formats, and generated outputs. Load a project and read a value ------------------------------- Load a reusable project, evaluate it, and inspect a known path: .. code-block:: cpp #include snt::dip::DIP parser; parser.add_project("DIPfile"); snt::dip::Environment env = parser.parse(); double speed = env["physics.speed"].as(); std::string units = env["physics.speed"].units(); See :doc:`DIPfile projects ` for the manifest format and :doc:`Parsing and environments ` for direct source registration. Apply an override before evaluation ----------------------------------- Register an override before calling ``parse()`` so dependent values use the replacement: .. code-block:: cpp snt::dip::DIP parser; parser.add_project("DIPfile"); parser.add_override_string("simulation.resolution = 1024\n"); snt::dip::Environment env = parser.parse(); int resolution = env["simulation.resolution"].as(); int cells = env["simulation.cells"].as(); The target must exist and the replacement must satisfy its type, units, and constraints. See :ref:`Overriding initial values ` for inline and file-based overrides and their provenance behavior. Discover and inspect nodes -------------------------- Use an inspector when the path is not known in advance: .. code-block:: cpp #include snt::dip::Inspector view{env}; snt::dip::TagFilter filter; filter.all = {"export"}; for (const auto& node : view.select("?physics.", filter)) std::cout << node->path.name << ": " << node->to_string() << "\n"; See :doc:`Inspection ` for descriptions, previews, table inspection, provenance, and dependency graphs. Persist, export, or report -------------------------- An evaluated environment can be reused without parsing the original inputs: .. code-block:: cpp env.save("run.diph5"); env.generate(snt::dip::ExportFormat::CPP, "parameters.hpp"); See :doc:`Environment persistence ` for the DIPH5 contract, :doc:`Static parameter generation ` for export formats, and :doc:`C++ report generation ` for report output. Compare evaluated environments ------------------------------ Load two DIPH5 snapshots and compare their effective values or complete evaluated state: .. code-block:: cpp #include snt::dip::ComparisonOptions options; options.scope = snt::dip::ComparisonScope::Effective; auto changes = snt::dip::compare_diph5( "before.diph5", "run.diph5", options); Use the effective scope for values that affect the result, or the full scope when changes to declarations and metadata also matter. See :ref:`DIPH5 comparison ` for scope and array-difference semantics.