aboutsummaryrefslogtreecommitdiff
path: root/paludis
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 /paludis
parent0f3eb4b7da157630049ad93334338c4ba796304c (diff)
downloadpaludis-aacbe32dcf604490ce9211d40c0d11a6e78a4cdf.tar.gz
paludis-aacbe32dcf604490ce9211d40c0d11a6e78a4cdf.tar.xz
DepTagCategoryMaker -> DepTagCategoryFactory
Diffstat (limited to 'paludis')
-rw-r--r--paludis/dep_tag-fwd.hh6
-rw-r--r--paludis/dep_tag.cc47
-rw-r--r--paludis/dep_tag.hh43
3 files changed, 37 insertions, 59 deletions
diff --git a/paludis/dep_tag-fwd.hh b/paludis/dep_tag-fwd.hh
index a480caca2..c8ed8cd14 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 1b5b1ce73..6923c20e1 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 03984b481..4210f1373 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