#pragma once #include #include #include #include "secsgem/gem/data_model.hpp" namespace secsgem::gem { // Resolve a human variable name to its numeric VID, spanning SVIDs and DVIDs // (one VID space). SVIDs win on a name collision. nullopt if unknown. // // This is the name->id half of the vendor-facing binding layer: the daemon and // any language client address items by the names from equipment.yaml, and the // engine stays numeric. Best-effort by design — duplicate names simply resolve // to the first match rather than erroring (see secsgem-vendor-accessibility). inline std::optional resolve_variable(const EquipmentDataModel& m, const std::string& name) { for (const auto& sv : m.svids.all()) if (sv.name == name) return sv.id; for (const auto& dv : m.dvids.all()) if (dv.name == name) return dv.id; return std::nullopt; } // Resolve a collection-event name to its CEID. nullopt if unknown. inline std::optional resolve_event(const EquipmentDataModel& m, const std::string& name) { for (const auto& e : m.events.all_events()) if (e.name == name) return e.id; return std::nullopt; } } // namespace secsgem::gem