LCOV - code coverage report
Current view: top level - cache - rrset_cache.h (source / functions) Hit Total Coverage
Test: report.info Lines: 3 3 100.0 %
Date: 2012-05-15 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 4 50.0 %

           Branch data     Line data    Source code
       1                 :            : // Copyright (C) 2010  Internet Systems Consortium, Inc. ("ISC")
       2                 :            : //
       3                 :            : // Permission to use, copy, modify, and/or distribute this software for any
       4                 :            : // purpose with or without fee is hereby granted, provided that the above
       5                 :            : // copyright notice and this permission notice appear in all copies.
       6                 :            : //
       7                 :            : // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
       8                 :            : // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
       9                 :            : // AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
      10                 :            : // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
      11                 :            : // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
      12                 :            : // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
      13                 :            : // PERFORMANCE OF THIS SOFTWARE.
      14                 :            : 
      15                 :            : #ifndef __RRSET_CACHE_H
      16                 :            : #define __RRSET_CACHE_H
      17                 :            : 
      18                 :            : #include <cache/rrset_entry.h>
      19                 :            : #include <nsas/hash_table.h>
      20                 :            : 
      21                 :            : #include <util/lru_list.h>
      22                 :            : 
      23                 :            : using namespace isc::nsas;
      24                 :            : 
      25                 :            : namespace isc {
      26                 :            : namespace cache {
      27                 :            : 
      28                 :            : class RRsetEntry;
      29                 :            : 
      30                 :            : /// \brief RRset Cache
      31                 :            : /// The object of RRsetCache represented the cache for class-specific
      32                 :            : /// RRsets.
      33                 :            : ///
      34                 :            : /// \todo The rrset cache class should provide the interfaces for
      35                 :            : ///       loading, dumping and resizing.
      36                 :            : class RRsetCache{
      37                 :            :     ///
      38                 :            :     /// \name Constructors and Destructor
      39                 :            :     ///
      40                 :            :     /// Note: The copy constructor and the assignment operator are intentionally
      41                 :            :     /// defined as private to make it uncopyable
      42                 :            :     //@{
      43                 :            : private:
      44                 :            :     RRsetCache(const RRsetCache&);
      45                 :            :     RRsetCache& operator=(const RRsetCache&);
      46                 :            : public:
      47                 :            :     /// \brief Constructor and Destructor
      48                 :            :     ///
      49                 :            :     /// \param cache_size the size of rrset cache.
      50                 :            :     /// \param rrset_class the class of rrset cache.
      51                 :            :     RRsetCache(uint32_t cache_size, uint16_t rrset_class);
      52         [ +  - ]:        105 :     virtual ~RRsetCache() {
      53         [ +  - ]:        105 :         rrset_lru_.clear(); // Clear the rrset entries in the list.
      54                 :        204 :     }
      55                 :            :     //@}
      56                 :            : 
      57                 :            :     /// \brief Look up rrset in cache.
      58                 :            :     ///
      59                 :            :     /// \param qname The query name to look up
      60                 :            :     /// \param qtype The query type 
      61                 :            :     /// \return return the shared_ptr of rrset entry if it can be
      62                 :            :     /// found in the cache, or else, return NULL.
      63                 :            :     RRsetEntryPtr lookup(const isc::dns::Name& qname,
      64                 :            :                          const isc::dns::RRType& qtype);
      65                 :            : 
      66                 :            :     /// \brief Update RRset Cache
      67                 :            :     /// Update the rrset entry in the cache with the new one.
      68                 :            :     /// If the rrset has expired or doesn't exist in the cache,
      69                 :            :     /// it will be added directly. It may be ingored if the new
      70                 :            :     /// rrset is not more authoritative than the old rrset in cache.
      71                 :            :     ///
      72                 :            :     /// \param rrset The new rrset used to update cache.
      73                 :            :     /// \param level trustworthiness of the rrset.
      74                 :            :     /// \return return the rrset entry in the cache, it may be the
      75                 :            :     /// new added rrset entry or existed one if it is not replaced.
      76                 :            :     RRsetEntryPtr update(const isc::dns::AbstractRRset& rrset,
      77                 :            :                          const RRsetTrustLevel& level);
      78                 :            : 
      79                 :            :     /// \short Protected memebers, so they can be accessed by tests.
      80                 :            : protected:
      81                 :            :     uint16_t class_; // The class of the rrset cache.
      82                 :            :     isc::nsas::HashTable<RRsetEntry> rrset_table_;
      83                 :            :     isc::util::LruList<RRsetEntry> rrset_lru_;
      84                 :            : };
      85                 :            : 
      86                 :            : typedef boost::shared_ptr<RRsetCache> RRsetCachePtr;
      87                 :            : typedef boost::shared_ptr<const RRsetCache> ConstRRsetCachePtr;
      88                 :            : 
      89                 :            : } // namespace cache
      90                 :            : } // namespace isc
      91                 :            : 
      92                 :            : #endif // __RRSET_CACHE_H
      93                 :            : 

Generated by: LCOV version 1.9