Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

GLNodeBuffer.H

Go to the documentation of this file.
00001 // Copyright (C) 2001, Compaq Computer Corporation
00002 // 
00003 // This file is part of Vesta.
00004 // 
00005 // Vesta is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 // 
00010 // Vesta is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with Vesta; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019 // Created on Tue Mar 11 14:18:49 PST 1997 by heydon
00020 
00021 // Last modified on Mon Aug  9 17:05:09 EDT 2004 by ken@xorian.net
00022 //      modified on Tue Dec 16 00:40:03 PST 1997 by heydon
00023 
00024 // GLNodeBuffer -- a buffer of GLNode objects, with an operation for
00025 //   evicting the oldest one.
00026 
00027 #ifndef _GL_NODE_BUFFER_H
00028 #define _GL_NODE_BUFFER_H
00029 
00030 #include <Basics.H>
00031 #include <IntKey.H>
00032 #include <FS.H>
00033 #include <Table.H>
00034 #include <Sequence.H>
00035 #include <Generics.H>   // for "IntSeq"
00036 #include <CacheIndex.H>
00037 #include <Derived.H>
00038 #include "GLNode.H"
00039 
00040 /* The methods of a "GLNodeBuffer" are unmonitored. */
00041 
00042 class GLNodeKids {
00043   public:
00044     GLNodeKids() throw () { /*SKIP*/ } // default constructor
00045     GLNodeKids(CacheEntry::Indices *kids, Derived::Indices *refs) throw ()
00046         : kids(kids), refs(refs) { /*SKIP*/ }
00047     GLNodeKids& operator= (const GLNodeKids& nk) throw ()
00048         { this->kids = nk.kids; this->refs = nk.refs; return *this; }
00049     CacheEntry::Indices *kids; // child entries
00050     Derived::Indices *refs;    // deriveds reachable from this entry
00051 };
00052 
00053 typedef Table<IntKey,GLNodeKids>::Default GLNodeTbl;
00054 typedef IntSeq CISeq;
00055 
00056 class GLNodeBuffer {
00057   public:
00058     GLNodeBuffer(int maxSize) throw ();
00059     /* Initialize this buffer so it can contain at most "maxSize" nodes. */
00060 
00061     bool Delete(CacheEntry::Index ci, /*OUT*/ GLNode &node) throw ();
00062     /* Look for a node in the buffer with index "ci". If one exists, remove it
00063        from the buffer, set "node" to the node, and return true. Otherwise,
00064        return false. */
00065 
00066     void Put(const GLNode &node, std::ostream &ofs) throw (FS::Failure);
00067     /* Add the node "node" to the buffer; if that causes the buffer to contain
00068        more than "maxSize" nodes, remove the oldest node in the buffer and
00069        write its contents to "ofs". Throws "FS::Failure" if there is an
00070        error writing such ``overflow'' nodes. It is a checked runtime error
00071        for the buffer to already contain a node indexed by "node.ci". */
00072 
00073     int flushedCnt;
00074     /* This field is incremented for each GLNode written to "ofs" by the
00075        "Put" method above. */
00076 
00077   private:
00078     int maxSize;
00079     GLNodeTbl *tbl;  // table of nodes: CI -> GLNodeKids
00080     CISeq *seq;      // sequence of CIs in order they were added
00081 };
00082 
00083 #endif // _GL_NODE_BUFFER_H

Generated on Mon May 8 00:48:59 2006 for Vesta by  doxygen 1.4.2