aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2008-07-02 13:32:39 +0100
committerAvatar David Leverton <levertond@googlemail.com> 2008-07-25 21:37:09 +0100
commit78d31e69f521798ef9f82027e0f5ca0d33ee7d40 (patch)
tree0a632e51f4c3da74f04497ac072abb3d6db7befe
parentd536873df7c747be1da6056997de5ba2a566876f (diff)
downloadpaludis-78d31e69f521798ef9f82027e0f5ca0d33ee7d40.tar.gz
paludis-78d31e69f521798ef9f82027e0f5ca0d33ee7d40.tar.xz
Add methods for format and config_location Environment MetadataKeys.
-rw-r--r--paludis/environment.hh18
-rw-r--r--paludis/environments/adapted/adapted_environment.cc12
-rw-r--r--paludis/environments/adapted/adapted_environment.hh3
-rw-r--r--paludis/environments/no_config/no_config_environment.cc12
-rw-r--r--paludis/environments/no_config/no_config_environment.hh3
-rw-r--r--paludis/environments/paludis/paludis_environment.cc18
-rw-r--r--paludis/environments/paludis/paludis_environment.hh3
-rw-r--r--paludis/environments/portage/portage_environment.cc18
-rw-r--r--paludis/environments/portage/portage_environment.hh3
-rw-r--r--paludis/environments/test/test_environment.cc12
-rw-r--r--paludis/environments/test/test_environment.hh3
-rw-r--r--python/environment.cc20
12 files changed, 119 insertions, 6 deletions
diff --git a/paludis/environment.hh b/paludis/environment.hh
index 128485d..f414b18 100644
--- a/paludis/environment.hh
+++ b/paludis/environment.hh
@@ -327,6 +327,24 @@ namespace paludis
virtual void remove_from_world(const SetName &) const = 0;
///\}
+
+ ///\name Specific metadata keys
+ ///\{
+
+ /**
+ * The format_key, if non-zero, holds our environment's format. Environment
+ * implementations should not return zero here, but clients should still
+ * check.
+ */
+ virtual const std::tr1::shared_ptr<const MetadataValueKey<std::string> > format_key() const = 0;
+
+ /**
+ * The config_location_key, if non-zero, specifies the location of the configuration file or directory,
+ * the contents of which depends on the format returned by format_key.
+ */
+ virtual const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> > config_location_key() const = 0;
+
+ ///\}
};
}
diff --git a/paludis/environments/adapted/adapted_environment.cc b/paludis/environments/adapted/adapted_environment.cc
index 69508f7..0ab410b 100644
--- a/paludis/environments/adapted/adapted_environment.cc
+++ b/paludis/environments/adapted/adapted_environment.cc
@@ -289,3 +289,15 @@ AdaptedEnvironment::clear_metadata_keys() const
_imp->has_metadata_keys = false;
}
+const std::tr1::shared_ptr<const MetadataValueKey<std::string> >
+AdaptedEnvironment::format_key() const
+{
+ return _imp->env->format_key();
+}
+
+const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> >
+AdaptedEnvironment::config_location_key() const
+{
+ return _imp->env->config_location_key();
+}
+
diff --git a/paludis/environments/adapted/adapted_environment.hh b/paludis/environments/adapted/adapted_environment.hh
index 1b0afc7..eddab4c 100644
--- a/paludis/environments/adapted/adapted_environment.hh
+++ b/paludis/environments/adapted/adapted_environment.hh
@@ -145,6 +145,9 @@ namespace paludis
virtual void remove_from_world(const QualifiedPackageName &) const;
virtual void remove_from_world(const SetName &) const;
+
+ virtual const std::tr1::shared_ptr<const MetadataValueKey<std::string> > format_key() const;
+ virtual const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> > config_location_key() const;
};
}
diff --git a/paludis/environments/no_config/no_config_environment.cc b/paludis/environments/no_config/no_config_environment.cc
index fa06394..bf0af42 100644
--- a/paludis/environments/no_config/no_config_environment.cc
+++ b/paludis/environments/no_config/no_config_environment.cc
@@ -517,3 +517,15 @@ NoConfigEnvironment::need_keys_added() const
{
}
+const std::tr1::shared_ptr<const MetadataValueKey<std::string> >
+NoConfigEnvironment::format_key() const
+{
+ return _imp->format_key;
+}
+
+const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> >
+NoConfigEnvironment::config_location_key() const
+{
+ return std::tr1::shared_ptr<const MetadataValueKey<FSEntry> >();
+}
+
diff --git a/paludis/environments/no_config/no_config_environment.hh b/paludis/environments/no_config/no_config_environment.hh
index 0c75765..dcfe4cc 100644
--- a/paludis/environments/no_config/no_config_environment.hh
+++ b/paludis/environments/no_config/no_config_environment.hh
@@ -159,6 +159,9 @@ namespace paludis
virtual void remove_from_world(const QualifiedPackageName &) const;
virtual void remove_from_world(const SetName &) const;
+
+ virtual const std::tr1::shared_ptr<const MetadataValueKey<std::string> > format_key() const;
+ virtual const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> > config_location_key() const;
};
}
diff --git a/paludis/environments/paludis/paludis_environment.cc b/paludis/environments/paludis/paludis_environment.cc
index 9cca3ed..7aed93b 100644
--- a/paludis/environments/paludis/paludis_environment.cc
+++ b/paludis/environments/paludis/paludis_environment.cc
@@ -85,7 +85,7 @@ namespace paludis
mutable std::map<SetName, std::tr1::shared_ptr<SetSpecTree::ConstItem> > sets;
std::tr1::shared_ptr<LiteralMetadataValueKey<std::string> > format_key;
- std::tr1::shared_ptr<LiteralMetadataValueKey<FSEntry> > conf_dir_key;
+ std::tr1::shared_ptr<LiteralMetadataValueKey<FSEntry> > config_location_key;
std::tr1::shared_ptr<LiteralMetadataValueKey<FSEntry> > world_file_key;
Implementation(PaludisEnvironment * const e, std::tr1::shared_ptr<PaludisConfig> c) :
@@ -94,7 +94,7 @@ namespace paludis
paludis_command("paludis"),
package_database(new PackageDatabase(e)),
format_key(new LiteralMetadataValueKey<std::string>("format", "Format", mkt_significant, "paludis")),
- conf_dir_key(new LiteralMetadataValueKey<FSEntry>("conf_dir", "Config dir", mkt_normal,
+ config_location_key(new LiteralMetadataValueKey<FSEntry>("conf_dir", "Config dir", mkt_normal,
config->config_dir())),
world_file_key(config->world()->location_if_set() ? make_shared_ptr(
new LiteralMetadataValueKey<FSEntry>("world_file", "World file", mkt_normal,
@@ -155,7 +155,7 @@ PaludisEnvironment::PaludisEnvironment(const std::string & s) :
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);
+ add_metadata_key(_imp->config_location_key);
if (_imp->world_file_key)
add_metadata_key(_imp->world_file_key);
}
@@ -570,3 +570,15 @@ PaludisEnvironment::need_keys_added() const
{
}
+const std::tr1::shared_ptr<const MetadataValueKey<std::string> >
+PaludisEnvironment::format_key() const
+{
+ return _imp->format_key;
+}
+
+const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> >
+PaludisEnvironment::config_location_key() const
+{
+ return _imp->config_location_key;
+}
+
diff --git a/paludis/environments/paludis/paludis_environment.hh b/paludis/environments/paludis/paludis_environment.hh
index 9cb7fcc..ab89300 100644
--- a/paludis/environments/paludis/paludis_environment.hh
+++ b/paludis/environments/paludis/paludis_environment.hh
@@ -153,6 +153,9 @@ namespace paludis
virtual void remove_from_world(const QualifiedPackageName &) const;
virtual void remove_from_world(const SetName &) const;
+
+ virtual const std::tr1::shared_ptr<const MetadataValueKey<std::string> > format_key() const;
+ virtual const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> > config_location_key() const;
};
}
#endif
diff --git a/paludis/environments/portage/portage_environment.cc b/paludis/environments/portage/portage_environment.cc
index a05c108..ceddf6b 100644
--- a/paludis/environments/portage/portage_environment.cc
+++ b/paludis/environments/portage/portage_environment.cc
@@ -107,7 +107,7 @@ namespace paludis
mutable Mutex world_mutex;
std::tr1::shared_ptr<LiteralMetadataValueKey<std::string> > format_key;
- std::tr1::shared_ptr<LiteralMetadataValueKey<FSEntry> > conf_dir_key;
+ std::tr1::shared_ptr<LiteralMetadataValueKey<FSEntry> > config_location_key;
std::tr1::shared_ptr<LiteralMetadataValueKey<FSEntry> > world_file_key;
Implementation(Environment * const e, const std::string & s) :
@@ -119,7 +119,7 @@ namespace paludis
package_database(new PackageDatabase(e)),
world_file("/var/lib/portage/world"),
format_key(new LiteralMetadataValueKey<std::string>("format", "Format", mkt_significant, "portage")),
- conf_dir_key(new LiteralMetadataValueKey<FSEntry>("conf_dir", "Config dir", mkt_normal,
+ config_location_key(new LiteralMetadataValueKey<FSEntry>("conf_dir", "Config dir", mkt_normal,
conf_dir)),
world_file_key(new LiteralMetadataValueKey<FSEntry>("world_file", "World file", mkt_normal,
world_file))
@@ -353,7 +353,7 @@ PortageEnvironment::PortageEnvironment(const std::string & s) :
_imp->ignore_breaks_portage.insert(*it);
add_metadata_key(_imp->format_key);
- add_metadata_key(_imp->conf_dir_key);
+ add_metadata_key(_imp->config_location_key);
add_metadata_key(_imp->world_file_key);
}
@@ -990,3 +990,15 @@ PortageEnvironment::need_keys_added() const
{
}
+const std::tr1::shared_ptr<const MetadataValueKey<std::string> >
+PortageEnvironment::format_key() const
+{
+ return _imp->format_key;
+}
+
+const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> >
+PortageEnvironment::config_location_key() const
+{
+ return _imp->config_location_key;
+}
+
diff --git a/paludis/environments/portage/portage_environment.hh b/paludis/environments/portage/portage_environment.hh
index 80fcf19..a495602 100644
--- a/paludis/environments/portage/portage_environment.hh
+++ b/paludis/environments/portage/portage_environment.hh
@@ -156,6 +156,9 @@ namespace paludis
virtual void remove_from_world(const QualifiedPackageName &) const;
virtual void remove_from_world(const SetName &) const;
+
+ virtual const std::tr1::shared_ptr<const MetadataValueKey<std::string> > format_key() const;
+ virtual const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> > config_location_key() const;
};
}
diff --git a/paludis/environments/test/test_environment.cc b/paludis/environments/test/test_environment.cc
index 4ea87e4..7400022 100644
--- a/paludis/environments/test/test_environment.cc
+++ b/paludis/environments/test/test_environment.cc
@@ -234,6 +234,18 @@ TestEnvironment::need_keys_added() const
{
}
+const std::tr1::shared_ptr<const MetadataValueKey<std::string> >
+TestEnvironment::format_key() const
+{
+ return std::tr1::shared_ptr<const MetadataValueKey<std::string> >();
+}
+
+const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> >
+TestEnvironment::config_location_key() const
+{
+ return std::tr1::shared_ptr<const MetadataValueKey<FSEntry> >();
+}
+
void
TestEnvironment::add_set(const SetName & s, const std::string & members_str)
{
diff --git a/paludis/environments/test/test_environment.hh b/paludis/environments/test/test_environment.hh
index 398bb28..689c499 100644
--- a/paludis/environments/test/test_environment.hh
+++ b/paludis/environments/test/test_environment.hh
@@ -127,6 +127,9 @@ namespace paludis
virtual void remove_from_world(const SetName &) const;
+ virtual const std::tr1::shared_ptr<const MetadataValueKey<std::string> > format_key() const;
+ virtual const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> > config_location_key() const;
+
void add_set(const SetName &, const std::string &);
};
}
diff --git a/python/environment.cc b/python/environment.cc
index cc2401c..863bf0a 100644
--- a/python/environment.cc
+++ b/python/environment.cc
@@ -415,6 +415,26 @@ class EnvironmentImplementationWrapper :
else
throw PythonMethodNotImplemented("EnvironmentImplementation", "need_keys_added");
}
+
+ virtual const std::tr1::shared_ptr<const MetadataValueKey<std::string> > format_key() const
+ {
+ Lock l(get_mutex());
+
+ if (bp::override f = get_override("format_key"))
+ return f();
+ else
+ throw PythonMethodNotImplemented("EnvironmentImplementation", "format_key");
+ }
+
+ virtual const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> > config_location_key() const
+ {
+ Lock l(get_mutex());
+
+ if (bp::override f = get_override("config_location_key"))
+ return f();
+ else
+ throw PythonMethodNotImplemented("EnvironmentImplementation", "config_location_key");
+ }
};
struct NoConfigEnvironmentWrapper :