Parcourir la source

doxygen

git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@922 e5f2f494-b856-4b98-b285-d166d9295462
Jelte Jansen il y a 15 ans
Parent
commit
c502e0e0f4
2 fichiers modifiés avec 58 ajouts et 2 suppressions
  1. 7 2
      src/lib/config/cpp/config_data.cc
  2. 51 0
      src/lib/config/cpp/config_data.h

+ 7 - 2
src/lib/config/cpp/config_data.cc

@@ -153,8 +153,13 @@ ConfigData::getValue(bool& is_default, const std::string& identifier)
         is_default = false;
     } else {
         ElementPtr spec_part = find_spec_part(_module_spec.getConfigSpec(), identifier);
-        value = spec_part->get("item_default");
-        is_default = true;
+        if (spec_part->contains("item_default")) {
+            value = spec_part->get("item_default");
+            is_default = true;
+        } else {
+            is_default = false;
+            return ElementPtr();
+        }
     }
     return value;
 }

+ 51 - 0
src/lib/config/cpp/config_data.h

@@ -26,6 +26,9 @@
 namespace isc {
 namespace config {
 
+/// This exception is thrown when the caller is trying to access
+/// data that doesn't exist (i.e. with an identifier that does not
+/// point to anything defined in the .spec file)
 class DataNotFoundError : public isc::Exception {
 public:
     DataNotFoundError(const char* file, size_t line, const std::string& what) :
@@ -34,16 +37,64 @@ public:
     
 class ConfigData {
 public:
+    /// Constructs a ConfigData option with no specification and an
+    /// empty configuration.
     ConfigData() { _config = Element::createFromString("{}"); };
+    /// Constructs a ConfigData option with the given specification
+    /// and an empty configuration.
+    /// \param module_spec A ModuleSpec for the relevant module
     ConfigData(const ModuleSpec& module_spec) : _module_spec(module_spec) { _config = Element::createFromString("{}"); }
 
+    /// Returns the value currently set for the given identifier
+    /// If no value is set, the default value (as specified by the
+    /// .spec file) is returned. If there is no value and no default,
+    /// an empty ElementPtr is returned.
+    /// Raises a DataNotFoundError if the identifier is bad.
+    /// \param identifier The identifier pointing to the configuration
+    ///        value that is to be returned
     ElementPtr getValue(const std::string& identifier);
+
+    /// Returns the value currently set for the given identifier
+    /// If no value is set, the default value (as specified by the
+    /// .spec file) is returned. If there is no value and no default,
+    /// an empty ElementPtr is returned.
+    /// Raises a DataNotFoundError if the identifier is bad.
+    /// \param is_default will be set to true if the value is taken
+    ///                   from the specifications item_default setting,
+    ///                   false otherwise
+    /// \param identifier The identifier pointing to the configuration
+    ///        value that is to be returned
     ElementPtr getValue(bool &is_default, const std::string& identifier);
+
+    /// Returns the ModuleSpec associated with this ConfigData object
     const ModuleSpec getModuleSpec() { return _module_spec; };
+    /// Set the ModuleSpec associated with this ConfigData object
     void setModuleSpec(ModuleSpec module_spec) { _module_spec = module_spec; };
+    /// Set the local configuration (i.e. all non-default values)
+    /// \param config An ElementPtr pointing to a MapElement containing
+    ///        *all* non-default configuration values. Existing values
+    ///        will be removed.
     void setLocalConfig(ElementPtr config) { _config = config; }
+    /// Returns the local (i.e. non-default) configuration.
+    /// \returns An ElementPtr pointing to a MapElement containing all
+    ///          non-default configuration options.
     ElementPtr getLocalConfig() { return _config; }
+    /// Returns a list of all possible configuration options as specified
+    ///         by the ModuleSpec.
+    /// \param identifier If given, show the items at the given identifier
+    ///                   (iff that is also a MapElement)
+    /// \param recurse If true, child MapElements will be traversed to
+    ///                add their identifiers to the result list
+    /// \return An ElementPtr pointing to a ListElement containing
+    ///         StringElements that specify the identifiers at the given
+    ///         location (or all possible identifiers if identifier==""
+    ///         and recurse==false)
     ElementPtr getItemList(const std::string& identifier = "", bool recurse = false);
+    /// Returns all current configuration settings (both non-default and default).
+    /// \return An ElementPtr pointing to a MapElement containing
+    ///         string->value elements, where the string is the
+    ///         full identifier of the configuration option and the
+    ///         value is an ElementPtr with the value.
     ElementPtr getFullConfig();
 
 private: