Workspace 6.21.5
Classes | Namespaces | Macros
typedoperationfactory.h File Reference
#include <QString>
#include "Workspace/Application/LanguageUtils/errorchecks.h"
#include "Workspace/Application/workspaceplugin.h"
#include "Workspace/api_workspace.h"
#include "operation.h"
#include "operationfactory.h"
#include "operationfactorytraits.h"
Include dependency graph for typedoperationfactory.h:
This graph shows which files directly or indirectly include this file:

Classes

class  TypedOperationFactory< T >
 Operation factory class template. More...
 

Namespaces

namespace  CSIRO
 Top level namespace for all Workspace code.
 
namespace  CSIRO::DataExecution
 Base workspace functionality not requiring a user interface.
 

Macros

#define CSIRO_TYPEDOPERATIONFACTORY_STRINGIFY(x)   #x
 
#define CSIRO_TYPEDOPERATIONFACTORY_TOSTRING(x)   CSIRO_TYPEDOPERATIONFACTORY_STRINGIFY(x)
 
#define DEFINE_WORKSPACE_OPERATION_FACTORY(T, P, C)    DEFINE_WORKSPACE_OPERATION_FACTORY_NAMED(T, P, C, #T)
 
#define DEFINE_WORKSPACE_OPERATION_FACTORY_NAMED(T, P, C, N)    DEFINE_WORKSPACE_OPERATION_FACTORY_NAMED_WITH_ICON(T, P, C, N, (P.getDefaultIconPath()))
 
#define DEFINE_WORKSPACE_OPERATION_FACTORY_NAMED_WITH_ICON(T, P, C, N, I)
 
#define DEFINE_WORKSPACE_OPERATION_FACTORY_WITH_ICON(T, P, C, I)    DEFINE_WORKSPACE_OPERATION_FACTORY_NAMED_WITH_ICON(T, P, C, #T, I)
 
#define DEPRECATE_WORKSPACE_OPERATION(T, M)
 

Macro Definition Documentation

◆ CSIRO_TYPEDOPERATIONFACTORY_STRINGIFY

#define CSIRO_TYPEDOPERATIONFACTORY_STRINGIFY (   x)    #x

◆ CSIRO_TYPEDOPERATIONFACTORY_TOSTRING

#define CSIRO_TYPEDOPERATIONFACTORY_TOSTRING (   x)    CSIRO_TYPEDOPERATIONFACTORY_STRINGIFY(x)

◆ DEFINE_WORKSPACE_OPERATION_FACTORY

#define DEFINE_WORKSPACE_OPERATION_FACTORY (   T,
  P,
 
)     DEFINE_WORKSPACE_OPERATION_FACTORY_NAMED(T, P, C, #T)
Parameters
TThe Operation to define a factory for. It can have scope qualification if required, but that will show up as part of the name. Either employ a using declaration to make the scoping unnecessary or else use the DEFINE_WORKSPACE_OPERATION_FACTORY_NAMED macro.
PA reference to the WorkspacePlugin instance this Operation belongs to. See OperationFactory::getPlugin() for more details.
CThe catalogue path for the Operation. See OperationFactory::getCataloguePath() for more details.

Simply forwards to DEFINE_WORKSPACE_OPERATION_FACTORY_NAMED with the N parameter set to T in string form and the Im parameter set to an empty string.

See also
DECLARE_WORKSPACE_OPERATION_FACTORY

◆ DEFINE_WORKSPACE_OPERATION_FACTORY_NAMED

#define DEFINE_WORKSPACE_OPERATION_FACTORY_NAMED (   T,
  P,
  C,
 
)     DEFINE_WORKSPACE_OPERATION_FACTORY_NAMED_WITH_ICON(T, P, C, N, (P.getDefaultIconPath()))
Parameters
TThe Operation to define a factory for. It can have scope qualification if required.
PA reference to the WorkspacePlugin instance this Operation belongs to. See OperationFactory::getPlugin() for more details.
CThe catalogue path for the Operation. See OperationFactory::getCataloguePath() for more details.
NThe name to use for the Operation T. This will be seen by users and will also be used to uniquely identify the Operation within the specified plugin, P. See OperationFactory::getType() for more details.

Simply forwards to DEFINE_WORKSPACE_OPERATION_FACTORY_NAMED_WITH_ICON, defaulting the value for I to the path to the default Operation icon image.

Note
Normally, this macro would not be used directly unless T was not a suitable name for the Operation. In most instances, N will be the same as T and the DEFINE_WORKSPACE_OPERATION_FACTORY macro would be easier to use.

◆ DEFINE_WORKSPACE_OPERATION_FACTORY_NAMED_WITH_ICON

#define DEFINE_WORKSPACE_OPERATION_FACTORY_NAMED_WITH_ICON (   T,
  P,
  C,
  N,
 
)
Parameters
TThe Operation to define a factory for. It can have scope qualification if required.
PA reference to the WorkspacePlugin instance this Operation belongs to. See OperationFactory::getPlugin() for more details.
CThe catalogue path for the Operation. See OperationFactory::getCataloguePath() for more details.
NThe name to use for the Operation T. This will be seen by users and will also be used to uniquely identify the Operation within the specified plugin, P. See OperationFactory::getType() for more details.
IThe resource path to the icon to use for all Operations of type T. This should be either an absolute path to an image, or a Qt resource path to an image.
Note
Normally, this macro would not be used directly unless T was not a suitable name for the Operation. In most instances, N will be the same as T and the DEFINE_WORKSPACE_OPERATION_FACTORY macro would be easier to use.

This macro defines the explicit specializations of the functions in OperationFactoryTraits for the type T. They are defined as forwarding functions to their corresponding equivalents in TypedOperationFactory<T>. This technique ensures that the function implementations for OperationFactoryTraits are only ever defined in the one place. Specifically, it ensures that T operations are always allocated and deleted in the same file when performed through the OperationFactoryTraits class.

The macro also takes care of explicitly instantiating TypedOperationFactory<T>.

Warning
Never use this macro in a header. It should only ever be used in an implementation file so that other compilation units do not see the implementation of each of the TypedOperationFactory member functions. This prevents compilers from inlining the creation and deletion of Operation's, which is the whole point of the macro. The normal usage of this macro is to put it at the end of the implementation file defining the implementation of T, outside of any namespace(s).
See also
DECLARE_WORKSPACE_OPERATION_FACTORY

◆ DEFINE_WORKSPACE_OPERATION_FACTORY_WITH_ICON

#define DEFINE_WORKSPACE_OPERATION_FACTORY_WITH_ICON (   T,
  P,
  C,
 
)     DEFINE_WORKSPACE_OPERATION_FACTORY_NAMED_WITH_ICON(T, P, C, #T, I)
Parameters
TThe Operation to define a factory for. It can have scope qualification if required.
PA reference to the WorkspacePlugin instance this Operation belongs to. See OperationFactory::getPlugin() for more details.
CThe catalogue path for the Operation. See OperationFactory::getCataloguePath() for more details.
IThe resource path to the icon to use for all Operations of type T. This should be either an absolute path to an image, or a Qt resource path to an image.

Simply forwards to DEFINE_WORKSPACE_OPERATION_FACTORY_NAMED_WITH_ICON, defaulting the value for N to the same name as the operation.

◆ DEPRECATE_WORKSPACE_OPERATION

#define DEPRECATE_WORKSPACE_OPERATION (   T,
 
)
Value:
namespace CSIRO \
{ \
namespace DataExecution \
{ \
template<> \
{ \
return true; \
} \
template<> \
{ \
return M; \
} \
} \
}
bool isDeprecated() const override
Definition: typedoperationfactory.h:141
QString getDeprecationMessage() const override
Definition: typedoperationfactory.h:150
Top level namespace for all Workspace code.
Definition: applicationsupportplugin.cpp:32
Parameters
TThe type of Operation to deprecate.
MThe deprecation message to show when the operation is instantiated. This should be of type QString and already wrapped in a tr() invocation.

Place this before the operation's DEFINE_WORKSPACE_OPERATION macro invocation to mark the operation as deprecated. Example usage from countedloop.cpp:

DEPRECATE_WORKSPACE_OPERATION(CountedLoop, Operation::tr("CountedLoop has been replaced by ForLoop. Use of CountedLoop in new workflows is not recommended.")); DEFINE_WORKSPACE_OPERATION_FACTORY_WITH_ICON(CountedLoop, BuiltinPlugin::getInstance(), Operation::tr("Builtin/Loops"), "images:/Workspace/operations/loop.png")