00001 // -*- C++ -*- 00002 // 00003 // This file is part of Siena, a wide-area event notification system. 00004 // See http://www.cs.colorado.edu/serl/siena/ 00005 // 00006 // Authors: Antonio Carzaniga <[email protected]> 00007 // See the file AUTHORS for full details. 00008 // 00009 // Copyright (C) 2001-2002 University of Colorado 00010 // 00011 // This program is free software; you can redistribute it and/or 00012 // modify it under the terms of the GNU General Public License 00013 // as published by the Free Software Foundation; either version 2 00014 // of the License, or (at your option) any later version. 00015 // 00016 // This program is distributed in the hope that it will be useful, 00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 // GNU General Public License for more details. 00020 // 00021 // You should have received a copy of the GNU General Public License 00022 // along with this program; if not, write to the Free Software 00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, 00024 // USA, or send email to [email protected]. 00025 // 00026 // 00027 // $Id: fwd_table.h,v 1.12 2002/09/30 04:50:25 carzanig Exp $ 00028 // 00029 #ifndef FWD_TABLE_H 00030 #define FWD_TABLE_H 00031 00032 #include "fwdconf.h" 00033 #include "siena_types.h" 00034 #include "tst.h" 00035 #include "ft_allocator.h" 00036 #include "bitvector.h" 00037 00038 using namespace std; 00039 00091 typedef unsigned int if_t; 00092 00105 typedef unsigned int ifid_t; 00106 00112 class IProcessor { 00113 public: 00121 virtual bool output(if_t) = 0; 00122 }; 00123 00124 class Constraint; 00125 class Selectivity; 00126 class Interface; 00127 class Attribute; 00128 class Filter; 00129 00151 class FwdTable { 00152 public: 00156 FwdTable(unsigned int memblk_size = 65536); 00157 00166 void ifconfig(if_t, const sx_predicate &); 00167 00171 void match(const sx_message &, IProcessor &) const; 00172 00178 void clear(); 00179 00185 unsigned int bytesize() const; 00186 00190 void set_preprocess_rounds(unsigned int); 00191 00194 unsigned int get_preprocess_rounds() const; 00195 00196 private: 00202 FTAllocator memory; 00203 00207 ifid_t ifcount; 00208 00211 unsigned int preprocess_rounds; 00212 00215 TST attributes; 00216 00223 Selectivity * selectivity_first; 00224 00229 Selectivity * selectivity_last; 00230 00233 void preprocess_message(const sx_message &, 00234 bitvector *, 00235 unsigned int) const; 00236 00247 Selectivity * new_selectivity(const string &, ifid_t); 00248 00258 void add_to_selectivity(Selectivity *, ifid_t); 00259 00261 Attribute * get_attribute(const sx_name & name); 00262 00266 void connect(Constraint *, Filter *); 00267 }; 00268 00272 class CProcessor { 00273 public: 00277 virtual bool process_constraint(const Constraint *) = 0; 00278 }; 00279 00284 class Filter { 00285 public: 00289 Filter(Interface * i); 00290 00304 Interface * i; 00305 00311 unsigned char size; 00312 }; 00313 00315 class flist { 00316 public: 00318 const Filter * f; 00320 const flist * next; 00321 00323 flist(Filter * xf, flist * xn); 00324 }; 00325 00331 class Constraint { 00332 public: 00343 flist * filters; 00345 Constraint(); 00346 }; 00347 00348 #ifdef HAVE_INLINE 00349 #include "fwd_table.icc" 00350 #endif 00351 00352 #endif