aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-01 14:58:37 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-01 14:58:37 +0100
commit0096d8728a54757fd6725c886df4e088223e5f28 (patch)
treeea99f90ccc6bae156f382548f3a182cf182c2d70
parentd97e4de383cf625e2fb96ce663b86fe4d8816629 (diff)
downloadpaludis-0096d8728a54757fd6725c886df4e088223e5f28.tar.gz
paludis-0096d8728a54757fd6725c886df4e088223e5f28.tar.xz
Clean up behaviours key storage
-rw-r--r--paludis/repositories/accounts/accounts_id.cc33
-rw-r--r--paludis/repositories/accounts/installed_accounts_id.cc37
-rw-r--r--paludis/repositories/repository/repository_id.cc35
-rw-r--r--paludis/repositories/unavailable/unavailable_repository_id.cc38
-rw-r--r--paludis/repositories/unpackaged/installed_id.cc31
5 files changed, 96 insertions, 78 deletions
diff --git a/paludis/repositories/accounts/accounts_id.cc b/paludis/repositories/accounts/accounts_id.cc
index 9242553..1a13a4d 100644
--- a/paludis/repositories/accounts/accounts_id.cc
+++ b/paludis/repositories/accounts/accounts_id.cc
@@ -31,6 +31,7 @@
#include <paludis/util/make_named_values.hh>
#include <paludis/util/wrapped_output_iterator.hh>
#include <paludis/util/make_null_shared_ptr.hh>
+#include <paludis/util/singleton-impl.hh>
#include <paludis/output_manager.hh>
#include <paludis/name.hh>
#include <paludis/version_spec.hh>
@@ -43,6 +44,23 @@
using namespace paludis;
using namespace paludis::accounts_repository;
+namespace
+{
+ struct AccountsIDBehaviours :
+ Singleton<AccountsIDBehaviours>
+ {
+ std::shared_ptr<Set<std::string> > behaviours_value;
+ std::shared_ptr<LiteralMetadataStringSetKey> behaviours_key;
+
+ AccountsIDBehaviours() :
+ behaviours_value(std::make_shared<Set<std::string>>()),
+ behaviours_key(std::make_shared<LiteralMetadataStringSetKey>("behaviours", "behaviours", mkt_internal, behaviours_value))
+ {
+ behaviours_value->insert("unbinaryable");
+ }
+ };
+}
+
namespace paludis
{
template <>
@@ -56,7 +74,6 @@ namespace paludis
const std::shared_ptr<const LiteralMetadataValueKey<FSEntry> > fs_location_key;
const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > from_repositories_key;
- static const std::shared_ptr<Set<std::string> > behaviours_set;
const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > behaviours_key;
const std::shared_ptr<const AccountsInstalledMask> mask;
@@ -88,7 +105,7 @@ namespace paludis
repository(r),
fs_location_key(std::make_shared<LiteralMetadataValueKey<FSEntry>>("location", "Location", mkt_internal, l)),
from_repositories_key(f),
- behaviours_key(std::make_shared<LiteralMetadataStringSetKey>("behaviours", "behaviours", mkt_internal, behaviours_set)),
+ behaviours_key(AccountsIDBehaviours::get_instance()->behaviours_key),
mask(m ? std::make_shared<AccountsInstalledMask>() : make_null_shared_ptr()),
is_user(u),
has_file_keys(false),
@@ -98,18 +115,6 @@ namespace paludis
};
}
-namespace
-{
- std::shared_ptr<Set<std::string> > make_behaviours()
- {
- std::shared_ptr<Set<std::string> > result(std::make_shared<Set<std::string>>());
- result->insert("unbinaryable");
- return result;
- }
-}
-
-const std::shared_ptr<Set<std::string> > Imp<AccountsID>::behaviours_set = make_behaviours();
-
AccountsID::AccountsID(const Environment * const e,
const QualifiedPackageName & q, const std::shared_ptr<const Repository> & r,
const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > & f, const FSEntry & l,
diff --git a/paludis/repositories/accounts/installed_accounts_id.cc b/paludis/repositories/accounts/installed_accounts_id.cc
index 00cffeb..74bfcd3 100644
--- a/paludis/repositories/accounts/installed_accounts_id.cc
+++ b/paludis/repositories/accounts/installed_accounts_id.cc
@@ -30,6 +30,7 @@
#include <paludis/util/mutex.hh>
#include <paludis/util/log.hh>
#include <paludis/util/make_null_shared_ptr.hh>
+#include <paludis/util/singleton-impl.hh>
#include <paludis/name.hh>
#include <paludis/version_spec.hh>
#include <paludis/literal_metadata_key.hh>
@@ -46,6 +47,24 @@
using namespace paludis;
using namespace paludis::accounts_repository;
+namespace
+{
+ struct InstalledAccountsIDBehaviours :
+ Singleton<InstalledAccountsIDBehaviours>
+ {
+ std::shared_ptr<Set<std::string> > behaviours_value;
+ std::shared_ptr<LiteralMetadataStringSetKey> behaviours_key;
+
+ InstalledAccountsIDBehaviours() :
+ behaviours_value(std::make_shared<Set<std::string>>()),
+ behaviours_key(std::make_shared<LiteralMetadataStringSetKey>("behaviours", "behaviours", mkt_internal, behaviours_value))
+ {
+ behaviours_value->insert("transient");
+ behaviours_value->insert("used");
+ }
+ };
+}
+
namespace paludis
{
template <>
@@ -56,8 +75,6 @@ namespace paludis
const QualifiedPackageName name;
const VersionSpec version;
const std::shared_ptr<const Repository> repository;
-
- static const std::shared_ptr<Set<std::string> > behaviours_set;
const std::shared_ptr<const LiteralMetadataStringSetKey> behaviours_key;
mutable Mutex mutex;
@@ -72,27 +89,13 @@ namespace paludis
name(q),
version("0", { }),
repository(r),
- behaviours_key(std::make_shared<LiteralMetadataStringSetKey>("behaviours", "Behaviours", mkt_internal,
- behaviours_set)),
+ behaviours_key(InstalledAccountsIDBehaviours::get_instance()->behaviours_key),
is_user(u)
{
}
};
}
-namespace
-{
- std::shared_ptr<Set<std::string> > make_behaviours()
- {
- std::shared_ptr<Set<std::string> > result(std::make_shared<Set<std::string>>());
- result->insert("transient");
- result->insert("used");
- return result;
- }
-}
-
-const std::shared_ptr<Set<std::string> > Imp<InstalledAccountsID>::behaviours_set = make_behaviours();
-
InstalledAccountsID::InstalledAccountsID(const Environment * const e,
const QualifiedPackageName & q, const std::shared_ptr<const Repository> & r, const bool u) :
Pimp<InstalledAccountsID>(e, q, r, u),
diff --git a/paludis/repositories/repository/repository_id.cc b/paludis/repositories/repository/repository_id.cc
index 45f5413..a147e43 100644
--- a/paludis/repositories/repository/repository_id.cc
+++ b/paludis/repositories/repository/repository_id.cc
@@ -26,6 +26,7 @@
#include <paludis/util/hashes.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/make_null_shared_ptr.hh>
+#include <paludis/util/singleton-impl.hh>
#include <paludis/name.hh>
#include <paludis/version_spec.hh>
#include <paludis/metadata_key.hh>
@@ -37,6 +38,24 @@
using namespace paludis;
using namespace paludis::repository_repository;
+namespace
+{
+ struct RepositoryIDBehaviours :
+ Singleton<RepositoryIDBehaviours>
+ {
+ std::shared_ptr<Set<std::string> > behaviours_value;
+ std::shared_ptr<LiteralMetadataStringSetKey> behaviours_key;
+
+ RepositoryIDBehaviours() :
+ behaviours_value(std::make_shared<Set<std::string>>()),
+ behaviours_key(std::make_shared<LiteralMetadataStringSetKey>("behaviours", "behaviours", mkt_internal, behaviours_value))
+ {
+ behaviours_value->insert("transient");
+ behaviours_value->insert("used");
+ }
+ };
+}
+
namespace paludis
{
template <>
@@ -48,32 +67,18 @@ namespace paludis
const RepositoryRepository * const repo;
const std::shared_ptr<LiteralMetadataStringSetKey> behaviours_key;
- static const std::shared_ptr<Set<std::string> > behaviours_set;
Imp(const RepositoryIDParams & e) :
env(e.environment()),
name(e.name()),
version("0", { }),
repo(e.repository()),
- behaviours_key(std::make_shared<LiteralMetadataStringSetKey>("behaviours", "behaviours", mkt_internal, behaviours_set))
+ behaviours_key(RepositoryIDBehaviours::get_instance()->behaviours_key)
{
}
};
}
-namespace
-{
- std::shared_ptr<Set<std::string> > make_behaviours()
- {
- std::shared_ptr<Set<std::string> > result(std::make_shared<Set<std::string>>());
- result->insert("transient");
- result->insert("used");
- return result;
- }
-}
-
-const std::shared_ptr<Set<std::string> > Imp<RepositoryID>::behaviours_set = make_behaviours();
-
RepositoryID::RepositoryID(const RepositoryIDParams & entry) :
Pimp<RepositoryID>(entry),
_imp(Pimp<RepositoryID>::_imp)
diff --git a/paludis/repositories/unavailable/unavailable_repository_id.cc b/paludis/repositories/unavailable/unavailable_repository_id.cc
index 4d5edf8..8b1944f 100644
--- a/paludis/repositories/unavailable/unavailable_repository_id.cc
+++ b/paludis/repositories/unavailable/unavailable_repository_id.cc
@@ -27,6 +27,7 @@
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/make_null_shared_ptr.hh>
+#include <paludis/util/singleton-impl.hh>
#include <paludis/name.hh>
#include <paludis/version_spec.hh>
#include <paludis/metadata_key.hh>
@@ -39,6 +40,23 @@
using namespace paludis;
using namespace paludis::unavailable_repository;
+namespace
+{
+ struct UnavailableRepositoryIDBehaviours :
+ Singleton<UnavailableRepositoryIDBehaviours>
+ {
+ std::shared_ptr<Set<std::string> > behaviours_value;
+ std::shared_ptr<LiteralMetadataStringSetKey> behaviours_key;
+
+ UnavailableRepositoryIDBehaviours() :
+ behaviours_value(std::make_shared<Set<std::string>>()),
+ behaviours_key(std::make_shared<LiteralMetadataStringSetKey>("behaviours", "behaviours", mkt_internal, behaviours_value))
+ {
+ behaviours_value->insert("unbinaryable");
+ }
+ };
+}
+
namespace paludis
{
template <>
@@ -54,12 +72,10 @@ namespace paludis
const std::shared_ptr<const MetadataValueKey<std::string> > homepage_key;
const std::shared_ptr<const MetadataValueKey<std::string> > sync_key;
const std::shared_ptr<const MetadataValueKey<std::string> > format_key;
- const std::shared_ptr<LiteralMetadataStringSetKey> behaviours_key;
- static const std::shared_ptr<Set<std::string> > behaviours_set;
+ const std::shared_ptr<const LiteralMetadataStringSetKey> behaviours_key;
const std::shared_ptr<const Mask> mask;
- Imp(
- const UnavailableRepositoryIDParams & e) :
+ Imp(const UnavailableRepositoryIDParams & e) :
env(e.environment()),
name(e.name()),
version("0", { }),
@@ -69,25 +85,13 @@ namespace paludis
homepage_key(e.homepage()),
sync_key(e.sync()),
format_key(e.format()),
- behaviours_key(std::make_shared<LiteralMetadataStringSetKey>("behaviours", "behaviours", mkt_internal, behaviours_set)),
+ behaviours_key(UnavailableRepositoryIDBehaviours::get_instance()->behaviours_key),
mask(e.mask())
{
}
};
}
-namespace
-{
- std::shared_ptr<Set<std::string> > make_behaviours()
- {
- std::shared_ptr<Set<std::string> > result(std::make_shared<Set<std::string>>());
- result->insert("unbinaryable");
- return result;
- }
-}
-
-const std::shared_ptr<Set<std::string> > Imp<UnavailableRepositoryID>::behaviours_set = make_behaviours();
-
UnavailableRepositoryID::UnavailableRepositoryID(const UnavailableRepositoryIDParams & entry) :
Pimp<UnavailableRepositoryID>(entry),
_imp(Pimp<UnavailableRepositoryID>::_imp)
diff --git a/paludis/repositories/unpackaged/installed_id.cc b/paludis/repositories/unpackaged/installed_id.cc
index 824987d..a323725 100644
--- a/paludis/repositories/unpackaged/installed_id.cc
+++ b/paludis/repositories/unpackaged/installed_id.cc
@@ -34,6 +34,7 @@
#include <paludis/util/return_literal_function.hh>
#include <paludis/util/timestamp.hh>
#include <paludis/util/make_null_shared_ptr.hh>
+#include <paludis/util/singleton-impl.hh>
#include <paludis/output_manager.hh>
#include <paludis/name.hh>
#include <paludis/version_spec.hh>
@@ -54,6 +55,20 @@ using namespace paludis::unpackaged_repositories;
namespace
{
+ struct InstalledUnpackagedIDBehaviours :
+ Singleton<InstalledUnpackagedIDBehaviours>
+ {
+ std::shared_ptr<Set<std::string> > behaviours_value;
+ std::shared_ptr<LiteralMetadataStringSetKey> behaviours_key;
+
+ InstalledUnpackagedIDBehaviours() :
+ behaviours_value(std::make_shared<Set<std::string>>()),
+ behaviours_key(std::make_shared<LiteralMetadataStringSetKey>("behaviours", "behaviours", mkt_internal, behaviours_value))
+ {
+ behaviours_value->insert("transient");
+ }
+ };
+
std::string format_string(const std::string & i, const Formatter<std::string> & f)
{
return f.format(i, format::Plain());
@@ -406,8 +421,6 @@ namespace paludis
std::shared_ptr<InstalledUnpackagedDependencyKey> run_dependencies_key;
std::shared_ptr<LiteralMetadataStringSetKey> behaviours_key;
- static const std::shared_ptr<Set<std::string> > behaviours_set;
-
Imp(
const Environment * const e,
const PackageID * const id,
@@ -428,7 +441,7 @@ namespace paludis
run_dependencies_labels(std::make_shared<DependenciesLabelSequence>()),
slot_key(std::make_shared<LiteralMetadataValueKey<SlotName> >("slot", "Slot", mkt_internal, s)),
fs_location_key(std::make_shared<InstalledUnpackagedFSEntryKey>(l)),
- behaviours_key(std::make_shared<LiteralMetadataStringSetKey>("behaviours", "behaviours", mkt_internal, behaviours_set))
+ behaviours_key(InstalledUnpackagedIDBehaviours::get_instance()->behaviours_key)
{
build_dependencies_labels->push_back(std::make_shared<DependenciesBuildLabel>("build_dependencies",
return_literal_function(true)));
@@ -464,18 +477,6 @@ namespace paludis
};
}
-namespace
-{
- std::shared_ptr<Set<std::string> > make_behaviours()
- {
- std::shared_ptr<Set<std::string> > result(std::make_shared<Set<std::string>>());
- result->insert("transient");
- return result;
- }
-}
-
-const std::shared_ptr<Set<std::string> > Imp<InstalledUnpackagedID>::behaviours_set = make_behaviours();
-
InstalledUnpackagedID::InstalledUnpackagedID(const Environment * const e, const QualifiedPackageName & q,
const VersionSpec & v, const SlotName & s, const RepositoryName & n, const FSEntry & l,
const std::string &, const FSEntry & ro, const NDBAM * const d) :