plugin_base.hh
Go to the documentation of this file.
/* -*- mia-c++ -*-
*
* This file is part of MIA - a toolbox for medical image analysis
* Copyright (c) Leipzig, Madrid 1999-2017 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 mia_core_plugin_base_hh
#define mia_core_plugin_base_hh
#include <map>
#include <set>
#include <string>
#include <ostream>
#include <mia/core/paramtranslator.hh>
#include <mia/core/module.hh>
#include <mia/core/property_flags.hh>
#include <mia/core/import_handler.hh>
NS_MIA_BEGIN
EXPORT_CORE extern const std::string plugin_help;
struct EXPORT_CORE PrepareTestPluginPath {
PrepareTestPluginPath();
~PrepareTestPluginPath();
};
class EXPORT_CORE CPluginBase: public CParamTranslator
{
public:
CPluginBase(const char *name);
virtual ~CPluginBase();
void set_priority(unsigned p);
unsigned get_priority() const;
void append_interface(CPluginBase *plugin);
CPluginBase *next_interface();
bool has_property(const char *property) const;
void set_module(const PPluginModule& module);
PPluginModule get_module() const;
void add_dependend_handlers(HandlerHelpMap& handler_map);
void add_property(const char *property);
private:
/* pointer to the next interface in a plugin chain
NULL indicates end of chain
*/
CPluginBase *m_next_interface;
/*
Specific properties of this plug in
*/
CPropertyFlagHolder m_properties;
unsigned m_priority;
/*
The dynamically loadable module that holds the code of this plugin.
*/
PPluginModule m_module;
};
template <typename D, typename T>
class EXPORT_HANDLER TPlugin: public CPluginBase
{
public:
typedef D PlugData;
typedef T PlugType;
TPlugin(const char *name);
virtual void get_help(std::ostream& os) const;
static const char *get_data_path_part();
static const char *get_type_path_part();
const std::string get_long_name() const;
};
template <typename Plugin>
struct plugin_can_chain {
static constexpr bool value = false;
typedef void Chained;
};
NS_MIA_END
#endif
CParamTranslator::CParamTranslator
CParamTranslator(const char *name)
CPluginBase::add_dependend_handlers
void add_dependend_handlers(HandlerHelpMap &handler_map)
CPluginBase::add_property
void add_property(const char *property)
CPluginBase::next_interface
CPluginBase * next_interface()
CPluginBase::append_interface
void append_interface(CPluginBase *plugin)
CPluginBase::~CPluginBase
virtual ~CPluginBase()
CPluginBase::set_priority
void set_priority(unsigned p)
CPluginBase::set_module
void set_module(const PPluginModule &module)
CPluginBase::has_property
bool has_property(const char *property) const
CPluginBase::get_module
PPluginModule get_module() const
CPluginBase::get_priority
unsigned get_priority() const
CPluginBase::CPluginBase
CPluginBase(const char *name)
CPropertyFlagHolder
This class holds a set of properties.
Definition property_flags.hh:42
TPlugin::PlugData
D PlugData
Typedef for the data type descriptor handled by this plug-in.
Definition plugin_base.hh:175
TPlugin::TPlugin
TPlugin(const char *name)
TPlugin::PlugType
T PlugType
Typedef for the plugin type descriptor handled by this plug-in.
Definition plugin_base.hh:178
TPlugin::get_type_path_part
static const char * get_type_path_part()
TPlugin::get_long_name
const std::string get_long_name() const
TPlugin::get_data_path_part
static const char * get_data_path_part()
TPlugin::get_help
virtual void get_help(std::ostream &os) const
EXPORT_HANDLER
#define EXPORT_HANDLER
Definition core/cost.hh:32
NS_MIA_BEGIN
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition defines.hh:33
EXPORT_CORE
#define EXPORT_CORE
Macro to manage Visual C++ style dllimport/dllexport.
Definition defines.hh:101
NS_MIA_END
#define NS_MIA_END
conveniance define to end the mia namespace
Definition defines.hh:36
PPluginModule
std::shared_ptr< CPluginModule > PPluginModule
Definition module.hh:81
HandlerHelpMap
std::map< std::string, const CPluginHandlerBase * > HandlerHelpMap
A map that is used to collect the plug-in handlers used in a program.
Definition handlerbase.hh:45
import_handler.hh
module.hh
paramtranslator.hh
plugin_help
EXPORT_CORE const std::string plugin_help
standard string to print out help in the factory plug-in handler
property_flags.hh
PrepareTestPluginPath::~PrepareTestPluginPath
~PrepareTestPluginPath()
PrepareTestPluginPath::PrepareTestPluginPath
PrepareTestPluginPath()
plugin_can_chain
Definition plugin_base.hh:210
plugin_can_chain::value
static constexpr bool value
Definition plugin_base.hh:211
plugin_can_chain::Chained
void Chained
Definition plugin_base.hh:212