#include <datasrc/memory/zone_data_loader.h>
#include <datasrc/memory/zone_data_updater.h>
#include <datasrc/logger.h>
+#include <datasrc/zone_table_accessor_cache.h>
#include <dns/masterload.h>
#include <util/memory_segment_local.h>
-#include <datasrc/zone_table_accessor_cache.h>
#include <memory>
#include <set>
return (result);
}
-boost::shared_ptr<const ZoneTableAccessor>
+ConstZoneTableAccessorPtr
ConfigurableClientList::getZoneTableAccessor(const std::string& datasrc_name,
bool use_cache) const
{
const internal::CacheConfig* config(info.getCacheConfig());
// If caching is disabled for the named data source, this will
// return an accessor to an effectivley empty table.
- return (boost::shared_ptr<const ZoneTableAccessor>
+ return (ConstZoneTableAccessorPtr
(new internal::ZoneTableAccessorCache(*config)));
}
- return (boost::shared_ptr<const ZoneTableAccessor>());
+ return (ConstZoneTableAccessorPtr());
}
}
MemorySegmentState state_;
};
+typedef boost::shared_ptr<const ZoneTableAccessor> ConstZoneTableAccessorPtr;
+
/// \brief The list of data source clients.
///
/// The purpose of this class is to hold several data source clients and search
virtual FindResult find(const dns::Name& zone,
bool want_exact_match = false,
bool want_finder = true) const = 0;
+
+ /// \brief Creates a ZoneTableAccessor object for the specified data
+ /// source.
+ ///
+ /// \param datasrc_name If not empty, the name of the data source.
+ /// \param use_cache If true, create a zone table for in-memory cache.
+ /// \throw NotImplemented if this method is not implemented.
+ /// \return A pointer to the accessor, or NULL if the requested data
+ /// source is not found.
+ virtual ConstZoneTableAccessorPtr
+ getZoneTableAccessor(const std::string& datasrc_name,
+ bool use_cache) const = 0;
+
};
/// \brief Shared pointer to the list.
/// \throw NotImplemented if \c use_cache is false.
/// \return A pointer to the accessor, or NULL if the requested data
/// source is not found.
- boost::shared_ptr<const ZoneTableAccessor>
+ ConstZoneTableAccessorPtr
getZoneTableAccessor(const std::string& datasrc_name,
bool use_cache) const;
-// Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2013 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
}
ConfigurableClientList::CacheStatus doReload(
const Name& origin, const string& datasrc_name = "");
- void accessorIterate(boost::shared_ptr<const ZoneTableAccessor> accessor,
+ void accessorIterate(ConstZoneTableAccessorPtr& accessor,
int numZones, const string& zoneName);
const RRClass rrclass_;
// through the table, and verifies that the expected number of zones are
// present, as well as the named zone.
void
-ListTest::accessorIterate(boost::shared_ptr<const ZoneTableAccessor> accessor,
+ListTest::accessorIterate(ConstZoneTableAccessorPtr& accessor,
int numZones, const string& zoneName="")
{
// Confirm basic iterator behavior.
ASSERT_TRUE(accessor);
ZoneTableAccessor::IteratorPtr it = accessor->getIterator();
ASSERT_TRUE(it);
+ // Iterator does not guarantee ordering, so we look for the target
+ // name anywhere in the table.
+ bool found = false;
+ int i;
+ for (i = 0; !it->isLast(); ++i, it->next()) {
+ if (Name(zoneName) == it->getCurrent().origin) {
+ found = true;
+ }
+ }
+ EXPECT_EQ(i, numZones);
if (numZones > 0) {
- EXPECT_FALSE(it->isLast());
- EXPECT_EQ(0, it->getCurrent().index);
- // Iterator does not guarantee ordering, so we look for the target
- // name anywhere in the table.
- bool found = false;
- int i = 0;
- while (!it->isLast()) {
- ++i;
- if (Name(zoneName) == it->getCurrent().origin) {
- found = true;
- }
- it->next();
- }
EXPECT_TRUE(found);
- EXPECT_EQ(i, numZones);
- } else {
- EXPECT_TRUE(it->isLast());
}
}
// empty list; expect it to return an empty list
list_->configure(config_elem_, true);
- boost::shared_ptr<const ZoneTableAccessor>
- z(list_->getZoneTableAccessor("", true));
+ ConstZoneTableAccessorPtr z(list_->getZoneTableAccessor("", true));
accessorIterate(z, 0);
const ConstElementPtr elem2(Element::fromJSON("["