diff options
author | Thomas Markwalder <tmark@isc.org> | 2013-07-30 20:24:25 +0200 |
---|---|---|
committer | Thomas Markwalder <tmark@isc.org> | 2013-07-30 20:24:25 +0200 |
commit | f964dbc5497ea2aef884251c708007e97185df2e (patch) | |
tree | 904ea373e5727643e416ac7f0a843616d958b414 /src/bin/d2/d2_queue_mgr.cc | |
parent | [3052] Removed extraneous const function return type. (diff) | |
download | kea-f964dbc5497ea2aef884251c708007e97185df2e.tar.xz kea-f964dbc5497ea2aef884251c708007e97185df2e.zip |
[3052] Added peekAt and dequeueAt methods to D2QueueMgr.
In order to add some flexibility in manipulating queue contents
these two methods provide access to queue entries based on their
ordinal position.
Diffstat (limited to 'src/bin/d2/d2_queue_mgr.cc')
-rw-r--r-- | src/bin/d2/d2_queue_mgr.cc | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/bin/d2/d2_queue_mgr.cc b/src/bin/d2/d2_queue_mgr.cc index aeb7ead691..9fe4ebb9e0 100644 --- a/src/bin/d2/d2_queue_mgr.cc +++ b/src/bin/d2/d2_queue_mgr.cc @@ -142,17 +142,39 @@ D2QueueMgr::removeListener() { const dhcp_ddns::NameChangeRequestPtr& D2QueueMgr::peek() const { if (getQueueSize() == 0) { - isc_throw(D2QueueMgrQueEmpty, + isc_throw(D2QueueMgrQueueEmpty, "D2QueueMgr peek attempted on an empty queue"); } return (ncr_queue_.front()); } +const dhcp_ddns::NameChangeRequestPtr& +D2QueueMgr::peekAt(size_t index) const { + if (index >= getQueueSize()) { + isc_throw(D2QueueMgrInvalidIndex, + "D2QueueMgr peek beyond end of queue attempted"); + } + + return (ncr_queue_.at(index)); +} + +void +D2QueueMgr::dequeueAt(size_t index) { + if (index >= getQueueSize()) { + isc_throw(D2QueueMgrInvalidIndex, + "D2QueueMgr dequeue beyond end of queue attempted"); + } + + RequestQueue::iterator pos = ncr_queue_.begin() + index; + ncr_queue_.erase(pos); +} + + void D2QueueMgr::dequeue() { if (getQueueSize() == 0) { - isc_throw(D2QueueMgrQueEmpty, + isc_throw(D2QueueMgrQueueEmpty, "D2QueueMgr dequeue attempted on an empty queue"); } |