GPL v2.
[metaproxy-moved-to-github.git] / src / factory_filter.hpp
1 /* $Id: factory_filter.hpp,v 1.7 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 FACTORY_FILTER_HPP
23 #define FACTORY_FILTER_HPP
24
25 #include <stdexcept>
26 #include <iostream>
27 #include <string>
28 #include <map>
29
30 #include <boost/noncopyable.hpp>
31 #include <boost/scoped_ptr.hpp>
32
33 #include "filter.hpp"
34
35 namespace metaproxy_1 {
36     class FactoryFilter : public boost::noncopyable
37     {
38         typedef metaproxy_1::filter::Base* (*CreateFilterCallback)();
39
40         class Rep;
41     public:
42         /// true if registration ok
43         
44         FactoryFilter();
45         ~FactoryFilter();
46
47         bool add_creator(std::string fi, CreateFilterCallback cfc);
48         
49         bool drop_creator(std::string fi);
50         
51         metaproxy_1::filter::Base* create(std::string fi);
52         bool exist(std::string fi);
53     
54         bool add_creator_dl(const std::string &fi, const std::string &path);
55
56         bool have_dl_support();
57
58         class NotFound : public std::runtime_error {
59         public:
60             NotFound(const std::string msg);
61         };
62     private:
63         boost::scoped_ptr<Rep> m_p;
64     };
65 }
66
67 #endif
68 /*
69  * Local variables:
70  * c-basic-offset: 4
71  * indent-tabs-mode: nil
72  * c-file-style: "stroustrup"
73  * End:
74  * vim: shiftwidth=4 tabstop=8 expandtab
75  */