Method configure takes const xmlNode pointer. Added testfilter2_2 which
[metaproxy-moved-to-github.git] / src / filter.hpp
1 /* $Id: filter.hpp,v 1.6 2005-10-24 09:53:06 adam Exp $
2    Copyright (c) 2005, Index Data.
3
4 %LICENSE%
5  */
6
7 #ifndef FILTER_HPP
8 #define FILTER_HPP
9
10 #include <stdexcept>
11 #include <libxml/tree.h>
12
13 namespace yp2 {
14
15     class Package;
16
17     namespace filter {
18         class Base {
19         public:
20             virtual ~Base(){};
21             
22             ///sends Package off to next Filter, returns altered Package
23             virtual void process(Package & package) const = 0;
24
25             virtual void configure(const xmlNode * ptr = 0) { } ;
26             
27             /// get function - right val in assignment
28             std::string name() const {
29                 return m_name;
30             }
31             
32             /// set function - left val in assignment
33             std::string & name() {
34                 return m_name;
35             }
36             
37             /// set function - can be chained
38             Base & name(const std::string & name){
39                 m_name = name;
40                 return *this;
41             }
42             
43         private:
44             std::string m_name;
45         };
46     }
47     
48     class FilterException : public std::runtime_error {
49     public:
50         FilterException(const std::string message)
51             : std::runtime_error("FilterException: " + message){
52         };
53     };
54
55   
56 }
57
58 #endif
59 /*
60  * Local variables:
61  * c-basic-offset: 4
62  * indent-tabs-mode: nil
63  * c-file-style: "stroustrup"
64  * End:
65  * vim: shiftwidth=4 tabstop=8 expandtab
66  */