BIND 10 trac1206, updated. fdf1c88a53f5970aa4e6d55da42303ce7d4730f7 [1206] move checkConfig into cozy anonymous namespace

BIND 10 source code commits bind10-changes at lists.isc.org
Thu Sep 29 13:24:03 UTC 2011


The branch, trac1206 has been updated
       via  fdf1c88a53f5970aa4e6d55da42303ce7d4730f7 (commit)
       via  33ee923f7139cbda7a616a83d572a4358f456e16 (commit)
      from  5e14c4caafaa44b92134c5df01b726f435f46845 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit fdf1c88a53f5970aa4e6d55da42303ce7d4730f7
Author: Jelte Jansen <jelte at isc.org>
Date:   Thu Sep 29 15:23:48 2011 +0200

    [1206] move checkConfig into cozy anonymous namespace

commit 33ee923f7139cbda7a616a83d572a4358f456e16
Author: Jelte Jansen <jelte at isc.org>
Date:   Thu Sep 29 15:10:49 2011 +0200

    [1206] comments pt1

-----------------------------------------------------------------------

Summary of changes:
 src/lib/datasrc/factory.cc          |    8 ++++--
 src/lib/datasrc/factory.h           |   36 +++++++++++++++++++++++++---------
 src/lib/datasrc/memory_datasrc.cc   |    4 +-
 src/lib/datasrc/sqlite3_accessor.cc |    3 +-
 4 files changed, 35 insertions(+), 16 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/factory.cc b/src/lib/datasrc/factory.cc
index e464c89..8ccf27f 100644
--- a/src/lib/datasrc/factory.cc
+++ b/src/lib/datasrc/factory.cc
@@ -51,7 +51,7 @@ LibraryContainer::getSym(const char* name) {
 
     const char* dlsym_error = dlerror();
     if (dlsym_error != NULL) {
-        isc_throw(DataSourceLibraryError, dlsym_error);
+        isc_throw(DataSourceLibrarySymbolError, dlsym_error);
     }
 
     return (sym);
@@ -61,8 +61,10 @@ DataSourceClientContainer::DataSourceClientContainer(const std::string& type,
                                                      ConstElementPtr config)
 : ds_lib_(type + "_ds.so")
 {
-    ds_creator* ds_create = (ds_creator*)ds_lib_.getSym("createInstance");
-    destructor_ = (ds_destructor*)ds_lib_.getSym("destroyInstance");
+    ds_creator* ds_create =
+        reinterpret_cast<ds_creator*>(ds_lib_.getSym("createInstance"));
+    destructor_ =
+        reinterpret_cast<ds_destructor*>(ds_lib_.getSym("destroyInstance"));
 
     instance_ = ds_create(config);
 }
diff --git a/src/lib/datasrc/factory.h b/src/lib/datasrc/factory.h
index 813b6d7..eff8891 100644
--- a/src/lib/datasrc/factory.h
+++ b/src/lib/datasrc/factory.h
@@ -15,10 +15,7 @@
 #ifndef __DATA_SOURCE_FACTORY_H
 #define __DATA_SOURCE_FACTORY_H 1
 
-//#include <boost/noncopyable.hpp>
-//#include <boost/shared_ptr.hpp>
-
-//#include <exceptions/exceptions.h>
+#include <boost/noncopyable.hpp>
 
 #include <datasrc/data_source.h>
 #include <datasrc/client.h>
@@ -31,13 +28,22 @@ namespace datasrc {
 
 
 /// \brief Raised if there is an error loading the datasource implementation
-///        library, or if that library misses a needed symbol
+///        library
 class DataSourceLibraryError : public DataSourceError {
 public:
     DataSourceLibraryError(const char* file, size_t line, const char* what) :
         DataSourceError(file, line, what) {}
 };
 
+/// \brief Raised if there is an error reading a symbol from the datasource
+///        implementation library
+class DataSourceLibrarySymbolError : public DataSourceError {
+public:
+    DataSourceLibrarySymbolError(const char* file, size_t line,
+                                 const char* what) :
+        DataSourceError(file, line, what) {}
+};
+
 /// \brief Raised if the given config contains bad data
 ///
 /// Depending on the datasource type, the configuration may differ (for
@@ -63,7 +69,7 @@ typedef void ds_destructor(DataSourceClient* instance);
 ///       in other places than for dynamically loading datasources, then, apart
 ///       from moving it to another location, we also need to make the
 ///       exceptions raised more general.
-class LibraryContainer {
+class LibraryContainer : boost::noncopyable {
 public:
     /// \brief Constructor
     ///
@@ -83,11 +89,19 @@ public:
     ///
     /// This retrieves a symbol from the loaded library.
     ///
-    /// \exception DataSourceLibraryError if the symbol cannot be found, or if
-    ///            another error (as reported by dlerror() occurs.
+    /// \exception DataSourceLibrarySymbolError if the symbol cannot be found,
+    ///            or if another error (as reported by dlerror() occurs.
     ///
     /// \param name The name of the symbol to retrieve
-    /// \return A pointer to the symbol
+    /// \return A pointer to the symbol. This may be NULL, and if so, indicates
+    ///         the symbol does indeed exist, but has the value NULL itself.
+    ///         If the symbol does not exist, a DataSourceLibrarySymbolError is
+    ///         raised.
+    ///
+    /// \note The argument is a const char* (and not a std::string like the
+    ///       argument in the constructor). This argument is always a fixed
+    ///       string in the code, while the other can be read from
+    ///       configuration, and needs modification
     void* getSym(const char* name);
 private:
     /// Pointer to the dynamically loaded library structure
@@ -120,12 +134,14 @@ private:
 ///
 /// extern "C" void destroyInstance(isc::data::DataSourceClient* instance);
 /// \endcode
-class DataSourceClientContainer {
+class DataSourceClientContainer : boost::noncopyable {
 public:
     /// \brief Constructor
     ///
     /// \exception DataSourceLibraryError if there is an error loading the
     ///            backend library
+    /// \exception DataSourceLibrarySymbolError if the library does not have
+    ///            the needed symbols, or if there is an error reading them
     /// \exception DataSourceConfigError if the given config is not correct
     ///            for the given type
     ///
diff --git a/src/lib/datasrc/memory_datasrc.cc b/src/lib/datasrc/memory_datasrc.cc
index 13ce348..a29e902 100644
--- a/src/lib/datasrc/memory_datasrc.cc
+++ b/src/lib/datasrc/memory_datasrc.cc
@@ -856,8 +856,6 @@ checkZoneConfig(ConstElementPtr config, ElementPtr errors) {
     return result;
 }
 
-} // end anonymous namespace
-
 bool
 checkConfig(ConstElementPtr config, ElementPtr errors) {
     /* Specific configuration is under discussion, right now this accepts
@@ -924,6 +922,8 @@ checkConfig(ConstElementPtr config, ElementPtr errors) {
     return true;
 }
 
+} // end anonymous namespace
+
 DataSourceClient *
 createInstance(isc::data::ConstElementPtr config) {
     ElementPtr errors(Element::createList());
diff --git a/src/lib/datasrc/sqlite3_accessor.cc b/src/lib/datasrc/sqlite3_accessor.cc
index 5ee58d4..8e9f511 100644
--- a/src/lib/datasrc/sqlite3_accessor.cc
+++ b/src/lib/datasrc/sqlite3_accessor.cc
@@ -669,7 +669,6 @@ addError(ElementPtr errors, const std::string& error) {
         errors->add(Element::create(error));
     }
 }
-} // end anonymous namespace
 
 bool
 checkConfig(ConstElementPtr config, ElementPtr errors) {
@@ -705,6 +704,8 @@ checkConfig(ConstElementPtr config, ElementPtr errors) {
     return (result);
 }
 
+} // end anonymous namespace
+
 DataSourceClient *
 createInstance(isc::data::ConstElementPtr config) {
     ElementPtr errors(Element::createList());




More information about the bind10-changes mailing list