regulators: Enhance IDMap to detect duplicate IDs
The IDMap class provides a mapping from unique string IDs to the
corresponding Device, Rail, and Rule objects.
Enhance IDMap to detect duplicate IDs. Throw an exception if the caller
tries to add a Device, Rail, or Rule whose ID already exists in the map.
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
Change-Id: I81176fae1415cd5a89dc4ff47f80d1bc70e0e004
diff --git a/phosphor-regulators/src/id_map.hpp b/phosphor-regulators/src/id_map.hpp
index 289c7a9..c466f23 100644
--- a/phosphor-regulators/src/id_map.hpp
+++ b/phosphor-regulators/src/id_map.hpp
@@ -47,6 +47,8 @@
/**
* Adds the specified device to this IDMap.
*
+ * Throws invalid_argument if the device's ID already exists in the map.
+ *
* @param device device to add
*/
void addDevice(Device& device);
@@ -54,6 +56,8 @@
/**
* Adds the specified rail to this IDMap.
*
+ * Throws invalid_argument if the rail's ID already exists in the map.
+ *
* @param rail rail to add
*/
void addRail(Rail& rail);
@@ -61,6 +65,8 @@
/**
* Adds the specified rule to this IDMap.
*
+ * Throws invalid_argument if the rule's ID already exists in the map.
+ *
* @param rule rule to add
*/
void addRule(Rule& rule);