aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-08-14 14:13:08 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-08-14 14:13:33 +0100
commit22f82c679d12c2a00bed70664a112a5870fa9570 (patch)
tree54c5aa8844c93068248fda90d7db9ecd15119c30
parent0df61ec1cd67846d28dbee79e4ba8dec79b6dfb2 (diff)
downloadpaludis-22f82c679d12c2a00bed70664a112a5870fa9570.tar.gz
paludis-22f82c679d12c2a00bed70664a112a5870fa9570.tar.xz
Remove more VirtualConstructor use.
-rw-r--r--paludis/repositories/e/e_repository.cc6
-rw-r--r--paludis/repositories/e/e_repository_entries.cc24
-rw-r--r--paludis/repositories/e/e_repository_entries.hh37
-rw-r--r--paludis/repositories/e/layout.cc27
-rw-r--r--paludis/repositories/e/layout.hh40
-rw-r--r--paludis/repository.hh1
6 files changed, 53 insertions, 82 deletions
diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc
index 1935fb2..d5d9ee5 100644
--- a/paludis/repositories/e/e_repository.cc
+++ b/paludis/repositories/e/e_repository.cc
@@ -208,10 +208,8 @@ namespace paludis
has_mirrors(false),
has_profiles_desc(false),
sets_ptr(new ERepositorySets(params.environment, r, p)),
- entries_ptr(erepository::ERepositoryEntriesMaker::get_instance()->find_maker(
- params.entry_format)(params.environment, r, p)),
- layout(erepository::LayoutMaker::get_instance()->find_maker(
- params.layout)(r, params.location, entries_ptr, params.master_repository ?
+ entries_ptr(erepository::ERepositoryEntriesFactory::get_instance()->create(params.entry_format, params.environment, r, p)),
+ layout(erepository::LayoutFactory::get_instance()->create(params.layout, r, params.location, entries_ptr, params.master_repository ?
make_shared_ptr(new FSEntry(params.master_repository->params().location)) :
std::tr1::shared_ptr<FSEntry>())),
format_key(new LiteralMetadataValueKey<std::string> ("format", "format",
diff --git a/paludis/repositories/e/e_repository_entries.cc b/paludis/repositories/e/e_repository_entries.cc
index 6b3152c..b3f45be 100644
--- a/paludis/repositories/e/e_repository_entries.cc
+++ b/paludis/repositories/e/e_repository_entries.cc
@@ -19,30 +19,30 @@
#include "e_repository_entries.hh"
#include "ebuild_entries.hh"
-#include <paludis/util/virtual_constructor-impl.hh>
#include <paludis/util/instantiation_policy-impl.hh>
+#include <paludis/util/make_shared_ptr.hh>
using namespace paludis;
using namespace paludis::erepository;
-
-template class VirtualConstructor<std::string,
- std::tr1::shared_ptr<ERepositoryEntries> (*) (const Environment * const, ERepository * const,
- const ERepositoryParams &),
- virtual_constructor_not_found::ThrowException<NoSuchERepositoryEntriesType> >;
-
-template class InstantiationPolicy<ERepositoryEntriesMaker, instantiation_method::SingletonTag>;
+template class InstantiationPolicy<ERepositoryEntriesFactory, instantiation_method::SingletonTag>;
ERepositoryEntries::~ERepositoryEntries()
{
}
-NoSuchERepositoryEntriesType::NoSuchERepositoryEntriesType(const std::string & format) throw ():
- ConfigurationError("No available maker for E Repository entries type '" + format + "'")
+ERepositoryEntriesFactory::ERepositoryEntriesFactory()
{
}
-ERepositoryEntriesMaker::ERepositoryEntriesMaker()
+const std::tr1::shared_ptr<ERepositoryEntries>
+ERepositoryEntriesFactory::create(
+ const std::string & s,
+ const Environment * const env,
+ ERepository * const r,
+ const ERepositoryParams & p) const
{
- register_maker("ebuild", &EbuildEntries::make_ebuild_entries);
+ if (s == "ebuild" || s == "exheres")
+ return make_shared_ptr(new EbuildEntries(env, r, p));
+ throw ConfigurationError("Unrecognised entries type '" + s + "'");
}
diff --git a/paludis/repositories/e/e_repository_entries.hh b/paludis/repositories/e/e_repository_entries.hh
index 86e0d01..eea36e9 100644
--- a/paludis/repositories/e/e_repository_entries.hh
+++ b/paludis/repositories/e/e_repository_entries.hh
@@ -27,7 +27,6 @@
#include <paludis/package_id-fwd.hh>
#include <paludis/environment-fwd.hh>
#include <paludis/util/instantiation_policy.hh>
-#include <paludis/util/virtual_constructor.hh>
#include <paludis/repositories/e/e_repository_profile.hh>
#include <paludis/repositories/e/e_repository_params.hh>
#include <paludis/repositories/e/e_repository_id.hh>
@@ -129,37 +128,25 @@ namespace paludis
};
/**
- * Thrown if a repository of the specified type does not exist.
- *
- * \ingroup grpexceptions
- * \ingroup grprepository
- * \nosubgrouping
- */
- class PALUDIS_VISIBLE NoSuchERepositoryEntriesType : public ConfigurationError
- {
- public:
- /**
- * Constructor.
- */
- NoSuchERepositoryEntriesType(const std::string & format) throw ();
- };
-
- /**
* Virtual constructor for ERepositoryEntries.
*
* \ingroup grprepository
*/
- class PALUDIS_VISIBLE ERepositoryEntriesMaker :
- public VirtualConstructor<std::string,
- std::tr1::shared_ptr<ERepositoryEntries> (*) (const Environment * const, ERepository * const,
- const ERepositoryParams &),
- virtual_constructor_not_found::ThrowException<NoSuchERepositoryEntriesType> >,
- public InstantiationPolicy<ERepositoryEntriesMaker, instantiation_method::SingletonTag>
+ class PALUDIS_VISIBLE ERepositoryEntriesFactory :
+ public InstantiationPolicy<ERepositoryEntriesFactory, instantiation_method::SingletonTag>
{
- friend class InstantiationPolicy<ERepositoryEntriesMaker, instantiation_method::SingletonTag>;
+ friend class InstantiationPolicy<ERepositoryEntriesFactory, instantiation_method::SingletonTag>;
private:
- ERepositoryEntriesMaker();
+ ERepositoryEntriesFactory();
+
+ public:
+ const std::tr1::shared_ptr<ERepositoryEntries> create(
+ const std::string &,
+ const Environment * const,
+ ERepository * const,
+ const ERepositoryParams &)
+ const PALUDIS_ATTRIBUTE((warn_unused_result));
};
}
}
diff --git a/paludis/repositories/e/layout.cc b/paludis/repositories/e/layout.cc
index 95de508..9e25875 100644
--- a/paludis/repositories/e/layout.cc
+++ b/paludis/repositories/e/layout.cc
@@ -22,20 +22,13 @@
#include <paludis/repositories/e/traditional_layout.hh>
#include <paludis/repositories/e/exheres_layout.hh>
#include <paludis/util/fs_entry.hh>
-#include <paludis/util/virtual_constructor-impl.hh>
#include <paludis/util/instantiation_policy-impl.hh>
#include <paludis/util/map-impl.hh>
using namespace paludis;
using namespace paludis::erepository;
-template class VirtualConstructor<std::string,
- std::tr1::shared_ptr<Layout> (*) (const ERepository * const, const FSEntry &,
- std::tr1::shared_ptr<const ERepositoryEntries>,
- std::tr1::shared_ptr<const FSEntry>),
- virtual_constructor_not_found::ThrowException<NoSuchLayoutType> >;
-
-template class InstantiationPolicy<LayoutMaker, instantiation_method::SingletonTag>;
+template class InstantiationPolicy<LayoutFactory, instantiation_method::SingletonTag>;
template class Map<FSEntry, std::string>;
@@ -72,14 +65,22 @@ namespace
}
}
-LayoutMaker::LayoutMaker()
+LayoutFactory::LayoutFactory()
{
- register_maker("traditional", &make_layout<TraditionalLayout>);
- register_maker("exheres", &make_layout<ExheresLayout>);
}
-NoSuchLayoutType::NoSuchLayoutType(const std::string & format) throw () :
- ConfigurationError("No available maker for E repository layout type '" + format + "'")
+const std::tr1::shared_ptr<Layout>
+LayoutFactory::create(
+ const std::string & s,
+ const ERepository * const r,
+ const FSEntry & f,
+ const std::tr1::shared_ptr<const ERepositoryEntries> & e,
+ const std::tr1::shared_ptr<const FSEntry> & ff) const
{
+ if (s == "traditional")
+ return make_layout<TraditionalLayout>(r, f, e, ff);
+ if (s == "exheres")
+ return make_layout<ExheresLayout>(r, f, e, ff);
+ throw ConfigurationError("Unrecognised layout '" + s + "'");
}
diff --git a/paludis/repositories/e/layout.hh b/paludis/repositories/e/layout.hh
index 523306c..93d63df 100644
--- a/paludis/repositories/e/layout.hh
+++ b/paludis/repositories/e/layout.hh
@@ -27,7 +27,6 @@
#include <paludis/util/attributes.hh>
#include <paludis/util/fs_entry-fwd.hh>
#include <paludis/util/exception.hh>
-#include <paludis/util/virtual_constructor.hh>
#include <paludis/util/map-fwd.hh>
#include <paludis/repositories/e/use_desc.hh>
#include <tr1/memory>
@@ -157,39 +156,26 @@ namespace paludis
};
/**
- * Thrown if a layout of the specified type does not exist.
- *
- * \ingroup grpexceptions
- * \ingroup grperepository
- * \nosubgrouping
- */
- class PALUDIS_VISIBLE NoSuchLayoutType :
- public ConfigurationError
- {
- public:
- /**
- * Constructor.
- */
- NoSuchLayoutType(const std::string & format) throw ();
- };
-
- /**
* Virtual constructor for Layout.
*
* \ingroup grperepository
*/
- class PALUDIS_VISIBLE LayoutMaker :
- public VirtualConstructor<std::string,
- std::tr1::shared_ptr<Layout> (*) (const ERepository * const, const FSEntry &,
- std::tr1::shared_ptr<const ERepositoryEntries>,
- std::tr1::shared_ptr<const FSEntry>),
- virtual_constructor_not_found::ThrowException<NoSuchLayoutType> >,
- public InstantiationPolicy<LayoutMaker, instantiation_method::SingletonTag>
+ class PALUDIS_VISIBLE LayoutFactory :
+ public InstantiationPolicy<LayoutFactory, instantiation_method::SingletonTag>
{
- friend class InstantiationPolicy<LayoutMaker, instantiation_method::SingletonTag>;
+ friend class InstantiationPolicy<LayoutFactory, instantiation_method::SingletonTag>;
private:
- LayoutMaker();
+ LayoutFactory();
+
+ public:
+ const std::tr1::shared_ptr<Layout> create(
+ const std::string &,
+ const ERepository * const,
+ const FSEntry &,
+ const std::tr1::shared_ptr<const ERepositoryEntries> &,
+ const std::tr1::shared_ptr<const FSEntry> &)
+ const PALUDIS_ATTRIBUTE((warn_unused_result));
};
}
}
diff --git a/paludis/repository.hh b/paludis/repository.hh
index 43a7e71..0db0581 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -31,7 +31,6 @@
#include <paludis/util/exception.hh>
#include <paludis/util/sr.hh>
#include <paludis/util/fs_entry.hh>
-#include <paludis/util/virtual_constructor.hh>
#include <paludis/util/wrapped_forward_iterator-fwd.hh>
#include <paludis/util/options.hh>
#include <paludis/util/named_value.hh>