aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2013-05-24 16:15:29 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2013-06-04 07:40:47 +0100
commit69b7b1d8961503771d03217e41669ca12e6852b5 (patch)
tree40329db77650def5536ae9479dc78f6f66e1dde9
parentb04e6805a25ef61c29fe88bcc4cea73ebb23f57a (diff)
downloadpaludis-69b7b1d8961503771d03217e41669ca12e6852b5.tar.gz
paludis-69b7b1d8961503771d03217e41669ca12e6852b5.tar.xz
Convert to fancy new visitors
-rw-r--r--paludis/create_output_manager_info.cc60
-rw-r--r--paludis/mask.cc37
2 files changed, 24 insertions, 73 deletions
diff --git a/paludis/create_output_manager_info.cc b/paludis/create_output_manager_info.cc
index eedfb62..34a6c0d 100644
--- a/paludis/create_output_manager_info.cc
+++ b/paludis/create_output_manager_info.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009, 2010, 2011 Ciaran McCreesh
+ * Copyright (c) 2009, 2010, 2011, 2013 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -34,50 +34,22 @@ using namespace paludis;
namespace
{
- struct GetFlagsVisitor
+ std::shared_ptr<Set<std::string> > get_flags(const Action & action)
{
- std::shared_ptr<Set<std::string> > visit(const InstallAction &) const
- {
- return std::make_shared<Set<std::string>>();
- }
-
- std::shared_ptr<Set<std::string> > visit(const UninstallAction &) const
- {
- return std::make_shared<Set<std::string>>();
- }
-
- std::shared_ptr<Set<std::string> > visit(const PretendAction &) const
- {
- return std::make_shared<Set<std::string>>();
- }
-
- std::shared_ptr<Set<std::string> > visit(const FetchAction & a) const
- {
- std::shared_ptr<Set<std::string> > result(std::make_shared<Set<std::string>>());
- if (a.options.ignore_unfetched())
- result->insert(FetchAction::ignore_unfetched_flag_name());
- return result;
- }
-
- std::shared_ptr<Set<std::string> > visit(const PretendFetchAction &) const
- {
- return std::make_shared<Set<std::string>>();
- }
-
- std::shared_ptr<Set<std::string> > visit(const ConfigAction &) const
- {
- return std::make_shared<Set<std::string>>();
- }
-
- std::shared_ptr<Set<std::string> > visit(const InfoAction &) const
- {
- return std::make_shared<Set<std::string>>();
- }
- };
-
- std::shared_ptr<Set<std::string> > get_flags(const Action & a)
- {
- return a.accept_returning<std::shared_ptr<Set<std::string> > >(GetFlagsVisitor());
+ return action.make_accept_returning(
+ [&] (const InstallAction &) { return std::make_shared<Set<std::string>>(); },
+ [&] (const UninstallAction &) { return std::make_shared<Set<std::string>>(); },
+ [&] (const PretendAction &) { return std::make_shared<Set<std::string>>(); },
+ [&] (const PretendFetchAction &) { return std::make_shared<Set<std::string>>(); },
+ [&] (const ConfigAction &) { return std::make_shared<Set<std::string>>(); },
+ [&] (const InfoAction &) { return std::make_shared<Set<std::string>>(); },
+ [&] (const FetchAction & a) {
+ std::shared_ptr<Set<std::string> > result(std::make_shared<Set<std::string>>());
+ if (a.options.ignore_unfetched())
+ result->insert(FetchAction::ignore_unfetched_flag_name());
+ return result;
+ }
+ );
}
}
diff --git a/paludis/mask.cc b/paludis/mask.cc
index ae3f6c2..17a731f 100644
--- a/paludis/mask.cc
+++ b/paludis/mask.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -37,35 +37,14 @@ UserMask::token() const
return "user";
}
-namespace
-{
- struct TokenGetter
- {
- std::string visit(const UserMask & m) const
- {
- return m.token();
- }
-
- std::string visit(const RepositoryMask & m) const
- {
- return m.token();
- }
-
- std::string visit(const UnacceptedMask &) const
- {
- return "";
- }
-
- std::string visit(const UnsupportedMask &) const
- {
- return "";
- }
- };
-}
-
const std::string
-paludis::get_mask_token(const Mask & m)
+paludis::get_mask_token(const Mask & mask)
{
- return m.accept_returning<std::string>(TokenGetter{});
+ return mask.make_accept_returning(
+ [&] (const UserMask & m) { return m.token(); },
+ [&] (const RepositoryMask & m) { return m.token(); },
+ [&] (const UnacceptedMask &) { return ""; },
+ [&] (const UnsupportedMask &) { return ""; }
+ );
}