47 nameStrings(nameStringsArg), parentSuperStruct(pSSArgs) {}
60 template<
class OBJ_TYPE,
typename OBJ_TYPE_POINTER,
typename WRAPPER_CLASS_NAME>
class ITKMLBaseWrapper
68 _realWrapper(realWrapper), _wrapperSuperStructPtrs(&parentSuperStruct)
70 _outputBaseField = NULL;
71 _inputBaseField = NULL;
75 _numAddOutputBaseFieldCalls=0;
76 _numAddInputBaseFieldCalls=0;
97 if (!outputFieldName){
101 if (_numAddOutputBaseFieldCalls!=0){
107 _outputBaseField = module.
addBase(outputFieldName);
109 ++_numAddOutputBaseFieldCalls;
119 if (!inputFieldName){
123 if (_numAddInputBaseFieldCalls!=0){
129 _inputBaseField = module.
addBase(inputFieldName);
131 ++_numAddInputBaseFieldCalls;
139 _outputObj = newObject;
140 if (_outputBaseField){ _outputBaseField->touch(); }
148 return _outputBaseField;
156 return _inputBaseField;
178 if (follow->
nameStrings[0] == className){
return true; }
193 if (_inputBaseField){
197 Base *inPtr = _inputBaseField->getBaseValue();
204 if (!wrapperBaseInPtr){
return NULL; }
207 WRAPPER_CLASS_NAME *wrapper = wrapperBaseInPtr ?
static_cast<WRAPPER_CLASS_NAME *
>(wrapperBaseInPtr) : NULL;
210 return (wrapper && wrapper->hasSuperClass(wrapper->getName())) ? wrapper->getWrappedOutputObject() : NULL;
260 #define ML_CREATE_BASE_WRAPPER_FOR_OBJECT_H(CLASS_NAME, CLASS_NAME_POINTER, WRAPPER_CLASS_NAME, PARENT_CLASS_NAME, ML_EXPORT_MACRO) \
265 class ML_EXPORT_MACRO WRAPPER_CLASS_NAME : public ITKWrapperBase \
269 WRAPPER_CLASS_NAME(); \
272 ~WRAPPER_CLASS_NAME(); \
277 void addOutputBaseField(Module &module, const char *outputFieldName); \
278 void addInputBaseField(Module &module, const char *inputFieldName); \
279 void setNewOutputBaseFieldObject(CLASS_NAME_POINTER newObject); \
280 BaseField *getOutputBaseField(); \
281 BaseField *getInputBaseField(); \
282 CLASS_NAME_POINTER getWrappedOutputObject(); \
283 CLASS_NAME_POINTER getWrappedInputObject(const RuntimeType * = NULL); \
284 bool hasSuperClass(const std::string &className) const; \
285 const std::string &getName(); \
288 static const std::string NameStrings[2]; \
292 static const WrapperSuperStructPtrs _wrapperSuperStructPtrs; \
300 ML_CLASS_HEADER(WRAPPER_CLASS_NAME); \
312 #define ML_CREATE_BASE_WRAPPER_FOR_OBJECT_CPP(CLASS_NAME, CLASS_NAME_POINTER, WRAPPER_CLASS_NAME, PARENT_CLASS_NAME, ML_EXPORT_MACRO) \
315 const std::string WRAPPER_CLASS_NAME::NameStrings[2] = { #CLASS_NAME, #PARENT_CLASS_NAME }; \
318 const WrapperSuperStructPtrs WRAPPER_CLASS_NAME::_wrapperSuperStructPtrs(WRAPPER_CLASS_NAME::NameStrings, &PARENT_CLASS_NAME##Wrapper::_wrapperSuperStructPtrs); \
321 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)); } \
324 WRAPPER_CLASS_NAME::~WRAPPER_CLASS_NAME(){ if (_obj){ delete (static_cast<ITKMLBaseWrapper<CLASS_NAME, CLASS_NAME_POINTER, WRAPPER_CLASS_NAME>*>(_obj)); _obj = NULL; }; } \
327 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); } \
328 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) ; } \
329 void WRAPPER_CLASS_NAME::setNewOutputBaseFieldObject(CLASS_NAME_POINTER newObject) { (static_cast<ITKMLBaseWrapper<CLASS_NAME, CLASS_NAME_POINTER, WRAPPER_CLASS_NAME>*>(_obj))->setNewOutputBaseFieldObject(newObject) ; } \
330 BaseField *WRAPPER_CLASS_NAME::getOutputBaseField() { return (static_cast<ITKMLBaseWrapper<CLASS_NAME, CLASS_NAME_POINTER, WRAPPER_CLASS_NAME>*>(_obj))->getOutputBaseField() ; } \
331 BaseField *WRAPPER_CLASS_NAME::getInputBaseField() { return (static_cast<ITKMLBaseWrapper<CLASS_NAME, CLASS_NAME_POINTER, WRAPPER_CLASS_NAME>*>(_obj))->getInputBaseField() ; } \
332 CLASS_NAME_POINTER WRAPPER_CLASS_NAME::getWrappedOutputObject() { return (static_cast<ITKMLBaseWrapper<CLASS_NAME, CLASS_NAME_POINTER, WRAPPER_CLASS_NAME>*>(_obj))->getWrappedOutputObject() ; } \
333 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) ; } \
334 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) ; } \
336 const std::string & WRAPPER_CLASS_NAME::getName() { return NameStrings[0]; }\
339 ML_CLASS_SOURCE(WRAPPER_CLASS_NAME, ITKWrapperBase); \
Field to encapsulate a pointer to an ML base object.
void setBaseValue(Base *basePointerValue)
Sets the value of the field to basePointerValue.
Class representing general ML objects that support import/export via strings (setPersistentState() an...
BaseField * addBase(const char *name)
Creates a Base field with name and adds it to the container. Default value is NULL.
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.
OBJ_TYPE_POINTER getWrappedInputObject(const RuntimeType *=NULL)
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 NULL 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...
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 NULL.
BaseField * getInputBaseField()
Return the pointer to the input base field or NULL if not created.
BaseField * _outputBaseField
Pointer to the field in _module which is used as output interface to another module; default is NULL.
BaseField * _inputBaseField
Pointer to the field in _module which is used as input interface to another module; default is NULL.
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.
const std::string *const nameStrings
Pointer to the type name and parent type name strings.
WrapperSuperStructPtrs(const std::string *const nameStringsArg, const WrapperSuperStructPtrs *const pSSArgs)
Default constructor.
#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.
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...