Workspace 6.21.5
Classes | Public Member Functions | List of all members
DataFactory Class Referenceabstract

Base class for all data type factories. More...

#include <Workspace/DataExecution/DataObjects/datafactory.h>

Inheritance diagram for DataFactory:
[legend]

Classes

struct  SharedInfo
 

Public Member Functions

 DataFactory ()
 
virtual ~DataFactory ()
 
bool addAdaptorFactory (const TypeAdaptorFactory &adaptor)
 
virtual void assignDataObject (const DataObject &src, DataObject &dest) const =0
 
virtual DataObjectcloneDataObject (const DataObject &obj) const =0
 
virtual bool compareDataObjects (const DataObject &lhs, const DataObject &rhs) const =0
 
virtual bool compareDataObjects (const DataObject &lhs, const DataObject &rhs, int &relationOut) const =0
 
virtual DataObjectcreateDataObject () const =0
 
virtual void destroyDataObject (DataObject *obj) const =0
 
const TypeAdaptorFactorygetAdaptorFactory (const DataFactory &destType) const
 
virtual void getEnumMap (QMap< int, QString > &map) const =0
 
virtual QStringList getEnumNames () const =0
 
QString getHeaderPath () const
 
virtual const Application::WorkspacePlugingetPlugin () const =0
 
DataFactorygetSharedDataFactory ()
 
const DataFactorygetSharedDataFactory () const
 
virtual SharedInfo getSharedInfo () const
 
virtual QString getSourceTreeTop () const =0
 
virtual QString getTypeName () const =0
 
virtual bool isAssignable () const =0
 
virtual bool isClonable () const =0
 
virtual bool isComparable () const =0
 
virtual bool isEnum () const =0
 
virtual bool isObjectGroup () const =0
 
virtual bool isSerializable () const =0
 
virtual bool isSortable () const =0
 
void removeAdaptorFactory (const TypeAdaptorFactory &adaptor)
 
virtual bool sharesData (const DataObject &a, const DataObject &b) const =0
 
void unloadPlugin (const Application::WorkspacePlugin &plugin)
 

Detailed Description

Each data factory is responsible for creating, cloning, assigning and destroying each instance of the particular data type it manages. The factory can handle raw data types or DataObject wrappers around those types.

All data factories should be Singletons or else the type adaptation mechanism (polymorphism, type conversion, etc.) will fail.

The TypedDataFactory template should be used to simplify the creation of type factories.

Constructor & Destructor Documentation

◆ DataFactory()

◆ ~DataFactory()

~DataFactory ( )
virtual

Member Function Documentation

◆ addAdaptorFactory()

bool addAdaptorFactory ( const TypeAdaptorFactory adaptor)
Parameters
adaptorThe TypeAdaptorFactory to add to this DataFactory. The source data factory of adaptor should be this factory (the one the adaptor is being added to). If it isn't, the adaptor will not be added. The data factory does not take ownership of the adaptor.
Returns
True if adaptor does not already exist in the list of adaptors for this DataFactory, or false if adaptor has already been added or does not have the correct source DataFactory type.

◆ assignDataObject()

virtual void assignDataObject ( const DataObject src,
DataObject dest 
) const
pure virtual
Parameters
srcThe source object to copy.
destThe destination object to assign to.
Precondition
The type associated with this data factory should be the same as both src and dest. Both src and dest must be of the exact same type. If they are not, then cloning is probably the mechanism to use instead.

If assignment is not supported by this data type, then a call to this function normally does nothing. Callers should check the result of isAssignable() before using this function.

See also
isAssignable(), cloneDataObject()

Implemented in TypedDataFactory< T >.

◆ cloneDataObject()

virtual DataObject * cloneDataObject ( const DataObject obj) const
pure virtual
Parameters
objThe object to clone.

The subclass implementation must check if obj is of the same type as what the factory manages. If it is not, it must forward the call to obj's data factory.

Returns
A clone of obj, or a null pointer if cloning is not supported for this data type.
See also
isClonable(), assignDataObject()

Implemented in TypedDataFactory< T >.

◆ compareDataObjects() [1/2]

virtual bool compareDataObjects ( const DataObject lhs,
const DataObject rhs 
) const
pure virtual
Parameters
lhsThe first operand
rhsThe second operand
Precondition
The type associated with this data factory should match both lhs and rhs.

If comparison is not supported by this data type, then a call to this function is guaranteed to return false.

See also
isComparable()

Implemented in TypedDataFactory< T >.

◆ compareDataObjects() [2/2]

virtual bool compareDataObjects ( const DataObject lhs,
const DataObject rhs,
int &  relationOut 
) const
pure virtual
Parameters
lhsThe first operand
rhsThe second operand
relationOutThe identified relationship between the two objects. If the return value is true (i.e. the items are the same), relationOut will be 0. If the return value is false, relationOut will be -1 if lhs < rhs, and 1 if lhs > rhs.
Precondition
The type associated with this data factory should match both lhs and rhs.
The type associated with this data factory should be quantifiable.

If sorting is not supported by this data type, then a call to this function is guaranteed to return false.

Returns
true if the two types are equal, false otherwise.
See also
isComparable()
isSortable()

Implemented in TypedDataFactory< T >.

◆ createDataObject()

virtual DataObject * createDataObject ( ) const
pure virtual
Returns
A new DataObject for this factory's type. It should be deleted by a call to destroyDataObject() and not by the delete operator.

Implemented in TypedDataFactory< T >.

◆ destroyDataObject()

virtual void destroyDataObject ( DataObject obj) const
pure virtual
Parameters
objThe DataObject to delete. It must have been created by a call to createDataObject() with this factory.
Note
obj can also be a null pointer, in which case the function should return silently. This is exactly the standard behaviour of the C++ delete command.

Implemented in TypedDataFactory< T >.

◆ getAdaptorFactory()

const TypeAdaptorFactory * getAdaptorFactory ( const DataFactory destType) const
Parameters
destTypeThe DataFactory of the type to convert to.
Returns
A pointer to a TypeAdaptorFactory if a compatible factory exists, otherwise a null pointer will be returned.

◆ getEnumMap()

virtual void getEnumMap ( QMap< int, QString > &  map) const
pure virtual
Parameters
mapMap object that maps enum values to enum names.

Implemented in TypedDataFactory< T >.

◆ getEnumNames()

virtual QStringList getEnumNames ( ) const
pure virtual
Returns
Return the list of enum names. An empty list is returned if the data type is not an enum.

Implemented in TypedDataFactory< T >.

◆ getHeaderPath()

QString getHeaderPath ( ) const
Returns
The header path to use in #include directives of C++ files that use this data type.

This function calls getRawHeaderPath() and modifies what it returns to form a more compact path. Typically this involves stripping off some portion of the start of an absolute path to leave a minimal path relative to either the top of the source tree or the directory above that. The result of getRawHeaderPath() will be returned unchanged if no leading part could be stripped off.

◆ getPlugin()

virtual const Application::WorkspacePlugin & getPlugin ( ) const
pure virtual

◆ getSharedDataFactory() [1/2]

DataFactory & getSharedDataFactory ( )
inline

◆ getSharedDataFactory() [2/2]

const DataFactory & getSharedDataFactory ( ) const
Returns
Shared data factory of this data factory, or itself if there is no shared data types of this data type.

◆ getSharedInfo()

DataFactory::SharedInfo getSharedInfo ( ) const
virtual

If a data type is defined by a third party library, it is possible the type may be added to Workspace by different plugins. Workspace may generate adaptor between them as long as they provide a non-empty identical string and the name of the type are identical as well. Recommend to use the name of third party library with it's version name to make them compatible.

See also
getTypeName()

Reimplemented in TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, and TypedDataFactory< T >.

◆ getSourceTreeTop()

virtual QString getSourceTreeTop ( ) const
pure virtual

Implemented in TypedDataFactory< T >.

◆ getTypeName()

virtual QString getTypeName ( ) const
pure virtual
Returns
The name for this data type. It must be unique among all data types from this plugin. It would be useful to use type names that have meaning to a user, since the type name is sometimes displayed in widgets for users to select.

Implemented in TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, TypedDataFactory< T >, and TypedDataFactory< T >.

◆ isAssignable()

virtual bool isAssignable ( ) const
pure virtual
Returns
True if the data type associated with this factory supports assignment.
See also
isClonable()

Implemented in TypedDataFactory< T >.

◆ isClonable()

virtual bool isClonable ( ) const
pure virtual
Returns
True if the data type associated with this factory can be cloned.
See also
isAssignable()

Implemented in TypedDataFactory< T >.

◆ isComparable()

virtual bool isComparable ( ) const
pure virtual
Returns
True if the data type is comparable via some comparison function.

Implemented in TypedDataFactory< T >.

◆ isEnum()

virtual bool isEnum ( ) const
pure virtual
Returns
True if the data type is a enum.

Implemented in TypedDataFactory< T >.

◆ isObjectGroup()

virtual bool isObjectGroup ( ) const
pure virtual
Returns
True if the underlying data produced by this factory is derived from ObjectGroup. This allows some tasks to be automated, such as composing and decomposing the group from/to subcomponents.

Implemented in TypedDataFactory< T >.

◆ isSerializable()

virtual bool isSerializable ( ) const
pure virtual
Returns
True if the data type is able to be serialized.

Implemented in TypedDataFactory< T >.

◆ isSortable()

virtual bool isSortable ( ) const
pure virtual
Returns
True if the data type is able to be quantified as part of a comparison function.

Implemented in TypedDataFactory< T >.

◆ removeAdaptorFactory()

void removeAdaptorFactory ( const TypeAdaptorFactory adaptor)
Parameters
adaptorThe TypeAdaptorFactory to remove from this DataFactory.

If adaptor is not in the list of adaptors for this DataFactory, the function does nothing and reports no error. Thus, it is always safe for a TypeAdaptorFactory to call removeAdaptorFactory() just before it is deleted or unloaded as long as it is known that its source DataFactory still exists.

◆ sharesData()

virtual bool sharesData ( const DataObject a,
const DataObject b 
) const
pure virtual
Returns
True if the a and b are using the same object.

Implemented in TypedDataFactory< T >.

◆ unloadPlugin()

void unloadPlugin ( const Application::WorkspacePlugin plugin)