aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-08-12 20:02:54 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-08-12 20:02:54 +0100
commitaacbe32dcf604490ce9211d40c0d11a6e78a4cdf (patch)
treede01cedfc7e66777ea650915f4cdfe7e99771a26
parent0f3eb4b7da157630049ad93334338c4ba796304c (diff)
downloadpaludis-aacbe32dcf604490ce9211d40c0d11a6e78a4cdf.tar.gz
paludis-aacbe32dcf604490ce9211d40c0d11a6e78a4cdf.tar.xz
DepTagCategoryMaker -> DepTagCategoryFactory
-rw-r--r--doc/api/cplusplus/examples/example_dep_tag.cc7
-rw-r--r--paludis/dep_tag-fwd.hh6
-rw-r--r--paludis/dep_tag.cc47
-rw-r--r--paludis/dep_tag.hh43
-rw-r--r--python/dep_tag.cc25
-rwxr-xr-xpython/dep_tag_TEST.py14
-rw-r--r--src/clients/paludis/Makefile.am2
-rw-r--r--src/clients/paludis/applets.cc18
-rw-r--r--src/clients/paludis/applets.hh3
-rw-r--r--src/clients/paludis/command_line.cc1
-rw-r--r--src/clients/paludis/command_line.hh3
-rwxr-xr-xsrc/clients/paludis/list_dep_tag_categories_TEST3
-rw-r--r--src/clients/paludis/paludis.cc9
-rw-r--r--src/output/console_install_task.cc3
14 files changed, 57 insertions, 127 deletions
diff --git a/doc/api/cplusplus/examples/example_dep_tag.cc b/doc/api/cplusplus/examples/example_dep_tag.cc
index 3d351c0..b44c324 100644
--- a/doc/api/cplusplus/examples/example_dep_tag.cc
+++ b/doc/api/cplusplus/examples/example_dep_tag.cc
@@ -150,11 +150,8 @@ int main(int argc, char * argv[])
{
cout << " " << *s << ":" << endl;
- /* Fetch the category. DepTagCategoryMaker::find_maker returns a
- * function that creates the category, rather than directly
- * returning the category. */
- std::tr1::shared_ptr<const DepTagCategory> category(
- DepTagCategoryMaker::get_instance()->find_maker(*s)());
+ /* Fetch the category. */
+ std::tr1::shared_ptr<const DepTagCategory> category(DepTagCategoryFactory::get_instance()->create(*s));
cout << left << setw(20) << " Visible:" << " " << boolalpha << category->visible() << endl;
cout << left << setw(20) << " ID:" << " " << category->id() << endl;
diff --git a/paludis/dep_tag-fwd.hh b/paludis/dep_tag-fwd.hh
index a480cac..c8ed8cd 100644
--- a/paludis/dep_tag-fwd.hh
+++ b/paludis/dep_tag-fwd.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008 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
@@ -33,9 +33,7 @@
namespace paludis
{
class DepTagCategory;
- class NoSuchDepTagCategory;
-
- class DepTagCategoryMaker;
+ class DepTagCategoryFactory;
class DepTag;
class GLSADepTag;
diff --git a/paludis/dep_tag.cc b/paludis/dep_tag.cc
index 1b5b1ce..6923c20 100644
--- a/paludis/dep_tag.cc
+++ b/paludis/dep_tag.cc
@@ -20,7 +20,6 @@
#include "dep_tag.hh"
#include <paludis/dep_spec.hh>
#include <paludis/dep_label.hh>
-#include <paludis/util/virtual_constructor-impl.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/instantiation_policy-impl.hh>
@@ -30,9 +29,6 @@
using namespace paludis;
-template class VirtualConstructor<std::string, std::tr1::shared_ptr<const DepTagCategory> (*) (),
- virtual_constructor_not_found::ThrowException<NoSuchDepTagCategory> >;
-
template class ConstVisitor<DepTagVisitorTypes>;
template class ConstAcceptInterface<DepTagVisitorTypes>;
@@ -46,7 +42,7 @@ template class Visits<const GLSADepTag>;
template class Visits<const DependencyDepTag>;
template class Visits<const TargetDepTag>;
-template class InstantiationPolicy<DepTagCategoryMaker, instantiation_method::SingletonTag>;
+template class InstantiationPolicy<DepTagCategoryFactory, instantiation_method::SingletonTag>;
template class Set<DepTagEntry>;
template class WrappedForwardIterator<Set<DepTagEntry>::ConstIteratorTag, const DepTagEntry>;
@@ -59,10 +55,10 @@ template class PrivateImplementationPattern<DependencyDepTag>;
namespace
{
- std::tr1::shared_ptr<const DepTagCategory>
+ std::tr1::shared_ptr<DepTagCategory>
make_glsa_dep_tag()
{
- return std::tr1::shared_ptr<const DepTagCategory>(new DepTagCategory(
+ return std::tr1::shared_ptr<DepTagCategory>(new DepTagCategory(
true,
"glsa",
"Security advisories",
@@ -70,10 +66,10 @@ namespace
"Please read the advisories carefully and take appropriate action."));
}
- std::tr1::shared_ptr<const DepTagCategory>
+ std::tr1::shared_ptr<DepTagCategory>
make_general_set_dep_tag()
{
- return std::tr1::shared_ptr<const DepTagCategory>(new DepTagCategory(
+ return std::tr1::shared_ptr<DepTagCategory>(new DepTagCategory(
true,
"general",
"General sets",
@@ -81,10 +77,10 @@ namespace
""));
}
- std::tr1::shared_ptr<const DepTagCategory>
+ std::tr1::shared_ptr<DepTagCategory>
make_dependency_set_dep_tag()
{
- return std::tr1::shared_ptr<const DepTagCategory>(new DepTagCategory(
+ return std::tr1::shared_ptr<DepTagCategory>(new DepTagCategory(
false,
"dependency",
"Dependencies",
@@ -92,10 +88,10 @@ namespace
""));
}
- std::tr1::shared_ptr<const DepTagCategory>
+ std::tr1::shared_ptr<DepTagCategory>
make_target_dep_tag()
{
- return std::tr1::shared_ptr<const DepTagCategory>(new DepTagCategory(
+ return std::tr1::shared_ptr<DepTagCategory>(new DepTagCategory(
false,
"target",
"Targets",
@@ -147,11 +143,6 @@ DepTagCategory::post_text() const
return _post_text;
}
-NoSuchDepTagCategory::NoSuchDepTagCategory(const std::string & s) throw () :
- Exception("No such dep tag category '" + s + "'")
-{
-}
-
DepTag::DepTag()
{
}
@@ -433,11 +424,21 @@ TargetDepTag::category() const
return "target";
}
-DepTagCategoryMaker::DepTagCategoryMaker()
+DepTagCategoryFactory::DepTagCategoryFactory()
+{
+}
+
+const std::tr1::shared_ptr<DepTagCategory>
+DepTagCategoryFactory::create(const std::string & s) const
{
- register_maker("glsa", &make_glsa_dep_tag);
- register_maker("general", &make_general_set_dep_tag);
- register_maker("dependency", &make_dependency_set_dep_tag);
- register_maker("target", &make_target_dep_tag);
+ if (s == "glsa")
+ return make_glsa_dep_tag();
+ if (s == "general")
+ return make_general_set_dep_tag();
+ if (s == "dependency")
+ return make_dependency_set_dep_tag();
+ if (s == "target")
+ return make_target_dep_tag();
+ throw ConfigurationError("No dep tag category named '" + s + "'");
}
diff --git a/paludis/dep_tag.hh b/paludis/dep_tag.hh
index 03984b4..4210f13 100644
--- a/paludis/dep_tag.hh
+++ b/paludis/dep_tag.hh
@@ -40,7 +40,6 @@
#include <paludis/package_id-fwd.hh>
#include <paludis/util/instantiation_policy.hh>
#include <paludis/util/visitor.hh>
-#include <paludis/util/virtual_constructor.hh>
#include <paludis/util/exception.hh>
#include <paludis/util/sr.hh>
#include <paludis/util/fs_entry.hh>
@@ -134,39 +133,22 @@ namespace paludis
};
/**
- * Thrown if DepTagCategoryMaker cannot find the named DepTagCategory.
+ * Factory for accessing DepTagCategory instances.
*
- * \ingroup g_exceptions
* \ingroup g_dep_spec
- * \nosubgrouping
- */
- class PALUDIS_VISIBLE NoSuchDepTagCategory :
- public Exception
- {
- public:
- ///\name Basic operations
- ///\{
-
- NoSuchDepTagCategory(const std::string &) throw ();
-
- ///\}
- };
-
- /**
- * Virtual constructor for accessing DepTagCategory instances.
- *
- * \ingroup g_dep_spec
- * \nosubgrouping
+ * \since 0.30
*/
- class PALUDIS_VISIBLE DepTagCategoryMaker :
- public VirtualConstructor<std::string, std::tr1::shared_ptr<const DepTagCategory> (*) (),
- virtual_constructor_not_found::ThrowException<NoSuchDepTagCategory> >,
- public InstantiationPolicy<DepTagCategoryMaker, instantiation_method::SingletonTag>
+ class PALUDIS_VISIBLE DepTagCategoryFactory :
+ public InstantiationPolicy<DepTagCategoryFactory, instantiation_method::SingletonTag>
{
- friend class InstantiationPolicy<DepTagCategoryMaker, instantiation_method::SingletonTag>;
+ friend class InstantiationPolicy<DepTagCategoryFactory, instantiation_method::SingletonTag>;
private:
- DepTagCategoryMaker();
+ DepTagCategoryFactory();
+
+ public:
+ const std::tr1::shared_ptr<DepTagCategory> create(const std::string &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
};
/**
@@ -362,9 +344,6 @@ namespace paludis
#include <paludis/dep_tag-sr.hh>
#ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
- extern template class VirtualConstructor<std::string, std::tr1::shared_ptr<const DepTagCategory> (*) (),
- virtual_constructor_not_found::ThrowException<NoSuchDepTagCategory> >;
-
extern template class ConstAcceptInterface<DepTagVisitorTypes>;
extern template class ConstAcceptInterfaceVisitsThis<DepTagVisitorTypes, DependencyDepTag>;
@@ -377,7 +356,7 @@ namespace paludis
extern template class Visits<const DependencyDepTag>;
extern template class Visits<const TargetDepTag>;
- extern template class InstantiationPolicy<DepTagCategoryMaker, instantiation_method::SingletonTag>;
+ extern template class InstantiationPolicy<DepTagCategoryFactory, instantiation_method::SingletonTag>;
extern template class PrivateImplementationPattern<DependencyDepTag>;
extern template class PrivateImplementationPattern<GeneralSetDepTag>;
#endif
diff --git a/python/dep_tag.cc b/python/dep_tag.cc
index 4cb746b..cce8ec8 100644
--- a/python/dep_tag.cc
+++ b/python/dep_tag.cc
@@ -29,26 +29,19 @@ using namespace paludis;
using namespace paludis::python;
namespace bp = boost::python;
-struct DepTagCategoryMakerWrapper
+struct DepTagCategoryFactoryWrapper
{
// More convenient way of creating DepTagCategories
static std::tr1::shared_ptr<const DepTagCategory>
- make_from_id(const DepTagCategoryMaker & self, const std::string & id)
+ create(const DepTagCategoryFactory & self, const std::string & id)
{
- return self[id]();
+ return self.create(id);
}
};
void expose_dep_tag()
{
/**
- * Exceptions
- */
- ExceptionRegister::get_instance()->add_exception<NoSuchDepTagCategory>
- ("NoSuchDepTagCategory", "BaseException",
- "Thrown if DepTagCategoryMaker cannot find the named DepTagCategory.");
-
- /**
* DepTagCategory
*/
register_shared_ptrs_to_python<DepTagCategory>();
@@ -87,21 +80,21 @@ void expose_dep_tag()
;
/**
- * DepTagCategoryMaker
+ * DepTagCategoryFactory
*/
- bp::class_<DepTagCategoryMaker, boost::noncopyable>
+ bp::class_<DepTagCategoryFactory, boost::noncopyable>
(
- "DepTagCategoryMaker",
+ "DepTagCategoryFactory",
"Virtual constructor for accessing DepTagCategory instances.",
bp::no_init
)
- .add_static_property("instance", bp::make_function(&DepTagCategoryMaker::get_instance,
+ .add_static_property("instance", bp::make_function(&DepTagCategoryFactory::get_instance,
bp::return_value_policy<bp::reference_existing_object>()),
"Singleton instance."
)
- .def("make_from_id", &DepTagCategoryMakerWrapper::make_from_id,
- "make_from_id(id_string) -> DepTagCategory\n"
+ .def("create", &DepTagCategoryFactory::create,
+ "create(id_string) -> DepTagCategory\n"
"Make DepTagCategory from id."
)
;
diff --git a/python/dep_tag_TEST.py b/python/dep_tag_TEST.py
index f98b9ce..75e3d52 100755
--- a/python/dep_tag_TEST.py
+++ b/python/dep_tag_TEST.py
@@ -84,23 +84,23 @@ class TestCase_05_TargetDepTag(unittest.TestCase):
self.assertEquals(dt.category, "target")
self.assertEquals(dt.short_text, "target")
-class TestCase_06_DepTagCategoryMaker(unittest.TestCase):
+class TestCase_06_DepTagCategoryFactory(unittest.TestCase):
def test_01_no_create(self):
- self.assertRaises(Exception, DepTagCategoryMaker)
+ self.assertRaises(Exception, DepTagCategoryFactory)
def test_02_instance(self):
- self.assert_(isinstance(DepTagCategoryMaker.instance, DepTagCategoryMaker))
+ self.assert_(isinstance(DepTagCategoryFactory.instance, DepTagCategoryFactory))
- def test_03_make_from_id(self):
- cdt = DepTagCategoryMaker.instance.make_from_id("glsa")
+ def test_03_create(self):
+ cdt = DepTagCategoryFactory.instance.create("glsa")
self.assert_(isinstance(cdt, DepTagCategory))
- self.assertRaises(NoSuchDepTagCategory, DepTagCategoryMaker.instance.make_from_id, "foo")
+ self.assertRaises(ConfigurationError, DepTagCategoryFactory.instance.create, "foo")
class TestCase_07_DepTagCategory(unittest.TestCase):
def setUp(self):
global cdt
- cdt = DepTagCategoryMaker.instance.make_from_id("glsa")
+ cdt = DepTagCategoryFactory.instance.create("glsa")
def test_01_no_create(self):
self.assertRaises(Exception, DepTagCategory)
diff --git a/src/clients/paludis/Makefile.am b/src/clients/paludis/Makefile.am
index b3a87c2..2e8aa09 100644
--- a/src/clients/paludis/Makefile.am
+++ b/src/clients/paludis/Makefile.am
@@ -75,7 +75,7 @@ TESTS_ENVIRONMENT = env \
bash $(top_srcdir)/test/run_test.sh bash
TESTS = version_TEST help_TEST \
- list_repository_formats_TEST list_dep_tag_categories_TEST \
+ list_repository_formats_TEST \
exception_TEST install_TEST pretend_TEST upgrade_TEST args_from_environment_TEST \
continue_on_failure_TEST
diff --git a/src/clients/paludis/applets.cc b/src/clients/paludis/applets.cc
index 2198c61..5e1f6db 100644
--- a/src/clients/paludis/applets.cc
+++ b/src/clients/paludis/applets.cc
@@ -392,24 +392,6 @@ int do_list_sync_protocols(std::tr1::shared_ptr<Environment> env)
return return_code;
}
-int do_list_dep_tag_categories()
-{
- int return_code(1);
-
- std::set<std::string> keys;
- DepTagCategoryMaker::get_instance()->copy_keys(std::inserter(keys, keys.begin()));
-
- if (! keys.empty())
- {
- return_code = 0;
- for (std::set<std::string>::const_iterator k(keys.begin()), k_end(keys.end()) ;
- k != k_end ; ++k)
- std::cout << "* " << colour(cl_key_name, *k) << std::endl;
- }
-
- return return_code;
-}
-
int do_regenerate_cache(std::tr1::shared_ptr<Environment> env, bool installed)
{
Context context("When performing cache regeneration action from command line:");
diff --git a/src/clients/paludis/applets.hh b/src/clients/paludis/applets.hh
index e3f0544..2280aa3 100644
--- a/src/clients/paludis/applets.hh
+++ b/src/clients/paludis/applets.hh
@@ -52,9 +52,6 @@ int do_list_repository_formats();
/// Handle --list-sync-protocols
int do_list_sync_protocols(std::tr1::shared_ptr<paludis::Environment>);
-/// Handle --list-dep-tag-categories
-int do_list_dep_tag_categories();
-
/// Handle cache regeneration
int do_regenerate_cache(std::tr1::shared_ptr<paludis::Environment>, bool installed);
diff --git a/src/clients/paludis/command_line.cc b/src/clients/paludis/command_line.cc
index ea63156..14f49ae 100644
--- a/src/clients/paludis/command_line.cc
+++ b/src/clients/paludis/command_line.cc
@@ -60,7 +60,6 @@ CommandLine::CommandLine() :
a_list_sync_protocols(&action_args_internal, "list-sync-protocols", '\0', "List available sync protocols", false),
a_list_repository_formats(&action_args_internal, "list-repository-formats", '\0',
"List available repository formats", false),
- a_list_dep_tag_categories(&action_args_internal, "list-dep-tag-categories", '\0', "List known dep tag categories", false),
a_regenerate_installed_cache(&action_args_internal, "regenerate-installed-cache", '\0',
"Regenerate (non-metadata) cache for installed repositories", false),
a_regenerate_installable_cache(&action_args_internal, "regenerate-installable-cache", '\0',
diff --git a/src/clients/paludis/command_line.hh b/src/clients/paludis/command_line.hh
index 153a735..ca0fd9c 100644
--- a/src/clients/paludis/command_line.hh
+++ b/src/clients/paludis/command_line.hh
@@ -137,9 +137,6 @@ class CommandLine :
/// --list-repository-formats
paludis::args::SwitchArg a_list_repository_formats;
- /// --list-dep-tag-categories
- paludis::args::SwitchArg a_list_dep_tag_categories;
-
/// --regenerate-installed-cache
paludis::args::SwitchArg a_regenerate_installed_cache;
diff --git a/src/clients/paludis/list_dep_tag_categories_TEST b/src/clients/paludis/list_dep_tag_categories_TEST
deleted file mode 100755
index 680f706..0000000
--- a/src/clients/paludis/list_dep_tag_categories_TEST
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/env bash
-
-PALUDIS_SKIP_CONFIG=yes ./paludis --list-dep-tag-categories
diff --git a/src/clients/paludis/paludis.cc b/src/clients/paludis/paludis.cc
index cd452f1..053e03d 100644
--- a/src/clients/paludis/paludis.cc
+++ b/src/clients/paludis/paludis.cc
@@ -183,7 +183,6 @@ main(int argc, char *argv[])
CommandLine::get_instance()->a_list_sets.specified() +
CommandLine::get_instance()->a_list_sync_protocols.specified() +
CommandLine::get_instance()->a_list_repository_formats.specified() +
- CommandLine::get_instance()->a_list_dep_tag_categories.specified() +
CommandLine::get_instance()->a_contents.specified() +
CommandLine::get_instance()->a_executables.specified() +
CommandLine::get_instance()->a_owner.specified() +
@@ -210,14 +209,6 @@ main(int argc, char *argv[])
return do_list_repository_formats();
}
- if (CommandLine::get_instance()->a_list_dep_tag_categories.specified())
- {
- if (! CommandLine::get_instance()->empty())
- throw args::DoHelp("list-dep-tag-categories action takes no parameters");
-
- return do_list_dep_tag_categories();
- }
-
/* these actions do need Environment or paludis_command */
std::string paludis_command(argv[0]), env_spec;
diff --git a/src/output/console_install_task.cc b/src/output/console_install_task.cc
index 5277550..f5bf97b 100644
--- a/src/output/console_install_task.cc
+++ b/src/output/console_install_task.cc
@@ -672,8 +672,7 @@ ConsoleInstallTask::display_merge_list_post_tags()
for (std::set<std::string>::iterator cat(tag_categories.begin()),
cat_end(tag_categories.end()) ; cat != cat_end ; ++cat)
{
- std::tr1::shared_ptr<const DepTagCategory> c(DepTagCategoryMaker::get_instance()->
- find_maker(*cat)());
+ std::tr1::shared_ptr<const DepTagCategory> c(DepTagCategoryFactory::get_instance()->create(*cat));
if (! c->visible())
continue;