320f86fe42836b0cde828cc70107e1c088768a7d
[metaproxy-moved-to-github.git] / src / filter_factory.hpp
1 /* $Id: filter_factory.hpp,v 1.6 2005-11-10 23:10:42 adam Exp $
2    Copyright (c) 2005, Index Data.
3
4 %LICENSE%
5  */
6
7 #ifndef FILTER_FACTORY_HPP
8 #define FILTER_FACTORY_HPP
9
10 #include <stdexcept>
11 #include <iostream>
12 #include <string>
13 #include <map>
14
15 #include <boost/noncopyable.hpp>
16 #include <boost/scoped_ptr.hpp>
17
18 #include "filter.hpp"
19
20
21 namespace yp2 {
22
23     class FilterFactoryException : public std::runtime_error {
24     public:
25         FilterFactoryException(const std::string message);
26     };
27     
28     class FilterFactory : public boost::noncopyable
29     {
30         typedef yp2::filter::Base* (*CreateFilterCallback)();
31         typedef std::map<std::string, CreateFilterCallback> CallbackMap;
32
33         class Rep;
34     public:
35         /// true if registration ok
36         
37         FilterFactory();
38         ~FilterFactory();
39
40         bool add_creator(std::string fi, CreateFilterCallback cfc);
41         /// true if unregistration ok
42         
43         bool drop_creator(std::string fi);
44         
45         /// factory create method
46         
47         yp2::filter::Base* create(std::string fi);
48         
49     private:
50         boost::scoped_ptr<Rep> m_p;
51     };
52 }
53
54 #endif
55 /*
56  * Local variables:
57  * c-basic-offset: 4
58  * indent-tabs-mode: nil
59  * c-file-style: "stroustrup"
60  * End:
61  * vim: shiftwidth=4 tabstop=8 expandtab
62  */