assert(load_action); // in this loop this should be always true
try {
memory::ZoneWriter writer(
- new_data_sources.back().ztable_segment_.get(),
+ *new_data_sources.back().ztable_segment_,
load_action, zname, rrclass_);
writer.load();
writer.install();
return (ZoneWriterPair(ZONE_SUCCESS,
ZoneWriterPtr(
new memory::ZoneWriter(
- result.info->ztable_segment_.get(),
+ *result.info->ztable_segment_,
load_action, name, rrclass_))));
}
namespace datasrc {
namespace memory {
-ZoneWriter::ZoneWriter(ZoneTableSegment* segment,
+ZoneWriter::ZoneWriter(ZoneTableSegment& segment,
const LoadAction& load_action,
const dns::Name& origin,
const dns::RRClass& rrclass) :
zone_data_(NULL),
state_(ZW_UNUSED)
{
- if (!segment->isWritable()) {
+ if (!segment.isWritable()) {
isc_throw(isc::InvalidOperation,
"Attempt to construct ZoneWriter for a read-only segment");
}
isc_throw(isc::InvalidOperation, "Trying to load twice");
}
- zone_data_ = load_action_(segment_->getMemorySegment());
+ zone_data_ = load_action_(segment_.getMemorySegment());
if (!zone_data_) {
// Bug inside load_action_.
isc_throw(isc::InvalidOperation, "No data to install");
}
- ZoneTable* table(segment_->getHeader().getTable());
+ ZoneTable* table(segment_.getHeader().getTable());
if (!table) {
isc_throw(isc::Unexpected, "No zone table present");
}
const ZoneTable::AddResult result(table->addZone(
- segment_->getMemorySegment(),
+ segment_.getMemorySegment(),
rrclass_, origin_, zone_data_));
state_ = ZW_INSTALLED;
// We eat the data (if any) now.
if (zone_data_ != NULL) {
- ZoneData::destroy(segment_->getMemorySegment(), zone_data_, rrclass_);
+ ZoneData::destroy(segment_.getMemorySegment(), zone_data_, rrclass_);
zone_data_ = NULL;
state_ = ZW_CLEANED;
}
/// \param load_action The callback used to load data.
/// \param install_action The callback used to install the loaded zone.
/// \param rrclass The class of the zone.
- ZoneWriter(ZoneTableSegment* segment,
+ ZoneWriter(ZoneTableSegment& segment,
const LoadAction& load_action, const dns::Name& name,
const dns::RRClass& rrclass);
void cleanup();
private:
- ZoneTableSegment* const segment_;
+ ZoneTableSegment& segment_;
const LoadAction load_action_;
const dns::Name origin_;
const dns::RRClass rrclass_;
// Load the data into the zone table.
if (enabled) {
boost::scoped_ptr<memory::ZoneWriter> writer(
- new memory::ZoneWriter(&(*dsrc_info.ztable_segment_),
- cache_conf->getLoadAction(rrclass_, zone),
- zone, rrclass_));
+ new memory::ZoneWriter(
+ *dsrc_info.ztable_segment_,
+ cache_conf->getLoadAction(rrclass_, zone),
+ zone, rrclass_));
writer->load();
writer->install();
writer->cleanup(); // not absolutely necessary, but just in case
" \"params\": {\"" + zname.toText() + "\": \"" + zone_file +
"\"}}"), true);
boost::scoped_ptr<memory::ZoneWriter> writer(
- new memory::ZoneWriter(&zt_sgmt,
+ new memory::ZoneWriter(zt_sgmt,
cache_conf.getLoadAction(zclass, zname),
zname, zclass));
writer->load();
const dns::RRClass& zclass, ZoneIterator& iterator)
{
boost::scoped_ptr<memory::ZoneWriter> writer(
- new memory::ZoneWriter(&zt_sgmt,
+ new memory::ZoneWriter(zt_sgmt,
IteratorLoader(zclass, zname, iterator),
zname, zclass));
writer->load();
ZoneWriterTest() :
segment_(ZoneTableSegment::create(RRClass::IN(), "local")),
writer_(new
- ZoneWriter(segment_.get(),
+ ZoneWriter(*segment_,
bind(&ZoneWriterTest::loadAction, this, _1),
Name("example.org"), RRClass::IN())),
load_called_(false),
TEST_F(ZoneWriterTest, constructForReadOnlySegment) {
MemorySegmentTest mem_sgmt;
ReadOnlySegment ztable_segment(RRClass::IN(), mem_sgmt);
- EXPECT_THROW(ZoneWriter(&ztable_segment,
+ EXPECT_THROW(ZoneWriter(ztable_segment,
bind(&ZoneWriterTest::loadAction, this, _1),
Name("example.org"), RRClass::IN()),
isc::InvalidOperation);
shared_ptr<ZoneTableSegment> ztable_segment(
ZoneTableSegment::create(zclass, cache_conf.getSegmentType()));
scoped_ptr<memory::ZoneWriter> writer(
- new memory::ZoneWriter(&(*ztable_segment),
+ new memory::ZoneWriter(*ztable_segment,
cache_conf.getLoadAction(zclass, zname),
zname, zclass));
writer->load();
rrclass_, cache_conf.getSegmentType()));
if (filename) {
boost::scoped_ptr<memory::ZoneWriter> writer(
- new memory::ZoneWriter(&(*ztable_segment_),
+ new memory::ZoneWriter(*ztable_segment_,
cache_conf.getLoadAction(rrclass_, zone),
zone, rrclass_));
writer->load();