13#ifndef ML_LIST_CONTAINER_H
14#define ML_LIST_CONTAINER_H
103 void *userData =
nullptr);
185 {
return !_fldInputList || (_listBasePtr != _fldInputList->getBaseValue()); }
323 std::string _listStringBackup;
329 void* _handleNotificationUserData;
470 ML_PRINT_FATAL_ERROR(
"ListContainerTemplate::ListContainerTemplate(const ListContainerTemplate &)",
472 "Usage of copy constructor of ListContainerTemplate is not supported.");
481 ML_PRINT_FATAL_ERROR(
"ListContainerTemplate& ListContainerTemplate::operator=(const ListContainerTemplate &)",
483 "Usage of assignment operator of ListContainerTemplate is not supported.");
538 _listPtr =
static_cast<T*
>(
basePtr);
553 return (_listPtr && (index >= 0) && (index <
static_cast<MLssize_t>(_listPtr->size())) )
563 const MLssize_t index = _fldIndex->getIntValue();
565 if (_listPtr && (index >= 0) && (index <
static_cast<MLssize_t>(_listPtr->size())) )
571 _fldId->setIntValue(
item->getId());
572 _fldName->setStringValue(
item->name() ?
item->name() :
"");
583 typename T::iterator
it;
585 if (_listPtr && (index >= 0) && (index <
listSize) && (num > 0))
590 it = _listPtr->begin()+index;
591 _listPtr->erase(
it,
it+num);
601 if (_listPtr && (index >= 0) && (index <=
static_cast<MLssize_t>(_listPtr->size())) )
606 _currentItem.
setId(_listPtr->newId());
608 _listPtr->insert(_listPtr->begin()+index, _currentItem);
614 _listPtr->insert(_listPtr->begin()+index,
tmpItem);
635 if (_listPtr && (index >= 0) && (index <
static_cast<MLssize_t>(_listPtr->size())) )
644 else if (
field == _fldId)
649 }
else if (
field == _fldName) {
671 _fldNewName->setStringValue(
item->name() ?
item->name() :
"" );
680 _currentItem.setName( _fldNewName->getStringValue().c_str() );
693 if (
item->getId() == 0) {
697 item->setId(_listPtr->newId());
Field to encapsulate a pointer to an ML base object.
void setBaseValueAndAddAllowedType(T *value)
convenience routine for setting the base value and its type at the same time.
General Base object class for list items that have an id and a name.
void setId(MLssize_t id)
Sets the id of the item.
Class representing general ML objects that support import/export via strings (setPersistentState() an...
Field to encapsulate a boolean value.
Field to encapsulate an enumerated value.
BaseField * addBase(const char *name)
Creates a Base field with name and adds it to the container. Default value is NULL.
Base class for all fields used in the ML.
Field to encapsulate an integer value.
Base object class ListBase managing a number of BaseItem objects.
ActionClass
Constants to describe the type of action most recently performed.
Abstract module class ListContainerBase implementing basic functionality for a list container module.
IntField * _fldId
List item id.
virtual void insertItem(MLssize_t index, bool fromCurrentItem)=0
Insert an item at position index.
virtual void doModifyItem(MLssize_t index, Field *field, bool fromCurrentItem)
Modify item at position index.
virtual void copyTemplateToCurrent()=0
Copy the values of the templates fields to _currentItem.
StringField * _fldListString
String representation of list.
NotifyField * _fldCopyItemToTemplate
Copy values from current item to template fields.
virtual void updateActionFields()
Update last action fields.
virtual ListBase * getInternalList()=0
void beginSaveFields() override
Prepare for persistence.
virtual void updatePropertyFields()=0
Update property fields from the current list item.
StringField * _fldActionClass
Action class of last action on list.
IntField * _fldCurrentIndex
Index of currently selected item.
virtual bool isPropertyField(Field *field)
virtual void updateDisplay()
Update display of list size, current item index and item properties.
OverflowModes
Mode constants for cases of list size overflow.
@ OvwRemoveFirst
Overflow ignored.
@ OvwRemoveAll
Last item(s) deleted.
@ OvwRemoveLast
First item(s) deleted.
@ OvwRemoveNew
All item(s) deleted.
void endSaveFields() override
Clean up after persistence.
StringField * _fldName
List item name.
virtual void updateListString(bool forceEnable=false)
virtual void doDeleteAll()
int _lockNotification
Suppress handleNotification() if non-zero.
NotifyField * _fldAdd
Add (= Append) button.
NotifyField * _fldDelete
Delete button.
virtual void doCopyItemToTemplate(MLssize_t index)
Copy values from item at position index to the template fields.
StringField * _fldNewName
List item name.
EnumField * _fldOverflowMode
Overflow mode, specifies which item(s) to delete on overflow.
BoolField * _fldUpToDate
Indicates that the property values are up to date.
IntField * _fldMaxSize
Maximum list size.
NotifyField * _fldCopyTemplateToItem
Copy values from template fields to current item.
virtual void doUpdate()
Update all fields and touch output list field.
virtual bool modifyItem(MLssize_t index, Field *field, bool fromCurrentItem)=0
Modify item at position index.
BoolField * _fldListStringEnable
Enable list string field.
virtual bool ownsList()
Return true if the active list is the internal list.
MLint maxNumItems() const
NotifyField * _fldInsert
Insert button.
IntField * _fldActionIndex
Index of last action on list.
BoolField * _fldApplySelect
Perform a Select-action when index is changed.
virtual void doSelectItem(MLssize_t index)
Select item at position index, or deselect if item == -1.
BaseField * _fldInputList
Input list field, initialized by derived class.
ListContainerBase()
Constructor.
virtual void touchList(ListBase::ActionClass actionClass, MLssize_t id, MLssize_t index)
Set last list action and touch output list field.
void setHandleNotificationCB(ListContainerHandleNotificationCB *cb=nullptr, void *userData=nullptr)
Set the callback for handleNotification.
void handleNotification(Field *field) override
Called when any field data in the field container of this module is modified.
virtual void doDeleteItem(MLssize_t index)
Delete single item at position index.
BoolField * _fldUseInsertTemplate
If true the container should use the template fields for initializing the inserted item.
NotifyField * _fldUpdate
Update button.
BaseField * _fldOutputList
Output list field, initialized by derived class.
virtual void doInsertItem(MLssize_t index, bool fromCurrentItem)
Insert an item at position index.
IntField * _fldNumItems
List size.
void activateAttachments() override
Update fields after an initialization without handleNotification() called.
virtual void resetPropertyFields()
Reset all property fields.
virtual void deleteItems(MLssize_t index, MLssize_t num)=0
virtual void copyItemToTemplate(MLssize_t index)=0
Copy values from item at position index to the template fields.
ListContainerBase(ListBase *listBasePtr, int inputNum, int outputNum)
Constructor In listBasePtr pass a pointer to the list object, which has to be a member of the derived...
int overflowMode() const
Returns the overflow mode.
virtual void initItem(MLssize_t index)=0
Initialize the list item at position index.
NotifyField * _fldDeleteAll
Delete All button.
virtual bool setActiveList(Base *basePtr)=0
Set the active list (i.e.
virtual void doClearItem(MLssize_t index)
Init item at position index.
BoolField * _fldOwnsList
Reflect owner state (true if internal list is active)
NotifyField * _fldClearItem
Clear the current item (i.e. init it again).
BaseField * getOutputField()
Returns a pointer to the output field.
virtual MLssize_t getId(MLssize_t index)=0
Return the item id of the item index.
BoolField * _fldPersistent
Activate internal list persistence.
IntField * _fldIndex
Current list index.
IntField * _fldActionId
Item id of last action on list.
Template module class ListContainerTemplate for a specific list class.
void copyTemplateToCurrent() override
Copy the values of the templates fields to _currentItem.
T::itemType _currentItem
List item object used by insertItem() and modifyItem().
void insertItem(MLssize_t index, bool fromCurrentItem) override
Insert an item at position index.
ListContainerTemplate(int inputNum, int outputNum)
Constructor The values inputNum and outputNum specify the number of input and output image fields,...
MLssize_t getId(MLssize_t index) override
Return the item id of the item index.
void copyItemToTemplate(MLssize_t index) override
Copy values from item at position index to the template fields.
T * _listPtr
Pointer to the active list object Use this pointer for list access after testing that it is !...
virtual T * getList()
Get pointer to the active list object Use this pointer for list access after testing that it is !...
ListBase * getInternalList() override
Return address of internal list object.
bool setActiveList(Base *basePtr) override
Set the active list pointer _listPtr to basePtr, provided that it is of the correct type.
void deleteItems(MLssize_t index, MLssize_t num) override
Remove num items, starting at item index.
~ListContainerTemplate() override
Destructor.
void updatePropertyFields() override
Update property fields from the current list item.
void initItem(MLssize_t index) override
Initialize the list item at position index.
bool modifyItem(MLssize_t index, Field *field, bool fromCurrentItem) override
Modify item at position index.
Base class for an image processing module of the ML.
Field without value for notifications.
RuntimeType contains type and inheritance information of a class and a static dictionary with informa...
Field to encapsulate a string value.
#define ML_ABSTRACT_MODULE_CLASS_HEADER(className)
Like ML_ABSTRACT_CLASS_HEADER for the usage of derived classes from Module.
#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_PROGRAMMING_ERROR
A case occurred which should not appear and here are a variety of reasons, typically it is a programm...
#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
#define ML_CHECK_RUNTIME_TYPE(x)
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 ...
SSIZE_T MLssize_t
The signed ML size type which is a signed 32 bit size_t on 32 bit platforms and 64 bit one on 64 bit ...
bool ListContainerHandleNotificationCB(void *usrData, Field *field)
Callback for handleNotification forwarding (return false if notification should not be propagated to ...