Commit 1fb24f54 authored by Mukund Sivaraman's avatar Mukund Sivaraman
Browse files

[2206] Change getHeader() to return a reference

parent c4c3946b
......@@ -71,14 +71,10 @@ public:
virtual ~ZoneTableSegment() {}
/// \brief Return the ZoneTableHeader for the zone table segment.
///
/// NOTE: This method should never return \c NULL.
virtual ZoneTableHeader* getHeader() = 0;
virtual ZoneTableHeader& getHeader() = 0;
/// \brief const version of \c getHeader().
///
/// NOTE: This method should never return \c NULL.
virtual const ZoneTableHeader* getHeader() const = 0;
virtual const ZoneTableHeader& getHeader() const = 0;
/// \brief Return the MemorySegment for the zone table segment.
virtual isc::util::MemorySegment& getMemorySegment() = 0;
......
......@@ -20,14 +20,14 @@ namespace isc {
namespace datasrc {
namespace memory {
ZoneTableHeader*
ZoneTableHeader&
ZoneTableSegmentLocal::getHeader() {
return (&header_);
return (header_);
}
const ZoneTableHeader*
const ZoneTableHeader&
ZoneTableSegmentLocal::getHeader() const {
return (&header_);
return (header_);
}
MemorySegment&
......
......@@ -45,14 +45,10 @@ public:
/// \brief Return the ZoneTableHeader for the local zone table
/// segment implementation.
///
/// NOTE: This method will never return \c NULL.
virtual ZoneTableHeader* getHeader();
virtual ZoneTableHeader& getHeader();
/// \brief const version of \c getHeader().
///
/// NOTE: This method will never return \c NULL.
virtual const ZoneTableHeader* getHeader() const;
virtual const ZoneTableHeader& getHeader() const;
/// \brief Return the MemorySegment for the local zone table segment
/// implementation (a MemorySegmentLocal instance).
......
......@@ -55,23 +55,20 @@ TEST_F(ZoneTableSegmentTest, create) {
}
TEST_F(ZoneTableSegmentTest, getHeader) {
// getHeader() should never return NULL.
ZoneTableHeader* header = segment_->getHeader();
EXPECT_NE(static_cast<void*>(NULL), header);
ZoneTableHeader& header = segment_->getHeader();
// The zone table is unset.
ZoneTable* table = header->getTable();
ZoneTable* table = header.getTable();
EXPECT_EQ(static_cast<void*>(NULL), table);
}
TEST_F(ZoneTableSegmentTest, getHeaderConst) {
// getHeader() should never return NULL.
const ZoneTableHeader* header =
// Test const methods
const ZoneTableHeader& header =
static_cast<const ZoneTableSegment*>(segment_)->getHeader();
EXPECT_NE(static_cast<void*>(NULL), header);
// The zone table is unset.
const ZoneTable* table = header->getTable();
const ZoneTable* table = header.getTable();
EXPECT_EQ(static_cast<void*>(NULL), table);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment