summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2018-05-12 16:25:32 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2018-05-12 16:25:32 +0100
commitc4019aac50df36fbab743b6dc1a882d9a9e30686 (patch)
tree659fb14b057ade4018845fe71452a033683d190b
parentAdd missing include guard (diff)
downloadlibadhocutil-c4019aac50df36fbab743b6dc1a882d9a9e30686.tar.bz2
libadhocutil-c4019aac50df36fbab743b6dc1a882d9a9e30686.tar.xz
libadhocutil-c4019aac50df36fbab743b6dc1a882d9a9e30686.zip
Move multi index typeslibadhocutil-0.5.1.1
Reduce header bloat by moving the types into the .cpp.
-rw-r--r--libadhocutil/plugins.cpp27
-rw-r--r--libadhocutil/plugins.h27
2 files changed, 25 insertions, 29 deletions
diff --git a/libadhocutil/plugins.cpp b/libadhocutil/plugins.cpp
index 4ac5992..dc92ca3 100644
--- a/libadhocutil/plugins.cpp
+++ b/libadhocutil/plugins.cpp
@@ -3,6 +3,9 @@
#include <dlfcn.h>
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/ordered_index.hpp>
+#include <boost/multi_index/member.hpp>
+#include <boost/multi_index/mem_fun.hpp>
+#include <boost/multi_index/composite_key.hpp>
#include "compileTimeFormatter.h"
#include "globalStatic.impl.h"
#include <cxxabi.h>
@@ -61,16 +64,26 @@ namespace AdHoc {
{
}
- PluginManager::PluginManager() :
- plugins(new PluginStore()),
- resolvers(new TypePluginResolvers())
+ class PluginManager::PluginStore : public boost::multi_index_container<PluginPtr,
+ boost::multi_index::indexed_by<
+ boost::multi_index::ordered_non_unique<boost::multi_index::member<Plugin, const std::string, &Plugin::name>>,
+ boost::multi_index::ordered_non_unique<boost::multi_index::const_mem_fun<Plugin, const std::type_info &, &Plugin::type>>,
+ boost::multi_index::ordered_unique<
+ boost::multi_index::composite_key<
+ Plugin,
+ boost::multi_index::member<Plugin, const std::string, &Plugin::name>,
+ boost::multi_index::const_mem_fun<Plugin, const std::type_info &, &Plugin::type>
+ >>
+ >>
{
- }
+ };
- PluginManager::~PluginManager()
+ class PluginManager::TypePluginResolvers : public std::map<size_t, PluginResolver> { };
+
+ PluginManager::PluginManager() :
+ plugins(std::make_unique<PluginStore>()),
+ resolvers(std::make_unique<TypePluginResolvers>())
{
- delete resolvers;
- delete plugins;
}
PluginManager *
diff --git a/libadhocutil/plugins.h b/libadhocutil/plugins.h
index fe86834..d51ad2b 100644
--- a/libadhocutil/plugins.h
+++ b/libadhocutil/plugins.h
@@ -4,11 +4,6 @@
#include <memory>
#include <functional>
#include <optional>
-#include <boost/multi_index_container_fwd.hpp>
-#include <boost/multi_index/ordered_index_fwd.hpp>
-#include <boost/multi_index/member.hpp>
-#include <boost/multi_index/mem_fun.hpp>
-#include <boost/multi_index/composite_key.hpp>
#include <typeinfo>
#include <set>
#include <map>
@@ -106,7 +101,7 @@ namespace AdHoc {
typedef std::function<std::optional<std::string> (const std::type_info &, const std::string &)> PluginResolver;
PluginManager();
- virtual ~PluginManager();
+ virtual ~PluginManager() = default;
/// Install a plugin.
void add(const PluginPtr &);
@@ -208,22 +203,10 @@ namespace AdHoc {
private:
static void loadLibrary(const std::string &);
- typedef boost::multi_index_container<PluginPtr,
- boost::multi_index::indexed_by<
- boost::multi_index::ordered_non_unique<boost::multi_index::member<Plugin, const std::string, &Plugin::name>>,
- boost::multi_index::ordered_non_unique<boost::multi_index::const_mem_fun<Plugin, const std::type_info &, &Plugin::type>>,
- boost::multi_index::ordered_unique<
- boost::multi_index::composite_key<
- Plugin,
- boost::multi_index::member<Plugin, const std::string, &Plugin::name>,
- boost::multi_index::const_mem_fun<Plugin, const std::type_info &, &Plugin::type>
- >>
- >> PluginStore;
-
- typedef std::map<size_t, PluginResolver> TypePluginResolvers;
-
- PluginStore * plugins;
- TypePluginResolvers * resolvers;
+ class PluginStore;
+ std::unique_ptr<PluginStore> plugins;
+ class TypePluginResolvers;
+ std::unique_ptr<TypePluginResolvers> resolvers;
};
}