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:
@@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user