// to indicate whether the zone is signed or not. Internal use,
// so defined as private.
static const ZoneNode::Flags DNSSEC_SIGNED = ZoneNode::FLAG_USER1;
+
+ // Also set in the origin node, indicating this is a special "empty zone",
+ // that could be created only by the corresponding create() method to be
+ // used for some kind of sentinel data.
+ static const ZoneNode::Flags EMPTY_ZONE = ZoneNode::FLAG_USER2;
public:
/// \brief Node flag indicating it is at a "wildcard level"
///
/// This means one of the node's immediate children is a wildcard.
- static const ZoneNode::Flags WILDCARD_NODE = ZoneNode::FLAG_USER2;
+ static const ZoneNode::Flags WILDCARD_NODE = ZoneNode::FLAG_USER3;
public:
/// \brief Allocate and construct \c ZoneData.
static ZoneData* create(util::MemorySegment& mem_sgmt,
const dns::Name& zone_origin);
+ /// \brief Allocate and construct a special "empty" \c ZoneData.
+ ///
+ /// A ZoneData object created this way holds all internal integrity
+ /// that those created by the other \c create() method have, but is not
+ /// publicly associated with any actual zone data. It's intended to be
+ /// used as a kind of sentinel data to representing the concept such as
+ /// "broken zone".
+ ///
+ /// Methods calls on empty \c ZoneData object except \c destroy() and
+ /// \c isEmpty() are meaningless, while they shouldn't cause disruption.
+ /// It's caller's responsibility to use empty zone data objects in the
+ /// intended way.
+ ///
+ /// \param mem_sgmt A \c MemorySegment from which memory for the new
+ /// \c ZoneData is allocated.
+ static ZoneData* create(util::MemorySegment& mem_sgmt);
+
/// \brief Destruct and deallocate \c ZoneData.
///
/// It releases all resource allocated in the internal storage NSEC3 for
/// \throw none
bool isNSEC3Signed() const { return (nsec3_data_); }
+ /// \brief Return whether or not the zone data is "empty".
+ ///
+ /// See the description of \c create() for the concept of empty zone data.
+ ///
+ /// \throw None
+ bool isEmpty() const { return (origin_node_->getFlag(EMPTY_ZONE)); }
+
/// \brief Return NSEC3Data of the zone.
///
/// This method returns non-NULL valid pointer to \c NSEC3Data object
zone_data_->setMinTTL(1200);
EXPECT_EQ(RRTTL(1200), createRRTTL(zone_data_->getMinTTLData()));
}
+
+TEST_F(ZoneDataTest, emptyData) {
+ // normally create zone data are never "empty"
+ EXPECT_FALSE(zone_data_->isEmpty());
+
+ // zone data instance created by the special create() is made "empty".
+ ZoneData* empty_data = ZoneData::create(mem_sgmt_);
+ EXPECT_TRUE(empty_data->isEmpty());
+ ZoneData::destroy(mem_sgmt_, empty_data, RRClass::IN());
+}
}