Skip to content

Commit

Permalink
Merge pull request #1776 from STEllAR-GROUP/plugin_cleanup
Browse files Browse the repository at this point in the history
Cleaning up util/plugin
  • Loading branch information
sithhell committed Oct 2, 2015
2 parents 7587657 + 8a9a00f commit e3a0e0a
Show file tree
Hide file tree
Showing 14 changed files with 105 additions and 654 deletions.
14 changes: 6 additions & 8 deletions hpx/plugins/plugin_factory_base.hpp
Expand Up @@ -9,11 +9,10 @@
#include <hpx/hpx_fwd.hpp>
#include <hpx/plugins/plugin_registry_base.hpp>

#include <hpx/util/detail/pack.hpp>
#include <hpx/util/plugin.hpp>
#include <hpx/util/plugin/export_plugin.hpp>

#include <boost/mpl/list.hpp>

///////////////////////////////////////////////////////////////////////////////
namespace hpx { namespace plugins
{
Expand All @@ -29,7 +28,7 @@ namespace hpx { namespace plugins
namespace hpx { namespace util { namespace plugin
{
///////////////////////////////////////////////////////////////////////////
// The following specialization of the virtual_constructors template
// The following specialization of the virtual_constructor template
// defines the argument list for the constructor of the concrete component
// factory (derived from the component_factory_base above). This magic is needed
// because we use hpx::plugin for the creation of instances of derived
Expand All @@ -47,13 +46,12 @@ namespace hpx { namespace util { namespace plugin
// };
//
template <>
struct virtual_constructors<hpx::plugins::plugin_factory_base>
struct virtual_constructor<hpx::plugins::plugin_factory_base>
{
typedef boost::mpl::list<
boost::mpl::list<
typedef
hpx::util::detail::pack<
hpx::util::section const*, hpx::util::section const*, bool
>
> type;
> type;
};
}}}

Expand Down
14 changes: 6 additions & 8 deletions hpx/runtime/components/component_factory_base.hpp
Expand Up @@ -10,15 +10,14 @@
#include <hpx/runtime/naming/name.hpp>
#include <hpx/runtime/components/component_type.hpp>
#include <hpx/runtime/components/component_registry_base.hpp>
#include <hpx/util/detail/pack.hpp>
#include <hpx/util/plugin.hpp>
#include <hpx/util/plugin/export_plugin.hpp>

#if defined(HPX_HAVE_SECURITY)
#include <hpx/components/security/capability.hpp>
#endif

#include <boost/mpl/list.hpp>

///////////////////////////////////////////////////////////////////////////////
namespace hpx { namespace components
{
Expand Down Expand Up @@ -130,7 +129,7 @@ namespace hpx { namespace components
namespace hpx { namespace util { namespace plugin
{
///////////////////////////////////////////////////////////////////////////
// The following specialization of the virtual_constructors template
// The following specialization of the virtual_constructor template
// defines the argument list for the constructor of the concrete component
// factory (derived from the component_factory_base above). This magic is needed
// because we use hpx::plugin for the creation of instances of derived
Expand All @@ -148,13 +147,12 @@ namespace hpx { namespace util { namespace plugin
// };
//
template <>
struct virtual_constructors<hpx::components::component_factory_base>
struct virtual_constructor<hpx::components::component_factory_base>
{
typedef boost::mpl::list<
boost::mpl::list<
typedef
hpx::util::detail::pack<
hpx::util::section const*, hpx::util::section const*, bool
>
> type;
> type;
};
}}}

Expand Down
2 changes: 1 addition & 1 deletion hpx/runtime/components/static_factory_data.hpp
Expand Up @@ -11,7 +11,7 @@
#include <hpx/config.hpp>
#include <hpx/util/plugin.hpp>
#include <hpx/util/plugin/export_plugin.hpp>
#include <hpx/util/plugin/virtual_constructors.hpp>
#include <hpx/util/plugin/virtual_constructor.hpp>

#include <boost/preprocessor/stringize.hpp>

Expand Down
2 changes: 1 addition & 1 deletion hpx/util/init_ini_data.hpp
Expand Up @@ -9,7 +9,7 @@

#include <hpx/util/ini.hpp>
#include <hpx/util/plugin/dll.hpp>
#include <hpx/util/plugin/virtual_constructors.hpp>
#include <hpx/util/plugin/virtual_constructor.hpp>
#include <hpx/plugins/plugin_registry_base.hpp>

#include <boost/filesystem/path.hpp>
Expand Down
60 changes: 15 additions & 45 deletions hpx/util/plugin/abstract_factory.hpp
Expand Up @@ -6,11 +6,7 @@
#ifndef HPX_ABSTRACT_FACTORY_VP_2004_08_25
#define HPX_ABSTRACT_FACTORY_VP_2004_08_25

#include <boost/mpl/inherit_linearly.hpp>
#include <boost/mpl/list.hpp>
#include <boost/shared_ptr.hpp>

#include <hpx/util/plugin/virtual_constructors.hpp>
#include <hpx/util/plugin/virtual_constructor.hpp>

namespace hpx { namespace util { namespace plugin {

Expand All @@ -22,59 +18,33 @@ namespace hpx { namespace util { namespace plugin {
void create(int*******);
};

template<typename BasePlugin, typename Base, typename Parameter>
struct abstract_factory_item;
/** A template class, which is given the base type of plugin and a set
of constructor parameter types and defines the appropriate virtual
'create' function.
*/
template<typename BasePlugin, typename Base, typename Parameters>
struct abstract_factory_item;

template<typename BasePlugin, typename Base>
struct abstract_factory_item<BasePlugin, Base, boost::mpl::list<> >
: public Base
{
using Base::create;
virtual BasePlugin* create(dll_handle dll) = 0;
};

template<typename BasePlugin, typename Base, typename A1>
struct abstract_factory_item<BasePlugin, Base, boost::mpl::list<A1> >
: public Base
template<typename BasePlugin, typename Base, typename...Parameters>
struct abstract_factory_item<BasePlugin, Base,
hpx::util::detail::pack<Parameters...> >
: public Base
{
using Base::create;
virtual BasePlugin* create(dll_handle dll, A1 a1) = 0;
};

template<typename BasePlugin, typename Base, typename A1, typename A2>
struct abstract_factory_item<BasePlugin, Base, boost::mpl::list<A1, A2> >
: public Base
{
using Base::create;
virtual BasePlugin* create(dll_handle dll, A1 a1, A2 a2) = 0;
virtual BasePlugin* create(dll_handle dll, Parameters...parameters) = 0;
};

///////////////////////////////////////////////////////////////////////////
//
// Bring in the remaining abstract_factory_item definitions for parameter
// counts greater 2
//
///////////////////////////////////////////////////////////////////////////
#include <hpx/util/plugin/detail/abstract_factory_impl.hpp>

///////////////////////////////////////////////////////////////////////////
} // namespace detail

///////////////////////////////////////////////////////////////////////////
template<class BasePlugin>
struct abstract_factory :
public boost::mpl::inherit_linearly<
typename virtual_constructors<BasePlugin>::type,
detail::abstract_factory_item<BasePlugin,
boost::mpl::placeholders::_, boost::mpl::placeholders::_>,
detail::abstract_factory_item_base
>::type
{
};
struct abstract_factory
: detail::abstract_factory_item<
BasePlugin,
detail::abstract_factory_item_base,
typename virtual_constructor<BasePlugin>::type
>
{};

}}}

Expand Down
62 changes: 14 additions & 48 deletions hpx/util/plugin/concrete_factory.hpp
Expand Up @@ -6,10 +6,8 @@
#ifndef HPX_CONCRETE_FACTORY_VP_2004_08_25
#define HPX_CONCRETE_FACTORY_VP_2004_08_25

#include <iostream>

#include <hpx/util/plugin/abstract_factory.hpp>
#include <hpx/util/plugin/detail/plugin_wrapper.hpp>
#include <hpx/util/plugin/plugin_wrapper.hpp>

///////////////////////////////////////////////////////////////////////////////
namespace hpx { namespace util { namespace plugin {
Expand All @@ -18,66 +16,34 @@ namespace hpx { namespace util { namespace plugin {
{
template<
typename BasePlugin, typename Concrete, typename Base,
typename Parameters
typename Parameter
>
struct concrete_factory_item;

template<typename BasePlugin, typename Concrete, typename Base>
struct concrete_factory_item<
BasePlugin, Concrete, Base, boost::mpl::list<>
>
: public Base
{
BasePlugin* create(dll_handle dll)
{
return new plugin_wrapper<Concrete, boost::mpl::list<> >(dll);
}
};

template<typename BasePlugin, typename Concrete, typename Base, typename A1>
struct concrete_factory_item<
BasePlugin, Concrete, Base, boost::mpl::list<A1>
template<
typename BasePlugin, typename Concrete, typename Base,
typename...Parameters
>
: public Base
{
BasePlugin* create(dll_handle dll, A1 a1)
{
return new plugin_wrapper<Concrete, boost::mpl::list<A1> >(dll, a1);
}
};

template<typename BasePlugin, typename Concrete, typename Base,
typename A1, typename A2>
struct concrete_factory_item<BasePlugin, Concrete, Base,
boost::mpl::list<A1, A2> >
: public Base
hpx::util::detail::pack<Parameters...> >
: public Base
{
BasePlugin* create(dll_handle dll, A1 a1, A2 a2)
BasePlugin* create(dll_handle dll, Parameters...parameters)
{
return new plugin_wrapper<Concrete, boost::mpl::list<A1
, A2> >(dll, a1, a2);
return new plugin_wrapper<Concrete, Parameters...>(dll, parameters...);
}
};
}

///////////////////////////////////////////////////////////////////////////////
//
// Bring in the remaining concrete_factory_item definitions for parameter
// counts greater 2
//
///////////////////////////////////////////////////////////////////////////////
#include <hpx/util/plugin/detail/concrete_factory_impl.hpp>

///////////////////////////////////////////////////////////////////////////
template<typename BasePlugin, typename Concrete>
struct concrete_factory
: public boost::mpl::inherit_linearly<
typename virtual_constructors<BasePlugin>::type,
detail::concrete_factory_item<BasePlugin, Concrete,
boost::mpl::placeholders::_, boost::mpl::placeholders::_>,
abstract_factory<BasePlugin>
>::type
{};
: detail::concrete_factory_item<
BasePlugin,
Concrete, abstract_factory<BasePlugin>,
typename virtual_constructor<BasePlugin>::type
> {};

///////////////////////////////////////////////////////////////////////////////
}}} // namespace hpx::util::plugin
Expand Down
52 changes: 0 additions & 52 deletions hpx/util/plugin/detail/abstract_factory_impl.hpp

This file was deleted.

61 changes: 0 additions & 61 deletions hpx/util/plugin/detail/concrete_factory_impl.hpp

This file was deleted.

0 comments on commit e3a0e0a

Please sign in to comment.