Parcourir la source

[2315] Add more comments in new functions.

Marcin Siodelski il y a 12 ans
Parent
commit
d831b49bea
2 fichiers modifiés avec 15 ajouts et 0 suppressions
  1. 12 0
      src/lib/dhcpsrv/cfgmgr.cc
  2. 3 0
      src/lib/dhcpsrv/cfgmgr.h

+ 12 - 0
src/lib/dhcpsrv/cfgmgr.cc

@@ -45,27 +45,39 @@ CfgMgr::addOptionDef(const OptionDefinitionPtr& def,
 
 const OptionDefContainer&
 CfgMgr::getOptionDefs(const std::string& option_space) const {
+    // Get all option definitions for the particular option space.
     const std::map<std::string, OptionDefContainer>::const_iterator& defs =
         option_def_spaces_.find(option_space);
+    // If there are no option definitions for the particular option space
+    // then return empty container.
     if (defs == option_def_spaces_.end()) {
         static OptionDefContainer empty_container;
         return (empty_container);
     }
+    // If option definitions found, return them.
     return (defs->second);
 }
 
 OptionDefinitionPtr
 CfgMgr::getOptionDef(const std::string& option_space,
                      const uint16_t option_code) const {
+    // Get a reference to option definitions for a particular option space.
     const OptionDefContainer& defs = getOptionDefs(option_space);
+    // If there are no matching option definitions then return the empty pointer.
     if (defs.empty()) {
         return (OptionDefinitionPtr());
     }
+    // If there are some option definitions for a particular option space
+    // use an option code to get the one we want.
     const OptionDefContainerTypeIndex& idx = defs.get<1>();
     const OptionDefContainerTypeRange& range = idx.equal_range(option_code);
+    // If there is no definition that matches option code, return empty pointer.
     if (std::distance(range.first, range.second) == 0) {
         return (OptionDefinitionPtr());
     }
+    // If there is more than one definition matching an option code, return
+    // the first one. This should not happen because we check for duplicates
+    // when addOptionDef is called.
     return (*range.first);
 }
 

+ 3 - 0
src/lib/dhcpsrv/cfgmgr.h

@@ -84,6 +84,9 @@ public:
     ///
     /// @throw isc::dhcp::DuplicateOptionDefinition when the particular
     /// option definition already exists.
+    /// @throw isc::dhcp::MalformedOptionDefinition when the pointer to
+    /// an option definition is NULL.
+    /// @throw isc::BadValue when the option space name is empty.
     void addOptionDef(const OptionDefinitionPtr& def,
                       const std::string& option_space);