1 /* $Id: filter_factory.cpp,v 1.1 2005-11-10 23:10:42 adam Exp $
2 Copyright (c) 2005, Index Data.
7 #include "filter_factory.hpp"
15 class FilterFactory::Rep {
17 friend class FilterFactory;
24 yp2::FilterFactoryException::FilterFactoryException(const std::string message)
25 : std::runtime_error("FilterException: " + message)
29 yp2::FilterFactory::Rep::Rep()
33 yp2::FilterFactory::Rep::~Rep()
37 yp2::FilterFactory::FilterFactory() : m_p(new yp2::FilterFactory::Rep)
42 yp2::FilterFactory::~FilterFactory()
47 bool yp2::FilterFactory::add_creator(std::string fi,
48 CreateFilterCallback cfc)
50 return m_p->m_fcm.insert(CallbackMap::value_type(fi, cfc)).second;
54 bool yp2::FilterFactory::drop_creator(std::string fi)
56 return m_p->m_fcm.erase(fi) == 1;
59 yp2::filter::Base* yp2::FilterFactory::create(std::string fi)
61 CallbackMap::const_iterator it = m_p->m_fcm.find(fi);
63 if (it == m_p->m_fcm.end()){
64 std::string msg = "filter type '" + fi + "' not found";
65 throw yp2::FilterFactoryException(msg);
67 // call create function
68 return (it->second());
74 * indent-tabs-mode: nil
75 * c-file-style: "stroustrup"
77 * vim: shiftwidth=4 tabstop=8 expandtab