13 #ifndef ML_COPY_BASE_H
14 #define ML_COPY_BASE_H
40 template <
class BASE_DERIVED_CLASS>
60 AutoUpdateModeDoNothing = 0,
67 static const char* autoUpdateModeNames[];
125 "Usage of copy constructor of CopyBase is not supported.");
136 "Usage of assignment operator of CopyBase is not supported.");
141 int _lockNotification;
180 template <
class BASE_DERIVED_CLASS>
190 template <
class BASE_DERIVED_CLASS>
193 _outputObject(nullptr),
207 _lockNotification = 0;
213 template <
class BASE_DERIVED_CLASS>
221 template <
class BASE_DERIVED_CLASS>
226 _fldObjectType->setStringValue(
"(NULL)");
227 _fldStatusString->setStringValue(
"No input object detected.");
232 const RuntimeType* inType = inputObject->getTypeId();
234 _fldObjectType->setStringValue(
"(INVALID TYPE)");
235 _fldStatusString->setStringValue(
"Error: Invalid input object type.");
239 _fldObjectType->setStringValue(inType->
getName());
240 _fldStatusString->setStringValue(
"Input Object Valid.");
247 template <
class BASE_DERIVED_CLASS>
253 Base* inputObject = _fldInputBase->getBaseValue();
254 BASE_DERIVED_CLASS* outputObject =
nullptr;
257 if (!checkObjectType(inputObject)) {
258 setNewOutputObject(
nullptr);
259 _fldUpToDate->setBoolValue(inputObject ==
nullptr);
264 outputObject =
static_cast<BASE_DERIVED_CLASS*
>(inputObject)->clone();
267 setNewOutputObject(outputObject);
268 _fldUpToDate->setBoolValue(
true);
269 _fldStatusString->setStringValue(
"ok.");
276 template <
class BASE_DERIVED_CLASS>
279 _outputObject = newOutObject;
280 _fldOutputBase->setBaseValue(_outputObject);
287 template <
class BASE_DERIVED_CLASS>
291 _fldOutputBase->setBaseValue(
nullptr);
293 delete _outputObject;
295 _outputObject =
nullptr;
302 template <
class BASE_DERIVED_CLASS>
305 if (!_lockNotification) {
309 if (field == _fldOutputBase) {
310 _fldUpToDate->setBoolValue(
false);
311 _fldStatusString->setStringValue(
"Output externally touched, possibly modified.");
315 if (field == _fldInputBase) {
316 switch (_fldAutoUpdateMode->getEnumValue()) {
317 case AutoUpdateModeDoNothing:
318 checkObjectType(_fldInputBase->getBaseValue());
319 _fldUpToDate->setBoolValue(
false);
321 case AutoUpdateModeAutoClear:
322 checkObjectType(_fldInputBase->getBaseValue());
326 case AutoUpdateModeAutoUpdate:
339 if (field == _fldClear) {
341 _fldStatusString->setStringValue(
"Output object deleted.");
342 _fldUpToDate->setBoolValue(_fldInputBase->getBaseValue() ==
nullptr);
347 if (field == _fldUpdate) {
Field to encapsulate a pointer to an ML base object.
Class representing general ML objects that support import/export via strings (setPersistentState() an...
Field to encapsulate a boolean value.
Engine template module CopyBase to copy any Base-derived object that provides a virtual assignment op...
void copyObject()
Copies the input object to _outputObject and updates the base output.
static const char * autoUpdateModeNames[]
auto update mode enum tokens
@ AutoUpdateModeAutoUpdate
@ AutoUpdateModeAutoClear
StringField * _fldStatusString
String with object type name.
NotifyField * _fldClear
delete the output object now Also sets upToDate to (input == NULL).
BaseField * _fldInputBase
Base input.
void setNewOutputObject(BASE_DERIVED_CLASS *newOutObject)
Sets output object to newOutObject, touches the output object.
BaseField * _fldOutputBase
Base output.
Base * _outputObject
Copied object:
BoolField * _fldUpToDate
Is the current output update consistent with the input object? Becomes false if the input or output o...
void deleteObject()
Deletes the output object.
NotifyField * _fldUpdate
Delete output object, then update output object and set upToDateFld to true.
const RuntimeType * checkObjectType(const Base *inputObject) const
Returns the ml-runtime type of the input object if valid, NULL otherwise.
void handleNotification(Field *field) override
handle field changes
~CopyBase() override
Destructor, deleting the _outputObject.
StringField * _fldObjectType
String with object type name.
EnumField * _fldAutoUpdateMode
Possible actions at input touch: DoNothing, AutoClear, AutoUpdate.
Engine module class for copying ListBase derived classes, which is okay because lists have an assignm...
Base class for all ML Engines that are derived from Module, and have no inputs or outputs but impleme...
Field to encapsulate an enumerated value.
EnumField * addEnum(const char *name, const char *const *enumerationItemNames, MLint numEnumerationItems)
Creates an EnumField field with name and adds it to the container.
NotifyField * addNotify(const char *name)
Creates a NotifyField field with name and adds it to the container.
StringField * addString(const char *name)
Creates a StringField with name and adds it to the container. Default value is empty string.
BaseField * addBase(const char *name)
Creates a Base field with name and adds it to the container. Default value is NULL.
BoolField * addBool(const char *name)
Creates a BoolField with name and adds it to the container. Default value is false.
Base class for all fields used in the ML.
Field without value for notifications.
RuntimeType contains type and inheritance information of a class and a static dictionary with informa...
bool canCreateInstance() const
Returns true if this (runtime) type knows how to create an instance of the class.
ML_UTILS_EXPORT bool isDerivedFrom(const RuntimeType *runtimeType) const
Returns true if this (runtime) type is derived from the argument (runtime) type runtimeType.
const char * getName() const
Returns the NULL-terminated string name of the class. Returns 'BadType' on error.
Field to encapsulate a string value.
#define ML_MODULE_CLASS_HEADER(className)
Similar to ML_CLASS_HEADER for the usage of derived classes from Module.
#define ML_PROGRAMMING_ERROR
A case occurred that should not appear and there are a variety of reasons, typically it is a programm...
#define ML_BAD_PARAMETER
A bad/invalid parameter (or even an inappropriate image) has been passed to a module or an algorithm,...
#define ML_PRINT_FATAL_ERROR(FUNC_NAME, REASON, HANDLING)
Like ML_PRINT_FATAL_ERROR_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ) without a runtime object to be du...
#define MLBASEEXPORT
defined Header file mlBaseInit.h