/usr/include/mia-2.0/mia/core/handler.hh is in libmia-2.0-dev 2.0.13-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | /* -*- mia-c++ -*-
*
* This file is part of MIA - a toolbox for medical image analysis
* Copyright (c) Leipzig, Madrid 1999-2013 Gert Wollny
*
* MIA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 MIA; if not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ph_handler_hh
#define ph_handler_hh
#include <string>
#include <map>
#include <set>
#include <vector>
#include <ostream>
#include <boost/any.hpp>
#include <mia/core/utils.hh>
#include <mia/core/filetools.hh>
#include <mia/core/defines.hh>
#include <mia/core/module.hh>
#include <mia/core/plugin_base.hh>
#include <mia/core/handlerbase.hh>
#include <mia/core/import_handler.hh>
NS_MIA_BEGIN
/**
\ingroup plugin
\brief The basic %template of all plugin handlers
The template TPluginHandler provides the base interface to all plug-in handlers.
\tparam I the plugin interface derived from \sa CPluginBase.
*/
template <typename I>
class EXPORT_HANDLER TPluginHandler: public CPluginHandlerBase {
public:
/// typedef for the plug-in interface provided by the class
typedef I Interface;
/// a map containing the names and theavailabe plug-ins
typedef std::map<std::string, Interface*> CPluginMap;
/// the iterator to walk over the available plug-ins
typedef typename CPluginMap::const_iterator const_iterator;
/**
The destructor frees the modules and plug-ins
*/
virtual ~TPluginHandler();
/// \returns the number of available plug-ins
size_t size() const;
/** \returns the names of the plug-ins as a space delimited string,
ordered case sensitive and alphabetically.
*/
const std::string get_plugin_names() const;
/** \returns the names of the plug-ins as a set */
const std::set<std::string> get_set() const;
/// \returns an iterator to the plug-ins
const_iterator begin()const;
/// \returns the behind-end iterator to the plug-ins
const_iterator end()const;
protected:
//! \name Constructors
//@{
/*! \brief Initializes the plugin handler based on the build-in search path
*/
TPluginHandler();
//@}
/** find a plugin by name. If the plug-in is not available, the method throws an
\a invalid_argument exception.
\param plugin name of the plugin
\returns pointer to the plug-in
*/
typename TPluginHandler<I>::Interface *plugin(const char *plugin) const;
/**
Add a given plug-in to the handler
@param plugin
*/
void add_plugin(Interface *plugin);
void initialise(CPathNameArray searchpath);
private:
virtual void do_initialise();
void global_searchpath(CPathNameArray& searchpath);
void do_add_dependend_handlers(HandlerHelpMap& handler_map) const;
std::vector<PPluginModule> m_modules;
CPluginMap m_plugins;
virtual void do_print_short_help(std::ostream& os) const;
virtual void do_print_help(std::ostream& os) const;
virtual void do_get_xml_help(xmlpp::Element *root) const;
static const char * const m_help;
};
/**
\ingroup plugin
\brief the singleton that a plug-in handler really is
Class to make a singleton out of a plugin handler by deriving from it.
*/
template <typename T>
class EXPORT_HANDLER THandlerSingleton : public T {
public:
/**
Set the plugin search path for the plug-in - throws "runtime_error" if the
plugin handler is already instanciated.
*/
static void set_search_path(const CPathNameArray& searchpath);
/// The instance of the plugin handler
typedef T Instance;
/// iterator to iterator over the actual plug-ins
typedef typename T::const_iterator const_iterator;
/// the name,plug-in pair \remark why do I need this
typedef typename T::CPluginMap::value_type value_type;
/**
\returns a reference to the only instance of the plugin handler
*/
static const T& instance();
/**
\returns a pointer to the only instance of the plugin handler, it is possible that
this instance is not yet initialized.
*/
static const T* pointer();
protected:
/** This mutex ensures that each Singleton is indeed only created once and
no race condition happens within a multi-threaded environmnet */
static CMutex m_creation_mutex;
private:
// the constructor is private because you must not derive the singleton
// derive the handler if you need specific funcionality, and then
// template the singleton with the derived handler.
THandlerSingleton();
static const T& do_instance(bool require_initialization);
static CPathNameArray m_searchpath;
static bool m_is_created;
static CMutex m_initialization_mutex;
static bool m_is_initialized;
};
NS_MIA_END
#endif
|