local_zone_data.h 2.3 KB
Newer Older
zhanglikun's avatar
zhanglikun committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// Copyright (C) 2010  Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.

15
16
#ifndef LOCAL_ZONE_DATA
#define LOCAL_ZONE_DATA
zhanglikun's avatar
zhanglikun committed
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

#include <map>
#include <string>
#include <boost/shared_ptr.hpp>
#include <dns/rrset.h>

namespace isc {
namespace cache {

/// \brief Local Zone Data
/// The object of LocalZoneData represents the data of one
/// local zone. It provides the interface for lookup the rrsets
/// in the zone.
class LocalZoneData {
public:
32
33
34
35
36
37
    /// \brief Constructor.
    ///
    /// The passed parameter is expected to be an RR class value, but is not
    /// currently unused.  And this library will be quite likely to
    /// deprecated anyway, so we don't touch it heavily.
    LocalZoneData(uint16_t) {}
zhanglikun's avatar
zhanglikun committed
38
39

    /// \brief Look up one rrset.
40
41
42
43
    ///
    /// \param qname The query name to look up
    /// \param qtype The query type to look up
    /// \return return the shared_ptr of rrset if it is
zhanglikun's avatar
zhanglikun committed
44
    /// found in the local zone, or else, return NULL.
zhanglikun's avatar
zhanglikun committed
45
46
47
    isc::dns::RRsetPtr lookup(const isc::dns::Name& qname,
                              const isc::dns::RRType& qtype);

48
49
50
51
52
53
    /// \brief Update the rrset in the local zone.
    ///
    /// If the rrset doesn't exist, it will be added.
    /// Otherwise, the existed one will be overwritten.
    ///
    /// \param rrset The rrset to update
54
    void update(const isc::dns::AbstractRRset& rrset);
zhanglikun's avatar
zhanglikun committed
55
56

private:
zhanglikun's avatar
zhanglikun committed
57
    std::map<std::string, isc::dns::RRsetPtr> rrsets_map_; // RRsets of the zone
zhanglikun's avatar
zhanglikun committed
58
59
};

zhanglikun's avatar
zhanglikun committed
60
61
62
typedef boost::shared_ptr<LocalZoneData> LocalZoneDataPtr;
typedef boost::shared_ptr<const LocalZoneData> ConstLocalZoneDataPtr;

zhanglikun's avatar
zhanglikun committed
63
64
65
} // namespace cache
} // namespace isc

66
#endif // LOCAL_ZONE_DATA
zhanglikun's avatar
zhanglikun committed
67