Kea 2.2.0
rrset_collection.h
Go to the documentation of this file.
1// Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef RRSET_COLLECTION_H
8#define RRSET_COLLECTION_H 1
9
11#include <dns/rrclass.h>
12
13#include <boost/tuple/tuple.hpp>
14#include <boost/tuple/tuple_comparison.hpp>
15
16#include <map>
17
18namespace isc {
19namespace dns {
20
24public:
31
44 RRsetCollection(const char* filename, const isc::dns::Name& origin,
45 const isc::dns::RRClass& rrclass);
46
57 RRsetCollection(std::istream& input_stream, const isc::dns::Name& origin,
58 const isc::dns::RRClass& rrclass);
59
61 virtual ~RRsetCollection() {}
62
76 void addRRset(isc::dns::RRsetPtr rrset);
77
85 bool removeRRset(const isc::dns::Name& name,
86 const isc::dns::RRClass& rrclass,
87 const isc::dns::RRType& rrtype);
88
100 const isc::dns::RRClass& rrclass,
101 const isc::dns::RRType& rrtype) const;
102
108 const isc::dns::RRClass& rrclass,
109 const isc::dns::RRType& rrtype);
110
111private:
112 template<typename T>
113 void constructHelper(T source, const isc::dns::Name& origin,
114 const isc::dns::RRClass& rrclass);
115 void loaderCallback(const std::string&, size_t, const std::string&);
116
117 typedef boost::tuple<isc::dns::RRClass, isc::dns::RRType, isc::dns::Name>
118 CollectionKey;
119 typedef std::map<CollectionKey, isc::dns::RRsetPtr> CollectionMap;
120
121 CollectionMap rrsets_;
122
123protected:
125 public:
126 DnsIter(CollectionMap::iterator& iter) :
127 iter_(iter)
128 {}
129
131 isc::dns::RRsetPtr& rrset = iter_->second;
132 return (*rrset);
133 }
134
135 virtual IterPtr getNext() {
136 CollectionMap::iterator it = iter_;
137 ++it;
138 return (RRsetCollectionBase::IterPtr(new DnsIter(it)));
139 }
140
141 virtual bool equals(Iter& other) {
142 const DnsIter* other_real = dynamic_cast<DnsIter*>(&other);
143 if (other_real == NULL) {
144 return (false);
145 }
146 return (iter_ == other_real->iter_);
147 }
148
149 private:
150 CollectionMap::iterator iter_;
151 };
152
155};
156
157} // end of namespace dns
158} // end of namespace isc
159
160#endif // RRSET_COLLECTION_H
161
162// Local Variables:
163// mode: c++
164// End:
The AbstractRRset class is an abstract base class that models a DNS RRset.
Definition: rrset.h:154
The Name class encapsulates DNS names.
Definition: name.h:223
The RRClass class encapsulates DNS resource record classes.
Definition: rrclass.h:98
The RRType class encapsulates DNS resource record types.
Definition: rrtype.h:106
A helper iterator interface for RRsetCollectionBase.
Generic class to represent a set of RRsets.
boost::shared_ptr< Iter > IterPtr
Wraps Iter with a reference count.
virtual IterPtr getNext()
Returns an IterPtr wrapping an Iter pointing to the next AbstractRRset in sequence in the collection.
DnsIter(CollectionMap::iterator &iter)
virtual const isc::dns::AbstractRRset & getValue()
Returns the AbstractRRset currently pointed to by the iterator.
virtual bool equals(Iter &other)
Check if another iterator is equal to this one.
libdns++ implementation of RRsetCollectionBase using an STL container.
virtual RRsetCollectionBase::IterPtr getBeginning()
Returns an IterPtr wrapping an Iter pointing to the beginning of the collection.
virtual RRsetCollectionBase::IterPtr getEnd()
Returns an IterPtr wrapping an Iter pointing past the end of the collection.
virtual isc::dns::ConstRRsetPtr find(const isc::dns::Name &name, const isc::dns::RRClass &rrclass, const isc::dns::RRType &rrtype) const
Find a matching RRset in the collection.
void addRRset(isc::dns::RRsetPtr rrset)
Add an RRset to the collection.
bool removeRRset(const isc::dns::Name &name, const isc::dns::RRClass &rrclass, const isc::dns::RRType &rrtype)
Remove an RRset from the collection.
virtual ~RRsetCollection()
Destructor.
boost::shared_ptr< AbstractRRset > RRsetPtr
A pointer-like type pointing to an RRset object.
Definition: rrset.h:47
boost::shared_ptr< const AbstractRRset > ConstRRsetPtr
A pointer-like type pointing to an (immutable) RRset object.
Definition: rrset.h:60
Defines the logger used by the top-level component of kea-lfc.