aboutsummaryrefslogtreecommitdiff
path: root/paludis
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-08-12 14:54:14 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-08-12 16:28:19 +0100
commit0f3eb4b7da157630049ad93334338c4ba796304c (patch)
tree8ca4326bbc6d54fa6839a35402c56d0844c94757 /paludis
parentdc24637ad9ea08b179bf76969533b29e95467eb4 (diff)
downloadpaludis-0f3eb4b7da157630049ad93334338c4ba796304c.tar.gz
paludis-0f3eb4b7da157630049ad93334338c4ba796304c.tar.xz
Replace EnvironmentMaker with EnvironmentFactory.
Diffstat (limited to 'paludis')
-rw-r--r--paludis/environment_factory-fwd.hh29
-rw-r--r--paludis/environment_factory.cc (renamed from paludis/environment_maker.cc)182
-rw-r--r--paludis/environment_factory.hh97
-rw-r--r--paludis/environment_maker.hh178
-rw-r--r--paludis/environments/adapted/registration.cc11
-rw-r--r--paludis/environments/no_config/registration.cc17
-rw-r--r--paludis/environments/paludis/paludis_config.hh5
-rw-r--r--paludis/environments/paludis/registration.cc16
-rw-r--r--paludis/environments/portage/registration.cc14
-rw-r--r--paludis/environments/test/registration.cc11
-rw-r--r--paludis/files.m42
11 files changed, 238 insertions, 324 deletions
diff --git a/paludis/environment_factory-fwd.hh b/paludis/environment_factory-fwd.hh
new file mode 100644
index 000000000..9379d7a5f
--- /dev/null
+++ b/paludis/environment_factory-fwd.hh
@@ -0,0 +1,29 @@
+/* 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
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_ENVIRONMENT_FACTORY_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_ENVIRONMENT_FACTORY_FWD_HH 1
+
+namespace paludis
+{
+ class EnvironmentFactory;
+ class FallBackToAnotherFormatError;
+}
+
+#endif
diff --git a/paludis/environment_maker.cc b/paludis/environment_factory.cc
index 335152e36..77c2b14a8 100644
--- a/paludis/environment_maker.cc
+++ b/paludis/environment_factory.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * 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
@@ -17,125 +17,54 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "environment_maker.hh"
+#include <paludis/environment_factory.hh>
+#include <paludis/util/instantiation_policy-impl.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/system.hh>
+#include <paludis/util/member_iterator-impl.hh>
+#include <paludis/util/join.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/dir_iterator.hh>
#include <paludis/util/is_file_with_extension.hh>
-#include <paludis/util/system.hh>
-#include <paludis/util/virtual_constructor-impl.hh>
-#include <paludis/util/instantiation_policy-impl.hh>
-#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/set.hh>
+#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/distribution.hh>
#include <paludis/about.hh>
-#include <list>
-#include <set>
+#include <tr1/unordered_map>
#include <dlfcn.h>
#include <stdint.h>
+#include <list>
#include "config.h"
using namespace paludis;
-template class VirtualConstructor<std::string,
- std::tr1::shared_ptr<Environment> (*) (const std::string &),
- virtual_constructor_not_found::ThrowException<NoSuchEnvironmentTypeError> >;
-
-template class InstantiationPolicy<EnvironmentMaker, instantiation_method::SingletonTag>;
-
-NoSuchEnvironmentTypeError::NoSuchEnvironmentTypeError(const std::string & format) throw ():
- ConfigurationError("No available maker for environment type '" + format + "'")
-{
-}
-
-PaludisEnvironmentSoDirNotADirectoryError::PaludisEnvironmentSoDirNotADirectoryError() throw () :
- Exception("PALUDIS_ENVIRONMENT_SO_DIR not a directory")
-{
-}
-
-PaludisEnvironmentSoDirCannotDlopenError::PaludisEnvironmentSoDirCannotDlopenError(
- const std::string & file, const std::string & e) throw () :
- Exception("Cannot dlopen an environment .so file"),
- _file(file),
- _dlerr(e)
-{
-}
-
-PaludisEnvironmentSoDirCannotDlopenError::~PaludisEnvironmentSoDirCannotDlopenError() throw ()
-{
-}
-
-const char *
-PaludisEnvironmentSoDirCannotDlopenError::what() const throw ()
-{
- if (_what.empty())
- _what = std::string(Exception::what()) +
- ": Cannot dlopen environment .so file '" + _file + "': '" + _dlerr + "'";
- return _what.c_str();
-}
+typedef std::tr1::unordered_map<std::string, EnvironmentFactory::CreateFunction> Keys;
namespace paludis
{
- template<>
- struct Implementation<EnvironmentMaker>
+ template <>
+ struct Implementation<EnvironmentFactory>
{
+ Keys keys;
std::list<void *> dl_opened;
};
}
-void
-EnvironmentMaker::load_dir(const FSEntry & so_dir)
-{
- for (DirIterator d(so_dir), d_end ; d != d_end ; ++d)
- {
- if (d->is_directory())
- load_dir(*d);
-
- if (! is_file_with_extension(*d, ".so." + stringify(100 * PALUDIS_VERSION_MAJOR + PALUDIS_VERSION_MINOR),
- IsFileWithOptions()))
- continue;
-
- /* don't use RTLD_LOCAL, g++ is over happy about template instantiations, and it
- * can lead to multiple singleton instances. */
- void * dl(dlopen(stringify(*d).c_str(), RTLD_GLOBAL | RTLD_NOW));
-
- if (dl)
- {
- _imp->dl_opened.push_back(dl);
-
- void * reg(dlsym(dl, "register_environments"));
- if (reg)
- {
- reinterpret_cast<void (*)(EnvironmentMaker *)>(
- reinterpret_cast<uintptr_t>(reg))(this);
- }
- else
- throw PaludisEnvironmentSoDirCannotDlopenError(stringify(*d),
- "no register_environments function defined");
- }
- else
- throw PaludisEnvironmentSoDirCannotDlopenError(stringify(*d), dlerror());
- }
-
- if ((so_dir / ".libs").is_directory())
- load_dir(so_dir / ".libs");
-}
-
-EnvironmentMaker::EnvironmentMaker() :
- PrivateImplementationPattern<EnvironmentMaker>(new Implementation<EnvironmentMaker>)
+EnvironmentFactory::EnvironmentFactory() :
+ PrivateImplementationPattern<EnvironmentFactory>(new Implementation<EnvironmentFactory>)
{
FSEntry so_dir(getenv_with_default("PALUDIS_ENVIRONMENT_SO_DIR", LIBDIR "/paludis/environments"));
-
if (! so_dir.is_directory())
- throw PaludisEnvironmentSoDirNotADirectoryError();
-
- load_dir(so_dir);
+ throw InternalError(PALUDIS_HERE, "PALUDIS_ENVIRONMENT_SO_DIR '" + stringify(so_dir) + "' not a directory");
+ _load_dir(so_dir);
}
-EnvironmentMaker::~EnvironmentMaker()
+EnvironmentFactory::~EnvironmentFactory()
{
}
-std::tr1::shared_ptr<Environment>
-EnvironmentMaker::make_from_spec(const std::string & s) const
+const std::tr1::shared_ptr<Environment>
+EnvironmentFactory::create(const std::string & s) const
{
Context context("When making environment from specification '" + s + "':");
@@ -156,18 +85,21 @@ EnvironmentMaker::make_from_spec(const std::string & s) const
try
{
- return (*find_maker(key))(suffix);
+ Keys::const_iterator i(_imp->keys.find(key));
+ if (_imp->keys.end() == i)
+ throw ConfigurationError("Format '" + key + "' not supported when creating an environment (known formats are { "
+ + join(first_iterator(_imp->keys.begin()), first_iterator(_imp->keys.end()), ", ") + "})");
+ return i->second(suffix);
}
- catch (const FallBackToAnotherMakerError &)
+ catch (const FallBackToAnotherFormatError &)
{
std::string f((*DistributionData::get_instance()->distribution_from_string(
getenv_with_default("PALUDIS_DISTRIBUTION", DEFAULT_DISTRIBUTION))).fallback_environment());
if (s.empty() && ! f.empty())
{
- std::set<std::string> keys;
- copy_keys(std::inserter(keys, keys.begin()));
- if (keys.end() != keys.find(f))
- return make_from_spec(f);
+ Keys::const_iterator i(_imp->keys.find(f));
+ if (_imp->keys.end() == i)
+ return i->second(suffix);
else
throw;
}
@@ -176,16 +108,56 @@ EnvironmentMaker::make_from_spec(const std::string & s) const
}
}
-FallBackToAnotherMakerError::FallBackToAnotherMakerError()
+void
+EnvironmentFactory::_load_dir(const FSEntry & so_dir)
{
-}
+ for (DirIterator d(so_dir), d_end ; d != d_end ; ++d)
+ {
+ if (d->is_directory())
+ _load_dir(*d);
-extern "C"
-{
- void PALUDIS_VISIBLE register_environments(EnvironmentMaker * maker);
+ if (! is_file_with_extension(*d, ".so." + stringify(100 * PALUDIS_VERSION_MAJOR + PALUDIS_VERSION_MINOR),
+ IsFileWithOptions()))
+ continue;
+
+ /* don't use RTLD_LOCAL, g++ is over happy about template instantiations, and it
+ * can lead to multiple singleton instances. */
+ void * dl(dlopen(stringify(*d).c_str(), RTLD_GLOBAL | RTLD_NOW));
+
+ if (dl)
+ {
+ _imp->dl_opened.push_back(dl);
+
+ void * reg(dlsym(dl, "paludis_initialise_environment_so"));
+ if (reg)
+ {
+ reinterpret_cast<void (*)(EnvironmentFactory * const)>(reinterpret_cast<uintptr_t>(reg))(this);
+ }
+ else
+ throw InternalError(PALUDIS_HERE, "No paludis_initialise_environment_so function defined in '" + stringify(*d) + "'");
+ }
+ else
+ throw InternalError(PALUDIS_HERE, "Couldn't dlopen '" + stringify(*d) + "': " + stringify(dlerror()));
+ }
+
+ if ((so_dir / ".libs").is_directory())
+ _load_dir(so_dir / ".libs");
}
-void register_environments(EnvironmentMaker *)
+void
+EnvironmentFactory::add_environment_format(
+ const std::tr1::shared_ptr<const Set<std::string> > & formats,
+ const CreateFunction & create_function
+ )
{
+ for (Set<std::string>::ConstIterator f(formats->begin()), f_end(formats->end()) ;
+ f != f_end ; ++f)
+ {
+ if (! _imp->keys.insert(std::make_pair(*f, create_function)).second)
+ throw ConfigurationError("Handler for environment format '" + stringify(*f) + "' already exists");
+ }
}
+template class InstantiationPolicy<EnvironmentFactory, instantiation_method::SingletonTag>;
+template class PrivateImplementationPattern<EnvironmentFactory>;
+
diff --git a/paludis/environment_factory.hh b/paludis/environment_factory.hh
new file mode 100644
index 000000000..b5821bf63
--- /dev/null
+++ b/paludis/environment_factory.hh
@@ -0,0 +1,97 @@
+/* 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
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_ENVIRONMENT_FACTORY_HH
+#define PALUDIS_GUARD_PALUDIS_ENVIRONMENT_FACTORY_HH 1
+
+#include <paludis/environment_factory-fwd.hh>
+#include <paludis/util/attributes.hh>
+#include <paludis/util/instantiation_policy.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/set-fwd.hh>
+#include <paludis/util/fs_entry-fwd.hh>
+#include <paludis/environment-fwd.hh>
+#include <tr1/memory>
+#include <tr1/functional>
+
+namespace paludis
+{
+ class PALUDIS_VISIBLE FallBackToAnotherFormatError
+ {
+ };
+
+ /**
+ * Factory for Environment creation.
+ *
+ * \ingroup g_environment
+ * \since 0.30
+ */
+ class PALUDIS_VISIBLE EnvironmentFactory :
+ private PrivateImplementationPattern<EnvironmentFactory>,
+ public InstantiationPolicy<EnvironmentFactory, instantiation_method::SingletonTag>
+ {
+ friend class InstantiationPolicy<EnvironmentFactory, instantiation_method::SingletonTag>;
+
+ private:
+ EnvironmentFactory();
+ ~EnvironmentFactory();
+
+ void _load_dir(const FSEntry &);
+
+ public:
+ typedef std::tr1::function<const std::tr1::shared_ptr<Environment>(const std::string &)> CreateFunction;
+
+ /**
+ * Create an Environment subclass from the specified spec.
+ *
+ * \param spec The environment spec, which is in the form
+ * env:suffix, where env is the string representing an
+ * Environment's kind (e.g. "paludis", "portage") and
+ * suffix is the information to pass to the constructing
+ * function (for paludis, a config suffix, and for portage,
+ * a location). If env is not specified, it defaults to
+ * trying paludis then portage. If suffix is not specified,
+ * it defaults to an empty string. If no colon is present,
+ * the supplied string is taken as env (this includes an
+ * empty string).
+ */
+ const std::tr1::shared_ptr<Environment> create(const std::string & spec) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ /**
+ * Add a repository format.
+ *
+ * \param formats must have at least one value, and no value may be
+ * specified more than once across all invocations.
+ *
+ * \param create_function is used to implement EnvironmentFactory::create.
+ */
+ void add_environment_format(
+ const std::tr1::shared_ptr<const Set<std::string> > & formats,
+ const CreateFunction & create_function
+ );
+ };
+
+#ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
+ extern template class PrivateImplementationPattern<EnvironmentFactory>;
+ extern template class InstantiationPolicy<EnvironmentFactory, instantiation_method::SingletonTag>;
+#endif
+}
+
+#endif
diff --git a/paludis/environment_maker.hh b/paludis/environment_maker.hh
deleted file mode 100644
index 2dc9b8883..000000000
--- a/paludis/environment_maker.hh
+++ /dev/null
@@ -1,178 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2007, 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
- */
-
-#ifndef PALUDIS_GUARD_PALUDIS_ENVIRONMENT_MAKER_HH
-#define PALUDIS_GUARD_PALUDIS_ENVIRONMENT_MAKER_HH 1
-
-#include <paludis/util/instantiation_policy.hh>
-#include <paludis/util/private_implementation_pattern.hh>
-#include <paludis/util/virtual_constructor.hh>
-#include <paludis/environment.hh>
-
-
-/** \file
- * Declarations for the EnvironmentMaker class.
- *
- * \ingroup g_environment
- *
- * \section Examples
- *
- * - \ref example_environment.cc "example_environment.cc"
- */
-
-namespace paludis
-{
- class FSEntry;
-
- /**
- * Thrown if an environment of the specified type does not exist.
- *
- * \ingroup g_exceptions
- * \ingroup g_environment
- * \nosubgrouping
- */
- class PALUDIS_VISIBLE NoSuchEnvironmentTypeError : public ConfigurationError
- {
- public:
- ///\name Basic operations
- ///\{
-
- NoSuchEnvironmentTypeError(const std::string & format) throw ();
-
- ///\}
- };
-
- /**
- * Thrown if PALUDIS_ENVIRONMENT_SO_DIR is not a directory.
- *
- * \ingroup g_exceptions
- * \ingroup g_environment
- * \nosubgrouping
- */
- class PALUDIS_VISIBLE PaludisEnvironmentSoDirNotADirectoryError :
- public Exception
- {
- public:
- ///\name Basic operations
- ///\{
-
- PaludisEnvironmentSoDirNotADirectoryError() throw ();
-
- ///\}
- };
-
- /**
- * Thrown if an environment .so cannot be used.
- *
- * \ingroup g_exceptions
- * \ingroup g_environment
- */
- class PALUDIS_VISIBLE PaludisEnvironmentSoDirCannotDlopenError :
- public Exception
- {
- private:
- std::string _file, _dlerr;
- mutable std::string _what;
-
- public:
- ///\name Basic operations
- ///\{
-
- PaludisEnvironmentSoDirCannotDlopenError(const std::string & file,
- const std::string & e) throw ();
-
- ~PaludisEnvironmentSoDirCannotDlopenError() throw ();
-
- ///\}
-
- const char * what() const throw ();
- };
-
- /**
- * If an EnvironmentMaker default call fails with an exception of this type,
- * it is ok to fall back and try another maker.
- *
- * \ingroup g_environment
- * \ingroup g_exceptions
- * \nosubgrouping
- */
- class PALUDIS_VISIBLE FallBackToAnotherMakerError
- {
- protected:
- ///\name Basic operations
- ///\{
-
- FallBackToAnotherMakerError();
-
- ///\}
- };
-
- /**
- * Virtual constructor for environments.
- *
- * \ingroup g_environment
- * \nosubgrouping
- */
- class PALUDIS_VISIBLE EnvironmentMaker :
- public VirtualConstructor<std::string,
- std::tr1::shared_ptr<Environment> (*) (const std::string &),
- virtual_constructor_not_found::ThrowException<NoSuchEnvironmentTypeError> >,
- public InstantiationPolicy<EnvironmentMaker, instantiation_method::SingletonTag>,
- private PrivateImplementationPattern<EnvironmentMaker>
- {
- friend class InstantiationPolicy<EnvironmentMaker, instantiation_method::SingletonTag>;
-
- private:
- EnvironmentMaker();
-
- void load_dir(const FSEntry &);
-
- public:
- ///\name Basic operations
- ///\{
-
- ~EnvironmentMaker();
-
- ///\}
-
- /**
- * Create an Environment subclass from the specified spec.
- *
- * \param spec The environment spec, which is in the form
- * env:suffix, where env is the string representing an
- * Environment's kind (e.g. "paludis", "portage") and
- * suffix is the information to pass to the constructing
- * function (for paludis, a config suffix, and for portage,
- * a location). If env is not specified, it defaults to
- * trying paludis then portage. If suffix is not specified,
- * it defaults to an empty string. If no colon is present,
- * the supplied string is taken as env (this includes an
- * empty string).
- *
- * \throw NoSuchEnvironmentTypeError if an invalid environment type
- * is specified.
- *
- * \see Environment
- * \ingroup g_environment
- */
- std::tr1::shared_ptr<Environment> make_from_spec(const std::string & spec) const;
- };
-}
-
-#endif
diff --git a/paludis/environments/adapted/registration.cc b/paludis/environments/adapted/registration.cc
index f6bf5f284..de91c5ecb 100644
--- a/paludis/environments/adapted/registration.cc
+++ b/paludis/environments/adapted/registration.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 Ciaran McCreesh
+ * Copyright (c) 2007, 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
@@ -17,16 +17,13 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis/environment_maker.hh>
+#include <paludis/environment_factory.hh>
using namespace paludis;
-extern "C"
-{
- void PALUDIS_VISIBLE register_environments(EnvironmentMaker * maker);
-}
+extern "C" void paludis_initialise_environment_so(EnvironmentFactory * const) PALUDIS_VISIBLE;
-void register_environments(EnvironmentMaker *)
+void paludis_initialise_environment_so(EnvironmentFactory * const)
{
}
diff --git a/paludis/environments/no_config/registration.cc b/paludis/environments/no_config/registration.cc
index 0601d22bc..091ba68f5 100644
--- a/paludis/environments/no_config/registration.cc
+++ b/paludis/environments/no_config/registration.cc
@@ -17,9 +17,10 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis/environment_maker.hh>
#include <paludis/environments/no_config/no_config_environment.hh>
+#include <paludis/environment_factory.hh>
#include <paludis/util/map.hh>
+#include <paludis/util/set.hh>
#include <paludis/util/tokeniser.hh>
#include <paludis/util/destringify.hh>
#include <paludis/util/make_shared_ptr.hh>
@@ -27,11 +28,6 @@
using namespace paludis;
-extern "C"
-{
- void PALUDIS_VISIBLE register_environments(EnvironmentMaker * maker);
-}
-
namespace
{
std::tr1::shared_ptr<Environment>
@@ -94,8 +90,13 @@ namespace
}
}
-void register_environments(EnvironmentMaker * maker)
+extern "C" void paludis_initialise_environment_so(EnvironmentFactory * const) PALUDIS_VISIBLE;
+
+void paludis_initialise_environment_so(EnvironmentFactory * const factory)
{
- maker->register_maker("no-config", &make_no_config_environment);
+ std::tr1::shared_ptr<Set<std::string> > no_config_formats(new Set<std::string>);
+ no_config_formats->insert("no_config");
+ no_config_formats->insert("no-config");
+ factory->add_environment_format(no_config_formats, &make_no_config_environment);
}
diff --git a/paludis/environments/paludis/paludis_config.hh b/paludis/environments/paludis/paludis_config.hh
index 6b8b76e70..6e9f8dff1 100644
--- a/paludis/environments/paludis/paludis_config.hh
+++ b/paludis/environments/paludis/paludis_config.hh
@@ -22,6 +22,7 @@
#include <paludis/dep_spec.hh>
#include <paludis/name.hh>
+#include <paludis/environment_factory.hh>
#include <paludis/util/exception.hh>
#include <paludis/util/instantiation_policy.hh>
#include <paludis/util/sr.hh>
@@ -29,7 +30,7 @@
#include <paludis/util/map-fwd.hh>
#include <paludis/util/wrapped_forward_iterator-fwd.hh>
#include <paludis/util/named_value.hh>
-#include <paludis/environment_maker.hh>
+#include <paludis/util/fs_entry-fwd.hh>
#include <string>
@@ -92,7 +93,7 @@ namespace paludis
*/
class PALUDIS_VISIBLE PaludisConfigNoDirectoryError :
public PaludisConfigError,
- public FallBackToAnotherMakerError
+ public FallBackToAnotherFormatError
{
public:
///\name Basic operations
diff --git a/paludis/environments/paludis/registration.cc b/paludis/environments/paludis/registration.cc
index 8b8dd3ed4..e8efc02e5 100644
--- a/paludis/environments/paludis/registration.cc
+++ b/paludis/environments/paludis/registration.cc
@@ -17,8 +17,9 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis/environment_maker.hh>
#include <paludis/environments/paludis/paludis_environment.hh>
+#include <paludis/environment_factory.hh>
+#include <paludis/util/set.hh>
using namespace paludis;
@@ -31,15 +32,12 @@ namespace
}
}
-extern "C"
-{
- void PALUDIS_VISIBLE register_environments(EnvironmentMaker * maker);
-}
+extern "C" void paludis_initialise_environment_so(EnvironmentFactory * const) PALUDIS_VISIBLE;
-void register_environments(EnvironmentMaker * maker)
+void paludis_initialise_environment_so(EnvironmentFactory * const factory)
{
- maker->register_maker("paludis", &make_paludis_environment);
+ std::tr1::shared_ptr<Set<std::string> > paludis_formats(new Set<std::string>);
+ paludis_formats->insert("paludis");
+ factory->add_environment_format(paludis_formats, &make_paludis_environment);
}
-
-
diff --git a/paludis/environments/portage/registration.cc b/paludis/environments/portage/registration.cc
index bdc6ada23..69b3a3634 100644
--- a/paludis/environments/portage/registration.cc
+++ b/paludis/environments/portage/registration.cc
@@ -17,8 +17,9 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis/environment_maker.hh>
+#include <paludis/environment_factory.hh>
#include <paludis/environments/portage/portage_environment.hh>
+#include <paludis/util/set.hh>
using namespace paludis;
@@ -31,13 +32,12 @@ namespace
}
}
-extern "C"
-{
- void PALUDIS_VISIBLE register_environments(EnvironmentMaker * maker);
-}
+extern "C" void paludis_initialise_environment_so(EnvironmentFactory * const) PALUDIS_VISIBLE;
-void register_environments(EnvironmentMaker * maker)
+void paludis_initialise_environment_so(EnvironmentFactory * const factory)
{
- maker->register_maker("portage", &make_portage_environment);
+ std::tr1::shared_ptr<Set<std::string> > portage_formats(new Set<std::string>);
+ portage_formats->insert("portage");
+ factory->add_environment_format(portage_formats, &make_portage_environment);
}
diff --git a/paludis/environments/test/registration.cc b/paludis/environments/test/registration.cc
index cc99da3cb..1b4a4c351 100644
--- a/paludis/environments/test/registration.cc
+++ b/paludis/environments/test/registration.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 Ciaran McCreesh
+ * Copyright (c) 2007, 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
@@ -17,17 +17,14 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis/environment_maker.hh>
+#include <paludis/environment_factory.hh>
#include <paludis/environments/test/test_environment.hh>
using namespace paludis;
-extern "C"
-{
- void PALUDIS_VISIBLE register_environments(EnvironmentMaker * maker);
-}
+extern "C" void paludis_initialise_environment_so(EnvironmentFactory * const) PALUDIS_VISIBLE;
-void register_environments(EnvironmentMaker *)
+void paludis_initialise_environment_so(EnvironmentFactory * const)
{
}
diff --git a/paludis/files.m4 b/paludis/files.m4
index 6a0487da1..c349656fc 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -28,8 +28,8 @@ add(`elike_package_dep_spec', `hh', `cc', `fwd', `se')
add(`elike_slot_requirement', `hh', `cc', `fwd')
add(`elike_use_requirement', `hh', `cc', `fwd', `se', `test')
add(`environment', `hh', `fwd', `cc')
+add(`environment_factory', `hh', `fwd', `cc')
add(`environment_implementation', `hh', `cc')
-add(`environment_maker', `hh', `cc')
add(`filter', `hh', `cc', `fwd', `test')
add(`filter_handler', `hh', `cc', `fwd')
add(`filtered_generator', `hh', `cc', `fwd', `test')