Workspace 6.21.5
Public Member Functions | Protected Member Functions | List of all members
PolymorphicDataOperation Class Referenceabstract

Base class for operations using a polymorphic type. More...

#include <Workspace/DataExecution/Operations/Builtin/polymorphicdataoperation.h>

Inheritance diagram for PolymorphicDataOperation:
[legend]

Public Member Functions

 PolymorphicDataOperation (const OperationFactory &opFactory, const QString &opName, const DataFactory &dataFactory, const QString &dataName=QString(), bool isNameable=true)
 
 ~PolymorphicDataOperation () override
 
virtual bool canChangeDataFactory (const DataFactory &factory) const =0
 
virtual bool canChangeDataName (const QString &name) const =0
 
Presentation::CustomOperationPropertiescreateCustomPropertiesHandler () override
 
virtual QString getAcceptableDataName (const QString &proposedName) const
 
const DataFactorygetDataFactory () const
 
const QString & getDataName () const
 
DataObjectgetDataObject ()
 
template<typename T >
bool isDataType () const
 
bool isDataType (const DataFactory &type) const
 
bool isNameable () const
 
bool isPolymorphicType () const override
 
bool isUserConfigurable () override
 
bool matchesDataType (const DataObject &otherObject) const
 
bool setDataFactory (const DataFactory &factory)
 
bool setDataName (const QString &name)
 
- Public Member Functions inherited from Operation
 ~Operation () override
 
bool addInput (Input &input, bool modifiedInPlace=false)
 
bool addOutput (Output &output)
 
template<typename T >
bool assignInput (const QString &inputName, const T &value)
 
bool canSerialize () const override
 
bool connectProgressEvents (QProgressBar *progressBar)
 
virtual Presentation::CustomOperationPropertiescreateCustomPropertiesHandler ()
 
virtual void ensureHasData ()
 
bool getBroadcastUpdateEvents () const
 
QColor getColor () const
 
virtual QString getDefaultIconPath () const
 
QString getDefaultUiPath () const
 
QString getDeprecationMessage () const
 
const QString & getDescription () const
 
SerializedItem getExtras ()
 
const OperationFactorygetFactory () const
 
OperationgetFromPath (const QString &path, Workspace &relativeTo, QStringList &errors) const override
 
virtual GraphicsSize getGraphicsSize () const
 
virtual QString getHelpPage () const
 
QString getIconPath () const
 
const QUuid & getId () const
 
QString getIdPath (bool scoped=true) const override
 
QString getIdPath (const Workspace &relativeTo) const
 
difference_type getIndex (const Input &input, IndexCountingOptions options=SkipNone) const
 
difference_type getIndex (const Output &output, IndexCountingOptions options=SkipNone) const
 
void getIndexPair (InputScalar &input, difference_type &mainIndex, difference_type &arrayIndex)
 
InputgetInput (const QString &name)
 
const InputgetInput (const QString &name) const
 
InputgetInput (size_type index)
 
const InputgetInput (size_type index) const
 
InputArraygetInputArray (const QString &name)
 
const InputArraygetInputArray (const QString &name) const
 
IOBaseIteratorRange< Input, false > getInputs ()
 
IOBaseIteratorRange< Input, true > getInputs () const
 
InputScalargetInputScalar (const QString &name)
 
const InputScalargetInputScalar (const QString &name) const
 
template<typename T >
T & getInputValue (const QString &inputName)
 
template<typename T >
const T & getInputValue (const QString &inputName) const
 
const QString & getLabel () const
 
QString getLabelRelativeToRoot () const
 
OutputgetOutput (const QString &name)
 
const OutputgetOutput (const QString &name) const
 
OutputgetOutput (size_type index)
 
const OutputgetOutput (size_type index) const
 
IOBaseIteratorRange< Output, false > getOutputs ()
 
IOBaseIteratorRange< Output, true > getOutputs () const
 
template<typename T >
T & getOutputValue (const QString &outputName)
 
template<typename T >
const T & getOutputValue (const QString &outputName) const
 
bool getProfilingEnabled () const
 
int getProgress () const
 
int getProgressContribution () const
 
bool getProgressResetByNotUpToDate () const
 
virtual SchedulerFeatures getRequiredSchedulerFeatures () const
 
InputScalargetScalarInput (size_type mainIndex, difference_type arrayIndex)
 
QString getShortLabel () const
 
QString getTagName () const
 
bool getTerminateExecution () const
 
QString getUiPath () const
 
bool getUpToDate () const override
 
virtual bool hasRequiredSchedulerFeatures () const
 
void idPathChanged () override
 
virtual bool inputRebuilt (InputScalar &input)
 
virtual bool isAsynchronous () const
 
virtual bool isAsynchronousProcess () const
 
virtual bool isAtomicUpdate () const
 
bool isConnectedToAsynchronous () const override
 
bool isDeprecated () const
 
bool isEditable () const
 
bool isIdPathCachingEnabled () const
 
virtual bool isPolymorphicType () const
 
virtual bool isRunningAsynchronously () const
 
virtual bool isThreadSafe () const
 
template<typename T >
bool isType () const
 
bool isType (const OperationFactory &type) const
 
bool isUpdating () const
 
virtual bool isUserConfigurable ()
 
bool isUsingDefaultColor () const
 
bool isUsingDefaultIconPath () const
 
bool isUsingDefaultUiPath () const
 
bool isWaitingForAsynchronousUpdate () const override
 
bool isWorkspaceType () const
 
bool load (const SerializedItem &item) override
 
void markUpToDateWhereSafe ()
 
bool matchesType (const Operation &otherOperation) const
 
size_type numInputs (IndexCountingOptions=SkipNone) const
 
size_type numOutputs (IndexCountingOptions=SkipNone) const
 
bool removeInput (const QString &name)
 
bool removeInput (Input &input)
 
bool removeOutput (const QString &name)
 
bool removeOutput (Output &output)
 
virtual void resetExecutionDependencies ()
 
bool save (SerializedItem &item) const override
 
virtual bool saveWithData (SerializedItem &item) const
 
virtual void setAtomicUpdate (bool atomic)
 
void setBroadcastUpdateEvents (bool enable)
 
void setColor (const QColor &c)
 
void setDescription (const QString &description)
 
void setEditable (bool b)
 
void setIconPath (const QString &path)
 
void setId (const QUuid &id)
 
virtual void setIdPathCachingEnabled (bool b)
 
virtual void setInputNotUpToDate (InputScalar &input)
 
virtual void setIsAsynchronous (bool asynchronous)
 
virtual void setIsAsynchronousProcess (bool)
 
virtual void setIsRunningAsynchronously (bool asynchronous)
 
void setLabel (const QString &label)
 
virtual void setOutputNotUpToDate (Output &output)
 
void setProfilingEnabled (bool enable)
 
virtual void setProgress (int percent)
 
void setProgressContribution (int percent)
 
void setProgressResetByNotUpToDate (bool b)
 
virtual void setRequiredSchedulerFeatures (const SchedulerFeatures &)
 
void setTerminateExecution (bool b)
 
void setUiPath (const QString &path)
 
void setUpToDate (bool b) override
 
bool update (Updater *updater=nullptr) override
 
- Public Member Functions inherited from WorkspaceElement
 ~WorkspaceElement () override
 
const WorkspacegetWorkspace () const override
 
WorkspacegetWorkspace () override
 
virtual void workspaceChanged (Workspace *oldWorkspace)
 
- Public Member Functions inherited from Updatable
 ~Updatable () override
 
virtual bool comesFromExternal () const
 
QString getEnclosingScope () const
 
virtual UpdatablegetFromPath (const QString &path, Workspace &relativeTo, QStringList &errors) const =0
 
const QString & getGlobalName () const
 
virtual QString getIdPath (bool scoped=true) const =0
 
virtual WorkspacegetRootWorkspace ()
 
virtual const WorkspacegetRootWorkspace () const
 
QString getScopedGlobalName () const
 
virtual bool getUpToDate () const =0
 
virtual const WorkspacegetWorkspace () const =0
 
virtual WorkspacegetWorkspace ()=0
 
virtual void idPathChanged ()
 
virtual bool isConnectedToAsynchronous () const =0
 
virtual bool isWaitingForAsynchronousUpdate () const =0
 
void setGlobalName (const QString &name)
 
virtual void setUpToDate (bool b)=0
 
virtual bool update (Updater *updater=nullptr)=0
 
- Public Member Functions inherited from Observable
virtual ~Observable ()
 
void attachObserver (Observer &observer)
 
void destroy ()
 
void detachObserver (Observer &observer)
 
void notifyEvent (const ObservableEvent &event)
 
- Public Member Functions inherited from Serialize
virtual ~Serialize ()=default
 
virtual bool canSerialize () const =0
 
virtual bool load (const SerializedItem &item)=0
 
virtual bool save (SerializedItem &item) const =0
 
- Public Member Functions inherited from TextLogger
 TextLogger ()
 
 TextLogger (const DataExecution::IOBase &io)
 
 TextLogger (const DataExecution::Operation &operation)
 
 TextLogger (const TextLogger &logger)
 
 TextLogger (TextLogger &&logger)
 
virtual ~TextLogger ()
 
void logLine (const Application::LogManager::MessageCategory &category, const QString &msg) const
 
void logLine (const QString &msg) const
 
void logText (const Application::LogManager::MessageCategory &category, const QString &msg) const
 
void logText (const QString &msg) const
 
TextLoggeroperator= (TextLogger)
 

Protected Member Functions

virtual void dataNameChanged (const QString &name)
 
virtual void dataObjectAboutToChange ()
 
virtual void dataObjectChanged (DataObject &oldDataObject)
 
bool loadPolyPart (const QString &dataPlugin, const QString &dataType, const QString &dataName)
 
bool postSave (SerializedItem &item) const override
 
bool prepareInputsOutputsForLoad (const SerializedItem &item) override
 
- Protected Member Functions inherited from Operation
 Operation (const OperationFactory &factory, const QString &label)
 
bool bringArrayOfInputsUpToDate (Input *&array, size_type arraySize)
 
bool bringArrayOfInputsUpToDate (std::vector< Input * > &array)
 
virtual bool bringInputsUpToDate ()
 
bool bringInputUpToDate (Input &input)
 
virtual void cancelExecution (bool b)
 
virtual bool execute ()=0
 
virtual bool finishInputsOutputsAfterLoad (const SerializedItem &item)
 
UpdatergetCurrentUpdater ()
 
virtual const InputgetRenamedInput (const QString &name) const
 
virtual const OutputgetRenamedOutput (const QString &name) const
 
virtual bool inputsAreUpToDate () const
 
virtual bool makeOutputsValid ()
 
virtual void markOutputsUpToDate ()
 
void pauseUpdate ()
 
virtual bool postSave (SerializedItem &item) const
 
virtual bool prepareInputsOutputsForLoad (const SerializedItem &item)
 
void saveExtras (SerializedItem &item) const
 
virtual bool shouldPutInExtras (const QString &tagName) const
 
- Protected Member Functions inherited from WorkspaceElement
 WorkspaceElement ()
 
- Protected Member Functions inherited from Updatable
 Updatable ()
 
 Updatable (const Updatable &up)
 
void notifyUpdated ()
 
Updatableoperator= (const Updatable &up)
 
- Protected Member Functions inherited from Observable
 Observable ()
 
 Observable (const Observable &)
 

Additional Inherited Members

- Public Types inherited from Operation
enum  ConfigStatus { GoodConfig = 0x00 , UnknownConfig = 0x01 , InvalidConfig = 0x02 }
 
using difference_type = ptrdiff_t
 
enum  GraphicsSize { Default = 100 , Small = 65 }
 Options for the graphical size of an operation, able to be changed by derived classes. Values are percentages. More...
 
enum  IndexCountingOption { SkipNone = 0x0 , SkipInvisible = 0x1 , SkipDependencies = 0x2 }
 
using size_type = size_t
 
- Static Public Member Functions inherited from Updatable
static InputScalarfindInputScalarGlobalName (const QString &scopedGlobalName, Workspace &relativeTo)
 
static IOBasefindIOBaseGlobalName (const QString &scopedGlobalName, Workspace &relativeTo)
 
static OperationfindOperationGlobalName (const QString &scopedGlobalName, Workspace &relativeTo)
 

Detailed Description

Subclasses would typically use the polymorphic type as an input or output to the operation. This base class handles the common tasks of changing the data factory and data name, along with augmenting the load and save functions to include the data type and name in the serialization process.

Constructor & Destructor Documentation

◆ PolymorphicDataOperation()

PolymorphicDataOperation ( const OperationFactory opFactory,
const QString &  opName,
const DataFactory dataFactory,
const QString &  dataName = QString(),
bool  isNameable = true 
)
Parameters
opFactoryThe factory for the concrete subclass.
opNameThe default label to use for the operation.
dataFactoryThe factory for the default data type this operation should start out with.
dataNameThe default name to use for the data type. It is up to the subclass what it wants to do with this name. If it is empty, the data name will be set to opName.
isNameableSome subclasses don't need the data name. If this is the case, they should set isNameable to false and all functionality related to the data name will be hidden/prevented.

◆ ~PolymorphicDataOperation()

~PolymorphicDataOperation ( )
override

Cleans up private implementation.

Member Function Documentation

◆ canChangeDataFactory()

virtual bool canChangeDataFactory ( const DataFactory factory) const
pure virtual
Parameters
factoryThe new factory that will be set.

This function is called by setDataFactory to determine if the data factory can indeed be changed. The old factory is still available by calling getDataFactory, since nothing has actually been changed at the point where canChangeDataFactory is called. It may also be called by other clients who are interested in knowing if a particular data factory change will be allowed before actually requesting the factory change.

Returns
True if the subclass is happy for the data factory to be set to factory. The subclass can return false to indicate that the data factory cannot be changed to factory, or indeed that it cannot be changed at all (ie to anything).

Implemented in Compare, Array3dInfo, GetSqlResultSetColumn, InsertColumnIntoSqlTable, ResizeImage, GetBsonItem, AddMeshModelState, CreateClipRegion, DeepConvertQVariant, GetItemFromJson, GetItemFromObjectDictionary, ModifyObjectDictionary, RunExternalScript, RunMatLabScript, RunRScript, CacheData, ComposeGroup, ConvertFromByteArray, ConvertToByteArray, DecomposeGroup, InitializedVariable, InsertIntoObjectDictionary, LoadDataFromFile, ModifyGroup, ObjectArrayAccessor, ObjectArrayBuilder, SaveDataToFile, SelectInput, SharedInfo, TryInputs, UpdateBarrier, Variable, WhileLoop, WorkspaceInput, and WorkspaceOutput.

◆ canChangeDataName()

virtual bool canChangeDataName ( const QString &  name) const
pure virtual
Parameters
nameThe new data name that will be set.

This function is called by setDataName to determine if the data name can indeed be changed. The old name is still available by calling getDataName, since nothing has actually been changed at the point where canChangeDataName is called. It may also be called by other clients who are interested in knowing if a particular name change will be allowed before actually requesting the name change.

Returns
True if the subclass is happy for the data name to be set to name. The subclass can return false to indicate that the data name cannot be changed to name, or indeed that it cannot be changed at all (ie to anything).

Implemented in Array3dInfo, GetSqlResultSetColumn, InsertColumnIntoSqlTable, ResizeImage, RunExternalScript, RunMatLabScript, RunRScript, GetBsonItem, AddMeshModelState, CreateClipRegion, CacheData, Compare, ComposeGroup, ConvertFromByteArray, ConvertToByteArray, DecomposeGroup, DeepConvertQVariant, GetItemFromJson, GetItemFromObjectDictionary, InitializedVariable, InsertIntoObjectDictionary, LoadDataFromFile, ModifyGroup, ModifyObjectDictionary, ObjectArrayAccessor, ObjectArrayBuilder, SaveDataToFile, SelectInput, SharedInfo, TryInputs, UpdateBarrier, Variable, WhileLoop, WorkspaceInput, and WorkspaceOutput.

◆ createCustomPropertiesHandler()

Presentation::CustomOperationProperties * createCustomPropertiesHandler ( )
overridevirtual
Returns
An object that can be used to add custom properties to a dialog and to create undoable commands to apply changes to those custom properties. If the operation has no custom properties, a null pointer will be returned Since most operations won't have custom properties, the default implementation simply returns a null pointer.

Reimplemented from Operation.

◆ dataNameChanged()

void dataNameChanged ( const QString &  name)
protectedvirtual
Parameters
nameThe new data name. This is the same as the return value from getDataName(). It is provided as a parameter merely for convenience and consistency.

This function is called by setDataName() once the data name has been changed. It allows the subclass to take additional action to update itself just before setDataName() returns.

The default implementation does nothing.

Note
This function cannot do anything which might fail.

Reimplemented in Array3dInfo, GetSqlResultSetColumn, InsertColumnIntoSqlTable, ResizeImage, RunExternalScript, RunMatLabScript, RunRScript, GetBsonItem, AddMeshModelState, CreateClipRegion, CacheData, ComposeGroup, ConvertFromByteArray, ConvertToByteArray, DecomposeGroup, DeepConvertQVariant, GetItemFromJson, GetItemFromObjectDictionary, InitializedVariable, InsertIntoObjectDictionary, LoadDataFromFile, ModifyGroup, ModifyObjectDictionary, ObjectArrayBuilder, SaveDataToFile, SelectInput, TryInputs, UpdateBarrier, Variable, WorkspaceInput, and WorkspaceOutput.

◆ dataObjectAboutToChange()

void dataObjectAboutToChange ( )
protectedvirtual

This function is called by setDataFactory() just before it changes the data object, which is the last thing it does before returning. The default implementation does nothing.

Note
This function cannot do anything which might fail.
See also
dataObjectChanged()

Reimplemented in Array3dInfo, ResizeImage, ComposeGroup, DecomposeGroup, ModifyGroup, and ModifyObjectDictionary.

◆ dataObjectChanged()

void dataObjectChanged ( DataObject oldDataObject)
protectedvirtual
Parameters
oldDataObjectThe old data object, which will be destroyed immediately after dataObjectChanged() returns. The new data object can be obtained by calling getDataObject().
Precondition
The up to date status of the operation will not yet have been reset. This will be done immediately after dataObjectChanged() returns.

This function is called by setDataFactory once the data object has been changed. It allows the subclass to take additional action to update itself before the process of changing the data factory is completed. After exit, the only thing setDataFactory will subsequently do is call setUpToDate(false) on the operation.

The default implementation does nothing.

Note
This function cannot do anything which might fail.
See also
dataObjectAboutToChange()

Reimplemented in Compare, Array3dInfo, GetSqlResultSetColumn, InsertColumnIntoSqlTable, ResizeImage, GetBsonItem, AddMeshModelState, CreateClipRegion, DeepConvertQVariant, GetItemFromJson, GetItemFromObjectDictionary, ModifyObjectDictionary, RunExternalScript, RunMatLabScript, RunRScript, CacheData, ComposeGroup, ConvertFromByteArray, ConvertToByteArray, DecomposeGroup, InitializedVariable, InsertIntoObjectDictionary, LoadDataFromFile, ModifyGroup, ObjectArrayAccessor, ObjectArrayBuilder, SaveDataToFile, SelectInput, TryInputs, UpdateBarrier, Variable, WhileLoop, WorkspaceInput, and WorkspaceOutput.

◆ getAcceptableDataName()

QString getAcceptableDataName ( const QString &  proposedName) const
virtual
Parameters
proposedNameThe name being tested.

This function can be called to obtain a name that would be accepted based on proposedName. Some subclasses have constraints on what names they can accept, but most will generally accept any name except one that matches an existing input or output of the operation.

The default implementation of this function first checks if proposedName matches the current name. If it does, then it is assumed that the proposedName must have been valid before and is still valid now, in which case proposedName is returned unchanged. If proposedName is different to the current name, the function then calls canChangeDataName() with the proposed name. If it is accepted, the proposed name is returned unchanged. Otherwise, the function constructs a name consisting of proposedName, a space and then a number. It will keep increasing that number (starting at 1) until canChangeDataName() accepts it.

Subclass authors should be aware that if the above strategy doesn't work with their implementation of canChangeDataName(), then they also need to reimplement getAcceptableDataName() with a suitable strategy or else calling getAcceptableDataName() will result in an infinte loop.

Returns
An acceptable data name based on proposedName.
See also
canChangeDataName(), setDataName()

Reimplemented in ObjectArrayAccessor.

◆ getDataFactory()

const DataFactory & getDataFactory ( ) const
Returns
The currently set data factory. It is always a valid data factory, since any attempt to set it to something not allowed will simply retain the previously set factory.

◆ getDataName()

const QString & getDataName ( ) const
Returns
The currently set data name.

setDataName()

◆ getDataObject()

DataObject & getDataObject ( )
Returns
The data object used by this operation. This data object can be used directly by the subclass implementation, but it must take care to properly handle the situations where the data object can change, including its factory.

◆ isDataType() [1/2]

bool isDataType ( ) const
inline
Returns
True if the object's type matches the specified type. False otherwise. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Template function for testing the type of the DataObject. Shorthand for:

&object.getDataFactory() == &DataFactoryTraits<T>::getInstance()

◆ isDataType() [2/2]

bool isDataType ( const DataFactory type) const
inline
Returns
True if the object's type matches the specified type. False otherwise. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Utility function for testing the type of the object. Shorthand for:

&object.getDataFactory() == &type

◆ isNameable()

bool isNameable ( ) const
Returns
True if this operation supports a name for the data. This is set in the constructor and cannot be altered thereafter. Any attempt to access the name for an operation that is not nameable is considered an error.

◆ isPolymorphicType()

bool isPolymorphicType ( ) const
overridevirtual
Returns
True - PolymorphicDataOperation and all classes that derive from it are Polymorphic types.

Reimplemented from Operation.

◆ isUserConfigurable()

bool isUserConfigurable ( )
overridevirtual
Returns
Is this operation user configurable. Examples would include: 1) a polymorphic operation 2) an operation where the number of inputs and/or outputs be: changed (such as CreateChart) or hidden (such as RunMatLabScript).

Reimplemented from Operation.

◆ loadPolyPart()

bool loadPolyPart ( const QString &  dataPlugin,
const QString &  dataType,
const QString &  dataName 
)
protected

◆ matchesDataType()

bool matchesDataType ( const DataObject otherObject) const
inline
Returns
True if the object's type matches the type of the other object. False otherwise.

Utility function for testing whether the data types of two DataObjects match. Shorthand for:

&object.getDataFactory() == &otherObject.getFactory()

◆ postSave()

bool postSave ( SerializedItem item) const
overrideprotectedvirtual

Saves the details of the data type this operation will be associated with. If subclasses override postSave() for themselves, they would normally call PolymorphicDataOperation::postSave() as their first step before performing any processing specific to the subclass.

Reimplemented from Operation.

◆ prepareInputsOutputsForLoad()

bool prepareInputsOutputsForLoad ( const SerializedItem item)
overrideprotectedvirtual

Loads the details of the data type this operation will be associated with. If subclasses override prepareInputsOutputsForLoad() for themselves, they would normally call PolymorphicDataOperation::prepareInputsOutputsForLoad() as their first step before performing any processing specific to the subclass.

Reimplemented from Operation.

Reimplemented in SaveDataToFile, Variable, WhileLoop, WorkspaceInput, and WorkspaceOutput.

◆ setDataFactory()

bool setDataFactory ( const DataFactory factory)
Parameters
factoryThe factory to try to set for this operation.

This is the main function for this base class. Subclasses are expected to make use of the data factory that is set. Typically, this changes the data type of an input and/or output.

If factory matches the current data factory, the function returns immediately without doing anything. Otherwise, before it tries to actually change the factory, setDataFactory() calls canChangeDataFactory(). If that returns true, it will change the factory and then call dataFactoryChanged() before calling setUpToDate(false) on the operation and then returning.

Returns
True if the operation's data factory could be set to factory or if the operation's data factory was already factory. Reasons for failure are determined by subclasses through their canChangeDataFactory() member function. If this function returns false, the old data factory is retained.

◆ setDataName()

bool setDataName ( const QString &  name)
Parameters
nameThe new name for the data object.

The data name can be used by subclasses in whatever way is meaningful to them. Typically, this usually means the name of an input and/or output, and usually the name Dependencies is prohibited.

Before trying to actually change the name, setDataName() calls canChangeDataName(). If that succeeds, it will change the name and then call dataNameChanged() before returning.

Returns
True if the data object's new name could be set to name. Reasons for failure are determined by subclasses through their canChangeDataName() member function. If this function returns false, the old name is retained.
See also
getDataName(), getAcceptableDataName()