All filters declare a yp2_filter_struct - used for both static and
[metaproxy-moved-to-github.git] / src / filter.hpp
1 /* $Id: filter.hpp,v 1.11 2006-01-04 11:19:04 adam Exp $
2    Copyright (c) 2005, Index Data.
3
4 %LICENSE%
5  */
6
7 #ifndef FILTER_HPP
8 #define FILTER_HPP
9
10 #include <string>
11 #include <stdexcept>
12 #include <libxml/tree.h>
13
14 namespace yp2 {
15
16     class Package;
17
18     namespace filter {
19         class Base {
20         public:
21             virtual ~Base(){};
22             
23             ///sends Package off to next Filter, returns altered Package
24             virtual void process(Package & package) const = 0;
25
26             virtual void configure(const xmlNode * ptr) { };
27         };
28
29         class FilterException : public std::runtime_error {
30         public:
31             FilterException(const std::string message)
32                 : std::runtime_error("FilterException: " + message){
33             };
34         };
35         
36     }
37 }
38
39 struct yp2_filter_struct {
40     int ver;
41     const char *type;
42     yp2::filter::Base* (*creator)();
43 };
44
45 #endif
46 /*
47  * Local variables:
48  * c-basic-offset: 4
49  * indent-tabs-mode: nil
50  * c-file-style: "stroustrup"
51  * End:
52  * vim: shiftwidth=4 tabstop=8 expandtab
53  */