352670e1a64f3e84e7c49c49089c2eb2d4d8b68b
[metaproxy-moved-to-github.git] / src / filter.hpp
1 /* $Id: filter.hpp,v 1.20 2007-05-09 21:23:09 adam Exp $
2    Copyright (c) 2005-2007, Index Data.
3
4 This file is part of Metaproxy.
5
6 Metaproxy is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
9 version.
10
11 Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Metaproxy; see the file LICENSE.  If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19 02111-1307, USA.
20  */
21
22 #ifndef FILTER_HPP
23 #define FILTER_HPP
24
25 #include <string>
26 #include <stdexcept>
27 #include <libxml/tree.h>
28 #include "xmlutil.hpp"
29
30 namespace metaproxy_1 {
31
32     class Package;
33
34     namespace filter {
35         class Base {
36         public:
37             virtual ~Base(){};
38             
39             ///sends Package off to next Filter, returns altered Package
40             virtual void process(Package & package) const = 0;
41
42             /// configuration during filter load 
43             virtual void configure(const xmlNode * ptr);
44         };
45
46         class FilterException : public std::runtime_error {
47         public:
48             FilterException(const std::string message)
49                 : std::runtime_error("FilterException: " + message){
50             };
51         };
52     }
53 }
54
55 struct metaproxy_1_filter_struct {
56     int ver;
57     const char *type;
58     metaproxy_1::filter::Base* (*creator)();
59 };
60
61 #endif
62 /*
63  * Local variables:
64  * c-basic-offset: 4
65  * indent-tabs-mode: nil
66  * c-file-style: "stroustrup"
67  * End:
68  * vim: shiftwidth=4 tabstop=8 expandtab
69  */