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),
209 _lockNotification = 0;
215 template <
class BASE_DERIVED_CLASS>
223 template <
class BASE_DERIVED_CLASS>
228 _fldObjectType->setStringValue(
"(NULL)");
229 _fldStatusString->setStringValue(
"No input object detected.");
234 const RuntimeType* inType = inputObject->getTypeId();
236 _fldObjectType->setStringValue(
"(INVALID TYPE)");
237 _fldStatusString->setStringValue(
"Error: Invalid input object type.");
241 _fldObjectType->setStringValue(inType->
getName());
242 _fldStatusString->setStringValue(
"Input Object Valid.");
249 template <
class BASE_DERIVED_CLASS>
255 Base* inputObject = _fldInputBase->getBaseValue();
256 BASE_DERIVED_CLASS* outputObject =
nullptr;
259 if (!checkObjectType(inputObject)) {
260 setNewOutputObject(
nullptr);
261 _fldUpToDate->setBoolValue(inputObject ==
nullptr);
266 outputObject =
static_cast<BASE_DERIVED_CLASS*
>(inputObject)->clone();
269 setNewOutputObject(outputObject);
270 _fldUpToDate->setBoolValue(
true);
271 _fldStatusString->setStringValue(
"ok.");
278 template <
class BASE_DERIVED_CLASS>
281 _outputObject = newOutObject;
282 _fldOutputBase->setBaseValue(_outputObject);
289 template <
class BASE_DERIVED_CLASS>
293 _fldOutputBase->setBaseValue(
nullptr);
295 delete _outputObject;
297 _outputObject =
nullptr;
304 template <
class BASE_DERIVED_CLASS>
307 if (!_lockNotification) {
311 if (field == _fldOutputBase) {
312 _fldUpToDate->setBoolValue(
false);
313 _fldStatusString->setStringValue(
"Output externally touched, possibly modified.");
317 if (field == _fldInputBase) {
318 switch (_fldAutoUpdateMode->getEnumValue()) {
319 case AutoUpdateModeDoNothing:
320 checkObjectType(_fldInputBase->getBaseValue());
321 _fldUpToDate->setBoolValue(
false);
323 case AutoUpdateModeAutoClear:
324 checkObjectType(_fldInputBase->getBaseValue());
328 case AutoUpdateModeAutoUpdate:
341 if (field == _fldClear) {
343 _fldStatusString->setStringValue(
"Output object deleted.");
344 _fldUpToDate->setBoolValue(_fldInputBase->getBaseValue() ==
nullptr);
349 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 ok because lists have an assignmen...
Base class for all ML Engines which are derived from Module, which have no inputs or outputs and whic...
Field to encapsulate an enumerated value.
Defines the class FieldContainer to encapsulate a vector of fields for (see class Field).
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.
FieldContainer * getFieldContainer()
Returns a pointer to the container of all the module's fields.
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)
Like ML_CLASS_HEADER for the usage of derived classes from Module.
#define ML_PROGRAMMING_ERROR
A case occurred which should not appear and here 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