aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-12-26 14:03:43 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-12-26 14:03:43 +0000
commitae63cf0e67bc73e0fe07f848f3a9e726f2e2d120 (patch)
tree04a18a12fbe9e2d945dec9f5e4456d516193570c
parent99b4ef766712ab455f5a510730b6d248b5c73028 (diff)
downloadpaludis-ae63cf0e67bc73e0fe07f848f3a9e726f2e2d120.tar.gz
paludis-ae63cf0e67bc73e0fe07f848f3a9e726f2e2d120.tar.xz
New virtual constructor that is much less sensitive to broken linkers
-rw-r--r--paludis/dep_tag.cc31
-rw-r--r--paludis/dep_tag.hh12
-rw-r--r--paludis/environment/default/default_environment.cc1
-rw-r--r--paludis/environment/no_config/no_config_environment.cc1
-rw-r--r--paludis/files.m42
-rw-r--r--paludis/qa/changelog_check.hh3
-rw-r--r--paludis/qa/create_metadata_check.hh3
-rw-r--r--paludis/qa/defaults_check.hh3
-rw-r--r--paludis/qa/dep_any_check.hh3
-rw-r--r--paludis/qa/dep_flags_check.hh3
-rw-r--r--paludis/qa/dep_packages_check.hh3
-rw-r--r--paludis/qa/deprecated_functions_check.hh3
-rw-r--r--paludis/qa/deps_exist_check.hh3
-rw-r--r--paludis/qa/deps_visible_check.hh4
-rw-r--r--paludis/qa/description_check.hh3
-rw-r--r--paludis/qa/digest_collisions_check.hh3
-rw-r--r--paludis/qa/ebuild_check.cc38
-rw-r--r--paludis/qa/ebuild_check.hh14
-rw-r--r--paludis/qa/ebuild_count_check.hh3
-rw-r--r--paludis/qa/extract_check.hh3
-rw-r--r--paludis/qa/file_check.cc24
-rw-r--r--paludis/qa/file_check.hh15
-rw-r--r--paludis/qa/file_permissions_check.hh3
-rw-r--r--paludis/qa/filename_check.hh3
-rw-r--r--paludis/qa/files_dir_size_check.hh3
-rw-r--r--paludis/qa/glep_31_check.hh3
-rw-r--r--paludis/qa/gpg_check.hh3
-rw-r--r--paludis/qa/has_ebuilds_check.hh3
-rw-r--r--paludis/qa/has_misc_files_check.hh3
-rw-r--r--paludis/qa/homepage_check.hh3
-rw-r--r--paludis/qa/inherits_check.hh3
-rw-r--r--paludis/qa/iuse_check.hh3
-rw-r--r--paludis/qa/keywords_check.hh3
-rw-r--r--paludis/qa/license_check.hh3
-rw-r--r--paludis/qa/metadata_check.hh3
-rw-r--r--paludis/qa/package_dir_check.cc25
-rw-r--r--paludis/qa/package_dir_check.hh14
-rw-r--r--paludis/qa/package_name_check.hh3
-rw-r--r--paludis/qa/parse_deps_check.hh3
-rw-r--r--paludis/qa/pdepend_overlap_check.hh3
-rw-r--r--paludis/qa/per_profile_ebuild_check.cc6
-rw-r--r--paludis/qa/per_profile_ebuild_check.hh14
-rw-r--r--paludis/qa/restrict_check.hh3
-rw-r--r--paludis/qa/slot_check.hh3
-rw-r--r--paludis/qa/src_uri_check.hh3
-rw-r--r--paludis/qa/subshell_die_check.hh3
-rw-r--r--paludis/qa/variable_assigns_check.hh3
-rw-r--r--paludis/qa/whitespace_check.hh3
-rw-r--r--paludis/repositories/cran/Makefile.am1
-rw-r--r--paludis/repositories/cran/cran_installed_repository.cc11
-rw-r--r--paludis/repositories/cran/cran_repository.cc14
-rw-r--r--paludis/repositories/cran/registration.cc42
-rw-r--r--paludis/repositories/fake/fake_repository.cc18
-rw-r--r--paludis/repositories/gems/Makefile.am1
-rw-r--r--paludis/repositories/gems/make_gems_repository.cc12
-rw-r--r--paludis/repositories/gems/registration.cc40
-rw-r--r--paludis/repositories/nothing/Makefile.am6
-rw-r--r--paludis/repositories/nothing/nothing_repository.cc12
-rw-r--r--paludis/repositories/nothing/registration.cc40
-rw-r--r--paludis/repositories/portage/Makefile.am1
-rw-r--r--paludis/repositories/portage/ebuild_entries.cc12
-rw-r--r--paludis/repositories/portage/make_ebuild_repository.cc27
-rw-r--r--paludis/repositories/portage/portage_repository_entries.cc5
-rw-r--r--paludis/repositories/portage/portage_repository_entries.hh13
-rw-r--r--paludis/repositories/portage/registration.cc54
-rw-r--r--paludis/repositories/portage/xml_things.cc18
-rw-r--r--paludis/repositories/vdb/Makefile.am6
-rw-r--r--paludis/repositories/vdb/registration.cc40
-rw-r--r--paludis/repositories/vdb/vdb_repository.cc12
-rw-r--r--paludis/repositories/virtuals/Makefile.am1
-rw-r--r--paludis/repositories/virtuals/installed_virtuals_repository.cc12
-rw-r--r--paludis/repositories/virtuals/registration.cc42
-rw-r--r--paludis/repositories/virtuals/virtuals_repository.cc12
-rw-r--r--paludis/repository.hh10
-rw-r--r--paludis/repository_maker.cc (renamed from paludis/repository_so_loader.cc)127
-rw-r--r--paludis/repository_maker.hh80
-rw-r--r--paludis/syncer.cc103
-rw-r--r--paludis/syncer.hh12
-rw-r--r--paludis/util/virtual_constructor.hh42
-rw-r--r--paludis/util/virtual_constructor_TEST.cc188
80 files changed, 754 insertions, 563 deletions
diff --git a/paludis/dep_tag.cc b/paludis/dep_tag.cc
index ebf0728..76f91fd 100644
--- a/paludis/dep_tag.cc
+++ b/paludis/dep_tag.cc
@@ -51,14 +51,6 @@ namespace
}
/**
- * Register the GLSA dep tag category instance.
- *
- * \ingroup grpdeptag
- */
- static const DepTagCategoryMaker::RegisterMaker register_glsa_dep_tag("glsa",
- &make_glsa_dep_tag);
-
- /**
* Create the DepTagCategory for general sets.
*
* \see register_general_set_dep_tag
@@ -77,14 +69,6 @@ namespace
}
/**
- * Register the general set dep tag category instance.
- *
- * \ingroup grpdeptag
- */
- static const DepTagCategoryMaker::RegisterMaker register_general_set_dep_tag("general",
- &make_general_set_dep_tag);
-
- /**
* Create the DepTagCategory for dependency sets.
*
* \see register_dependency_set_dep_tag
@@ -101,14 +85,6 @@ namespace
"",
""));
}
-
- /**
- * Register the general set dep tag category instance.
- *
- * \ingroup grpdeptag
- */
- static const DepTagCategoryMaker::RegisterMaker register_dependency_set_dep_tag("dependency",
- &make_dependency_set_dep_tag);
}
DepTagCategory::DepTagCategory(
@@ -204,3 +180,10 @@ DependencyDepTag::category() const
return "dependency";
}
+DepTagCategoryMaker::DepTagCategoryMaker()
+{
+ register_maker("glsa", &make_glsa_dep_tag);
+ register_maker("general", &make_general_set_dep_tag);
+ register_maker("dependency", &make_dependency_set_dep_tag);
+}
+
diff --git a/paludis/dep_tag.hh b/paludis/dep_tag.hh
index c37010e..d443c91 100644
--- a/paludis/dep_tag.hh
+++ b/paludis/dep_tag.hh
@@ -140,8 +140,16 @@ namespace paludis
*
* \ingroup grpdeptag
*/
- typedef VirtualConstructor<std::string, DepTagCategory::ConstPointer (*) (),
- virtual_constructor_not_found::ThrowException<NoSuchDepTagCategory> > DepTagCategoryMaker;
+ class DepTagCategoryMaker :
+ public VirtualConstructor<std::string, DepTagCategory::ConstPointer (*) (),
+ virtual_constructor_not_found::ThrowException<NoSuchDepTagCategory> >,
+ public InstantiationPolicy<DepTagCategoryMaker, instantiation_method::SingletonAsNeededTag>
+ {
+ friend class InstantiationPolicy<DepTagCategoryMaker, instantiation_method::SingletonAsNeededTag>;
+
+ private:
+ DepTagCategoryMaker();
+ };
class DepTag;
class GLSADepTag;
diff --git a/paludis/environment/default/default_environment.cc b/paludis/environment/default/default_environment.cc
index 6cbd4c6..945e6bc 100644
--- a/paludis/environment/default/default_environment.cc
+++ b/paludis/environment/default/default_environment.cc
@@ -24,6 +24,7 @@
#include <paludis/match_package.hh>
#include <paludis/package_database.hh>
#include <paludis/repository.hh>
+#include <paludis/repository_maker.hh>
#include <paludis/util/collection_concrete.hh>
#include <paludis/util/is_file_with_extension.hh>
#include <paludis/util/log.hh>
diff --git a/paludis/environment/no_config/no_config_environment.cc b/paludis/environment/no_config/no_config_environment.cc
index 2478d9f..24e3973 100644
--- a/paludis/environment/no_config/no_config_environment.cc
+++ b/paludis/environment/no_config/no_config_environment.cc
@@ -23,6 +23,7 @@
#include <paludis/util/log.hh>
#include <paludis/util/dir_iterator.hh>
#include <paludis/repositories/portage/portage_repository.hh>
+#include <paludis/repository_maker.hh>
#include <paludis/config_file.hh>
#include <set>
diff --git a/paludis/files.m4 b/paludis/files.m4
index f9dd615..d806266 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -29,8 +29,8 @@ add(`paludis', `hh', `cc')
add(`portage_dep_lexer', `hh', `cc', `test')
add(`portage_dep_parser', `hh', `cc', `test')
add(`repository', `hh', `cc', `sr')
+add(`repository_maker', `hh', `cc')
add(`repository_name_cache', `hh', `cc', `test', `testscript')
-add(`repository_so_loader', `cc')
add(`syncer', `hh', `cc', `sr')
add(`version_metadata', `hh', `cc', `sr')
add(`version_operator', `hh', `cc', `test')
diff --git a/paludis/qa/changelog_check.hh b/paludis/qa/changelog_check.hh
index 8da85e9..41486e1 100644
--- a/paludis/qa/changelog_check.hh
+++ b/paludis/qa/changelog_check.hh
@@ -47,9 +47,6 @@ namespace paludis
return "Checks that the ChangeLog is a regular file";
}
};
-
- static const FileCheckMaker::RegisterMaker register_changelog_check(
- ChangeLogCheck::identifier(), &MakeFileCheck<ChangeLogCheck>::make_file_check);
}
}
diff --git a/paludis/qa/create_metadata_check.hh b/paludis/qa/create_metadata_check.hh
index 109cfc8..77714b6 100644
--- a/paludis/qa/create_metadata_check.hh
+++ b/paludis/qa/create_metadata_check.hh
@@ -52,9 +52,6 @@ namespace paludis
return true;
}
};
-
- static const EbuildCheckMaker::RegisterMaker register_create_metadata_check(
- CreateMetadataCheck::identifier(), &MakeEbuildCheck<CreateMetadataCheck>::make_ebuild_check);
}
}
diff --git a/paludis/qa/defaults_check.hh b/paludis/qa/defaults_check.hh
index 8c6beaa..c29a50f 100644
--- a/paludis/qa/defaults_check.hh
+++ b/paludis/qa/defaults_check.hh
@@ -48,9 +48,6 @@ namespace paludis
return "Checks for default function reimplementations";
}
};
-
- static const FileCheckMaker::RegisterMaker register_defaults_check(
- DefaultsCheck::identifier(), &MakeFileCheck<DefaultsCheck>::make_file_check);
}
}
diff --git a/paludis/qa/dep_any_check.hh b/paludis/qa/dep_any_check.hh
index ed2968b..abc06e6 100644
--- a/paludis/qa/dep_any_check.hh
+++ b/paludis/qa/dep_any_check.hh
@@ -47,9 +47,6 @@ namespace paludis
return "Checks || ( ) block sanity in *DEPEND";
}
};
-
- static const EbuildCheckMaker::RegisterMaker register_dep_any_check(
- DepAnyCheck::identifier(), &MakeEbuildCheck<DepAnyCheck>::make_ebuild_check);
}
}
diff --git a/paludis/qa/dep_flags_check.hh b/paludis/qa/dep_flags_check.hh
index 97f2dd0..4c830d4 100644
--- a/paludis/qa/dep_flags_check.hh
+++ b/paludis/qa/dep_flags_check.hh
@@ -47,9 +47,6 @@ namespace paludis
return "Checks use? flags in metadata";
}
};
-
- static const EbuildCheckMaker::RegisterMaker register_dep_flags_check(
- DepFlagsCheck::identifier(), &MakeEbuildCheck<DepFlagsCheck>::make_ebuild_check);
}
}
diff --git a/paludis/qa/dep_packages_check.hh b/paludis/qa/dep_packages_check.hh
index 96782a4..546c08b 100644
--- a/paludis/qa/dep_packages_check.hh
+++ b/paludis/qa/dep_packages_check.hh
@@ -47,9 +47,6 @@ namespace paludis
return "Checks for packages that usually should not be in *DEPEND";
}
};
-
- static const EbuildCheckMaker::RegisterMaker register_dep_packages_check(
- DepPackagesCheck::identifier(), &MakeEbuildCheck<DepPackagesCheck>::make_ebuild_check);
}
}
diff --git a/paludis/qa/deprecated_functions_check.hh b/paludis/qa/deprecated_functions_check.hh
index e3dab8d..d609b9f 100644
--- a/paludis/qa/deprecated_functions_check.hh
+++ b/paludis/qa/deprecated_functions_check.hh
@@ -47,9 +47,6 @@ namespace paludis
return "Checks for deprecated functions";
}
};
-
- static const FileCheckMaker::RegisterMaker register_deprecated_functions_check(
- DeprecatedFunctionsCheck::identifier(), &MakeFileCheck<DeprecatedFunctionsCheck>::make_file_check);
}
}
diff --git a/paludis/qa/deps_exist_check.hh b/paludis/qa/deps_exist_check.hh
index 43cb9df..7b79ca8 100644
--- a/paludis/qa/deps_exist_check.hh
+++ b/paludis/qa/deps_exist_check.hh
@@ -47,9 +47,6 @@ namespace paludis
return "Checks that packages in *DEPEND exist";
}
};
-
- static const EbuildCheckMaker::RegisterMaker register_deps_exist_check(
- DepsExistCheck::identifier(), &MakeEbuildCheck<DepsExistCheck>::make_ebuild_check);
}
}
diff --git a/paludis/qa/deps_visible_check.hh b/paludis/qa/deps_visible_check.hh
index 0b2b151..ad26f63 100644
--- a/paludis/qa/deps_visible_check.hh
+++ b/paludis/qa/deps_visible_check.hh
@@ -47,10 +47,6 @@ namespace paludis
return "Checks that packages in *DEPEND are visible";
}
};
-
- static const PerProfileEbuildCheckMaker::RegisterMaker register_deps_visible_check(
- DepsVisibleCheck::identifier(),
- &MakePerProfileEbuildCheck<DepsVisibleCheck>::make_per_profile_ebuild_check);
}
}
diff --git a/paludis/qa/description_check.hh b/paludis/qa/description_check.hh
index c3c547c..d6c3c40 100644
--- a/paludis/qa/description_check.hh
+++ b/paludis/qa/description_check.hh
@@ -47,9 +47,6 @@ namespace paludis
return "Checks that DESCRIPTION is sane";
}
};
-
- static const EbuildCheckMaker::RegisterMaker register_description_check(
- DescriptionCheck::identifier(), &MakeEbuildCheck<DescriptionCheck>::make_ebuild_check);
}
}
diff --git a/paludis/qa/digest_collisions_check.hh b/paludis/qa/digest_collisions_check.hh
index 6024741..d477524 100644
--- a/paludis/qa/digest_collisions_check.hh
+++ b/paludis/qa/digest_collisions_check.hh
@@ -47,9 +47,6 @@ namespace paludis
return "Checks for digest collisions";
}
};
-
- static const PackageDirCheckMaker::RegisterMaker register_digest_collisions_check(
- DigestCollisionsCheck::identifier(), &MakePackageDirCheck<DigestCollisionsCheck>::make_package_dir_check);
}
}
diff --git a/paludis/qa/ebuild_check.cc b/paludis/qa/ebuild_check.cc
index 32dd3ad..05e2bb0 100644
--- a/paludis/qa/ebuild_check.cc
+++ b/paludis/qa/ebuild_check.cc
@@ -18,6 +18,23 @@
*/
#include <paludis/qa/ebuild_check.hh>
+#include <paludis/qa/create_metadata_check.hh>
+#include <paludis/qa/dep_any_check.hh>
+#include <paludis/qa/dep_flags_check.hh>
+#include <paludis/qa/dep_packages_check.hh>
+#include <paludis/qa/deps_exist_check.hh>
+#include <paludis/qa/description_check.hh>
+#include <paludis/qa/extract_check.hh>
+#include <paludis/qa/homepage_check.hh>
+#include <paludis/qa/inherits_check.hh>
+#include <paludis/qa/iuse_check.hh>
+#include <paludis/qa/keywords_check.hh>
+#include <paludis/qa/license_check.hh>
+#include <paludis/qa/parse_deps_check.hh>
+#include <paludis/qa/restrict_check.hh>
+#include <paludis/qa/src_uri_check.hh>
+#include <paludis/qa/pdepend_overlap_check.hh>
+#include <paludis/qa/slot_check.hh>
using namespace paludis;
using namespace paludis::qa;
@@ -33,3 +50,24 @@ NoSuchEbuildCheckTypeError::NoSuchEbuildCheckTypeError(const std::string & s) th
{
}
+EbuildCheckMaker::EbuildCheckMaker()
+{
+ register_maker(CreateMetadataCheck::identifier(), &MakeEbuildCheck<CreateMetadataCheck>::make_ebuild_check);
+ register_maker(DepAnyCheck::identifier(), &MakeEbuildCheck<DepAnyCheck>::make_ebuild_check);
+ register_maker(DepFlagsCheck::identifier(), &MakeEbuildCheck<DepFlagsCheck>::make_ebuild_check);
+ register_maker(DepPackagesCheck::identifier(), &MakeEbuildCheck<DepPackagesCheck>::make_ebuild_check);
+ register_maker(DepsExistCheck::identifier(), &MakeEbuildCheck<DepsExistCheck>::make_ebuild_check);
+ register_maker(DescriptionCheck::identifier(), &MakeEbuildCheck<DescriptionCheck>::make_ebuild_check);
+ register_maker(ExtractCheck::identifier(), &MakeEbuildCheck<ExtractCheck>::make_ebuild_check);
+ register_maker(HomepageCheck::identifier(), &MakeEbuildCheck<HomepageCheck>::make_ebuild_check);
+ register_maker(InheritsCheck::identifier(), &MakeEbuildCheck<InheritsCheck>::make_ebuild_check);
+ register_maker(IuseCheck::identifier(), &MakeEbuildCheck<IuseCheck>::make_ebuild_check);
+ register_maker(KeywordsCheck::identifier(), &MakeEbuildCheck<KeywordsCheck>::make_ebuild_check);
+ register_maker(LicenseCheck::identifier(), &MakeEbuildCheck<LicenseCheck>::make_ebuild_check);
+ register_maker(ParseDepsCheck::identifier(), &MakeEbuildCheck<ParseDepsCheck>::make_ebuild_check);
+ register_maker(RestrictCheck::identifier(), &MakeEbuildCheck<RestrictCheck>::make_ebuild_check);
+ register_maker(SrcUriCheck::identifier(), &MakeEbuildCheck<SrcUriCheck>::make_ebuild_check);
+ register_maker(PdependOverlapCheck::identifier(), &MakeEbuildCheck<PdependOverlapCheck>::make_ebuild_check);
+ register_maker(SlotCheck::identifier(), &MakeEbuildCheck<SlotCheck>::make_ebuild_check);
+}
+
diff --git a/paludis/qa/ebuild_check.hh b/paludis/qa/ebuild_check.hh
index 0de5d80..b7cc839 100644
--- a/paludis/qa/ebuild_check.hh
+++ b/paludis/qa/ebuild_check.hh
@@ -81,10 +81,16 @@ namespace paludis
}
};
- typedef VirtualConstructor<
- std::string,
- EbuildCheck::Pointer (*) (),
- virtual_constructor_not_found::ThrowException<NoSuchEbuildCheckTypeError> > EbuildCheckMaker;
+ class EbuildCheckMaker :
+ public VirtualConstructor<std::string, EbuildCheck::Pointer (*) (),
+ virtual_constructor_not_found::ThrowException<NoSuchEbuildCheckTypeError> >,
+ public InstantiationPolicy<EbuildCheckMaker, instantiation_method::SingletonAsNeededTag>
+ {
+ friend class InstantiationPolicy<EbuildCheckMaker, instantiation_method::SingletonAsNeededTag>;
+
+ private:
+ EbuildCheckMaker();
+ };
}
}
diff --git a/paludis/qa/ebuild_count_check.hh b/paludis/qa/ebuild_count_check.hh
index d2734c9..1526fb4 100644
--- a/paludis/qa/ebuild_count_check.hh
+++ b/paludis/qa/ebuild_count_check.hh
@@ -47,9 +47,6 @@ namespace paludis
return "Checks for a sane number of ebuilds";
}
};
-
- static const PackageDirCheckMaker::RegisterMaker register_ebuild_count_check(
- EbuildCountCheck::identifier(), &MakePackageDirCheck<EbuildCountCheck>::make_package_dir_check);
}
}
diff --git a/paludis/qa/extract_check.hh b/paludis/qa/extract_check.hh
index 18a98af..0ff4082 100644
--- a/paludis/qa/extract_check.hh
+++ b/paludis/qa/extract_check.hh
@@ -46,9 +46,6 @@ namespace paludis
return "Checks that extraction dependencies are correct";
}
};
-
- static const EbuildCheckMaker::RegisterMaker register_extract_check(
- ExtractCheck::identifier(), &MakeEbuildCheck<ExtractCheck>::make_ebuild_check);
}
}
diff --git a/paludis/qa/file_check.cc b/paludis/qa/file_check.cc
index 7af87cd..a8ce7d7 100644
--- a/paludis/qa/file_check.cc
+++ b/paludis/qa/file_check.cc
@@ -18,6 +18,16 @@
*/
#include <paludis/qa/file_check.hh>
+#include <paludis/qa/changelog_check.hh>
+#include <paludis/qa/defaults_check.hh>
+#include <paludis/qa/deprecated_functions_check.hh>
+#include <paludis/qa/filename_check.hh>
+#include <paludis/qa/file_permissions_check.hh>
+#include <paludis/qa/glep_31_check.hh>
+#include <paludis/qa/metadata_check.hh>
+#include <paludis/qa/subshell_die_check.hh>
+#include <paludis/qa/variable_assigns_check.hh>
+#include <paludis/qa/whitespace_check.hh>
using namespace paludis;
using namespace paludis::qa;
@@ -31,3 +41,17 @@ NoSuchFileCheckTypeError::NoSuchFileCheckTypeError(const std::string & s) throw
{
}
+FileCheckMaker::FileCheckMaker()
+{
+ register_maker(ChangeLogCheck::identifier(), &MakeFileCheck<ChangeLogCheck>::make_file_check);
+ register_maker(DefaultsCheck::identifier(), &MakeFileCheck<DefaultsCheck>::make_file_check);
+ register_maker(DeprecatedFunctionsCheck::identifier(), &MakeFileCheck<DeprecatedFunctionsCheck>::make_file_check);
+ register_maker(FileNameCheck::identifier(), &MakeFileCheck<FileNameCheck>::make_file_check);
+ register_maker(FilePermissionsCheck::identifier(), &MakeFileCheck<FilePermissionsCheck>::make_file_check);
+ register_maker(Glep31Check::identifier(), &MakeFileCheck<Glep31Check>::make_file_check);
+ register_maker(MetadataCheck::identifier(), &MakeFileCheck<MetadataCheck>::make_file_check);
+ register_maker(SubshellDieCheck::identifier(), &MakeFileCheck<SubshellDieCheck>::make_file_check);
+ register_maker(VariableAssignsCheck::identifier(), &MakeFileCheck<VariableAssignsCheck>::make_file_check);
+ register_maker(WhitespaceCheck::identifier(), &MakeFileCheck<WhitespaceCheck>::make_file_check);
+}
+
diff --git a/paludis/qa/file_check.hh b/paludis/qa/file_check.hh
index 048af41..17e5a20 100644
--- a/paludis/qa/file_check.hh
+++ b/paludis/qa/file_check.hh
@@ -83,10 +83,16 @@ namespace paludis
*
* \ingroup grpqa
*/
- typedef VirtualConstructor<
- std::string,
- FileCheck::Pointer (*) (),
- virtual_constructor_not_found::ThrowException<NoSuchFileCheckTypeError> > FileCheckMaker;
+ class FileCheckMaker :
+ public VirtualConstructor<std::string, FileCheck::Pointer (*) (),
+ virtual_constructor_not_found::ThrowException<NoSuchFileCheckTypeError> >,
+ public InstantiationPolicy<FileCheckMaker, instantiation_method::SingletonAsNeededTag>
+ {
+ friend class InstantiationPolicy<FileCheckMaker, instantiation_method::SingletonAsNeededTag>;
+
+ private:
+ FileCheckMaker();
+ };
}
}
@@ -98,5 +104,4 @@ paludis::qa::MakeFileCheck<T_>::make_file_check()
return paludis::qa::FileCheck::Pointer(new T_);
}
-
#endif
diff --git a/paludis/qa/file_permissions_check.hh b/paludis/qa/file_permissions_check.hh
index b466cc0..807b7fa 100644
--- a/paludis/qa/file_permissions_check.hh
+++ b/paludis/qa/file_permissions_check.hh
@@ -47,9 +47,6 @@ namespace paludis
return "Checks that file and directory permissions are sane";
}
};
-
- static const FileCheckMaker::RegisterMaker register_file_permissions_check(
- FilePermissionsCheck::identifier(), &MakeFileCheck<FilePermissionsCheck>::make_file_check);
}
}
diff --git a/paludis/qa/filename_check.hh b/paludis/qa/filename_check.hh
index 722fc6d..20dc03a 100644
--- a/paludis/qa/filename_check.hh
+++ b/paludis/qa/filename_check.hh
@@ -52,9 +52,6 @@ namespace paludis
return true;
}
};
-
- static const FileCheckMaker::RegisterMaker register_file_name_check(
- FileNameCheck::identifier(), &MakeFileCheck<FileNameCheck>::make_file_check);
}
}
diff --git a/paludis/qa/files_dir_size_check.hh b/paludis/qa/files_dir_size_check.hh
index 8e9d585..287d494 100644
--- a/paludis/qa/files_dir_size_check.hh
+++ b/paludis/qa/files_dir_size_check.hh
@@ -47,9 +47,6 @@ namespace paludis
return "Checks that files/ (excluding digests) is below 20k";
}
};
-
- static const PackageDirCheckMaker::RegisterMaker register_files_dir_size_check(
- FilesDirSizeCheck::identifier(), &MakePackageDirCheck<FilesDirSizeCheck>::make_package_dir_check);
}
}
diff --git a/paludis/qa/glep_31_check.hh b/paludis/qa/glep_31_check.hh
index b88bcb4..9f47d37 100644
--- a/paludis/qa/glep_31_check.hh
+++ b/paludis/qa/glep_31_check.hh
@@ -50,9 +50,6 @@ namespace paludis
return "Checks that files conform to GLEP 31";
}
};
-
- static const FileCheckMaker::RegisterMaker register_glep_31_check(
- Glep31Check::identifier(), &MakeFileCheck<Glep31Check>::make_file_check);
}
}
diff --git a/paludis/qa/gpg_check.hh b/paludis/qa/gpg_check.hh
index b7e07fb..07b4317 100644
--- a/paludis/qa/gpg_check.hh
+++ b/paludis/qa/gpg_check.hh
@@ -47,9 +47,6 @@ namespace paludis
return "Checks whether the Manifest is signed";
}
};
-
- static const PackageDirCheckMaker::RegisterMaker register_gpg_check(
- GPGCheck::identifier(), &MakePackageDirCheck<GPGCheck>::make_package_dir_check);
}
}
diff --git a/paludis/qa/has_ebuilds_check.hh b/paludis/qa/has_ebuilds_check.hh
index baf2dc3..424a671 100644
--- a/paludis/qa/has_ebuilds_check.hh
+++ b/paludis/qa/has_ebuilds_check.hh
@@ -47,9 +47,6 @@ namespace paludis
return "Checks that there are ebuilds present";
}
};
-
- static const PackageDirCheckMaker::RegisterMaker register_has_ebuilds_check(
- HasEbuildsCheck::identifier(), &MakePackageDirCheck<HasEbuildsCheck>::make_package_dir_check);
}
}
diff --git a/paludis/qa/has_misc_files_check.hh b/paludis/qa/has_misc_files_check.hh
index 3af0006..bfa9c2e 100644
--- a/paludis/qa/has_misc_files_check.hh
+++ b/paludis/qa/has_misc_files_check.hh
@@ -47,9 +47,6 @@ namespace paludis
return "Checks that ChangeLog, metadata.xml, files/ exist";
}
};
-
- static const PackageDirCheckMaker::RegisterMaker register_misc_files_check(
- HasMiscFilesCheck::identifier(), &MakePackageDirCheck<HasMiscFilesCheck>::make_package_dir_check);
}
}
diff --git a/paludis/qa/homepage_check.hh b/paludis/qa/homepage_check.hh
index cc40fbc..2aca08c 100644
--- a/paludis/qa/homepage_check.hh
+++ b/paludis/qa/homepage_check.hh
@@ -47,9 +47,6 @@ namespace paludis
return "Checks that HOMEPAGE is sane";
}
};
-
- static const EbuildCheckMaker::RegisterMaker register_homepage_check(
- HomepageCheck::identifier(), &MakeEbuildCheck<HomepageCheck>::make_ebuild_check);
}
}
diff --git a/paludis/qa/inherits_check.hh b/paludis/qa/inherits_check.hh
index 47ab06f..b0bc59d 100644
--- a/paludis/qa/inherits_check.hh
+++ b/paludis/qa/inherits_check.hh
@@ -47,9 +47,6 @@ namespace paludis
return "Checks that inherits are sane";
}
};
-
- static const EbuildCheckMaker::RegisterMaker register_inherits_check(
- InheritsCheck::identifier(), &MakeEbuildCheck<InheritsCheck>::make_ebuild_check);
}
}
diff --git a/paludis/qa/iuse_check.hh b/paludis/qa/iuse_check.hh
index 37346ed..a1695a7 100644
--- a/paludis/qa/iuse_check.hh
+++ b/paludis/qa/iuse_check.hh
@@ -52,9 +52,6 @@ namespace paludis
return true;
}
};
-
- static const EbuildCheckMaker::RegisterMaker register_iuse_check(
- IuseCheck::identifier(), &MakeEbuildCheck<IuseCheck>::make_ebuild_check);
}
}
diff --git a/paludis/qa/keywords_check.hh b/paludis/qa/keywords_check.hh
index b284fb2..1176a06 100644
--- a/paludis/qa/keywords_check.hh
+++ b/paludis/qa/keywords_check.hh
@@ -47,9 +47,6 @@ namespace paludis
return "Checks that KEYWORDS is sane";
}
};
-
- static const EbuildCheckMaker::RegisterMaker register_keywords_check(
- KeywordsCheck::identifier(), &MakeEbuildCheck<KeywordsCheck>::make_ebuild_check);
}
}
diff --git a/paludis/qa/license_check.hh b/paludis/qa/license_check.hh
index 94cf3cf..985464d 100644
--- a/paludis/qa/license_check.hh
+++ b/paludis/qa/license_check.hh
@@ -47,9 +47,6 @@ namespace paludis
return "Checks that LICENSE is sane";
}
};
-
- static const EbuildCheckMaker::RegisterMaker register_license_check(
- LicenseCheck::identifier(), &MakeEbuildCheck<LicenseCheck>::make_ebuild_check);
}
}
diff --git a/paludis/qa/metadata_check.hh b/paludis/qa/metadata_check.hh
index ab3dbc9..7d2842e 100644
--- a/paludis/qa/metadata_check.hh
+++ b/paludis/qa/metadata_check.hh
@@ -47,9 +47,6 @@ namespace paludis
return "Checks that metadata.xml is valid";
}
};
-
- static const FileCheckMaker::RegisterMaker register_metadata_check(
- MetadataCheck::identifier(), &MakeFileCheck<MetadataCheck>::make_file_check);
}
}
diff --git a/paludis/qa/package_dir_check.cc b/paludis/qa/package_dir_check.cc
index c604251..db55575 100644
--- a/paludis/qa/package_dir_check.cc
+++ b/paludis/qa/package_dir_check.cc
@@ -18,6 +18,13 @@
*/
#include <paludis/qa/package_dir_check.hh>
+#include <paludis/qa/digest_collisions_check.hh>
+#include <paludis/qa/ebuild_count_check.hh>
+#include <paludis/qa/files_dir_size_check.hh>
+#include <paludis/qa/gpg_check.hh>
+#include <paludis/qa/has_ebuilds_check.hh>
+#include <paludis/qa/has_misc_files_check.hh>
+#include <paludis/qa/package_name_check.hh>
using namespace paludis;
using namespace paludis::qa;
@@ -31,3 +38,21 @@ NoSuchPackageDirCheckTypeError::NoSuchPackageDirCheckTypeError(const std::string
{
}
+PackageDirCheckMaker::PackageDirCheckMaker()
+{
+ register_maker(DigestCollisionsCheck::identifier(),
+ &MakePackageDirCheck<DigestCollisionsCheck>::make_package_dir_check);
+ register_maker(EbuildCountCheck::identifier(),
+ &MakePackageDirCheck<EbuildCountCheck>::make_package_dir_check);
+ register_maker(FilesDirSizeCheck::identifier(),
+ &MakePackageDirCheck<FilesDirSizeCheck>::make_package_dir_check);
+ register_maker(GPGCheck::identifier(),
+ &MakePackageDirCheck<GPGCheck>::make_package_dir_check);
+ register_maker(HasEbuildsCheck::identifier(),
+ &MakePackageDirCheck<HasEbuildsCheck>::make_package_dir_check);
+ register_maker(HasMiscFilesCheck::identifier(),
+ &MakePackageDirCheck<HasMiscFilesCheck>::make_package_dir_check);
+ register_maker(PackageNameCheck::identifier(),
+ &MakePackageDirCheck<PackageNameCheck>::make_package_dir_check);
+}
+
diff --git a/paludis/qa/package_dir_check.hh b/paludis/qa/package_dir_check.hh
index fa40c74..3441814 100644
--- a/paludis/qa/package_dir_check.hh
+++ b/paludis/qa/package_dir_check.hh
@@ -87,10 +87,16 @@ namespace paludis
*
* \ingroup grpqa
*/
- typedef VirtualConstructor<
- std::string,
- PackageDirCheck::Pointer (*) (),
- virtual_constructor_not_found::ThrowException<NoSuchPackageDirCheckTypeError> > PackageDirCheckMaker;
+ class PackageDirCheckMaker :
+ public VirtualConstructor<std::string, PackageDirCheck::Pointer (*) (),
+ virtual_constructor_not_found::ThrowException<NoSuchPackageDirCheckTypeError> >,
+ public InstantiationPolicy<PackageDirCheckMaker, instantiation_method::SingletonAsNeededTag>
+ {
+ friend class InstantiationPolicy<PackageDirCheckMaker, instantiation_method::SingletonAsNeededTag>;
+
+ private:
+ PackageDirCheckMaker();
+ };
}
}
#endif
diff --git a/paludis/qa/package_name_check.hh b/paludis/qa/package_name_check.hh
index b661f76..f40b323 100644
--- a/paludis/qa/package_name_check.hh
+++ b/paludis/qa/package_name_check.hh
@@ -52,9 +52,6 @@ namespace paludis
return true;
}
};
-
- static const PackageDirCheckMaker::RegisterMaker register_package_name_check(
- PackageNameCheck::identifier(), &MakePackageDirCheck<PackageNameCheck>::make_package_dir_check);
}
}
diff --git a/paludis/qa/parse_deps_check.hh b/paludis/qa/parse_deps_check.hh
index 82c43a4..321226b 100644
--- a/paludis/qa/parse_deps_check.hh
+++ b/paludis/qa/parse_deps_check.hh
@@ -52,9 +52,6 @@ namespace paludis
return true;
}
};
-
- static const EbuildCheckMaker::RegisterMaker register_parse_deps_check(
- ParseDepsCheck::identifier(), &MakeEbuildCheck<ParseDepsCheck>::make_ebuild_check);
}
}
diff --git a/paludis/qa/pdepend_overlap_check.hh b/paludis/qa/pdepend_overlap_check.hh
index 33b5eb1..8976d7f 100644
--- a/paludis/qa/pdepend_overlap_check.hh
+++ b/paludis/qa/pdepend_overlap_check.hh
@@ -47,9 +47,6 @@ namespace paludis
return "Checks for PDEPEND overlap";
}
};
-
- static const EbuildCheckMaker::RegisterMaker register_pdepend_overlap_check(
- PdependOverlapCheck::identifier(), &MakeEbuildCheck<PdependOverlapCheck>::make_ebuild_check);
}
}
diff --git a/paludis/qa/per_profile_ebuild_check.cc b/paludis/qa/per_profile_ebuild_check.cc
index ffa9f1d..a492cfd 100644
--- a/paludis/qa/per_profile_ebuild_check.cc
+++ b/paludis/qa/per_profile_ebuild_check.cc
@@ -18,6 +18,7 @@
*/
#include "per_profile_ebuild_check.hh"
+#include <paludis/qa/deps_visible_check.hh>
using namespace paludis;
using namespace paludis::qa;
@@ -33,4 +34,9 @@ NoSuchPerProfileEbuildCheckTypeError::NoSuchPerProfileEbuildCheckTypeError(const
{
}
+PerProfileEbuildCheckMaker::PerProfileEbuildCheckMaker()
+{
+ register_maker(DepsVisibleCheck::identifier(),
+ &MakePerProfileEbuildCheck<DepsVisibleCheck>::make_per_profile_ebuild_check);
+}
diff --git a/paludis/qa/per_profile_ebuild_check.hh b/paludis/qa/per_profile_ebuild_check.hh
index a778114..78576ef 100644
--- a/paludis/qa/per_profile_ebuild_check.hh
+++ b/paludis/qa/per_profile_ebuild_check.hh
@@ -82,10 +82,16 @@ namespace paludis
}
};
- typedef VirtualConstructor<
- std::string,
- PerProfileEbuildCheck::Pointer (*) (),
- virtual_constructor_not_found::ThrowException<NoSuchPerProfileEbuildCheckTypeError> > PerProfileEbuildCheckMaker;
+ class PerProfileEbuildCheckMaker :
+ public VirtualConstructor<std::string, PerProfileEbuildCheck::Pointer (*) (),
+ virtual_constructor_not_found::ThrowException<NoSuchPerProfileEbuildCheckTypeError> >,
+ public InstantiationPolicy<PerProfileEbuildCheckMaker, instantiation_method::SingletonAsNeededTag>
+ {
+ friend class InstantiationPolicy<PerProfileEbuildCheckMaker, instantiation_method::SingletonAsNeededTag>;
+
+ private:
+ PerProfileEbuildCheckMaker();
+ };
}
}
diff --git a/paludis/qa/restrict_check.hh b/paludis/qa/restrict_check.hh
index c3706ce..ab26dbc 100644
--- a/paludis/qa/restrict_check.hh
+++ b/paludis/qa/restrict_check.hh
@@ -47,9 +47,6 @@ namespace paludis
return "Checks that RESTRICT is sane";
}
};
-
- static const EbuildCheckMaker::RegisterMaker register_restrict_check(
- RestrictCheck::identifier(), &MakeEbuildCheck<RestrictCheck>::make_ebuild_check);
}
}
diff --git a/paludis/qa/slot_check.hh b/paludis/qa/slot_check.hh
index 1b5f568..f1b5a24 100644
--- a/paludis/qa/slot_check.hh
+++ b/paludis/qa/slot_check.hh
@@ -47,9 +47,6 @@ namespace paludis
return "Checks that SLOT is sane";
}
};
-
- static const EbuildCheckMaker::RegisterMaker register_slot_check(
- SlotCheck::identifier(), &MakeEbuildCheck<SlotCheck>::make_ebuild_check);
}
}
diff --git a/paludis/qa/src_uri_check.hh b/paludis/qa/src_uri_check.hh
index 250e1e3..b9b7b6b 100644
--- a/paludis/qa/src_uri_check.hh
+++ b/paludis/qa/src_uri_check.hh
@@ -47,9 +47,6 @@ namespace paludis
return "Checks that SRC_URI is sane";
}
};
-
- static const EbuildCheckMaker::RegisterMaker register_src_uri_check(
- SrcUriCheck::identifier(), &MakeEbuildCheck<SrcUriCheck>::make_ebuild_check);
}
}
diff --git a/paludis/qa/subshell_die_check.hh b/paludis/qa/subshell_die_check.hh
index 7504a3a..b398f2c 100644
--- a/paludis/qa/subshell_die_check.hh
+++ b/paludis/qa/subshell_die_check.hh
@@ -47,9 +47,6 @@ namespace paludis
return "Checks for call to die functions within subshells";
}
};
-
- static const FileCheckMaker::RegisterMaker register_subshell_die_check(
- SubshellDieCheck::identifier(), &MakeFileCheck<SubshellDieCheck>::make_file_check);
}
}
diff --git a/paludis/qa/variable_assigns_check.hh b/paludis/qa/variable_assigns_check.hh
index 830cfd1..79a88b8 100644
--- a/paludis/qa/variable_assigns_check.hh
+++ b/paludis/qa/variable_assigns_check.hh
@@ -47,9 +47,6 @@ namespace paludis
return "Checks for illegal variable assigns";
}
};
-
- static const FileCheckMaker::RegisterMaker register_variable_assigns_check(
- VariableAssignsCheck::identifier(), &MakeFileCheck<VariableAssignsCheck>::make_file_check);
}
}
diff --git a/paludis/qa/whitespace_check.hh b/paludis/qa/whitespace_check.hh
index 4d237a5..d2365a0 100644
--- a/paludis/qa/whitespace_check.hh
+++ b/paludis/qa/whitespace_check.hh
@@ -47,9 +47,6 @@ namespace paludis
return "Checks whitespace";
}
};
-
- static const FileCheckMaker::RegisterMaker register_whitespace_check(
- WhitespaceCheck::identifier(), &MakeFileCheck<WhitespaceCheck>::make_file_check);
}
}
diff --git a/paludis/repositories/cran/Makefile.am b/paludis/repositories/cran/Makefile.am
index d8e51c6..5aab858 100644
--- a/paludis/repositories/cran/Makefile.am
+++ b/paludis/repositories/cran/Makefile.am
@@ -37,6 +37,7 @@ libpaludiscranrepository_la_SOURCES = \
cran_dep_parser.cc \
cran_repository.cc \
cran_installed_repository.cc \
+ registration.cc \
$(paludis_repositories_cran_include_HEADERS)
libpaludiscranrepository_la_LIBADD = \
diff --git a/paludis/repositories/cran/cran_installed_repository.cc b/paludis/repositories/cran/cran_installed_repository.cc
index fc49132..3879375 100644
--- a/paludis/repositories/cran/cran_installed_repository.cc
+++ b/paludis/repositories/cran/cran_installed_repository.cc
@@ -660,15 +660,4 @@ CRANInstalledRepository::is_suitable_destination_for(const PackageDatabaseEntry
return _imp->env->package_database()->fetch_repository(e.repository)->format() == "cran";
}
-#ifdef PALUDIS_ENABLE_VISIBILITY
-# pragma GCC visibility push(default)
-#endif
-namespace
-{
- const RepositoryMaker::RegisterMaker register_cran_installed_repository PALUDIS_ATTRIBUTE((used)) (
- "cran_installed", &CRANInstalledRepository::make_cran_installed_repository);
-}
-#ifdef PALUDIS_ENABLE_VISIBILITY
-# pragma GCC visibility pop
-#endif
diff --git a/paludis/repositories/cran/cran_repository.cc b/paludis/repositories/cran/cran_repository.cc
index 54d5512..a8f04f4 100644
--- a/paludis/repositories/cran/cran_repository.cc
+++ b/paludis/repositories/cran/cran_repository.cc
@@ -29,6 +29,7 @@
#include <paludis/repositories/cran/cran_dep_parser.hh>
#include <paludis/repositories/cran/cran_description.hh>
#include <paludis/repositories/cran/cran_repository.hh>
+#include <paludis/repository_maker.hh>
#include <paludis/syncer.hh>
#include <paludis/util/collection_concrete.hh>
#include <paludis/util/dir_iterator.hh>
@@ -617,16 +618,3 @@ CRANRepository::invalidate() const
{
_imp->invalidate();
}
-
-#ifdef PALUDIS_ENABLE_VISIBILITY
-# pragma GCC visibility push(default)
-#endif
-namespace
-{
- const RepositoryMaker::RegisterMaker register_cran_repository PALUDIS_ATTRIBUTE((used)) (
- "cran", &CRANRepository::make_cran_repository);
-}
-#ifdef PALUDIS_ENABLE_VISIBILITY
-# pragma GCC visibility pop
-#endif
-
diff --git a/paludis/repositories/cran/registration.cc b/paludis/repositories/cran/registration.cc
new file mode 100644
index 0000000..57b5000
--- /dev/null
+++ b/paludis/repositories/cran/registration.cc
@@ -0,0 +1,42 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/repository_maker.hh>
+#include <paludis/repositories/cran/cran_repository.hh>
+#include <paludis/repositories/cran/cran_installed_repository.hh>
+#include "config.h"
+
+using namespace paludis;
+
+#ifndef MONOLITHIC
+
+extern "C"
+{
+ void register_repositories(RepositoryMaker * maker);
+}
+
+void register_repositories(RepositoryMaker * maker)
+{
+ maker->register_maker("cran", &CRANRepository::make_cran_repository);
+ maker->register_maker("cran_installed", &CRANInstalledRepository::make_cran_installed_repository);
+}
+
+#endif
+
+
diff --git a/paludis/repositories/fake/fake_repository.cc b/paludis/repositories/fake/fake_repository.cc
index d58fdb2..0b5caea 100644
--- a/paludis/repositories/fake/fake_repository.cc
+++ b/paludis/repositories/fake/fake_repository.cc
@@ -47,3 +47,21 @@ FakeRepository::do_install(const QualifiedPackageName &, const VersionSpec &,
{
}
+#ifndef MONOLITHIC
+
+namespace paludis
+{
+ class RepositoryMaker;
+}
+
+extern "C"
+{
+ void register_repositories(RepositoryMaker * maker);
+}
+
+void register_repositories(RepositoryMaker *)
+{
+}
+
+#endif
+
diff --git a/paludis/repositories/gems/Makefile.am b/paludis/repositories/gems/Makefile.am
index 4355a00..9cb5ae4 100644
--- a/paludis/repositories/gems/Makefile.am
+++ b/paludis/repositories/gems/Makefile.am
@@ -43,6 +43,7 @@ libpaludisgemsrepository_la_SOURCES = \
cache.cc \
make_gems_repository.cc \
yaml.cc \
+ registration.cc \
$(paludis_repositories_gems_include_HEADERS)
libpaludisgemsrepository_la_LIBADD = \
diff --git a/paludis/repositories/gems/make_gems_repository.cc b/paludis/repositories/gems/make_gems_repository.cc
index 2e4374f..da51eab 100644
--- a/paludis/repositories/gems/make_gems_repository.cc
+++ b/paludis/repositories/gems/make_gems_repository.cc
@@ -63,16 +63,4 @@ paludis::make_gems_repository(const Environment * const env,
}
-#ifdef PALUDIS_ENABLE_VISIBILITY
-# pragma GCC visibility push(default)
-#endif
-namespace
-{
- const RepositoryMaker::RegisterMaker register_gems_repository PALUDIS_ATTRIBUTE((used)) (
- "gems", &make_gems_repository);
-}
-#ifdef PALUDIS_ENABLE_VISIBILITY
-# pragma GCC visibility pop
-#endif
-
diff --git a/paludis/repositories/gems/registration.cc b/paludis/repositories/gems/registration.cc
new file mode 100644
index 0000000..4902173
--- /dev/null
+++ b/paludis/repositories/gems/registration.cc
@@ -0,0 +1,40 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/repository_maker.hh>
+#include <paludis/repositories/gems/make_gems_repository.hh>
+#include "config.h"
+
+using namespace paludis;
+
+#ifndef MONOLITHIC
+
+extern "C"
+{
+ void register_repositories(RepositoryMaker * maker);
+}
+
+void register_repositories(RepositoryMaker * maker)
+{
+ maker->register_maker("gems", &make_gems_repository);
+}
+
+#endif
+
+
diff --git a/paludis/repositories/nothing/Makefile.am b/paludis/repositories/nothing/Makefile.am
index b191155..c12e690 100644
--- a/paludis/repositories/nothing/Makefile.am
+++ b/paludis/repositories/nothing/Makefile.am
@@ -20,7 +20,11 @@ paludis_repositories_lib_LTLIBRARIES = libpaludisnothingrepository.la
endif
-libpaludisnothingrepository_la_SOURCES = nothing_repository.cc nothing_repository.hh
+libpaludisnothingrepository_la_SOURCES = \
+ nothing_repository.cc \
+ nothing_repository.hh \
+ registration.cc
+
libpaludisnothingrepository_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSION_LIB_REVISION@:0
paludis_repositories_nothing_includedir = $(includedir)/paludis/repositories/nothing/
diff --git a/paludis/repositories/nothing/nothing_repository.cc b/paludis/repositories/nothing/nothing_repository.cc
index 3b69f0d..aa82a92 100644
--- a/paludis/repositories/nothing/nothing_repository.cc
+++ b/paludis/repositories/nothing/nothing_repository.cc
@@ -244,15 +244,3 @@ NothingRepository::invalidate() const
{
}
-#ifdef PALUDIS_ENABLE_VISIBILITY
-# pragma GCC visibility push(default)
-#endif
-namespace
-{
- const RepositoryMaker::RegisterMaker register_nothing_repository PALUDIS_ATTRIBUTE((used)) (
- "nothing", &NothingRepository::make_nothing_repository);
-}
-#ifdef PALUDIS_ENABLE_VISIBILITY
-# pragma GCC visibility pop
-#endif
-
diff --git a/paludis/repositories/nothing/registration.cc b/paludis/repositories/nothing/registration.cc
new file mode 100644
index 0000000..4ca54f8
--- /dev/null
+++ b/paludis/repositories/nothing/registration.cc
@@ -0,0 +1,40 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/repository_maker.hh>
+#include <paludis/repositories/nothing/nothing_repository.hh>
+#include "config.h"
+
+using namespace paludis;
+
+#ifndef MONOLITHIC
+
+extern "C"
+{
+ void register_repositories(RepositoryMaker * maker);
+}
+
+void register_repositories(RepositoryMaker * maker)
+{
+ maker->register_maker("nothing", &NothingRepository::make_nothing_repository);
+}
+
+#endif
+
+
diff --git a/paludis/repositories/portage/Makefile.am b/paludis/repositories/portage/Makefile.am
index 9c61782..7b528ba 100644
--- a/paludis/repositories/portage/Makefile.am
+++ b/paludis/repositories/portage/Makefile.am
@@ -51,6 +51,7 @@ libpaludisportagerepository_la_SOURCES = \
portage_repository_params.cc \
make_ebuild_repository.cc \
use_desc.cc \
+ registration.cc \
$(paludis_repositories_portage_include_HEADERS)
libpaludisportagerepository_la_LIBADD = \
diff --git a/paludis/repositories/portage/ebuild_entries.cc b/paludis/repositories/portage/ebuild_entries.cc
index 5beaa96..0d7cfb1 100644
--- a/paludis/repositories/portage/ebuild_entries.cc
+++ b/paludis/repositories/portage/ebuild_entries.cc
@@ -524,15 +524,3 @@ EbuildEntries::make_ebuild_entries(
return Pointer(new EbuildEntries(e, r, p));
}
-#ifdef PALUDIS_ENABLE_VISIBILITY
-# pragma GCC visibility push(default)
-#endif
-namespace
-{
- const PortageRepositoryEntriesMaker::RegisterMaker register_portage_repository_ebuild_entries PALUDIS_ATTRIBUTE((used)) (
- "ebuild", &EbuildEntries::make_ebuild_entries);
-}
-#ifdef PALUDIS_ENABLE_VISIBILITY
-# pragma GCC visibility pop
-#endif
-
diff --git a/paludis/repositories/portage/make_ebuild_repository.cc b/paludis/repositories/portage/make_ebuild_repository.cc
index 7f24866..4ed483f 100644
--- a/paludis/repositories/portage/make_ebuild_repository.cc
+++ b/paludis/repositories/portage/make_ebuild_repository.cc
@@ -148,30 +148,3 @@ paludis::make_ebuild_repository(
.buildroot(buildroot)));
}
-namespace
-{
- CountedPtr<Repository>
- make_ebuild_repository_wrapped(
- const Environment * const env,
- const PackageDatabase * const db,
- AssociativeCollection<std::string, std::string>::ConstPointer m)
- {
- return make_ebuild_repository(env, db, m);
- }
-}
-
-#ifdef PALUDIS_ENABLE_VISIBILITY
-# pragma GCC visibility push(default)
-#endif
-namespace
-{
- const RepositoryMaker::RegisterMaker register_portage_ebuild_repository PALUDIS_ATTRIBUTE((used)) (
- "ebuild", &make_ebuild_repository_wrapped);
-
- const RepositoryMaker::RegisterMaker register_portage_portage_repository PALUDIS_ATTRIBUTE((used)) (
- "portage", &make_ebuild_repository_wrapped);
-}
-#ifdef PALUDIS_ENABLE_VISIBILITY
-# pragma GCC visibility pop
-#endif
-
diff --git a/paludis/repositories/portage/portage_repository_entries.cc b/paludis/repositories/portage/portage_repository_entries.cc
index c891b04..6abed92 100644
--- a/paludis/repositories/portage/portage_repository_entries.cc
+++ b/paludis/repositories/portage/portage_repository_entries.cc
@@ -18,6 +18,7 @@
*/
#include "portage_repository_entries.hh"
+#include "ebuild_entries.hh"
using namespace paludis;
@@ -35,4 +36,8 @@ NoSuchPortageRepositoryEntriesType::NoSuchPortageRepositoryEntriesType(const std
{
}
+PortageRepositoryEntriesMaker::PortageRepositoryEntriesMaker()
+{
+ register_maker("ebuild", &EbuildEntries::make_ebuild_entries);
+}
diff --git a/paludis/repositories/portage/portage_repository_entries.hh b/paludis/repositories/portage/portage_repository_entries.hh
index f5807aa..99f1bc4 100644
--- a/paludis/repositories/portage/portage_repository_entries.hh
+++ b/paludis/repositories/portage/portage_repository_entries.hh
@@ -117,11 +117,18 @@ namespace paludis
*
* \ingroup grprepository
*/
- typedef VirtualConstructor<std::string,
+ class PortageRepositoryEntriesMaker :
+ public VirtualConstructor<std::string,
PortageRepositoryEntries::Pointer (*) (const Environment * const, PortageRepository * const,
const PortageRepositoryParams &),
- virtual_constructor_not_found::ThrowException<NoSuchPortageRepositoryEntriesType> >
- PortageRepositoryEntriesMaker;
+ virtual_constructor_not_found::ThrowException<NoSuchPortageRepositoryEntriesType> >,
+ public InstantiationPolicy<PortageRepositoryEntriesMaker, instantiation_method::SingletonAsNeededTag>
+ {
+ friend class InstantiationPolicy<PortageRepositoryEntriesMaker, instantiation_method::SingletonAsNeededTag>;
+
+ private:
+ PortageRepositoryEntriesMaker();
+ };
}
diff --git a/paludis/repositories/portage/registration.cc b/paludis/repositories/portage/registration.cc
new file mode 100644
index 0000000..7c00dc5
--- /dev/null
+++ b/paludis/repositories/portage/registration.cc
@@ -0,0 +1,54 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/repository_maker.hh>
+#include <paludis/repositories/portage/make_ebuild_repository.hh>
+#include "config.h"
+
+using namespace paludis;
+
+#ifndef MONOLITHIC
+
+extern "C"
+{
+ void register_repositories(RepositoryMaker * maker);
+}
+
+
+namespace
+{
+ CountedPtr<Repository>
+ make_ebuild_repository_wrapped(
+ const Environment * const env,
+ const PackageDatabase * const db,
+ AssociativeCollection<std::string, std::string>::ConstPointer m)
+ {
+ return make_ebuild_repository(env, db, m);
+ }
+}
+
+void register_repositories(RepositoryMaker * maker)
+{
+ maker->register_maker("ebuild", &make_ebuild_repository_wrapped);
+ maker->register_maker("portage", &make_ebuild_repository_wrapped);
+}
+
+#endif
+
+
diff --git a/paludis/repositories/portage/xml_things.cc b/paludis/repositories/portage/xml_things.cc
index bfca771..10dc694 100644
--- a/paludis/repositories/portage/xml_things.cc
+++ b/paludis/repositories/portage/xml_things.cc
@@ -186,3 +186,21 @@ create_glsa_from_xml_file(const std::string & filename)
return h.glsa();
}
+#ifndef MONOLITHIC
+
+namespace paludis
+{
+ class RepositoryMaker;
+}
+
+extern "C"
+{
+ void register_repositories(RepositoryMaker * maker);
+}
+
+void register_repositories(RepositoryMaker * maker)
+{
+}
+
+#endif
+
diff --git a/paludis/repositories/vdb/Makefile.am b/paludis/repositories/vdb/Makefile.am
index 8f12945..14d9272 100644
--- a/paludis/repositories/vdb/Makefile.am
+++ b/paludis/repositories/vdb/Makefile.am
@@ -20,7 +20,11 @@ paludis_repositories_lib_LTLIBRARIES = libpaludisvdbrepository.la
endif
-libpaludisvdbrepository_la_SOURCES = vdb_repository.cc vdb_repository.hh
+libpaludisvdbrepository_la_SOURCES = \
+ vdb_repository.cc \
+ vdb_repository.hh \
+ registration.cc
+
libpaludisvdbrepository_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSION_LIB_REVISION@:0
paludis_repositories_vdb_includedir = $(includedir)/paludis/repositories/vdb/
paludis_repositories_vdb_include_HEADERS = \
diff --git a/paludis/repositories/vdb/registration.cc b/paludis/repositories/vdb/registration.cc
new file mode 100644
index 0000000..44d6130
--- /dev/null
+++ b/paludis/repositories/vdb/registration.cc
@@ -0,0 +1,40 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/repository_maker.hh>
+#include <paludis/repositories/vdb/vdb_repository.hh>
+#include "config.h"
+
+using namespace paludis;
+
+#ifndef MONOLITHIC
+
+extern "C"
+{
+ void register_repositories(RepositoryMaker * maker);
+}
+
+void register_repositories(RepositoryMaker * maker)
+{
+ maker->register_maker("vdb", &VDBRepository::make_vdb_repository);
+}
+
+#endif
+
+
diff --git a/paludis/repositories/vdb/vdb_repository.cc b/paludis/repositories/vdb/vdb_repository.cc
index 3d8987b..ba14d72 100644
--- a/paludis/repositories/vdb/vdb_repository.cc
+++ b/paludis/repositories/vdb/vdb_repository.cc
@@ -1442,15 +1442,3 @@ VDBRepository::do_describe_use_flag(const UseFlagName &,
return "";
}
-#ifdef PALUDIS_ENABLE_VISIBILITY
-# pragma GCC visibility push(default)
-#endif
-namespace
-{
- const RepositoryMaker::RegisterMaker register_vdb_repository PALUDIS_ATTRIBUTE((used)) (
- "vdb", &VDBRepository::make_vdb_repository);
-}
-#ifdef PALUDIS_ENABLE_VISIBILITY
-# pragma GCC visibility pop
-#endif
-
diff --git a/paludis/repositories/virtuals/Makefile.am b/paludis/repositories/virtuals/Makefile.am
index ce21ecf..70ec690 100644
--- a/paludis/repositories/virtuals/Makefile.am
+++ b/paludis/repositories/virtuals/Makefile.am
@@ -33,6 +33,7 @@ libpaludisvirtualsrepository_la_SOURCES = \
virtuals_repository.cc \
installed_virtuals_repository.cc \
vr_entry.cc \
+ registration.cc \
$(paludis_repositories_portage_include_HEADERS)
libpaludisvirtualsrepository_la_LIBADD = \
diff --git a/paludis/repositories/virtuals/installed_virtuals_repository.cc b/paludis/repositories/virtuals/installed_virtuals_repository.cc
index 4317cef..f9c6448 100644
--- a/paludis/repositories/virtuals/installed_virtuals_repository.cc
+++ b/paludis/repositories/virtuals/installed_virtuals_repository.cc
@@ -307,15 +307,3 @@ InstalledVirtualsRepository::do_uninstall(const QualifiedPackageName &, const Ve
{
}
-#ifdef PALUDIS_ENABLE_VISIBILITY
-# pragma GCC visibility push(default)
-#endif
-namespace
-{
- const RepositoryMaker::RegisterMaker register_installed_virtuals_repository PALUDIS_ATTRIBUTE((used)) (
- "installed_virtuals", &InstalledVirtualsRepository::make_installed_virtuals_repository);
-}
-#ifdef PALUDIS_ENABLE_VISIBILITY
-# pragma GCC visibility pop
-#endif
-
diff --git a/paludis/repositories/virtuals/registration.cc b/paludis/repositories/virtuals/registration.cc
new file mode 100644
index 0000000..60191d0
--- /dev/null
+++ b/paludis/repositories/virtuals/registration.cc
@@ -0,0 +1,42 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/repository_maker.hh>
+#include <paludis/repositories/virtuals/installed_virtuals_repository.hh>
+#include <paludis/repositories/virtuals/virtuals_repository.hh>
+#include "config.h"
+
+using namespace paludis;
+
+#ifndef MONOLITHIC
+
+extern "C"
+{
+ void register_repositories(RepositoryMaker * maker);
+}
+
+void register_repositories(RepositoryMaker * maker)
+{
+ maker->register_maker("virtuals", &VirtualsRepository::make_virtuals_repository);
+ maker->register_maker("installed_virtuals", &InstalledVirtualsRepository::make_installed_virtuals_repository);
+}
+
+#endif
+
+
diff --git a/paludis/repositories/virtuals/virtuals_repository.cc b/paludis/repositories/virtuals/virtuals_repository.cc
index 6382f2f..49175fa 100644
--- a/paludis/repositories/virtuals/virtuals_repository.cc
+++ b/paludis/repositories/virtuals/virtuals_repository.cc
@@ -373,15 +373,3 @@ VirtualsRepository::do_install(const QualifiedPackageName &, const VersionSpec &
{
}
-#ifdef PALUDIS_ENABLE_VISIBILITY
-# pragma GCC visibility push(default)
-#endif
-namespace
-{
- const RepositoryMaker::RegisterMaker register_virtuals_repository PALUDIS_ATTRIBUTE((used)) (
- "virtuals", &VirtualsRepository::make_virtuals_repository);
-}
-#ifdef PALUDIS_ENABLE_VISIBILITY
-# pragma GCC visibility pop
-#endif
-
diff --git a/paludis/repository.hh b/paludis/repository.hh
index 12c9e7b..094ff30 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -1110,16 +1110,6 @@ namespace paludis
class PackageDatabase;
-
- /**
- * Virtual constructor for repositories.
- *
- * \ingroup grprepository
- */
- typedef VirtualConstructor<std::string,
- Repository::Pointer (*) (const Environment * const, const PackageDatabase * const,
- AssociativeCollection<std::string, std::string>::ConstPointer),
- virtual_constructor_not_found::ThrowException<NoSuchRepositoryTypeError> > RepositoryMaker;
}
#endif
diff --git a/paludis/repository_so_loader.cc b/paludis/repository_maker.cc
index e3cc960..0d9e01a 100644
--- a/paludis/repository_so_loader.cc
+++ b/paludis/repository_maker.cc
@@ -17,85 +17,57 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis/about.hh>
-#include <paludis/util/system.hh>
+#include "repository_maker.hh"
#include <paludis/util/fs_entry.hh>
#include <paludis/util/dir_iterator.hh>
#include <paludis/util/is_file_with_extension.hh>
-
-#include <dlfcn.h>
+#include <paludis/util/system.hh>
+#include <paludis/about.hh>
#include <list>
-#include <algorithm>
+#include <dlfcn.h>
+
+#include "config.h"
using namespace paludis;
-namespace
+PaludisRepositorySoDirNotADirectoryError::PaludisRepositorySoDirNotADirectoryError() throw () :
+ Exception("PALUDIS_REPOSITORY_SO_DIR not a directory")
{
- class PaludisRepositorySoDirNotADirectoryError :
- public Exception
- {
- public:
- PaludisRepositorySoDirNotADirectoryError() throw () :
- Exception("PALUDIS_REPOSITORY_SO_DIR not a directory")
- {
- }
- };
+}
- class PaludisRepositorySoDirCannotDlopenError :
- public Exception
- {
- private:
- std::string _file, _dlerr;
- mutable std::string _what;
-
- public:
- PaludisRepositorySoDirCannotDlopenError(const std::string & file,
- const std::string & e) throw () :
- Exception("Cannot dlopen a repository. so file"),
- _file(file),
- _dlerr(e)
- {
- }
+PaludisRepositorySoDirCannotDlopenError::PaludisRepositorySoDirCannotDlopenError(
+ const std::string & file, const std::string & e) throw () :
+ Exception("Cannot dlopen a repository. so file"),
+ _file(file),
+ _dlerr(e)
+{
+}
- ~PaludisRepositorySoDirCannotDlopenError() throw ()
- {
- }
+PaludisRepositorySoDirCannotDlopenError::~PaludisRepositorySoDirCannotDlopenError() throw ()
+{
+}
- const char * what() const throw ()
- {
- if (_what.empty())
- _what = std::string(Exception::what()) +
- ": Cannot dlopen repository .so file '" + _file + "': '" + _dlerr + "'";
- return _what.c_str();
- }
- };
+const char *
+PaludisRepositorySoDirCannotDlopenError::what() const throw ()
+{
+ if (_what.empty())
+ _what = std::string(Exception::what()) +
+ ": Cannot dlopen repository .so file '" + _file + "': '" + _dlerr + "'";
+ return _what.c_str();
+}
- struct RepositorySoLoader
+namespace paludis
+{
+ template<>
+ struct Implementation<RepositoryMaker> :
+ InternalCounted<Implementation<RepositoryMaker> >
{
- RepositorySoLoader();
- ~RepositorySoLoader();
-
- void load_dir(const FSEntry &);
-
std::list<void *> dl_opened;
};
-
- static RepositorySoLoader repository_so_loader;
-}
-
-RepositorySoLoader::RepositorySoLoader()
-{
- FSEntry so_dir(getenv_with_default("PALUDIS_REPOSITORY_SO_DIR",
- LIBDIR "/paludis/repositories"));
-
- if (! so_dir.is_directory())
- throw PaludisRepositorySoDirNotADirectoryError();
-
- load_dir(so_dir);
}
void
-RepositorySoLoader::load_dir(const FSEntry & so_dir)
+RepositoryMaker::load_dir(const FSEntry & so_dir)
{
for (DirIterator d(so_dir), d_end ; d != d_end ; ++d)
{
@@ -111,7 +83,19 @@ RepositorySoLoader::load_dir(const FSEntry & so_dir)
void * dl(dlopen(stringify(*d).c_str(), RTLD_GLOBAL | RTLD_NOW));
if (dl)
- dl_opened.push_back(dl);
+ {
+ _imp->dl_opened.push_back(dl);
+
+ void * reg(dlsym(dl, "register_repositories"));
+ if (reg)
+ {
+ reinterpret_cast<void (*)(RepositoryMaker *)>(
+ reinterpret_cast<uintptr_t>(reg))(this);
+ }
+ else
+ throw PaludisRepositorySoDirCannotDlopenError(stringify(*d),
+ "no register_repositories function defined");
+ }
else
throw PaludisRepositorySoDirCannotDlopenError(stringify(*d), dlerror());
}
@@ -120,8 +104,23 @@ RepositorySoLoader::load_dir(const FSEntry & so_dir)
load_dir(so_dir / ".libs");
}
-RepositorySoLoader::~RepositorySoLoader()
+RepositoryMaker::RepositoryMaker() :
+ PrivateImplementationPattern<RepositoryMaker>(new Implementation<RepositoryMaker>)
+{
+#ifdef MONOLITHIC
+
+#else
+ FSEntry so_dir(getenv_with_default("PALUDIS_REPOSITORY_SO_DIR", LIBDIR "/paludis/repositories"));
+
+ if (! so_dir.is_directory())
+ throw PaludisRepositorySoDirNotADirectoryError();
+
+ load_dir(so_dir);
+
+#endif
+}
+
+RepositoryMaker::~RepositoryMaker()
{
- std::for_each(dl_opened.begin(), dl_opened.end(), &::dlclose);
}
diff --git a/paludis/repository_maker.hh b/paludis/repository_maker.hh
new file mode 100644
index 0000000..bc154c8
--- /dev/null
+++ b/paludis/repository_maker.hh
@@ -0,0 +1,80 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORY_MAKER_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORY_MAKER_HH 1
+
+#include <paludis/util/instantiation_policy.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/virtual_constructor.hh>
+#include <paludis/repository.hh>
+
+namespace paludis
+{
+ class FSEntry;
+
+ class PALUDIS_VISIBLE PaludisRepositorySoDirNotADirectoryError :
+ public Exception
+ {
+ public:
+ PaludisRepositorySoDirNotADirectoryError() throw ();
+ };
+
+ class PaludisRepositorySoDirCannotDlopenError :
+ public Exception
+ {
+ private:
+ std::string _file, _dlerr;
+ mutable std::string _what;
+
+ public:
+ PaludisRepositorySoDirCannotDlopenError(const std::string & file,
+ const std::string & e) throw ();
+
+ ~PaludisRepositorySoDirCannotDlopenError() throw ();
+
+ const char * what() const throw ();
+ };
+
+ /*
+ * Virtual constructor for repositories.
+ *
+ * \ingroup grprepository
+ */
+ class PALUDIS_VISIBLE RepositoryMaker :
+ public VirtualConstructor<std::string,
+ Repository::Pointer (*) (const Environment * const, const PackageDatabase * const,
+ AssociativeCollection<std::string, std::string>::ConstPointer),
+ virtual_constructor_not_found::ThrowException<NoSuchRepositoryTypeError> >,
+ public InstantiationPolicy<RepositoryMaker, instantiation_method::SingletonAsNeededTag>,
+ private PrivateImplementationPattern<RepositoryMaker>
+ {
+ friend class InstantiationPolicy<RepositoryMaker, instantiation_method::SingletonAsNeededTag>;
+
+ private:
+ RepositoryMaker();
+
+ void load_dir(const FSEntry &);
+
+ public:
+ ~RepositoryMaker();
+ };
+}
+
+#endif
diff --git a/paludis/syncer.cc b/paludis/syncer.cc
index 23391a3..80de9a4 100644
--- a/paludis/syncer.cc
+++ b/paludis/syncer.cc
@@ -174,92 +174,6 @@ namespace
return Syncer::Pointer(new CvsSyncer(local, remote));
}
};
-
- /**
- * Register rsync:// protocol.
- *
- * \ingroup grpsyncer
- */
- static const SyncerMaker::RegisterMaker register_rsync_syncer("rsync", &RsyncSyncer::make);
-
- /**
- * Register file:// protocol.
- *
- * \ingroup grpsyncer
- */
- static const SyncerMaker::RegisterMaker register_file_syncer("file", &RsyncSyncer::make);
-
- /**
- * Register svn:// protocol.
- *
- * \ingroup grpsyncer
- */
- static const SyncerMaker::RegisterMaker register_svn_syncer("svn", &SvnSyncer::make);
-
- /**
- * Register svn+ssh:// protocol.
- *
- * \ingroup grpsyncer
- */
- static const SyncerMaker::RegisterMaker register_svnplusssh_syncer("svn+ssh", &SvnSyncer::make);
-
- /**
- * Register svn+http:// protocol.
- *
- * \ingroup grpsyncer
- */
- static const SyncerMaker::RegisterMaker register_svnplushttp_syncer("svn+http", &SvnSyncer::make);
-
- /**
- * Register svn+https:// protocol.
- *
- * \ingroup grpsyncer
- */
- static const SyncerMaker::RegisterMaker register_svnplushttps_syncer("svn+https", &SvnSyncer::make);
-
-
- /**
- * Register git:// protocol.
- *
- * \ingroup grpsyncer
- */
- static const SyncerMaker::RegisterMaker register_git_syncer("git", &GitSyncer::make);
-
- /**
- * Register git+ssh:// protocol.
- *
- * \ingroup grpsyncer
- */
- static const SyncerMaker::RegisterMaker register_gitplusssh_syncer("git+ssh", &GitSyncer::make);
-
- /**
- * Register git+http:// protocol.
- *
- * \ingroup grpsyncer
- */
- static const SyncerMaker::RegisterMaker register_gitplushttp_syncer("git+http", &GitSyncer::make);
-
- /**
- * Register cvs+ext:// protocol.
- *
- * \ingroup grpsyncer
- */
- static const SyncerMaker::RegisterMaker register_cvsplusext_syncer("cvs+ext", &CvsSyncer::make);
-
- /**
- * Register cvs+ssh:// protocol.
- *
- * \ingroup grpsyncer
- */
- static const SyncerMaker::RegisterMaker register_cvsplusssh_syncer("cvs+ssh", &CvsSyncer::make);
-
- /**
- * Register cvs+pserver:// protocol.
- *
- * \ingroup grpsyncer
- */
- static const SyncerMaker::RegisterMaker register_cvspluspserver_syncer("cvs+pserver", &CvsSyncer::make);
-
}
void
@@ -357,3 +271,20 @@ SyncCvsUrlInvalid::SyncCvsUrlInvalid(const std::string & url) throw () :
SyncFailedError("'" + url + "' is not a valid URL for a CVS repository")
{
}
+
+SyncerMaker::SyncerMaker()
+{
+ register_maker("rsync", &RsyncSyncer::make);
+ register_maker("file", &RsyncSyncer::make);
+ register_maker("svn", &SvnSyncer::make);
+ register_maker("svn+ssh", &SvnSyncer::make);
+ register_maker("svn+http", &SvnSyncer::make);
+ register_maker("svn+https", &SvnSyncer::make);
+ register_maker("git", &GitSyncer::make);
+ register_maker("git+ssh", &GitSyncer::make);
+ register_maker("git+http", &GitSyncer::make);
+ register_maker("cvs+ext", &CvsSyncer::make);
+ register_maker("cvs+ssh", &CvsSyncer::make);
+ register_maker("cvs+pserver", &CvsSyncer::make);
+}
+
diff --git a/paludis/syncer.hh b/paludis/syncer.hh
index 7aea76f..c439348 100644
--- a/paludis/syncer.hh
+++ b/paludis/syncer.hh
@@ -142,8 +142,16 @@ namespace paludis
*
* \ingroup grpsyncer
*/
- typedef VirtualConstructor<std::string, Syncer::Pointer (*) (const std::string &, const std::string &),
- virtual_constructor_not_found::ThrowException<NoSuchSyncerError> > SyncerMaker;
+ class SyncerMaker :
+ public VirtualConstructor<std::string, Syncer::Pointer (*) (const std::string &, const std::string &),
+ virtual_constructor_not_found::ThrowException<NoSuchSyncerError> >,
+ public InstantiationPolicy<SyncerMaker, instantiation_method::SingletonAsNeededTag>
+ {
+ friend class InstantiationPolicy<SyncerMaker, instantiation_method::SingletonAsNeededTag>;
+
+ private:
+ SyncerMaker();
+ };
}
#endif
diff --git a/paludis/util/virtual_constructor.hh b/paludis/util/virtual_constructor.hh
index ab4f88f..5725f47 100644
--- a/paludis/util/virtual_constructor.hh
+++ b/paludis/util/virtual_constructor.hh
@@ -21,7 +21,6 @@
#define PALUDIS_GUARD_PALUDIS_VIRTUAL_CONSTRUCTOR_HH 1
#include <paludis/util/exception.hh>
-#include <paludis/util/instantiation_policy.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/iterator.hh>
@@ -120,25 +119,21 @@ namespace paludis
*/
template <typename KeyType_, typename ValueType_, typename NotFoundBehaviour_>
class PALUDIS_VISIBLE VirtualConstructor :
- public NotFoundBehaviour_::template Parent<KeyType_, ValueType_>,
- public InstantiationPolicy<VirtualConstructor<KeyType_, ValueType_, NotFoundBehaviour_>,
- instantiation_method::SingletonAsNeededTag>
+ public NotFoundBehaviour_::template Parent<KeyType_, ValueType_>
{
- friend class InstantiationPolicy<
- VirtualConstructor<KeyType_, ValueType_, NotFoundBehaviour_>,
- instantiation_method::SingletonAsNeededTag>;
-
- private:
- VirtualConstructor()
- {
- }
-
protected:
/**
* Our entries, sorted.
*/
std::vector<std::pair<KeyType_, ValueType_> > entries;
+ /**
+ * Constructor.
+ */
+ VirtualConstructor()
+ {
+ }
+
public:
/**
* The type of our key.
@@ -170,8 +165,7 @@ namespace paludis
}
/**
- * Register a new maker (should usually be called by the
- * RegisterMaker child class.
+ * Register a new maker.
*/
void register_maker(const KeyType_ & k, const ValueType_ & v);
@@ -180,24 +174,6 @@ namespace paludis
*/
template <typename T_>
void copy_keys(T_ out_iter) const;
-
- /**
- * An instance of this class registers a new maker with the
- * specified key.
- *
- * \ingroup grpvc
- */
- struct RegisterMaker
- {
- /**
- * Constructor.
- */
- RegisterMaker(const KeyType_ & k, const ValueType_ & v)
- {
- VirtualConstructor<KeyType_, ValueType_, NotFoundBehaviour_>::get_instance()->
- register_maker(k, v);
- }
- };
};
template <typename KeyType_, typename ValueType_, typename NotFoundBehaviour_>
diff --git a/paludis/util/virtual_constructor_TEST.cc b/paludis/util/virtual_constructor_TEST.cc
index d53363f..51f311b 100644
--- a/paludis/util/virtual_constructor_TEST.cc
+++ b/paludis/util/virtual_constructor_TEST.cc
@@ -31,107 +31,115 @@
using namespace test;
using namespace paludis;
-#ifndef DOXYGEN
-enum CookieSize
+namespace
{
- cs_small,
- cs_large
-};
-
-class Cookie :
- public InternalCounted<Cookie>
-{
- private:
- CookieSize _size;
-
- protected:
- Cookie(CookieSize size) :
- _size(size)
- {
- };
-
- public:
- virtual std::string flavour() const = 0;
-
- virtual ~Cookie()
- {
- }
-
- CookieSize size() const
- {
- return _size;
- }
-};
-
-struct NoCookie
-{
- NoCookie(const std::string &)
+ enum CookieSize
{
- }
-};
-
-typedef VirtualConstructor<std::string,
- CountedPtr<Cookie> (*) (CookieSize),
- virtual_constructor_not_found::ThrowException<NoCookie> > CookieMaker;
-
-class ChocolateChipCookie : public Cookie
-{
- public:
- ChocolateChipCookie(CookieSize size) :
- Cookie(size)
- {
- }
-
- std::string flavour() const
- {
- return "Chocolate Chip";
- }
+ cs_small,
+ cs_large
+ };
- static CountedPtr<Cookie> make(CookieSize size)
- {
- return CountedPtr<Cookie>(new ChocolateChipCookie(size));
- }
-};
-
-CookieMaker::RegisterMaker register_chocolate_chip("chocolate chip", &ChocolateChipCookie::make);
-
-class GingerCookie : public Cookie
-{
- private:
- bool _with_crunchy_bits;
+ class Cookie :
+ public InternalCounted<Cookie>
+ {
+ private:
+ CookieSize _size;
- public:
- GingerCookie(CookieSize size, bool with_crunchy_bits) :
- Cookie(size),
- _with_crunchy_bits(with_crunchy_bits)
- {
- }
+ protected:
+ Cookie(CookieSize size) :
+ _size(size)
+ {
+ };
- std::string flavour() const
- {
- return _with_crunchy_bits ? "Crunchy Ginger" : "Ginger";
- }
+ public:
+ virtual std::string flavour() const = 0;
- bool with_crunchy_bits() const
- {
- return _with_crunchy_bits;
- }
+ virtual ~Cookie()
+ {
+ }
- static CountedPtr<Cookie> make(CookieSize size)
- {
- return CountedPtr<Cookie>(new GingerCookie(size, false));
- }
+ CookieSize size() const
+ {
+ return _size;
+ }
+ };
- static CountedPtr<Cookie> make_crunchy(CookieSize size)
+ struct NoCookie
+ {
+ NoCookie(const std::string &)
{
- return CountedPtr<Cookie>(new GingerCookie(size, true));
}
-};
+ };
-CookieMaker::RegisterMaker register_ginger("ginger", &GingerCookie::make);
-CookieMaker::RegisterMaker register_crunchy_ginger("crunchy ginger", &GingerCookie::make_crunchy);
-
-#endif
+ class ChocolateChipCookie : public Cookie
+ {
+ public:
+ ChocolateChipCookie(CookieSize size) :
+ Cookie(size)
+ {
+ }
+
+ std::string flavour() const
+ {
+ return "Chocolate Chip";
+ }
+
+ static CountedPtr<Cookie> make(CookieSize size)
+ {
+ return CountedPtr<Cookie>(new ChocolateChipCookie(size));
+ }
+ };
+
+ class GingerCookie : public Cookie
+ {
+ private:
+ bool _with_crunchy_bits;
+
+ public:
+ GingerCookie(CookieSize size, bool with_crunchy_bits) :
+ Cookie(size),
+ _with_crunchy_bits(with_crunchy_bits)
+ {
+ }
+
+ std::string flavour() const
+ {
+ return _with_crunchy_bits ? "Crunchy Ginger" : "Ginger";
+ }
+
+ bool with_crunchy_bits() const
+ {
+ return _with_crunchy_bits;
+ }
+
+ static CountedPtr<Cookie> make(CookieSize size)
+ {
+ return CountedPtr<Cookie>(new GingerCookie(size, false));
+ }
+
+ static CountedPtr<Cookie> make_crunchy(CookieSize size)
+ {
+ return CountedPtr<Cookie>(new GingerCookie(size, true));
+ }
+ };
+
+ class CookieMaker :
+ public VirtualConstructor<std::string,
+ CountedPtr<Cookie> (*) (CookieSize),
+ virtual_constructor_not_found::ThrowException<NoCookie> >,
+ public InstantiationPolicy<CookieMaker, instantiation_method::SingletonAsNeededTag>
+ {
+ friend class InstantiationPolicy<CookieMaker, instantiation_method::SingletonAsNeededTag>;
+
+ private:
+ CookieMaker()
+ {
+ register_maker("chocolate chip", &ChocolateChipCookie::make);
+ register_maker("ginger", &GingerCookie::make);
+ register_maker("crunchy ginger", &GingerCookie::make_crunchy);
+ }
+ };
+}
namespace test_cases
{