2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 14:05:33 +00:00

[2206] Change getHeader() to return a reference

This commit is contained in:
Mukund Sivaraman
2012-10-03 11:11:02 +05:30
parent c4c3946bad
commit 1fb24f540a
4 changed files with 13 additions and 24 deletions

View File

@@ -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;

View File

@@ -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&

View File

@@ -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).

View File

@@ -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);
}