60template<
class OBJ_TYPE,
typename OBJ_TYPE_POINTER,
typename WRAPPER_CLASS_NAME>
class ITKMLBaseWrapper
68 _realWrapper(
realWrapper), _wrapperSuperStructPtrs(&parentSuperStruct)
70 _outputBaseField =
nullptr;
71 _inputBaseField =
nullptr;
75 _numAddOutputBaseFieldCalls=0;
76 _numAddInputBaseFieldCalls=0;
101 if (_numAddOutputBaseFieldCalls!=0){
107 _outputBaseField =
module.addBase(outputFieldName);
109 _outputBaseField->setBaseValue(&_realWrapper);
110 ++_numAddOutputBaseFieldCalls;
124 if (_numAddInputBaseFieldCalls!=0){
130 _inputBaseField =
module.addBase(inputFieldName);
132 _inputBaseField->setBaseValue(
nullptr);
133 ++_numAddInputBaseFieldCalls;
142 if (_outputBaseField){ _outputBaseField->touch(); }
150 return _outputBaseField;
158 return _inputBaseField;
181 if (
follow->nameStrings[0] ==
follow->nameStrings[1]){
return false; }
195 if (_inputBaseField){
199 Base *
inPtr = _inputBaseField->getBaseValue();
265#define ML_CREATE_BASE_WRAPPER_FOR_OBJECT_H(CLASS_NAME, CLASS_NAME_POINTER, WRAPPER_CLASS_NAME, PARENT_CLASS_NAME, ML_EXPORT_MACRO) \
270class ML_EXPORT_MACRO WRAPPER_CLASS_NAME : public ITKWrapperBase \
274 WRAPPER_CLASS_NAME(); \
277 ~WRAPPER_CLASS_NAME(); \
282 void addOutputBaseField(Module &module, const char *outputFieldName); \
283 void addInputBaseField(Module &module, const char *inputFieldName); \
284 void setNewOutputBaseFieldObject(CLASS_NAME_POINTER newObject); \
285 BaseField *getOutputBaseField(); \
286 BaseField *getInputBaseField(); \
287 CLASS_NAME_POINTER getWrappedOutputObject(); \
288 CLASS_NAME_POINTER getWrappedInputObject(const RuntimeType * = nullptr); \
289 bool hasSuperClass(const std::string &className) const; \
290 const std::string &getName(); \
293 static const std::string NameStrings[2]; \
297 static const WrapperSuperStructPtrs _wrapperSuperStructPtrs; \
305 ML_CLASS_HEADER(WRAPPER_CLASS_NAME); \
317#define ML_CREATE_BASE_WRAPPER_FOR_OBJECT_CPP(CLASS_NAME, CLASS_NAME_POINTER, WRAPPER_CLASS_NAME, PARENT_CLASS_NAME, ML_EXPORT_MACRO) \
320 const std::string WRAPPER_CLASS_NAME::NameStrings[2] = { #CLASS_NAME, #PARENT_CLASS_NAME }; \
323 const WrapperSuperStructPtrs WRAPPER_CLASS_NAME::_wrapperSuperStructPtrs(WRAPPER_CLASS_NAME::NameStrings, &PARENT_CLASS_NAME##Wrapper::_wrapperSuperStructPtrs); \
326 WRAPPER_CLASS_NAME::WRAPPER_CLASS_NAME(){ _obj = static_cast<void*>(new ITKMLBaseWrapper<CLASS_NAME, CLASS_NAME_POINTER, WRAPPER_CLASS_NAME>(WRAPPER_CLASS_NAME::_wrapperSuperStructPtrs, *this)); } \
329 WRAPPER_CLASS_NAME::~WRAPPER_CLASS_NAME(){ if (_obj){ delete (static_cast<ITKMLBaseWrapper<CLASS_NAME, CLASS_NAME_POINTER, WRAPPER_CLASS_NAME>*>(_obj)); _obj = nullptr; }; } \
332 void WRAPPER_CLASS_NAME::addOutputBaseField(Module &module, const char *outputFieldName){ (static_cast<ITKMLBaseWrapper<CLASS_NAME, CLASS_NAME_POINTER, WRAPPER_CLASS_NAME>*>(_obj))->addOutputBaseField(module, outputFieldName); } \
333 void WRAPPER_CLASS_NAME::addInputBaseField(Module &module, const char *inputFieldName) { (static_cast<ITKMLBaseWrapper<CLASS_NAME, CLASS_NAME_POINTER, WRAPPER_CLASS_NAME>*>(_obj))->addInputBaseField(module, inputFieldName) ; } \
334 void WRAPPER_CLASS_NAME::setNewOutputBaseFieldObject(CLASS_NAME_POINTER newObject) { (static_cast<ITKMLBaseWrapper<CLASS_NAME, CLASS_NAME_POINTER, WRAPPER_CLASS_NAME>*>(_obj))->setNewOutputBaseFieldObject(newObject) ; } \
335 BaseField *WRAPPER_CLASS_NAME::getOutputBaseField() { return (static_cast<ITKMLBaseWrapper<CLASS_NAME, CLASS_NAME_POINTER, WRAPPER_CLASS_NAME>*>(_obj))->getOutputBaseField() ; } \
336 BaseField *WRAPPER_CLASS_NAME::getInputBaseField() { return (static_cast<ITKMLBaseWrapper<CLASS_NAME, CLASS_NAME_POINTER, WRAPPER_CLASS_NAME>*>(_obj))->getInputBaseField() ; } \
337 CLASS_NAME_POINTER WRAPPER_CLASS_NAME::getWrappedOutputObject() { return (static_cast<ITKMLBaseWrapper<CLASS_NAME, CLASS_NAME_POINTER, WRAPPER_CLASS_NAME>*>(_obj))->getWrappedOutputObject() ; } \
338 CLASS_NAME_POINTER WRAPPER_CLASS_NAME::getWrappedInputObject(const RuntimeType *rt) { return (static_cast<ITKMLBaseWrapper<CLASS_NAME, CLASS_NAME_POINTER, WRAPPER_CLASS_NAME>*>(_obj))->getWrappedInputObject(rt) ; } \
339 bool WRAPPER_CLASS_NAME::hasSuperClass(const std::string &className) const { return (static_cast<ITKMLBaseWrapper<CLASS_NAME, CLASS_NAME_POINTER, WRAPPER_CLASS_NAME>*>(_obj))->hasSuperClass(className) ; } \
341 const std::string & WRAPPER_CLASS_NAME::getName() { return NameStrings[0]; }\
344 ML_CLASS_SOURCE(WRAPPER_CLASS_NAME, ITKWrapperBase); \
Field to encapsulate a pointer to an ML base object.
Class representing general ML objects that support import/export via strings (setPersistentState() an...
Class to create a Base wrapper around an object of a certain template type.
const WrapperSuperStructPtrs * _wrapperSuperStructPtrs
Reference to the inheritance pointer correlated to this class.
OBJ_TYPE_POINTER _outputObj
Smart pointer to the OBJ_TYPE created and wrapped by this class if an output connector is created.
OBJ_TYPE_POINTER getWrappedOutputObject()
Return the pointer to the wrapped object.
void addOutputBaseField(Module &module, const char *outputFieldName)
Method to add a base field to the passed Module module.
void setNewOutputBaseFieldObject(OBJ_TYPE_POINTER newObject)
Set base field so that it points to the new object.
BaseField * getInputBaseField()
Return the pointer to the input base field or nullptr if not created.
bool hasSuperClass(const std::string &className) const
Return true if the passed parent class name is in the list of classes.
BaseField * getOutputBaseField()
Return the pointer to the output base field or nullptr if not created.
Base & _realWrapper
Reference to the real wrapper object creating this.
OBJ_TYPE_POINTER _inputObj
Smart pointer to the connected OBJ_TYPE wrapped by this class if an input connector is created or nul...
OBJ_TYPE_POINTER getWrappedInputObject(const RuntimeType *=nullptr)
MLint _numAddInputBaseFieldCalls
Counter for the number of addInputBaseField method calls.
void addInputBaseField(Module &module, const char *inputFieldName)
Method to add a base field to the passed Module module.
virtual ~ITKMLBaseWrapper()
Destructor.
ITKMLBaseWrapper(const WrapperSuperStructPtrs &parentSuperStruct, ITKWrapperBase &realWrapper)
Constructor.
MLint _numAddOutputBaseFieldCalls
Counter for the number of addOutputBaseField method calls.
Module * _module
Pointer to the Module which shall handle this; default is nullptr.
BaseField * _outputBaseField
Pointer to the field in _module which is used as output interface to another module; default is nullp...
BaseField * _inputBaseField
Pointer to the field in _module which is used as input interface to another module; default is nullpt...
Helper class to have a common base class for all derived wrapper.
ML_ABSTRACT_CLASS_HEADER(ITKWrapperBase)
Register this class abstractly.
ITKWrapperBase()
Private on purpose to avoid instantiations.
Base class for an image processing module of the ML.
RuntimeType contains type and inheritance information of a class and a static dictionary with informa...
Link structure between names and superclass names.
const WrapperSuperStructPtrs *const parentSuperStruct
Pointer to the WrapperSuperStructPtrs of the parent class.
WrapperSuperStructPtrs(const std::string *const nameStringsArg, const WrapperSuperStructPtrs *const pSSArgs)
Default constructor.
const std::string *const nameStrings
Pointer to the type name and parent type name strings.
#define ML_BASE_IS_A(base, type)
This file defines macros, which are inserted in classes to declare and implement additional class mem...
#define ML_BAD_POINTER_OR_0
A pointer is NULL or a value is NULL or 0 where it should not be; this sometimes indicates a memory a...
#define ML_BAD_STATE
The current state of an object is not appropriate for an operation; perhaps it is not initialized or ...
#define ML_PRINT_ERROR(FUNC_NAME, REASON, HANDLING)
Like ML_PRINT_ERROR_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ) without a runtime object to be dumped.
#define MLITK_SUPPORT_EXPORT
When included by other libraries MLITK_SUPPORT_EXPORT is compiled as import symbol.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...