aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-01-27 21:43:34 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-01-31 14:27:28 +0000
commit6eeca897e480fbb24cc5bfd6df6cf97fc5d82594 (patch)
treeae4b1bc3ec7dc01b35997635db527f12c463eea3
parent565a93fad0cee550c2fb44286e64f02685cbed88 (diff)
downloadpaludis-6eeca897e480fbb24cc5bfd6df6cf97fc5d82594.tar.gz
paludis-6eeca897e480fbb24cc5bfd6df6cf97fc5d82594.tar.xz
Refactor EChoiceValue
-rw-r--r--paludis/repositories/e/e_choice_value.cc41
-rw-r--r--paludis/repositories/e/e_choice_value.hh49
-rw-r--r--paludis/repositories/e/e_installed_repository_id.cc12
-rw-r--r--paludis/repositories/e/ebuild_id.cc29
4 files changed, 74 insertions, 57 deletions
diff --git a/paludis/repositories/e/e_choice_value.cc b/paludis/repositories/e/e_choice_value.cc
index fec3508..2251efa 100644
--- a/paludis/repositories/e/e_choice_value.cc
+++ b/paludis/repositories/e/e_choice_value.cc
@@ -19,84 +19,67 @@
#include <paludis/repositories/e/e_choice_value.hh>
#include <paludis/repositories/e/use_desc.hh>
+#include <paludis/util/make_null_shared_ptr.hh>
using namespace paludis;
using namespace paludis::erepository;
-EChoiceValue::EChoiceValue(const ChoicePrefixName & r, const UnprefixedChoiceName & v, const ChoiceNameWithPrefix & np, const QualifiedPackageName & p,
- const std::shared_ptr<const UseDesc> & d,
- bool b, bool def, bool l, bool x, const std::string & o,
- const std::string & pv, const std::shared_ptr<const PermittedChoiceValueParameterValues> & e) :
- _prefix(r),
- _unprefixed_name(v),
- _name_with_prefix(np),
- _package_name(p),
- _use_desc(d),
- _enabled(b),
- _enabled_by_default(def),
- _locked(l),
- _explicitly_listed(x),
- _override_description(o),
- _parameter(pv),
- _permitted(e)
+EChoiceValue::EChoiceValue(const EChoiceValueParams & p) :
+ _params(p)
{
}
const UnprefixedChoiceName
EChoiceValue::unprefixed_name() const
{
- return _unprefixed_name;
+ return _params.unprefixed_choice_name();
}
const ChoiceNameWithPrefix
EChoiceValue::name_with_prefix() const
{
- return _name_with_prefix;
+ return _params.choice_name_with_prefix();
}
const std::string
EChoiceValue::description() const
{
- if (! _override_description.empty())
- return _override_description;
- if (! _use_desc)
- return "";
- return _use_desc->describe(_package_name, _prefix, _unprefixed_name);
+ return _params.description();
}
bool
EChoiceValue::enabled() const
{
- return _enabled;
+ return _params.enabled();
}
bool
EChoiceValue::enabled_by_default() const
{
- return _enabled_by_default;
+ return _params.enabled_by_default();
}
bool
EChoiceValue::locked() const
{
- return _locked;
+ return _params.locked();
}
bool
EChoiceValue::explicitly_listed() const
{
- return _explicitly_listed;
+ return _params.explicitly_listed();
}
const std::string
EChoiceValue::parameter() const
{
- return _parameter;
+ return "";
}
const std::shared_ptr<const PermittedChoiceValueParameterValues>
EChoiceValue::permitted_parameter_values() const
{
- return _permitted;
+ return make_null_shared_ptr();
}
diff --git a/paludis/repositories/e/e_choice_value.hh b/paludis/repositories/e/e_choice_value.hh
index 71fc260..5f65656 100644
--- a/paludis/repositories/e/e_choice_value.hh
+++ b/paludis/repositories/e/e_choice_value.hh
@@ -21,6 +21,7 @@
#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_E_CHOICE_VALUE_HH 1
#include <paludis/util/attributes.hh>
+#include <paludis/util/named_value.hh>
#include <paludis/choice.hh>
#include <paludis/name.hh>
#include <functional>
@@ -28,38 +29,40 @@
namespace paludis
{
- struct UseDesc;
+ namespace n
+ {
+ typedef Name<struct name_choice_name_with_prefix> choice_name_with_prefix;
+ typedef Name<struct name_choice_prefix_name> choice_prefix_name;
+ typedef Name<struct name_description> description;
+ typedef Name<struct name_enabled> enabled;
+ typedef Name<struct name_enabled_by_default> enabled_by_default;
+ typedef Name<struct name_explicitly_listed> explicitly_listed;
+ typedef Name<struct name_locked> locked;
+ typedef Name<struct name_unprefixed_choice_name> unprefixed_choice_name;
+ }
namespace erepository
{
+ struct EChoiceValueParams
+ {
+ NamedValue<n::choice_name_with_prefix, ChoiceNameWithPrefix> choice_name_with_prefix;
+ NamedValue<n::choice_prefix_name, ChoicePrefixName> choice_prefix_name;
+ NamedValue<n::description, std::string> description;
+ NamedValue<n::enabled, bool> enabled;
+ NamedValue<n::enabled_by_default, bool> enabled_by_default;
+ NamedValue<n::explicitly_listed, bool> explicitly_listed;
+ NamedValue<n::locked, bool> locked;
+ NamedValue<n::unprefixed_choice_name, UnprefixedChoiceName> unprefixed_choice_name;
+ };
+
class PALUDIS_VISIBLE EChoiceValue :
public ChoiceValue
{
private:
- const ChoicePrefixName _prefix;
- const UnprefixedChoiceName _unprefixed_name;
- const ChoiceNameWithPrefix _name_with_prefix;
- const QualifiedPackageName _package_name;
- const std::shared_ptr<const UseDesc> _use_desc;
- const bool _enabled;
- const bool _enabled_by_default;
- const bool _locked;
- const bool _explicitly_listed;
- const std::string _override_description;
- const std::string _parameter;
- const std::shared_ptr<const PermittedChoiceValueParameterValues> _permitted;
+ const EChoiceValueParams _params;
public:
- EChoiceValue(const ChoicePrefixName & r,
- const UnprefixedChoiceName & n,
- const ChoiceNameWithPrefix & np,
- const QualifiedPackageName & p,
- const std::shared_ptr<const UseDesc> & d,
- bool b, bool def,
- bool l, bool x,
- const std::string & o,
- const std::string & pr,
- const std::shared_ptr<const PermittedChoiceValueParameterValues> & e);
+ EChoiceValue(const EChoiceValueParams &);
const UnprefixedChoiceName unprefixed_name() const;
const ChoiceNameWithPrefix name_with_prefix() const;
diff --git a/paludis/repositories/e/e_installed_repository_id.cc b/paludis/repositories/e/e_installed_repository_id.cc
index 7a43ff6..c33464f 100644
--- a/paludis/repositories/e/e_installed_repository_id.cc
+++ b/paludis/repositories/e/e_installed_repository_id.cc
@@ -1064,8 +1064,16 @@ EInstalledRepositoryID::make_choice_value(const std::shared_ptr<const Choice> &
if (raw_use_key())
enabled = (raw_use_key()->value()->end() != raw_use_key()->value()->find(name_with_prefix));
- return std::make_shared<EChoiceValue>(c->prefix(), v, ChoiceNameWithPrefix(name_with_prefix), name(), std::shared_ptr<const UseDesc>(),
- enabled, enabled, true, explicitly_listed, override_description, "", make_null_shared_ptr());
+ return std::make_shared<EChoiceValue>(make_named_values<EChoiceValueParams>(
+ n::choice_name_with_prefix() = ChoiceNameWithPrefix(name_with_prefix),
+ n::choice_prefix_name() = c->prefix(),
+ n::description() = override_description,
+ n::enabled() = enabled,
+ n::enabled_by_default() = enabled,
+ n::explicitly_listed() = explicitly_listed,
+ n::locked() = true,
+ n::unprefixed_choice_name() = v
+ ));
}
void
diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc
index 36a9139..83519d4 100644
--- a/paludis/repositories/e/ebuild_id.cc
+++ b/paludis/repositories/e/ebuild_id.cc
@@ -1403,6 +1403,22 @@ EbuildID::slot_key() const
return _imp->slot;
}
+namespace
+{
+ std::string get_description(const std::shared_ptr<const UseDesc> & use_desc, const std::string & override_description,
+ const QualifiedPackageName & package, const ChoicePrefixName & prefix, const UnprefixedChoiceName & suffix)
+ {
+ if (! override_description.empty())
+ return override_description;
+
+ if (use_desc)
+ return use_desc->describe(package, prefix, suffix);
+ else
+ return "";
+ }
+}
+
+
std::shared_ptr<ChoiceValue>
EbuildID::make_choice_value(
const std::shared_ptr<const Choice> & choice,
@@ -1482,9 +1498,16 @@ EbuildID::make_choice_value(
}
}
- return std::make_shared<EChoiceValue>(choice->prefix(), value_name, ChoiceNameWithPrefix(name_with_prefix), name(),
- e_repo->use_desc(),
- enabled, enabled_by_default, force_locked || locked, explicitly_listed, override_description, "", make_null_shared_ptr());
+ return std::make_shared<EChoiceValue>(make_named_values<EChoiceValueParams>(
+ n::choice_name_with_prefix() = ChoiceNameWithPrefix(name_with_prefix),
+ n::choice_prefix_name() = choice->prefix(),
+ n::description() = get_description(e_repo->use_desc(), override_description, name(), choice->prefix(), value_name),
+ n::enabled() = enabled,
+ n::enabled_by_default() = enabled_by_default,
+ n::explicitly_listed() = explicitly_listed,
+ n::locked() = force_locked || locked,
+ n::unprefixed_choice_name() = value_name
+ ));
}
namespace