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 Mon Mar 30 11:34:17 PST 1998 by heydon 00020 // Last modified on Tue Aug 3 14:01:36 EDT 2004 by ken@xorian.net 00021 // modified on Fri May 8 14:55:48 PDT 1998 by heydon 00022 00023 #ifndef _COMPACT_FV_H 00024 #define _COMPACT_FV_H 00025 00026 /* This class defines an alternative, compact representation 00027 for a sequence of names. The names are represented by a 00028 "PrefixTbl" paired with two arrays. The first array gives 00029 the indices of the names in the "PrefixTbl", and the second 00030 array gives the one-character prefix for each name. */ 00031 00032 #include <Basics.H> 00033 #include <SRPC.H> 00034 #include <FS.H> 00035 #include "FV.H" 00036 #include "PrefixTbl.H" 00037 #include "BitVector.H" 00038 00039 namespace CompactFV 00040 { 00041 class List { 00042 public: 00043 PrefixTbl tbl; // table of names 00044 Basics::int16 num; // cardinality of "idx" and "types" 00045 Basics::int16 *idx; // indices of names in "tbl"; has length "num" 00046 char *types; // array of types; has length "num" 00047 // NOTE: Both "idx" and "types" may be NULL if "num == 0". 00048 00049 List() throw () { /*SKIP*/; } 00050 List(const FV::List &names) throw (PrefixTbl::Overflow); 00051 /* Initialize this "CompactFV::List" to represent the 00052 names "names". */ 00053 00054 List(SRPC &srpc) throw (SRPC::failure) 00055 { this->Recv(srpc); } 00056 List(std::ifstream &ifs) throw (FS::Failure, FS::EndOfFile) 00057 { this->Read(ifs); } 00058 00059 // convert to FV::List 00060 void ToFVList(/*INOUT*/ FV::ListApp &fvl) const throw (); 00061 /* Append the names in this "CompactFV::List" to "fvl", which is 00062 required to be empty. */ 00063 00064 // write/read 00065 void Write(std::ostream &ofs) const throw (FS::Failure); 00066 void Read(std::istream &ifs) throw (FS::EndOfFile, FS::Failure); 00067 00068 // send/receive 00069 void Send(SRPC &sprc) const throw (SRPC::failure); 00070 void Recv(SRPC &sprc) throw (SRPC::failure); 00071 00072 // print 00073 void Print(std::ostream &os, int indent) const throw (); 00074 }; 00075 } 00076 00077 #endif // _COMPACT_FV_H