/* $Id: filtertypes.h 4025 2008-10-01 00:01:14Z abehm $ Copyright (C) 2008 by The Regents of the University of California Redistribution of this file is permitted under the terms of the BSD license Date: 04/04/2008 Author: Alexander Behm */ #ifndef _filtertypes_h_ #define _filtertypes_h_ #include #include #include "common/simmetric.h" using namespace std; // any single signature filter must inherit from this class AbstractFilter { protected: FilterType ft; public: AbstractFilter() {} virtual unsigned getFilterLbound() const = 0; virtual unsigned getFilterUbound() const = 0; virtual unsigned getKey(const string& s) const = 0; virtual AbstractFilter* clone() const = 0; FilterType getType() const { return ft; } // create appropriate sub-class from ifstream and FilterType static AbstractFilter* loadFilterInstance(ifstream& fpIn); virtual void saveFilterInstance(ofstream& fpOut) const = 0; virtual ~AbstractFilter() {}; }; class LengthFilter : public AbstractFilter { private: unsigned maxStrLength; public: LengthFilter(unsigned maxStringLength) { ft = FT_LENGTH; maxStrLength = maxStringLength; } LengthFilter(ifstream& fpIn); unsigned getFilterLbound() const; unsigned getFilterUbound() const; unsigned getKey(const string& s) const; AbstractFilter* clone() const; // methods for saving and loading to/from a file void saveFilterInstance(ofstream& fpOut) const; }; unsigned checksum(const string& s); class ChecksumFilter : public AbstractFilter { private: unsigned maxChecksum; unsigned maxStrLength; public: ChecksumFilter(unsigned maxStringLength) { ft = FT_CHECKSUM; maxStrLength = maxStringLength; maxChecksum = maxStringLength * CHECKSUM_ASCII_MAX; } ChecksumFilter(ifstream& fpIn); unsigned getFilterLbound() const; unsigned getFilterUbound() const; unsigned getKey(const string& s) const; AbstractFilter* clone() const; // static methods for saving and loading to/from a file void saveFilterInstance(ofstream& fpOut) const; }; #endif