aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Matthias Langer <mlangc@gmx.at> 2008-10-06 19:42:23 +0200
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-10-06 22:46:07 +0100
commit69880891f02ff6c40e3b716c55234b5ca4c1b117 (patch)
treeef0b35c46f8b8513609c5257f702635c94514ccb
parent6d4eee21ade8eec93dc69a36b9a2f262c5419908 (diff)
downloadpaludis-69880891f02ff6c40e3b716c55234b5ca4c1b117.tar.gz
paludis-69880891f02ff6c40e3b716c55234b5ca4c1b117.tar.xz
FakeInstalledRepository should now register itself with RepositoryFactory.
-rw-r--r--paludis/repositories/fake/Makefile.am3
-rw-r--r--paludis/repositories/fake/fake_installed_repository.cc25
-rw-r--r--paludis/repositories/fake/fake_installed_repository.hh16
-rw-r--r--paludis/repositories/fake/fake_repository.cc4
-rw-r--r--paludis/repositories/fake/registration.cc54
5 files changed, 97 insertions, 5 deletions
diff --git a/paludis/repositories/fake/Makefile.am b/paludis/repositories/fake/Makefile.am
index bf825bc..50d1fc6 100644
--- a/paludis/repositories/fake/Makefile.am
+++ b/paludis/repositories/fake/Makefile.am
@@ -74,7 +74,8 @@ libpaludisfakerepository_@PALUDIS_PC_SLOT@_la_SOURCES = \
fake_repository_base.cc fake_repository_base.hh \
fake_repository.cc fake_repository.hh \
fake_installed_repository.cc fake_installed_repository.hh \
- fake_package_id.cc fake_package_id.hh
+ fake_package_id.cc fake_package_id.hh \
+ registration.cc
libpaludisfakerepository_@PALUDIS_PC_SLOT@_la_LIBADD = \
$(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \
diff --git a/paludis/repositories/fake/fake_installed_repository.cc b/paludis/repositories/fake/fake_installed_repository.cc
index 6532012..cd891a6 100644
--- a/paludis/repositories/fake/fake_installed_repository.cc
+++ b/paludis/repositories/fake/fake_installed_repository.cc
@@ -211,3 +211,28 @@ FakeInstalledRepository::installed_root_key() const
return _imp->installed_root_key;
}
+RepositoryName FakeInstalledRepository::repository_factory_name(
+ const Environment * const,
+ const std::tr1::function<std::string (const std::string &)> & f)
+{
+ return RepositoryName(f("name"));
+}
+
+std::tr1::shared_ptr<Repository>
+FakeInstalledRepository::repository_factory_create(
+ Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> & f)
+{
+ Context context("When creating FakeInstalledRepository:");
+ RepositoryName name(f("name"));
+
+ return make_shared_ptr(new FakeInstalledRepository(env, name));
+}
+
+std::tr1::shared_ptr<const RepositoryNameSet>
+FakeInstalledRepository::repository_factory_dependencies(
+ const Environment * const,
+ const std::tr1::function<std::string (const std::string&)> &)
+{
+ return make_shared_ptr(new RepositoryNameSet);
+}
diff --git a/paludis/repositories/fake/fake_installed_repository.hh b/paludis/repositories/fake/fake_installed_repository.hh
index 4f3123e..2848867 100644
--- a/paludis/repositories/fake/fake_installed_repository.hh
+++ b/paludis/repositories/fake/fake_installed_repository.hh
@@ -73,6 +73,22 @@ namespace paludis
virtual const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> > location_key() const;
virtual const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> > installed_root_key() const;
+ ///\name RepositoryFactory functions
+ ///\{
+
+ static RepositoryName repository_factory_name(
+ const Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ static std::tr1::shared_ptr<Repository> repository_factory_create(
+ Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ static std::tr1::shared_ptr<const RepositoryNameSet> repository_factory_dependencies(
+ const Environment * const env,
+ const std::tr1::function<std::string (const std::string &)> &);
+
+ ///\}
};
}
diff --git a/paludis/repositories/fake/fake_repository.cc b/paludis/repositories/fake/fake_repository.cc
index fcd9f4c..ef23de1 100644
--- a/paludis/repositories/fake/fake_repository.cc
+++ b/paludis/repositories/fake/fake_repository.cc
@@ -128,10 +128,6 @@ namespace paludis
class RepositoryFactory;
}
-extern "C" void PALUDIS_VISIBLE paludis_initialise_repository_so(paludis::RepositoryFactory * const)
-{
-}
-
namespace
{
struct SupportsActionQuery :
diff --git a/paludis/repositories/fake/registration.cc b/paludis/repositories/fake/registration.cc
new file mode 100644
index 0000000..014d821
--- /dev/null
+++ b/paludis/repositories/fake/registration.cc
@@ -0,0 +1,54 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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_factory.hh>
+#include <paludis/repositories/fake/fake_installed_repository.hh>
+#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/destringify.hh>
+#include <paludis/util/set.hh>
+#include <paludis/environment.hh>
+
+using namespace paludis;
+
+namespace
+{
+ int generic_importance(const Environment * const, const std::tr1::function<std::string (const std::string &)> & f)
+ {
+ if (! f("importance").empty())
+ return destringify<int>(f("importance"));
+ else
+ return 1;
+ }
+}
+
+extern "C" void paludis_initialise_repository_so(RepositoryFactory * const factory) PALUDIS_VISIBLE;
+
+void paludis_initialise_repository_so(RepositoryFactory * const factory)
+{
+ std::tr1::shared_ptr<Set<std::string> > fake_formats(new Set<std::string>);
+ fake_formats->insert("fake_installed");
+
+ factory->add_repository_format(
+ fake_formats,
+ FakeInstalledRepository::repository_factory_name,
+ &generic_importance,
+ FakeInstalledRepository::repository_factory_create,
+ FakeInstalledRepository::repository_factory_dependencies
+ );
+}