aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-07-01 07:25:35 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-07-01 07:25:35 +0100
commit1b2cc63afb4c201834a2157d196b868fa209a45b (patch)
tree625a91a2b8fff33a640e86c03871cf37e9a8f0d3
parent1c359b6841082de0d5fb9b29719b2c410cb60b0f (diff)
downloadpaludis-1b2cc63afb4c201834a2157d196b868fa209a45b.tar.gz
paludis-1b2cc63afb4c201834a2157d196b868fa209a45b.tar.xz
Convert RepositoryConfigEntry to kc
-rw-r--r--paludis/environments/paludis/Makefile.am12
-rw-r--r--paludis/environments/paludis/paludis_config.cc46
-rw-r--r--paludis/environments/paludis/paludis_config.hh7
-rw-r--r--paludis/environments/paludis/paludis_environment.cc39
-rw-r--r--paludis/environments/paludis/repository_config_entry.sr22
-rw-r--r--paludis/util/keys.hh3
6 files changed, 46 insertions, 83 deletions
diff --git a/paludis/environments/paludis/Makefile.am b/paludis/environments/paludis/Makefile.am
index d1b8ee0..ef942d4 100644
--- a/paludis/environments/paludis/Makefile.am
+++ b/paludis/environments/paludis/Makefile.am
@@ -1,7 +1,6 @@
CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda *.loT
DISTCLEANFILES = \
use_config_entry-sr.hh use_config_entry-sr.cc \
- repository_config_entry-sr.hh repository_config_entry-sr.cc
BUILT_SOURCES = $(DISTCLEANFILES)
MAINTAINERCLEANFILES = Makefile.in
AM_CXXFLAGS = -I$(top_srcdir) @PALUDIS_CXXFLAGS@ @PALUDIS_CXXFLAGS_VISIBILITY@
@@ -50,7 +49,6 @@ paludis_environment_paludis_include_HEADERS = \
paludis_config.hh \
paludis_environment.hh \
use_config_entry-sr.hh \
- repository_config_entry-sr.hh \
use_conf.hh \
keywords_conf.hh \
licenses_conf.hh \
@@ -64,8 +62,7 @@ EXTRA_DIST = \
paludis_environment_TEST.cc \
paludis_environment_TEST_cleanup.sh \
$(BUILT_SOURCES) \
- use_config_entry.sr \
- repository_config_entry.sr
+ use_config_entry.sr
TESTS = paludis_environment_TEST
@@ -126,12 +123,6 @@ use_config_entry-sr.hh : use_config_entry.sr $(top_srcdir)/misc/make_sr.bash
use_config_entry-sr.cc : use_config_entry.sr $(top_srcdir)/misc/make_sr.bash
$(top_srcdir)/misc/make_sr.bash --source $(srcdir)/use_config_entry.sr > $@
-repository_config_entry-sr.hh : repository_config_entry.sr $(top_srcdir)/misc/make_sr.bash
- $(top_srcdir)/misc/make_sr.bash --header $(srcdir)/repository_config_entry.sr > $@
-
-repository_config_entry-sr.cc : repository_config_entry.sr $(top_srcdir)/misc/make_sr.bash
- $(top_srcdir)/misc/make_sr.bash --source $(srcdir)/repository_config_entry.sr > $@
-
distcheck-deps-local : $(DISTCHECK_DEPS)
distcheck-deps : distcheck-deps-subdirs
@@ -139,3 +130,4 @@ distcheck-deps : distcheck-deps-subdirs
distcheck-deps-subdirs :
for s in $(SUBDIRS) . ; do if test x$$s = x. ; then $(MAKE) distcheck-deps-local || exit 1 ; \
else $(MAKE) -C $$s distcheck-deps || exit 1 ; fi ; done
+
diff --git a/paludis/environments/paludis/paludis_config.cc b/paludis/environments/paludis/paludis_config.cc
index 3e571bd..1e72cff 100644
--- a/paludis/environments/paludis/paludis_config.cc
+++ b/paludis/environments/paludis/paludis_config.cc
@@ -45,6 +45,7 @@
#include <paludis/util/wrapped_output_iterator.hh>
#include <paludis/util/wrapped_forward_iterator-impl.hh>
#include <paludis/util/kc.hh>
+#include <paludis/util/make_shared_ptr.hh>
#include <tr1/functional>
#include <fstream>
@@ -72,20 +73,25 @@ using namespace paludis::paludis_environment;
template class WrappedForwardIterator<PaludisConfig::RepositoryConstIteratorTag, const RepositoryConfigEntry>;
#include <paludis/environments/paludis/use_config_entry-sr.cc>
-#include <paludis/environments/paludis/repository_config_entry-sr.cc>
namespace
{
+ std::string from_keys(const std::tr1::shared_ptr<const Map<std::string, std::string> > & m,
+ const std::string & k)
+ {
+ Map<std::string, std::string>::ConstIterator mm(m->find(k));
+ if (m->end() == mm)
+ return "";
+ else
+ return mm->second;
+ }
+
std::string predefined(
const std::tr1::shared_ptr<const Map<std::string, std::string> > & m,
const KeyValueConfigFile &,
const std::string & k)
{
- const Map<std::string, std::string>::ConstIterator i(m->find(k));
- if (m->end() != i)
- return i->second;
- else
- return "";
+ return from_keys(m, k);
}
}
@@ -344,10 +350,17 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
std::tr1::shared_ptr<Map<std::string, std::string> > iv_keys(
new Map<std::string, std::string>);
iv_keys->insert("root", root_prefix.empty() ? "/" : root_prefix);
- _imp->repos.push_back(RepositoryConfigEntry("installed_virtuals", -1, iv_keys));
-
- _imp->repos.push_back(RepositoryConfigEntry("virtuals", -2,
- std::tr1::shared_ptr<Map<std::string, std::string> >()));
+ _imp->repos.push_back(RepositoryConfigEntry::named_create()
+ (k::format(), "installed_virtuals")
+ (k::importance(), -1)
+ (k::keys(), std::tr1::bind(&from_keys, iv_keys, std::tr1::placeholders::_1))
+ );
+
+ _imp->repos.push_back(RepositoryConfigEntry::named_create()
+ (k::format(), "virtuals")
+ (k::importance(), -2)
+ (k::keys(), std::tr1::bind(&from_keys, make_shared_ptr(new Map<std::string, std::string>), std::tr1::placeholders::_1))
+ );
}
/* add normal repositories */
@@ -459,14 +472,21 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
{
Log::get_instance()->message("paludis_environment.repositories.not_delaying", ll_debug, lc_context)
<< "Not delaying '" << *repo_file << "'";
- _imp->repos.push_back(RepositoryConfigEntry(format, importance, keys));
+ _imp->repos.push_back(RepositoryConfigEntry::named_create()
+ (k::format(), format)
+ (k::importance(), importance)
+ (k::keys(), std::tr1::bind(&from_keys, keys, std::tr1::placeholders::_1))
+ );
}
}
for (std::list<std::tr1::shared_ptr<Map<std::string, std::string> > >::const_iterator
k(later_keys.begin()), k_end(later_keys.end()) ; k != k_end ; ++k)
- _imp->repos.push_back(RepositoryConfigEntry((*k)->find("format")->second,
- destringify<int>((*k)->find("importance")->second), *k));
+ _imp->repos.push_back(RepositoryConfigEntry::named_create()
+ (k::format(), (*k)->find("format")->second)
+ (k::importance(), destringify<int>((*k)->find("importance")->second))
+ (k::keys(), std::tr1::bind(&from_keys, *k, std::tr1::placeholders::_1))
+ );
if (_imp->repos.empty())
throw PaludisConfigError("No repositories specified");
diff --git a/paludis/environments/paludis/paludis_config.hh b/paludis/environments/paludis/paludis_config.hh
index e3c7ee9..dadce73 100644
--- a/paludis/environments/paludis/paludis_config.hh
+++ b/paludis/environments/paludis/paludis_config.hh
@@ -51,6 +51,12 @@ namespace paludis
struct MirrorsConf;
struct World;
+ typedef kc::KeyedClass<
+ kc::Field<k::format, std::string>,
+ kc::Field<k::importance, int>,
+ kc::Field<k::keys, std::tr1::function<std::string (const std::string &)> >
+ > RepositoryConfigEntry;
+
/**
* A PaludisConfigError is thrown if a configuration error is encountered
* by PaludisConfig.
@@ -89,7 +95,6 @@ namespace paludis
};
#include <paludis/environments/paludis/use_config_entry-sr.hh>
-#include <paludis/environments/paludis/repository_config_entry-sr.hh>
/**
* PaludisConfig is used by PaludisEnvironment to access the user's
diff --git a/paludis/environments/paludis/paludis_environment.cc b/paludis/environments/paludis/paludis_environment.cc
index b4cd6b6..9cca3ed 100644
--- a/paludis/environments/paludis/paludis_environment.cc
+++ b/paludis/environments/paludis/paludis_environment.cc
@@ -142,19 +142,6 @@ namespace paludis
};
}
-namespace
-{
- std::string from_keys(const std::tr1::shared_ptr<const Map<std::string, std::string> > & m,
- const std::string & k)
- {
- Map<std::string, std::string>::ConstIterator mm(m->find(k));
- if (m->end() == mm)
- return "";
- else
- return mm->second;
- }
-}
-
PaludisEnvironment::PaludisEnvironment(const std::string & s) :
PrivateImplementationPattern<PaludisEnvironment>(new Implementation<PaludisEnvironment>(
this, std::tr1::shared_ptr<PaludisConfig>(new PaludisConfig(this, s)))),
@@ -164,30 +151,8 @@ PaludisEnvironment::PaludisEnvironment(const std::string & s) :
for (PaludisConfig::RepositoryConstIterator r(_imp->config->begin_repositories()),
r_end(_imp->config->end_repositories()) ; r != r_end ; ++r)
- {
- std::string keys;
- if (Log::get_instance()->log_level() <= ll_debug)
- {
- if (r->keys)
- for (Map<std::string, std::string>::ConstIterator
- i(r->keys->begin()), i_end(r->keys->end()) ; i != i_end ; ++i)
- {
- if (! keys.empty())
- keys.append(", ");
- keys.append("'" + i->first + "'='" + i->second + "'");
- }
- else
- keys = "empty";
-
- Log::get_instance()->message("paludis_environment.making_repository", ll_debug, lc_context) <<
- "Creating repository with format='" << r->format << "', importance='" << r->importance
- << "', keys " << keys;
- }
-
- _imp->package_database->add_repository(r->importance,
- RepositoryMaker::get_instance()->find_maker(r->format)(this,
- std::tr1::bind(from_keys, r->keys, std::tr1::placeholders::_1)));
- }
+ _imp->package_database->add_repository((*r)[k::importance()],
+ RepositoryMaker::get_instance()->find_maker((*r)[k::format()])(this, (*r)[k::keys()]));
add_metadata_key(_imp->format_key);
add_metadata_key(_imp->conf_dir_key);
diff --git a/paludis/environments/paludis/repository_config_entry.sr b/paludis/environments/paludis/repository_config_entry.sr
deleted file mode 100644
index 07eec25..0000000
--- a/paludis/environments/paludis/repository_config_entry.sr
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/bash
-# vim: set sw=4 sts=4 et :
-
-make_class_RepositoryConfigEntry()
-{
- key format std::string
- key importance int
- key keys "std::tr1::shared_ptr<Map<std::string, std::string> >"
-
- doxygen_comment << "END"
- /**
- * Represents a PaludisConfig repository config file.
- *
- * \see PaludisConfig
- * \ingroup grppaludisconfig
- * \nosubgrouping
- */
-END
-
- comparison_operators all importance
-}
-
diff --git a/paludis/util/keys.hh b/paludis/util/keys.hh
index 0b0dcec..ab8a9c8 100644
--- a/paludis/util/keys.hh
+++ b/paludis/util/keys.hh
@@ -185,6 +185,9 @@ namespace paludis
typedef kc::Key<156> repository_description;
typedef kc::Key<157> get_new_ids_or_minus_one;
typedef kc::Key<158> rewrite_ids_over_to_root;
+ typedef kc::Key<159> importance;
+ typedef kc::Key<160> keys;
+ typedef kc::Key<161> format;
}
}