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 _LOCAL_ZONE_DATA
16 : : #define _LOCAL_ZONE_DATA
17 : :
18 : : #include <map>
19 : : #include <string>
20 : : #include <boost/shared_ptr.hpp>
21 : : #include <dns/rrset.h>
22 : :
23 : : namespace isc {
24 : : namespace cache {
25 : :
26 : : /// \brief Local Zone Data
27 : : /// The object of LocalZoneData represents the data of one
28 : : /// local zone. It provides the interface for lookup the rrsets
29 : : /// in the zone.
30 : 37 : class LocalZoneData {
31 : : public:
32 : 74 : LocalZoneData(uint16_t rrset_class) : class_(rrset_class)
33 : : {}
34 : :
35 : : /// \brief Look up one rrset.
36 : : ///
37 : : /// \param qname The query name to look up
38 : : /// \param qtype The query type to look up
39 : : /// \return return the shared_ptr of rrset if it is
40 : : /// found in the local zone, or else, return NULL.
41 : : isc::dns::RRsetPtr lookup(const isc::dns::Name& qname,
42 : : const isc::dns::RRType& qtype);
43 : :
44 : : /// \brief Update the rrset in the local zone.
45 : : ///
46 : : /// If the rrset doesn't exist, it will be added.
47 : : /// Otherwise, the existed one will be overwritten.
48 : : ///
49 : : /// \param rrset The rrset to update
50 : : void update(const isc::dns::AbstractRRset& rrset);
51 : :
52 : : private:
53 : : std::map<std::string, isc::dns::RRsetPtr> rrsets_map_; // RRsets of the zone
54 : : uint16_t class_; // The class of the zone
55 : : };
56 : :
57 : : typedef boost::shared_ptr<LocalZoneData> LocalZoneDataPtr;
58 : : typedef boost::shared_ptr<const LocalZoneData> ConstLocalZoneDataPtr;
59 : :
60 : : } // namespace cache
61 : : } // namespace isc
62 : :
63 : : #endif // _LOCAL_ZONE_DATA
64 : :
|