From: JINMEI Tatuya Date: Thu, 8 Mar 2012 05:15:03 +0000 (-0800) Subject: [1608] moved RBNodeRRset internals to the in-memory implementation file. X-Git-Tag: trac2351_base~226^2~116^2~127^2~3^2~17 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fe8e4b87d5b493fa2cf41f1e8dce1b5809c27679;p=thirdparty%2Fkea.git [1608] moved RBNodeRRset internals to the in-memory implementation file. For that purpose RBNodeRRsetImpl structure was introduced. no functional change. --- diff --git a/src/lib/datasrc/memory_datasrc.cc b/src/lib/datasrc/memory_datasrc.cc index 0392720260..7f158359cc 100644 --- a/src/lib/datasrc/memory_datasrc.cc +++ b/src/lib/datasrc/memory_datasrc.cc @@ -66,6 +66,8 @@ typedef boost::shared_ptr DomainPtr; // The tree stores domains typedef RBTree DomainTree; typedef RBNode DomainNode; +// RRset specified for this implementation +typedef boost::shared_ptr RBNodeRRsetPtr; // Separate storage for NSEC3 RRs (and their RRSIGs). It's an STL map // from string to the NSEC3 RRset. The map key is the first label @@ -106,6 +108,139 @@ struct ZoneData { }; } +// RBNodeRRset details +namespace internal { + +struct RBNodeRRsetImpl { +public: + RBNodeRRsetImpl(const ConstRRsetPtr& rrset) : rrset_(rrset) + {} + + ConstRRsetPtr rrset_; ///< Underlying RRset +}; + +RBNodeRRset::RBNodeRRset(const ConstRRsetPtr& rrset) : + impl_(new RBNodeRRsetImpl(rrset)) +{ +} + +RBNodeRRset::~RBNodeRRset() { + delete impl_; +} + +unsigned int +RBNodeRRset::getRdataCount() const { + return (impl_->rrset_->getRdataCount()); +} + +const Name& +RBNodeRRset::getName() const { + return (impl_->rrset_->getName()); +} + +const RRClass& +RBNodeRRset::getClass() const { + return (impl_->rrset_->getClass()); +} + +const RRType& +RBNodeRRset::getType() const { + return (impl_->rrset_->getType()); +} + +const RRTTL& +RBNodeRRset::getTTL() const { + return (impl_->rrset_->getTTL()); +} + +void +RBNodeRRset::setName(const Name&) { + isc_throw(isc::NotImplemented, "RBNodeRRset::setName() not supported"); +} + +void +RBNodeRRset::setTTL(const RRTTL&) { + isc_throw(isc::NotImplemented, "RBNodeRRset::setTTL() not supported"); +} + +string +RBNodeRRset::toText() const { + return (impl_->rrset_->toText()); +} + +unsigned int +RBNodeRRset::toWire(AbstractMessageRenderer& renderer) const { + return (impl_->rrset_->toWire(renderer)); +} + +unsigned int +RBNodeRRset::toWire(isc::util::OutputBuffer& buffer) const { + return (impl_->rrset_->toWire(buffer)); +} + +void +RBNodeRRset::addRdata(ConstRdataPtr) { + isc_throw(isc::NotImplemented, "RBNodeRRset::addRdata() not supported"); +} + +void +RBNodeRRset::addRdata(const Rdata&) { + isc_throw(isc::NotImplemented, "RBNodeRRset::addRdata() not supported"); +} + +RdataIteratorPtr +RBNodeRRset::getRdataIterator() const { + return (impl_->rrset_->getRdataIterator()); +} + +RRsetPtr +RBNodeRRset::getRRsig() const { + return (impl_->rrset_->getRRsig()); +} + +void +RBNodeRRset::addRRsig(const ConstRdataPtr& rdata) { + AbstractRRset* p = const_cast(impl_->rrset_.get()); + p->addRRsig(rdata); +} + +void +RBNodeRRset::addRRsig(const RdataPtr& rdata) { + AbstractRRset* p = const_cast(impl_->rrset_.get()); + p->addRRsig(rdata); +} + +void +RBNodeRRset::addRRsig(const AbstractRRset& sigs) { + AbstractRRset* p = const_cast(impl_->rrset_.get()); + p->addRRsig(sigs); +} + +void +RBNodeRRset::addRRsig(const ConstRRsetPtr& sigs) { + AbstractRRset* p = const_cast(impl_->rrset_.get()); + p->addRRsig(sigs); +} + +void +RBNodeRRset::addRRsig(const RRsetPtr& sigs) { + AbstractRRset* p = const_cast(impl_->rrset_.get()); + p->addRRsig(sigs); +} + +void +RBNodeRRset::removeRRsig() { + AbstractRRset* p = const_cast(impl_->rrset_.get()); + p->removeRRsig(); +} + +ConstRRsetPtr +RBNodeRRset::getUnderlyingRRset() const { + return (impl_->rrset_); +} + +} // end of internal + class InMemoryZoneFinder::Context_ : public ZoneFinder::Context { public: Context_(ZoneFinder& finder, ZoneFinder::FindOptions options, @@ -442,7 +577,7 @@ struct InMemoryZoneFinder::InMemoryZoneFinderImpl { // ... although instead of loading the RRset directly, we encapsulate // it within an RBNodeRRset. This contains additional information that // speeds up queries. - ConstRRsetPtr rrset(new internal::RBNodeRRset(rawrrset)); + RBNodeRRsetPtr rrset(new internal::RBNodeRRset(rawrrset)); if (rrset->getType() == RRType::NSEC3()) { return (addNSEC3(rrset, zone_data)); diff --git a/src/lib/datasrc/rbnode_rrset.h b/src/lib/datasrc/rbnode_rrset.h index 968e7a83ff..9e46ffef5a 100644 --- a/src/lib/datasrc/rbnode_rrset.h +++ b/src/lib/datasrc/rbnode_rrset.h @@ -29,6 +29,12 @@ namespace isc { namespace datasrc { namespace internal { +/// \brief The actual content of \c RBNodeRRset +/// +/// This is defined in the namespace-scope (not hidden in the main class) +/// so that the In-memory data source implementation can refer to it. +struct RBNodeRRsetImpl; + /// \brief Special RRset for optimizing memory datasource requirement /// /// To speed up the performance of the in-memory data source, at load time @@ -84,11 +90,10 @@ public: /// Creates an RBNodeRRset from the pointer to the RRset passed to it. /// /// \param rrset Pointer to underlying RRset encapsulated by this object. - explicit RBNodeRRset(const isc::dns::ConstRRsetPtr& rrset) : rrset_(rrset) - {} + explicit RBNodeRRset(const isc::dns::ConstRRsetPtr& rrset); /// \brief Destructor - virtual ~RBNodeRRset() {} + virtual ~RBNodeRRset(); // Getter and Setter Methods // @@ -96,64 +101,34 @@ public: // setter methods thrown an exception - this specialisation of the RRset // object does not expect the underlying RRset to be modified. - virtual unsigned int getRdataCount() const { - return (rrset_->getRdataCount()); - } + virtual unsigned int getRdataCount() const; - virtual const isc::dns::Name& getName() const { - return (rrset_->getName()); - } + virtual const isc::dns::Name& getName() const; - virtual const isc::dns::RRClass& getClass() const { - return (rrset_->getClass()); - } + virtual const isc::dns::RRClass& getClass() const; - virtual const isc::dns::RRType& getType() const { - return (rrset_->getType()); - } + virtual const isc::dns::RRType& getType() const; - virtual const isc::dns::RRTTL& getTTL() const { - return (rrset_->getTTL()); - } + virtual const isc::dns::RRTTL& getTTL() const; - virtual void setName(const isc::dns::Name&) { - isc_throw(isc::NotImplemented, "RBNodeRRset::setName() not supported"); - } + virtual void setName(const isc::dns::Name&); - virtual void setTTL(const isc::dns::RRTTL&) { - isc_throw(isc::NotImplemented, "RBNodeRRset::setTTL() not supported"); - } + virtual void setTTL(const isc::dns::RRTTL&); - virtual std::string toText() const { - return (rrset_->toText()); - } + virtual std::string toText() const; virtual unsigned int toWire( - isc::dns::AbstractMessageRenderer& renderer) const { - return (rrset_->toWire(renderer)); - } + isc::dns::AbstractMessageRenderer& renderer) const; - virtual unsigned int toWire(isc::util::OutputBuffer& buffer) const { - return (rrset_->toWire(buffer)); - } + virtual unsigned int toWire(isc::util::OutputBuffer& buffer) const; - virtual void addRdata(isc::dns::rdata::ConstRdataPtr) { - isc_throw(isc::NotImplemented, - "RBNodeRRset::addRdata() not supported"); - } + virtual void addRdata(isc::dns::rdata::ConstRdataPtr); - virtual void addRdata(const isc::dns::rdata::Rdata&) { - isc_throw(isc::NotImplemented, - "RBNodeRRset::addRdata() not supported"); - } + virtual void addRdata(const isc::dns::rdata::Rdata&); - virtual isc::dns::RdataIteratorPtr getRdataIterator() const { - return (rrset_->getRdataIterator()); - } + virtual isc::dns::RdataIteratorPtr getRdataIterator() const; - virtual isc::dns::RRsetPtr getRRsig() const { - return (rrset_->getRRsig()); - } + virtual isc::dns::RRsetPtr getRRsig() const; // With all the RRsig methods, we have the problem that we store the // underlying RRset using a ConstRRsetPtr - a pointer to a "const" RRset - @@ -161,45 +136,25 @@ public: // this by temporarily violating the "const" nature of the RRset to add the // data. - virtual void addRRsig(const isc::dns::rdata::ConstRdataPtr& rdata) { - AbstractRRset* p = const_cast(rrset_.get()); - p->addRRsig(rdata); - } + virtual void addRRsig(const isc::dns::rdata::ConstRdataPtr& rdata); - virtual void addRRsig(const isc::dns::rdata::RdataPtr& rdata) { - AbstractRRset* p = const_cast(rrset_.get()); - p->addRRsig(rdata); - } + virtual void addRRsig(const isc::dns::rdata::RdataPtr& rdata); - virtual void addRRsig(const AbstractRRset& sigs) { - AbstractRRset* p = const_cast(rrset_.get()); - p->addRRsig(sigs); - } + virtual void addRRsig(const AbstractRRset& sigs); - virtual void addRRsig(const isc::dns::ConstRRsetPtr& sigs) { - AbstractRRset* p = const_cast(rrset_.get()); - p->addRRsig(sigs); - } + virtual void addRRsig(const isc::dns::ConstRRsetPtr& sigs); - virtual void addRRsig(const isc::dns::RRsetPtr& sigs) { - AbstractRRset* p = const_cast(rrset_.get()); - p->addRRsig(sigs); - } + virtual void addRRsig(const isc::dns::RRsetPtr& sigs); - virtual void removeRRsig() { - AbstractRRset* p = const_cast(rrset_.get()); - p->removeRRsig(); - } + virtual void removeRRsig(); /// \brief Return underlying RRset pointer /// /// ... mainly for testing. - isc::dns::ConstRRsetPtr getUnderlyingRRset() const { - return (rrset_); - } + isc::dns::ConstRRsetPtr getUnderlyingRRset() const; private: - isc::dns::ConstRRsetPtr rrset_; ///< Underlying RRset + RBNodeRRsetImpl* impl_; }; } // namespace internal