22 #ifndef CTKCMDLINEMODULEBACKENDFUNCTIONPOINTER_H
23 #define CTKCMDLINEMODULEBACKENDFUNCTIONPOINTER_H
27 #include "ctkCommandLineModulesBackendFunctionPointerExport.h"
29 #include "ctkCmdLineModuleBackendFPUtil_p.h"
31 #include <QScopedPointer>
32 #include <QSharedPointer>
41 namespace CmdLineModuleBackendFunctionPointer {
43 struct FunctionPointerProxy;
51 template<
typename T,
typename Enable =
void>
54 static QString
parameter(
int index,
const QString& typeName,
const QString& label = QString(),
const QString& description = QString())
57 QTextStream str(&xmlParameter);
58 str <<
" <" << typeName <<
">\n";
59 str <<
" <name>" << QString(
"param%1").arg(index) <<
"</name>\n";
60 str <<
" <index>" << index <<
"</index>\n";
61 str <<
" <description>" << (description.isEmpty() ?
"Description not available." : description) <<
"</description>\n";
62 str <<
" <label>" << (label.isEmpty() ? QString(
"Parameter %1").arg(index) : label) <<
"</label>\n";
63 str <<
" </" << typeName <<
">\n";
72 static QString
parameter(
int index,
const QString& typeName,
const QString& label = QString(),
const QString& description = QString())
75 QTextStream str(&xmlParameter);
76 str <<
" <" << typeName <<
">\n";
77 str <<
" <name>" << QString(
"param%1").arg(index) <<
"</name>\n";
78 str <<
" <index>" << index <<
"</index>\n";
79 str <<
" <description>" << (description.isEmpty() ?
"Description not available." : description) <<
"</description>\n";
80 str <<
" <label>" << (label.isEmpty() ? QString(
"Parameter %1").arg(index) : label) <<
"</label>\n";
81 str <<
" <channel>input</channel>\n";
82 str <<
" </" << typeName <<
">\n";
92 struct ctkCmdLineModuleBackendFunctionPointerPrivate;
107 class DescriptionPrivate;
136 friend class ctkCmdLineModuleFunctionPointerTask;
137 Description(
const QUrl& location,
const ctk::CmdLineModuleBackendFunctionPointer::FunctionPointerProxy& fpProxy);
139 QSharedPointer<DescriptionPrivate> d;
159 const QString& paramLabel = QString(),
const QString& paramDescr = QString())
164 params << ctk::CmdLineModuleBackendFunctionPointer::CreateXmlFor<RawTypeA>::
166 ctk::CmdLineModuleBackendFunctionPointer::GetParameterTypeName<RawTypeA>(),
167 paramLabel, paramDescr);
168 return this->registerFunctionPointerProxy(title, ctk::CmdLineModuleBackendFunctionPointer::FunctionPointerProxy(fp), params);
171 template<
typename A,
typename B>
173 const QString& paramLabel0 = QString(),
const QString& paramDescr0 = QString(),
174 const QString& paramLabel1 = QString(),
const QString& paramDescr1 = QString())
180 params << ctk::CmdLineModuleBackendFunctionPointer::CreateXmlFor<RawTypeA>::
182 ctk::CmdLineModuleBackendFunctionPointer::GetParameterTypeName<RawTypeA>(),
183 paramLabel0, paramDescr0);
184 params << ctk::CmdLineModuleBackendFunctionPointer::CreateXmlFor<RawTypeB>::
186 ctk::CmdLineModuleBackendFunctionPointer::GetParameterTypeName<RawTypeB>(),
187 paramLabel1, paramDescr1);
188 return this->registerFunctionPointerProxy(title, ctk::CmdLineModuleBackendFunctionPointer::FunctionPointerProxy(fp), params);
199 Description* registerFunctionPointerProxy(
const QString &title,
200 const ctk::CmdLineModuleBackendFunctionPointer::FunctionPointerProxy& proxy,
204 QScopedPointer<ctkCmdLineModuleBackendFunctionPointerPrivate> d;
void setModuleCategory(const QString &category)
void setModuleVersion(const QString &version)
QUrl moduleLocation() const
QString moduleDescription() const
void setModuleContributor(const QString &contributor)
QString moduleVersion() const
QString moduleContributor() const
QString moduleCategory() const
QString moduleTitle() const
void setModuleTitle(const QString &title)
void setModuleDescription(const QString &description)
Provides a back-end implementation to enable directly calling a function pointer.
virtual ctkCmdLineModuleFuture run(ctkCmdLineModuleFrontend *frontend)
The main method to actually execute the back-end process.
Description * registerFunctionPointer(const QString &title, void(*fp)(A, B), const QString ¶mLabel0=QString(), const QString ¶mDescr0=QString(), const QString ¶mLabel1=QString(), const QString ¶mDescr1=QString())
virtual QList< QString > schemes() const
Returns a list of URL schemes this back-end can handle.
virtual QString name() const
Returns the name of the type of the backend, not the name of the thing or application that is run.
ctkCmdLineModuleBackendFunctionPointer()
Description * registerFunctionPointer(const QString &title, void(*fp)(A), const QString ¶mLabel=QString(), const QString ¶mDescr=QString())
virtual qint64 timeStamp(const QUrl &location) const
Returns a timestap of the backend, which for example in the case of the LocalProcess may be the last ...
~ctkCmdLineModuleBackendFunctionPointer()
virtual QList< QVariant > arguments(ctkCmdLineModuleFrontend *frontend) const
virtual QString description() const
Returns a brief description of the type of the backend.
QList< QUrl > registeredFunctionPointers() const
virtual QByteArray rawXmlDescription(const QUrl &location, int timeout)
Get the XML parameter description from the given location.
Abstract base class for all front-end command line module implementations.
QFuture sub-class for enhanced communication with running modules.
Select< isPointer, typename UnConst< PointeeType >::Result, typename Select< isReference, typename UnConst< ReferenceType >::Result, typename UnConst< T >::Result >::Result >::Result RawType
Q_DECLARE_METATYPE(ctkDICOMPersonName)
QString GetParameterTypeName()
Abstract base class for all back-end command line module implementations.
static QString parameter(int index, const QString &typeName, const QString &label=QString(), const QString &description=QString())
static QString parameter(int index, const QString &typeName, const QString &label=QString(), const QString &description=QString())