Loadable filter support for FilterFactory using dlopen/dlsym. Only
[metaproxy-moved-to-github.git] / src / filter_factory.hpp
1 /* $Id: filter_factory.hpp,v 1.7 2005-12-10 09:59:10 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
32         class Rep;
33     public:
34         /// true if registration ok
35         
36         FilterFactory();
37         ~FilterFactory();
38
39         bool add_creator(std::string fi, CreateFilterCallback cfc);
40         
41         bool drop_creator(std::string fi);
42         
43         yp2::filter::Base* create(std::string fi);
44
45         bool add_creator_dyn(const std::string &fi, const std::string &path);
46     private:
47         boost::scoped_ptr<Rep> m_p;
48     };
49 }
50
51 #endif
52 /*
53  * Local variables:
54  * c-basic-offset: 4
55  * indent-tabs-mode: nil
56  * c-file-style: "stroustrup"
57  * End:
58  * vim: shiftwidth=4 tabstop=8 expandtab
59  */