[svn] commit: r3791 - in /branches/trac422/src/lib/datasrc: Makefile.am memory_datasrc.cc memory_datasrc.h tests/Makefile.am tests/memory_datasrc_unittest.cc tests/zonetable_unittest.cc zonetable.cc zonetable.h
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Dec 10 09:39:01 UTC 2010
Author: chenzhengzhang
Date: Fri Dec 10 09:39:01 2010
New Revision: 3791
Log:
add class MemoryDataSrc
update ZoneTable::FindResule
Added:
branches/trac422/src/lib/datasrc/memory_datasrc.cc
branches/trac422/src/lib/datasrc/memory_datasrc.h
branches/trac422/src/lib/datasrc/tests/memory_datasrc_unittest.cc
Modified:
branches/trac422/src/lib/datasrc/Makefile.am
branches/trac422/src/lib/datasrc/tests/Makefile.am
branches/trac422/src/lib/datasrc/tests/zonetable_unittest.cc
branches/trac422/src/lib/datasrc/zonetable.cc
branches/trac422/src/lib/datasrc/zonetable.h
Modified: branches/trac422/src/lib/datasrc/Makefile.am
==============================================================================
--- branches/trac422/src/lib/datasrc/Makefile.am (original)
+++ branches/trac422/src/lib/datasrc/Makefile.am Fri Dec 10 09:39:01 2010
@@ -16,3 +16,4 @@
libdatasrc_la_SOURCES += query.h query.cc
libdatasrc_la_SOURCES += cache.h cache.cc
libdatasrc_la_SOURCES += zonetable.h zonetable.cc
+libdatasrc_la_SOURCES += memory_datasrc.h memory_datasrc.cc
Modified: branches/trac422/src/lib/datasrc/tests/Makefile.am
==============================================================================
--- branches/trac422/src/lib/datasrc/tests/Makefile.am (original)
+++ branches/trac422/src/lib/datasrc/tests/Makefile.am Fri Dec 10 09:39:01 2010
@@ -25,11 +25,12 @@
run_unittests_SOURCES += cache_unittest.cc
run_unittests_SOURCES += test_datasrc.h test_datasrc.cc
run_unittests_SOURCES += zonetable_unittest.cc
+run_unittests_SOURCES += memory_datasrc_unittest.cc
run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS)
run_unittests_LDADD = $(GTEST_LDADD)
run_unittests_LDADD += $(SQLITE_LIBS)
-run_unittests_LDADD += $(top_builddir)/src/lib/datasrc/libdatasrc.la
+run_unittests_LDADD += $(top_builddir)/src/lib/datasrc/libdatasrc.la
run_unittests_LDADD += $(top_builddir)/src/lib/dns/libdns++.la
run_unittests_LDADD += $(top_builddir)/src/lib/cc/libcc.la
run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
Modified: branches/trac422/src/lib/datasrc/tests/zonetable_unittest.cc
==============================================================================
--- branches/trac422/src/lib/datasrc/tests/zonetable_unittest.cc (original)
+++ branches/trac422/src/lib/datasrc/tests/zonetable_unittest.cc Fri Dec 10 09:39:01 2010
@@ -93,7 +93,7 @@
EXPECT_EQ(ZoneTable::NOTFOUND,
zone_table.find(Name("example.org")).code);
- EXPECT_EQ(static_cast<const Zone*>(NULL),
+ EXPECT_EQ(ConstZonePtr(static_cast<const Zone*>(NULL)),
zone_table.find(Name("example.org")).zone);
// there's no exact match. the result should be the longest match,
Modified: branches/trac422/src/lib/datasrc/zonetable.cc
==============================================================================
--- branches/trac422/src/lib/datasrc/zonetable.cc (original)
+++ branches/trac422/src/lib/datasrc/zonetable.cc Fri Dec 10 09:39:01 2010
@@ -108,10 +108,10 @@
impl_->zones.find(matchname);
if (found != impl_->zones.end()) {
return (FindResult(i == 0 ? SUCCESS : PARTIALMATCH,
- (*found).second.get()));
+ (*found).second));
}
}
- return (FindResult(NOTFOUND, NULL));
+ return (FindResult(NOTFOUND, ConstZonePtr(static_cast<const Zone*>(NULL))));
}
} // end of namespace datasrc
} // end of namespace isc
Modified: branches/trac422/src/lib/datasrc/zonetable.h
==============================================================================
--- branches/trac422/src/lib/datasrc/zonetable.h (original)
+++ branches/trac422/src/lib/datasrc/zonetable.h Fri Dec 10 09:39:01 2010
@@ -241,13 +241,9 @@
/// while it wouldn't be safe to delete unnecessary zones inside the zone
/// table.
///
-/// On the other hand, the find() method returns a bare pointer, rather than
-/// the shared pointer, in order to minimize the dependency on Boost
-/// definitions in our public interfaces. This means the caller can only
-/// refer to the returned object (via the pointer) for a short period.
-/// It should be okay for simple lookup purposes, but if we see the need
-/// for keeping a \c Zone object for a longer period of context, we may
-/// have to revisit this decision.
+/// The find() method returns a (Boost) shared pointer, so that the higher
+/// level \c MemoryDataSrc can provide the genenral interface for all data
+/// sources.
///
/// Currently, \c FindResult::zone is immutable for safety.
/// In future versions we may want to make it changeable. For example,
@@ -272,14 +268,14 @@
SUCCESS, ///< The operation is successful.
EXIST, ///< A zone is already stored in \c ZoneTable.
NOTFOUND, ///< The specified zone is not found in \c ZoneTable.
- PARTIALMATCH ///< \c Only a partial match is found in \c find().
+ PARTIALMATCH ///< \c Only a partial match is found in \c find().
};
/// \brief A helper structure to represent the search result of
/// <code>ZoneTable::find()</code>.
///
- /// This is a straightforward pair of the result code and a pointer
- /// to the found zone to represent the result of \c find().
+ /// This is a straightforward pair of the result code and a (Boost) shared
+ /// pointer to the found zone to represent the result of \c find().
/// We use this in order to avoid overloading the return value for both
/// the result code ("success" or "not found") and the found object,
/// i.e., avoid using \c NULL to mean "not found", etc.
@@ -291,11 +287,11 @@
/// See the description of \c find() for the semantics of the member
/// variables.
struct FindResult {
- FindResult(Result param_code, const Zone* param_zone) :
+ FindResult(Result param_code, const ConstZonePtr param_zone) :
code(param_code), zone(param_zone)
{}
const Result code;
- const Zone* const zone;
+ const ConstZonePtr zone;
};
///
@@ -356,13 +352,8 @@
/// - \c PARTIALMATCH: A zone whose origin is a super domain of
/// \c name is found (but there is no exact match)
/// - \c NOTFOUND: For all other cases.
- /// - \c zone: A pointer to the found \c Zone object if one is found;
- /// otherwise \c NULL.
- ///
- /// The pointer returned in the \c FindResult object is only valid until
- /// the corresponding zone is removed from the zone table.
- /// The caller must ensure that the zone is held in the zone table while
- /// it needs to refer to it.
+ /// - \c zone: A (Boost) shared pointer to the found \c Zone object if one
+ /// is found; otherwise \c NULL.
///
/// This method never throws an exception.
///
More information about the bind10-changes
mailing list