TraceMaker
C++ API of the engine
Loading...
Searching...
No Matches
overrides.hpp File Reference

The user override file (design doc 15 §3.5 level 1, §6.3): the user disables rules, forces or forbids a category on a part, or changes a rule parameter. More...

#include <cstdint>
#include <string>
#include <string_view>
#include <vector>
#include <nlohmann/json.hpp>
#include "crules/catalogue.hpp"
#include "model/board.hpp"

Go to the source code of this file.

Classes

struct  tmk::crules::OverrideEntry
struct  tmk::crules::Overrides

Namespaces

namespace  tmk
namespace  tmk::crules

Functions

Overrides tmk::crules::parse_overrides (std::string_view json_text, const Catalogue &cat, const std::string &source="rules override")
 Parses and validates an override file.
Overrides tmk::crules::load_overrides_file (const std::string &path, const Catalogue &cat)
 Reads a JSON file; a .yaml/.yml file is refused with the conversion command.
void tmk::crules::check_override_refs (const Overrides &ov, const model::Board &b)
 Every reference must name a footprint of the board (throws otherwise, listing the unknown ones).

Detailed Description

The user override file (design doc 15 §3.5 level 1, §6.3): the user disables rules, forces or forbids a category on a part, or changes a rule parameter.

The engine reads JSON (it has no YAML parser, like the catalogue); the YAML form of doc 15 §6.3 maps 1:1 to it and scripts/crules_override.py converts it.

{ "version": 1, "disable": ["USB2-04\@J2", "XTAL-04", "mounting_hole", "crystal\@Y2"], "assert": {"J5": "usb2"}, // or [{"category": "usb2", "ref": "J5"}] "deny": {"U7": "buck"}, // or [{"category": "buck", "ref": "U7"}] "set": [{"rule": "XTAL-02", "param": "max_mm", "value": 5}, {"rule": "XTAL-01\@Y1", "param": "max_mm", "value": 8}] }

Everything is validated against the catalogue when the file is read: unknown keys, rule ids, categories, parameters and value types are errors, never ignored (a typo must not silently drop an override). References are validated against the board by check_override_refs (detect() calls it).

Definition in file overrides.hpp.