49 typedef std::map<std::string,std::string>
Data;
70 const std::string &description,
const std::string &creationSyntax){
71 Plugin p = { name, description, creationSyntax,
create };
78 typename std::map<std::string,Plugin>::iterator it =
plugins.find(name);
80 std::ostringstream all;
81 for(
typename std::map<std::string,Plugin>::iterator jt =
plugins.begin(); jt !=
plugins.end();){
83 if(++jt !=
plugins.end()) all <<
",";
85 throw utils::ICLException(
"PluginRegister<T>: unknow type: '"+ name +
"' (registered are: " +all.str() +
")");
88 return it->second.create(
data);
95 t(1,0) =
"Description";
96 t(2,0) =
"Creation Syntax";
98 for(
typename std::map<std::string,Plugin>::iterator it =
plugins.begin();
99 it !=
plugins.end(); ++it, ++i){
100 t(0,i) = it->second.name;
101 t(1,i) = it->second.description;
102 t(2,i) = it->second.creationSyntax;
123 #define REGISTER_PLUGIN(TYPE,NAME,CREATE_FUNCTION,DESCRIPTION,SYNTAX) \ 124 struct Static_##TYPE##_PluginRegistration__##NAME{ \ 125 Static_##TYPE##_PluginRegistration__##NAME(){ \ 126 PluginRegister<TYPE> &r = PluginRegister<TYPE>::instance(); \ 127 r.add(#NAME,CREATE_FUNCTION,DESCRIPTION,SYNTAX); \ 129 } static_##TYPE##_PluginRegistration__##NAME;
const std::map< std::string, Plugin > & getRegisteredPlugins() const
returns a all registered plugins
Definition: PluginRegister.h:108
PluginRegister()
private constructor (use singelton creator function instance())
Definition: PluginRegister.h:114
undocument this line if you encounter any issues!
Definition: Any.h:37
ICLQt_API core::Img< T > create(const std::string &name, core::format fmt=icl::core::formatRGB)
create a test image (converted to destination core::format) (affinity for floats)
static PluginRegister< T > & instance()
returns the static instance for the specific type
Definition: PluginRegister.h:63
T * createInstance(const std::string &name, const Data &data)
creates an instance (or throws
Definition: PluginRegister.h:76
CreateFunction create
factory function
Definition: PluginRegister.h:59
std::string description
description
Definition: PluginRegister.h:57
ICLQt_API ImgROI data(ImgQ &r)
creates full ROI ROI-struct
std::map< std::string, Plugin > plugins
internal plugin list
Definition: PluginRegister.h:117
std::map< std::string, std::string > Data
data used for instance creation
Definition: PluginRegister.h:49
std::string creationSyntax
syntax used for creation
Definition: PluginRegister.h:58
utils::Function< T *, const Data & > CreateFunction
creator function for instances
Definition: PluginRegister.h:52
Utility class for plugin registration.
Definition: PluginRegister.h:45
Utility class for pretty console output.
Definition: TextTable.h:85
std::string getRegisteredInstanceDescription()
returns a string representation of all registered types
Definition: PluginRegister.h:92
std::string toString() const
serializes the table to a std::string
void add(const std::string &name, CreateFunction create, const std::string &description, const std::string &creationSyntax)
adds a new plugin
Definition: PluginRegister.h:69
Base class for Exception handling in the ICL.
Definition: Exception.h:42
internally used instance type:
Definition: PluginRegister.h:55
std::string name
instance ID
Definition: PluginRegister.h:56