xorp

update_queue.hh

00001 // -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*-
00002 
00003 // Copyright (c) 2001-2011 XORP, Inc and Others
00004 //
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License, Version 2, June
00007 // 1991 as published by the Free Software Foundation. Redistribution
00008 // and/or modification of this program under the terms of any other
00009 // version of the GNU General Public License is not permitted.
00010 // 
00011 // This program is distributed in the hope that it will be useful, but
00012 // WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details,
00014 // see the GNU General Public License, Version 2, a copy of which can be
00015 // found in the XORP LICENSE.gpl file.
00016 // 
00017 // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA;
00018 // http://xorp.net
00019 
00020 // $XORP: xorp/rip/update_queue.hh,v 1.17 2008/10/02 21:58:18 bms Exp $
00021 
00022 #ifndef __RIP_UPDATE_QUEUE__
00023 #define __RIP_UPDATE_QUEUE__
00024 
00025 
00026 #include "route_db.hh"
00027 
00028 template <typename A>
00029 class UpdateQueueImpl;
00030 
00031 
00039 template <typename A>
00040 class UpdateQueueReader {
00041 public:
00042     UpdateQueueReader(UpdateQueueImpl<A>* i);
00043     ~UpdateQueueReader();
00044 
00045     uint32_t id() const;
00046     bool parent_is(const UpdateQueueImpl<A>* o) const;
00047 
00048 private:
00049     UpdateQueueImpl<A>* _impl;
00050     uint32_t        _id;
00051 };
00052 
00053 
00061 template <typename A>
00062 class UpdateQueue {
00063 protected:
00064     typedef UpdateQueueReader<A>    Reader;
00065 
00066 public:
00067     typedef ref_ptr<Reader>     ReadIterator;
00068     typedef RouteEntryRef<A>        RouteUpdate;
00069 
00070 public:
00071     UpdateQueue();
00072     ~UpdateQueue();
00073 
00077     void push_back(const RouteUpdate& ru);
00078 
00083     void flush();
00084 
00090     ReadIterator create_reader();
00091 
00096     void destroy_reader(ReadIterator& r);
00097 
00104     bool reader_valid(const ReadIterator& r);
00105 
00111     const RouteEntry<A>* next(ReadIterator& r);
00112 
00118     const RouteEntry<A>* get(ReadIterator& r) const;
00119 
00125     void ffwd(ReadIterator& r);
00126 
00130     void rwd(ReadIterator& r);
00131 
00139     uint32_t updates_queued() const;
00140 
00141 protected:
00142     UpdateQueueImpl<A>* _impl;
00143 };
00144 
00145 #endif // __RIP_UPDATE_QUEUE__
 All Classes Namespaces Functions Variables Typedefs Enumerations