Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

filter.h

Go to the documentation of this file.
00001 /* 
00002  * This file is part of the rfc822 library (C) rebel42@users.sourceforge.net.
00003  *
00004  * The rfc822 library is released under the terms of the GNU Library General Public License as
00005  * published by the Free Software Foundation; either version 2 of the
00006  * License, or (at your option) any later version. See the file COPYING
00007  * as included in the distribution for details.
00008  */
00009 #ifndef RFC822_FILTER_H
00010 #define RFC822_FILTER_H
00011 
00012 #include <rfc822/msg.h>
00013 
00014 #include <set>
00015 
00016 using namespace std;
00017 
00018 namespace rfc822
00019 {
00020 
00021 namespace filter
00022 {
00023 
00025 
00038 class filter
00039 {
00040 public:
00042         filter();
00043         
00045         virtual ~filter();
00046                 
00048 
00054         bool no_loop_check();
00055 
00057 
00064         virtual void onMsg(const msg&);
00065 
00067 
00071         virtual void onCleanup();
00072         
00074 
00078         virtual void onInit();
00079         
00081 
00097         void connect(const string& outgoing, filter& dest, bool fConnect = true);
00098 
00099         void connect(filter& dest, bool fConnect = true);
00100 
00101         static void connect(filter& src, filter& dest, bool fConnect = true)
00102                 { src.connect(dest, fConnect); }
00103 
00104         static void connect(filter& src, const string& outgoing, filter& dest, bool fConnect = true)
00105                 { src.connect(outgoing, dest, fConnect); }
00106 
00108         template <class T>
00109         static void copy(T& in, filter& f);
00110         
00112         static void copy(const msg& in, filter& f);
00113         
00114 protected:
00116 
00126         void redirect(const msg& m, const string& slot);
00127         
00129         void redirect(const msg& m);
00130         
00131 private:
00132         // checks for loops
00133         bool no_loop_check(set<filter*>&);
00134         
00135         // returns a list of recipients.
00136         set<filter*> recipients();
00137         
00138         typedef multimap<string, filter*> Map;
00139         Map m_targets;
00140         
00142         filter(const filter&);
00143         
00145         filter& operator = (const filter&);
00146 };
00147 
00148 template <class T>
00149 void copy(T& in, filter& f)
00150 {
00151         typename T::iterator it;
00152         for(it = in.begin(); it != in.end(); ++it)
00153                 f.onMsg(*it);
00154 }
00155 
00156 inline void copy(const msg& in, filter& f)
00157 {
00158         f.onMsg(in);
00159 }
00160 
00161 /*
00162  * include filters
00163  */
00164 #define IN_RFC822_FILTER_H
00165 
00166 #include <rfc822/filter/mboxwriter.h>
00167 #include <rfc822/filter/conditional.h>
00168 
00169 #undef  IN_RFC822_FILTER_H
00170 
00171 };      // namespace rfc822::filter
00172 };      // namespace rfc822
00173 
00174 
00175 #endif

Generated on Mon Oct 22 17:03:48 2001 for rfc822 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001