Windows: use Boost 1.59, msvc 14.0
[metaproxy-moved-to-github.git] / src / factory_filter.hpp
1 /* This file is part of Metaproxy.
2    Copyright (C) Index Data
3
4 Metaproxy is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8
9 Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17 */
18
19 #ifndef FACTORY_FILTER_HPP
20 #define FACTORY_FILTER_HPP
21
22 #include <stdexcept>
23 #include <iostream>
24 #include <string>
25 #include <map>
26
27 #include <boost/noncopyable.hpp>
28 #include <boost/scoped_ptr.hpp>
29
30 #include <metaproxy/filter.hpp>
31
32 namespace metaproxy_1 {
33     class FactoryFilter : public boost::noncopyable
34     {
35         typedef metaproxy_1::filter::Base* (*CreateFilterCallback)();
36
37         class Rep;
38     public:
39         /// true if registration ok
40
41         FactoryFilter();
42         ~FactoryFilter();
43
44         bool add_creator(const std::string &fi, CreateFilterCallback cfc);
45
46         bool drop_creator(std::string fi);
47
48         metaproxy_1::filter::Base* create(std::string fi);
49         bool exist(std::string fi);
50
51         bool add_creator_dl(const std::string &fi, const std::string &path);
52
53         class NotFound : public std::runtime_error {
54         public:
55             NotFound(const std::string msg);
56         };
57     private:
58         boost::scoped_ptr<Rep> m_p;
59     };
60 }
61
62 #endif
63 /*
64  * Local variables:
65  * c-basic-offset: 4
66  * c-file-style: "Stroustrup"
67  * indent-tabs-mode: nil
68  * End:
69  * vim: shiftwidth=4 tabstop=8 expandtab
70  */
71