aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-08-14 19:09:46 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-08-14 19:09:46 +0100
commit02c0429d9a58c9c577adf24c9c816bbfca5ddec8 (patch)
tree50d752ae709867641cccc669a29c18d8d4f26b3a
parent889f976165403678c3c4ec3e45e18c05995f3e51 (diff)
downloadpaludis-02c0429d9a58c9c577adf24c9c816bbfca5ddec8.tar.gz
paludis-02c0429d9a58c9c577adf24c9c816bbfca5ddec8.tar.xz
Stop using VirtualConstructor
-rw-r--r--src/clients/inquisitio/do_search.cc4
-rw-r--r--src/clients/inquisitio/matcher.cc24
-rw-r--r--src/clients/inquisitio/matcher.hh18
3 files changed, 25 insertions, 21 deletions
diff --git a/src/clients/inquisitio/do_search.cc b/src/clients/inquisitio/do_search.cc
index dcf195a..c5a2162 100644
--- a/src/clients/inquisitio/do_search.cc
+++ b/src/clients/inquisitio/do_search.cc
@@ -197,8 +197,8 @@ do_search(const Environment & env)
std::list<std::tr1::shared_ptr<Matcher> > matchers;
for (CommandLine::ParametersConstIterator p(CommandLine::get_instance()->begin_parameters()),
p_end(CommandLine::get_instance()->end_parameters()) ; p != p_end ; ++p)
- matchers.push_back(MatcherMaker::get_instance()->find_maker(
- CommandLine::get_instance()->a_matcher.argument())(*p));
+ matchers.push_back(MatcherFactory::get_instance()->create(
+ CommandLine::get_instance()->a_matcher.argument(), *p));
std::list<std::tr1::shared_ptr<Extractor> > extractors;
if (CommandLine::get_instance()->a_keys.begin_args() == CommandLine::get_instance()->a_keys.end_args())
diff --git a/src/clients/inquisitio/matcher.cc b/src/clients/inquisitio/matcher.cc
index dea0d31..75ab3a4 100644
--- a/src/clients/inquisitio/matcher.cc
+++ b/src/clients/inquisitio/matcher.cc
@@ -21,18 +21,13 @@
#include "exact_matcher.hh"
#include "pcre_matcher.hh"
#include "text_matcher.hh"
-#include <paludis/util/virtual_constructor-impl.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/instantiation_policy-impl.hh>
using namespace inquisitio;
using namespace paludis;
-template class paludis::VirtualConstructor<std::string,
- std::tr1::shared_ptr<Matcher> (*) (const std::string &),
- paludis::virtual_constructor_not_found::ThrowException<NoSuchMatcherError> >;
-
-template class paludis::InstantiationPolicy<MatcherMaker, paludis::instantiation_method::SingletonTag>;
+template class paludis::InstantiationPolicy<MatcherFactory, paludis::instantiation_method::SingletonTag>;
Matcher::Matcher()
{
@@ -57,10 +52,19 @@ namespace
}
}
-MatcherMaker::MatcherMaker()
+MatcherFactory::MatcherFactory()
+{
+}
+
+const std::tr1::shared_ptr<Matcher>
+MatcherFactory::create(const std::string & s, const std::string & t) const
{
- register_maker("exact", &make<ExactMatcher>);
- register_maker("pcre", &make<PCREMatcher>);
- register_maker("text", &make<TextMatcher>);
+ if (s == "exact")
+ return make<ExactMatcher>(t);
+ if (s == "pcre")
+ return make<PCREMatcher>(t);
+ if (s == "text")
+ return make<TextMatcher>(t);
+ throw NoSuchMatcherError(t);
}
diff --git a/src/clients/inquisitio/matcher.hh b/src/clients/inquisitio/matcher.hh
index 8b2b985..86b69de 100644
--- a/src/clients/inquisitio/matcher.hh
+++ b/src/clients/inquisitio/matcher.hh
@@ -22,7 +22,7 @@
#include <paludis/util/instantiation_policy.hh>
#include <paludis/util/sr.hh>
-#include <paludis/util/virtual_constructor.hh>
+#include <paludis/util/exception.hh>
#include <string>
#include <tr1/memory>
@@ -49,17 +49,17 @@ namespace inquisitio
NoSuchMatcherError(const std::string &) throw ();
};
- class MatcherMaker :
- public paludis::InstantiationPolicy<MatcherMaker, paludis::instantiation_method::SingletonTag>,
- public paludis::VirtualConstructor<
- std::string,
- std::tr1::shared_ptr<Matcher> (*) (const std::string &),
- paludis::virtual_constructor_not_found::ThrowException<NoSuchMatcherError> >
+ class MatcherFactory :
+ public paludis::InstantiationPolicy<MatcherFactory, paludis::instantiation_method::SingletonTag>
{
- friend class paludis::InstantiationPolicy<MatcherMaker, paludis::instantiation_method::SingletonTag>;
+ friend class paludis::InstantiationPolicy<MatcherFactory, paludis::instantiation_method::SingletonTag>;
private:
- MatcherMaker();
+ MatcherFactory();
+
+ public:
+ const std::tr1::shared_ptr<Matcher> create(const std::string &, const std::string &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
};
}