Biorithm  1.1
 All Classes Functions Variables Typedefs Friends
Filter.h
00001 /**************************************************************************
00002  * Copyright (c) 2007 Clifford Conley Owens III                           *
00003  *                                                                        *
00004  * This file is part of Biorithm.                                         *
00005  *                                                                        *
00006  * Biorithm is free software: you can redistribute it and/or modify       *
00007  * it under the terms of the GNU General Public License as published by   *
00008  * the Free Software Foundation, either version 3 of the License, or      *
00009  * (at your option) any later version.                                    *
00010  *                                                                        *
00011  * Biorithm is distributed in the hope that it will be useful,            *
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of         *
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
00014  * GNU General Public License for more details.                           *
00015  *                                                                        *
00016  * You should have received a copy of the GNU General Public License      *
00017  * along with Biorithm.  If not, see <http://www.gnu.org/licenses/>.      *
00018  *                                                                        *
00019  **************************************************************************/
00020 
00032 #ifndef FILTER_H
00033 #define FILTER_H
00034 
00035 #include <set>
00036 using namespace std;
00037 
00038 // ---------------------------- Internal Headers ---------------------------- //
00039 
00040 #include "ItemSet.h"
00041 #include "Monitorable.h"
00042 #include "TruthMatrix.h"
00043 #include <iostream>
00044 
00051 class Filter
00052 {
00053     public:
00054         virtual ~Filter(){};
00055         virtual bool filter(const ItemSet& is, TruthMatrix& tm, string& msg) =
00056             0;
00057         virtual void printis(const ItemSet& is, const TruthMatrix& tm,
00058             ostream& out) const
00059         {
00060             for (unsigned int i = 0; i < is.size(); i++)
00061             {
00062                 if (i)
00063                 {
00064                     out << ", ";
00065                 }
00066                 out << is[i] << ':' << tm.getColname(is[i]);
00067             }
00068         };
00069 };
00070 
00071 
00072 // conley, i needed two functions to get the names of columns in an
00073 // itemset and to make them into a string. please put them somewhere else, if you like.
00074 inline void _makeColumnSet(const ItemSet &is, TruthMatrix& tm, set< string > &columns)
00075 {
00076   for (unsigned int i = 0; i < is.size(); i++)
00077     {
00078       columns.insert(tm.getColname(is[i]));
00079     }
00080 }
00081 
00082 inline void _makeName(const set< string > &columns, string &name, string sep = "\n")
00083 {
00084   // form name by concatenating all elements of columns.
00085   set< string >::const_iterator citr;
00086   citr = columns.begin();
00087   name = *citr;
00088   citr++;
00089   for (; citr != columns.end(); citr++)
00090     {
00091       name += sep + *citr;
00092     }
00093 }
00094 
00095 
00096 #endif
 All Classes Functions Variables Typedefs Friends